using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Device; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.Event; using Aitex.Core.RT.IOCore; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Event; using MECF.Framework.Common.SubstrateTrackings; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; namespace Aitex.Core.RT.Device.Unit { public class IoAutoShutter : BaseDevice, IDevice { public enum ASOpenCloseStatus { Unknown, Open, Close, } public enum ASUpDownStatus { Unknown, Up, Down, } public IoAutoShutter(string module, XmlElement node, string ioModule = "") { base.Module = string.IsNullOrEmpty(node.GetAttribute("module")) ? module : node.GetAttribute("module"); base.Name = node.GetAttribute("id"); base.Display = node.GetAttribute("display"); base.DeviceID = node.GetAttribute("schematicId"); _diOpen = ParseDiNode("diOpen", node, ioModule); _diClose = ParseDiNode("diClose", node, ioModule); _diUp = ParseDiNode("diUp", node, ioModule); _diDown = ParseDiNode("diDown", node, ioModule); _doOpen = ParseDoNode("doOpen", node, ioModule); _doClose = ParseDoNode("doClose", node, ioModule); _doUp = ParseDoNode("doUp", node, ioModule); _doDown = ParseDoNode("doDown", node, ioModule); } #region fields private DIAccessor _diOpen; private DIAccessor _diClose; private DIAccessor _diUp; private DIAccessor _diDown; private DOAccessor _doOpen; private DOAccessor _doClose; private DOAccessor _doUp; private DOAccessor _doDown; #endregion public AlarmEventItem AutoShutterMoveFailedForInterlock { get; set; } public AlarmEventItem AutoShutterOpenTimeOut { get; set; } public AlarmEventItem AutoShutterCloseTimeOut { get; set; } public AlarmEventItem AutoShutterUpTimeOut { get; set; } public AlarmEventItem AutoShutterDownTimeOut { get; set; } #region properties public ASOpenCloseStatus OpenCloseStatus { get { if (_diOpen != null && _diClose != null && _diOpen.Value && !_diClose.Value) return ASOpenCloseStatus.Open; if (_diOpen != null && _diClose != null && !_diOpen.Value && _diClose.Value) return ASOpenCloseStatus.Close; return ASOpenCloseStatus.Unknown; } } public ASUpDownStatus UpDownStatus { get { if (_diUp != null && _diDown != null && _diUp.Value && !_diDown.Value) return ASUpDownStatus.Up; if (_diUp != null && _diDown != null && !_diUp.Value && _diDown.Value) return ASUpDownStatus.Down; return ASUpDownStatus.Unknown; } } #endregion public bool Initialize() { DATA.Subscribe(Name, "OpenCloseStatus", () => OpenCloseStatus.ToString()); DATA.Subscribe(Name, "UpDownStatus", () => UpDownStatus.ToString()); return true; } public void Monitor() { } public void Reset() { } public void Terminate() { } public bool SetOpen(bool isOpen, out string reason) { if (isOpen) { _doClose.SetValue(!isOpen, out reason); return _doOpen.SetValue(isOpen, out reason); } else { _doOpen.SetValue(isOpen, out reason); return _doClose.SetValue(!isOpen, out reason); } } public bool SetUp(bool isUp, out string reason) { if (isUp) { _doDown.SetValue(!isUp, out reason); return _doUp.SetValue(isUp, out reason); } else { _doUp.SetValue(isUp, out reason); return _doDown.SetValue(!isUp, out reason); } } } }