using System.Diagnostics;
using System.Linq;
using Aitex.Core.RT.IOCore.Interlock.Actions;
using MECF.Framework.Common.Equipment;

namespace Aitex.Core.RT.IOCore.Interlock;

public class InterlockDaemonManager : InterlockManagerBase<InterlockDaemonAction>
{
   public InterlockDaemonManager()
   {
      RootNodeName = "Daemon";
   }
   
   /// <summary>
   /// <inheritdoc cref="InterlockManagerBase{TAction}.Monitor()"/>
   /// </summary>
   public override void Monitor()
   {
      // 按Module扫描Interlock Limit
      foreach (var moduleName in _dictINTLKActionsPerModule.Keys.ToList())
      {
         Debug.Assert(moduleName != ModuleName.UnDefined,
            $"Interlock Manager CanSetDo() undesired module name {ModuleName.UnDefined}");

         foreach (var action in _dictINTLKActionsPerModule[moduleName].ToList())
            action.Monitor();
      }
   }
}