123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Aitex.Core.Util;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Log;
- namespace Aitex.Core.RT.IOCore
- {
- public class SafePlcInterlockChecker
- {
- public SafePlcInterlockChecker(DOAccessor doo,DIAccessor di)
- {
- _do = doo;
- _di = di;
-
- _timer.Start(1000);
- }
- private DOAccessor _do = null;
- private DIAccessor _di = null;
- DeviceTimer _timer = new DeviceTimer();
- R_TRIG _trigInterlock = new R_TRIG();
- private string Module = "IO";
- //检查安全逻辑是否被触发动作
- public void Monitor()
- {
- if (_do == null || _di == null)
- {
- LOG.Warning(String.Format("SafePlcInterlockChecker do or di is null"));
- }
- else
- {
- bool setpoint = _do.Value;
- bool feedback = _di.Value;
- if (setpoint == feedback)
- _timer.Start(1000);
- _trigInterlock.CLK = (setpoint != feedback) && _timer.IsTimeout();
- if (_trigInterlock.Q)
- {
- //for DO and send alarm event
- string reason = string.Format("DO-{0}({1})被强制{2},原因是该数字量输出值不满足安全PLC的检查条件",
- _do.Index,
- _di.Name,
- setpoint ? "OFF" : "ON");
- EV.PostMessage(Module, EventEnum.SafePlcInterlock, Module, reason);
- _do.Value = feedback;
- }
- }
- }
- }
- }
|