using System.Collections.Generic; using System.Runtime.InteropServices; using Aitex.Core.Util; namespace Aitex.Core.RT.IOCore { /* * * */ internal class InterlockLimit { public string Name { get { return _di.Name; } } public bool Value { get { return _limitValue; } } public string Tip { get { return _tip; } } public string Module { get { return _module; } } private DIAccessor _di; private bool _limitValue; private string _tip; private string _module; private Dictionary _cultureTip = new Dictionary(); R_TRIG _trigger = new R_TRIG(); public InterlockLimit(DIAccessor diItem, bool value, string tip, Dictionary cultureTip, string module) { _di = diItem; _limitValue = value; _tip = tip; _cultureTip = cultureTip; _module = module; } public bool IsSame(string diName, bool value) { return (diName == _di.Name) && (_limitValue == value); } public bool IsSame(InterlockLimit limit) { return (limit.Name == _di.Name) && (_limitValue == limit.Value); } public bool IsTriggered() { _trigger.CLK = _di.Value != _limitValue; return _trigger.Q; } public bool CanDo(out string reason) { reason = string.Empty; if (_di.Value == _limitValue) return true; reason = string.Format("DI-{0}({1}) = [{2}],{3}", _di.IoTableIndex, _di.Name, _di.Value ? "ON" : "OFF", _tip); return false; } } }