| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747 | using Aitex.Core.RT.DataCenter;using Aitex.Core.RT.Device;using Aitex.Core.RT.Log;using Aitex.Core.RT.OperationCenter;using Aitex.Core.Util;using MECF.Framework.Common.Beckhoff.ModuleIO;using MECF.Framework.Common.CommonData.Prewet;using MECF.Framework.Common.Device.Safety;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.TwinCat;using MECF.Framework.Common.Utilities;using PunkHPX8_Core;using System;using System.Collections.Generic;using System.Linq;using System.Reflection;using System.Text;using System.Threading.Tasks;using PunkHPX8_RT.Devices.AXIS;using Aitex.Core.RT.SCCore;using MECF.Framework.Common.IOCore;namespace PunkHPX8_RT.Devices.Safety{    public class SafetyDevice : BaseDevice, IDevice    {        #region 常量        private const string IS_INITIALIZED = "IsInitialized";        private const double OP_HOT_CONNECT_STATE = 8;        #region Hot_Connect        /// <summary>        /// Twincat状态        /// </summary>        private const string TWINCAT_STATE="TwincatState";        /// <summary>        /// Main通信故障        /// </summary>        private const string MAIN_COMM_ERR="MainCommErr";        /// <summary>        /// Main Function Block故障        /// </summary>        private const string  MAIN_FB_ERR="MainFbErr";        /// <summary>        /// VPW状态        /// </summary>        private const string VPW_HOTCONNECT_STATE="VpwHotConnectState";        /// <summary>        /// VPW通信故障        /// </summary>        private const string VPW_COMM_ERR="VpwCommErr";        /// <summary>        /// VPW function block故障        /// </summary>        private const string VPW_FB_ERR="VpwFbErr";        /// <summary>        /// RES1_2状态        /// </summary>        private const string RES1_2_HOT_CONNECT_STATE="Res12HotConnectState";        /// <summary>        /// RES1_2通信故障        /// </summary>        private const string RES1_2_COMM_ERR="Res12CommErr";        /// <summary>        /// RES1_2 Function Block故障        /// </summary>        private const string RES1_2_FB_ERR="Res12FbErr";        /// <summary>        /// RES3_4状态        /// </summary>        private const string RES3_4_HOT_CONNECT_STATE="Res34HotConnectState";        /// <summary>        /// RES3_4通信故障        /// </summary>        private const string RES3_4_COMM_ERR="Res34CommErr";        /// <summary>        /// RES3_4Function Block故障        /// </summary>        private const string RES3_4_FB_ERR="Res34FbErr";        /// <summary>        /// Facility状态        /// </summary>        private const string FACILITY_HOT_CONNECT_STATE="FacilityHotConnectState";        /// <summary>        /// Facility通信故障        /// </summary>        private const string FACILITY_COMM_ERR="FacilityCommErr";        /// <summary>        /// Facility Function Block故障        /// </summary>        private const string FACILITY_FB_ERR="FacilityFbErr";        /// <summary>        /// PlatingCell1_2状态        /// </summary>        private const string PLATING1_2_HOT_CONNECT_STATE="Plating12HotConnectState";        /// <summary>        /// Plating1_2通信故障        /// </summary>        private const string PLATING1_2_COMM_ERR="Plating12CommErr";        /// <summary>        /// Plating1_2 Function Block故障        /// </summary>        private const string PLATING1_2_FB_ERR="Plating12FbErr";        /// <summary>        /// Plating3_4状态        /// </summary>        private const string PLATING3_4_HOT_CONNECT_STATE="Plating34HotConnectState";        /// <summary>        /// Plating3_4通信故障        /// </summary>        private const string PLATING3_4_COMM_ERR="Plating34CommErr";        /// <summary>        /// Plating34 Function Block故障        /// </summary>        private const string PLATING3_4_FB_ERR="Plating34FbErr";        /// <summary>        /// SRD状态        /// </summary>        private const string SRD_HOT_CONNECT_STATE="SrdHotConnectState";        /// <summary>        /// SRD通信故障        /// </summary>        private const string SRD_COMM_ERR="SrdCommErr";        /// <summary>        /// SRD Function Block故障        /// </summary>        private const string SRD_FB_ERR="SrdFbErr";        #endregion        #region restart        /// <summary>        /// Run stop        /// </summary>        private const string RUN_STOP="RunStop";        /// <summary>        /// Err ack        /// </summary>        private const string ERR_ACK="ErrAck";        /// <summary>        /// VPW Estop restart        /// </summary>        private const string VPW_STO_ESTOP_RESTART="VpwStoEstopRestart";        /// <summary>        /// Res12 Estop restart        /// </summary>        private const string RES1_2_STO_ESTOP_RESTART="Res12StoEstopRestart";        /// <summary>        /// Res34 Estop restart        /// </summary>        private const string RES3_4_STO_ESTOP_RESTART="Res34StoEstopRestart";        /// <summary>        /// Plating cell 1_2 sto1 estop restart        /// </summary>        private const string PLATING_CELL1_2_STO1_ESTOP_RESTART="PlatingCell12Sto1EstopRestart";        /// <summary>        /// Plating cell 1_2 sto2 estop restart        /// </summary>        private const string PLATING_CELL1_2_STO2_ESTOP_RESTART="PlatingCell12Sto2EstopRestart";        /// <summary>        /// Plating cell 3_4 sto1 estop restart        /// </summary>        private const string PLATING_CELL3_4_STO1_ESTOP_RESTART="PlatingCell34Sto1EstopRestart";        /// <summary>        /// Plating cell 3_4 sto2 estop restart        /// </summary>        private const string PLATING_CELL3_4_STO2_ESTOP_RESTART="PlatingCell34Sto2EstopRestart";        /// <summary>        /// Facility sto estop restart        /// </summary>        private const string FACILITY_STO_ESTOP_RESTART="FacilityStoEstopRestart";        /// <summary>        /// SRD Sto Estop restart        /// </summary>        private const string SRD_STO_ESTOP_RESTART="SrdStoEstopRestart";        #endregion        #region Doors Lock        /// <summary>        /// Req Aligner Door Lock        /// </summary>        private const string REQ_ALIGNER_DOOR_LOCK="ReqAlignerDoorLock";        /// <summary>        /// Req cassette doors lock        /// </summary>        private const string REQ_CASSETE_DOORS_LOCK="ReqCassetteDoorsLock";        /// <summary>        /// Req cell 1_2 doors lock        /// </summary>        private const string REQ_CELL1_2_DOORS_LOCK="ReqCell12DoorsLock";        /// <summary>        /// Req cell doors lock        /// </summary>        private const string REQ_CELL3_4_DOORS_LOCK="ReqCell34DoorsLock";        #endregion        #region locked        /// <summary>        /// Cell1_2 Doors Left Locked        /// </summary>        private const string CELL1_2_DOORS_LEFT_LOCKED="Cell12DoorsLeftLocked";        /// <summary>        /// Cell1_2 Doors Right Locked        /// </summary>        private const string CELL1_2_DOORS_RIGHT_LOCKED="Cell12DoorsRightLocked";        /// <summary>        /// Cell3_4 Doors Left Locked        /// </summary>        private const string CELL3_4_DOORS_LEFT_LOCKED="Cell34DoorsLeftLocked";        /// <summary>        /// Cell3_4 Doors Right Locked        /// </summary>        private const string CELL3_4_DOORS_RIGHT_LOCKED="Cell34DoorsRightLocked";        /// <summary>        /// Cassette Doors Left locked        /// </summary>        private const string CASSETE_DOORS_LEFT_LOCKED="CassetteDoorsLeftLocked";        /// <summary>        /// Cassette Doors Right locked        /// </summary>        private const string CASSETE_DOORS_RIGHT_LOCKED="CassetteDoorsRightLocked";        #endregion        #region Closed        /// <summary>        /// Aligner Door closed        /// </summary>        private const string ALIGNER_DOOR_CLOSED="AlignerDoorClosed";        private const string RES1_2_DOOR_CLOED="Res12DoorClosed";        private const string RES3_4_DOOR_CLOED="Res34DoorClosed";        private const string VPW_DOOR_CLOSED="VpwDoorClosed";        private const string PLUMBLING_DOOR_CLOSED="PlumblingDoorClosed";        private const string SRD_PANEL_CLOSED="SrdPanelClosed";        #endregion        #region Halt        private const string HALT_BUTTON_LEFT="HaltButtonLeft";        private const string HALT_BUTTON_RIGHT="HaltButtonRight";        #endregion        #region Leak Detected        private const string PLATINGCELL12LEAKDETECTED = "PlatingCell12LeakDetected";        private const string PLATINGCELL34LEAKDETECTED = "PlatingCell34LeakDetected";        private const string VACUUMPREWETLEAKDETECTED = "VacuumPrewetLeakDetected";        private const string SAMPLESTATION1LEAKDETECTED= "SampleStation1LeakDetected";        private const string SAMPLESTATION2LEAKDETECTED = "SampleStation2LeakDetected";        private const string FRAMECONTAINMENTLEAKDETECTED = "FrameContainmentLeakDetected";        #endregion        #region EDM        private const string RESERVOIR12CAPUMPEDM = "Reservoir12CAPumpEdm";        private const string RESERVOIR34CAPUMPEDM = "Reservoir34CAPumpEdm";        private const string RESDEGAS1PUMPEDM = "ResDegas1PumpEdm";        private const string RESDEGAS2PUMPEDM = "ResDegas2PumpEdm";        private const string VPWVACUUMPUMPEDM = "VpwVacuumPumpEdm";        private const string VPWBOOSTERPUMPEDM = "VpwBoosterPumpEdm";        private const string EXTFLUDIENABLEEDM = "ExtFluidEnableEdm";        #endregion        #region Level High        private const string RESERVOIR1CALEVELHIGH = "Reservoir1CALevelHigh";        private const string RESERVOIR2CALEVELHIGH = "Reservoir2CALevelHigh";        private const string RESERVOIR3CALEVELHIGH = "Reservoir3CALevelHigh";        private const string RESERVOIR4CALEVELHIGH = "Reservoir4CALevelHigh";        #endregion        #region Axis STO        private const string VPWCELL1ROTATIONSTOEDM = "VpwCell1RotationStoEdm";        private const string VPWCELL2ROTATIONSTOEDM = "VpwCell2RotationStoEdm";        private const string PLATINGCELL1ROTATIONSTOEDM = "PlatingCell1RotationStoEdm";        private const string PLATINGCELL2ROTATIONSTOEDM = "PlatingCell2RotationStoEdm";        private const string PLATINGCELL3ROTATIONSTOEDM = "PlatingCell3RotationStoEdm";        private const string PLATINGCELL4ROTATIONSTOEDM = "PlatingCell4RotationStoEdm";        private const string PLATINGCELL12VERTICALSTOEDM = "PlatingCell12VerticalStoEdm";        private const string PLATINGCELL34VERTICALSTOEDM = "PlatingCell34VerticalStoEdm";        private const string SRD1ROTATIONSTOEDM = "Srd1RotationStoEdm";        private const string SRD2ROTATIONSTOEDM = "Srd2RotationStoEdm";        #endregion        private const string SAFETY_DATA="SafetyData";        #endregion        #region 内部变量        /// <summary>        /// Reset Routine        /// </summary>        private SafetyResetRoutine _resetRoutine;        /// <summary>        /// All Switch On Routine        /// </summary>        private SafetyAllOnRoutine _allOnRoutine;        /// <summary>        /// AllOnRoutine状态        /// </summary>        private RState _allOnStatus;        /// <summary>        /// 操作当前状态        /// </summary>        private RState _status;        /// <summary>        /// 变量是否初始化字典        /// </summary>        private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();        /// <summary>        /// 定时器Job        /// </summary>        PeriodicJob _periodicJob = null;        #endregion        #region 属性        /// <summary>        /// 数据对象        /// </summary>        public SafetyData SafetyData { get; set; }        /// <summary>        /// 状态        /// </summary>        public RState Status { get; set; }        /// <summary>        /// 所有io变量是否初始化        /// </summary>        public bool IOInitialized { get { return IOVariableDictionaryUtil.AllIoVariableInitialized(eEvent.ERR_SAFETY,Module,_variableInitializeDic); } }        #endregion        /// <summary>        /// 构造函数        /// </summary>        /// <param name="moduleName"></param>        public SafetyDevice() : base("Safety", "Safety", "Safety", "Safety")        {                       SafetyData = new SafetyData();        }        /// <summary>        /// 定时器        /// </summary>        /// <returns></returns>        private bool OnTimer()        {            if (_status==RState.Running)            {                _status = _resetRoutine.Monitor();                if(_status==RState.End)                {                    LOG.WriteLog(eEvent.INFO_SAFETY, Module, "Reset Complete");                }                else if(_status==RState.Failed)                {                    LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reset Error");                }            }            //AllOnRoutine监控            if (_allOnStatus == RState.Running)            {                _allOnStatus = _allOnRoutine.Monitor();                if (_allOnStatus == RState.End)                {                    LOG.WriteLog(eEvent.INFO_SAFETY, Module, "All On Complete");                }                else if (_allOnStatus == RState.Failed)                {                    LOG.WriteLog(eEvent.ERR_SAFETY, Module, "All On Error");                }            }            return true;        }        /// <summary>        /// 初始化        /// </summary>        /// <returns></returns>        public bool Initialize()        {            InitializeRoutine();            InitializeData();            SubscribeValueAction();            InitializeOperation();            _periodicJob = new PeriodicJob(200, OnTimer, $"{Module}.OnTimer", true);            return true;        }        /// <summary>        /// 初始化Routine        /// </summary>        private void InitializeRoutine()        {            _resetRoutine = new SafetyResetRoutine(Module);            _allOnRoutine = new SafetyAllOnRoutine(Module);        }        /// <summary>        /// 初始化DATA        /// </summary>        private void InitializeData()        {            DATA.Subscribe($"{Module}.{SAFETY_DATA}",() => SafetyData, SubscriptionAttribute.FLAG.IgnoreSaveDB);            DATA.Subscribe($"{Module}.{IS_INITIALIZED}", () => IOInitialized, SubscriptionAttribute.FLAG.IgnoreSaveDB);            DATA.Subscribe($"{Module}.TwincatState", () => SafetyData.TwincatState, SubscriptionAttribute.FLAG.IgnoreSaveDB);        }        /// <summary>        /// 初始化Operation        /// </summary>        private void InitializeOperation()        {            OP.Subscribe($"{Module}.LockAlignerDoor", (cmd,args) => LockAlignerDoor());            OP.Subscribe($"{Module}.UnlockAlignerDoor", (cmd, args) => UnlockAlignerDoor());            OP.Subscribe($"{Module}.LockCasseteDoor", (cmd, args) => LockCasseteDoor());            OP.Subscribe($"{Module}.UnlockCasseteDoor", (cmd, args) => UnlockCasseteDoor());            OP.Subscribe($"{Module}.LockCell12Door", (cmd, args) => LockCell12Door());            OP.Subscribe($"{Module}.UnlockCell12Door", (cmd, args) => UnlockCell12Door());            OP.Subscribe($"{Module}.LockCell34Door", (cmd, args) => LockCell34Door());            OP.Subscribe($"{Module}.UnlockCell34Door", (cmd, args) => UnlockCell34Door());            OP.Subscribe($"{Module}.ResetOperation",(cmd, args) => ResetOperation());            OP.Subscribe($"{Module}.AllOnOperation", (cmd, args) => AllOnOperation());                    }        /// <summary>        /// 订阅变量数值发生变化        /// </summary>        private void SubscribeValueAction()        {            BeckhoffIoSubscribeUpdateVariable( MAIN_COMM_ERR);            BeckhoffIoSubscribeUpdateVariable( TWINCAT_STATE);            BeckhoffIoSubscribeUpdateVariable( MAIN_FB_ERR);            BeckhoffIoSubscribeUpdateVariable( VPW_HOTCONNECT_STATE);            BeckhoffIoSubscribeUpdateVariable( VPW_COMM_ERR);            BeckhoffIoSubscribeUpdateVariable( VPW_FB_ERR);            BeckhoffIoSubscribeUpdateVariable( FACILITY_HOT_CONNECT_STATE);            BeckhoffIoSubscribeUpdateVariable( FACILITY_COMM_ERR);            BeckhoffIoSubscribeUpdateVariable( FACILITY_FB_ERR);            BeckhoffIoSubscribeUpdateVariable( RES1_2_HOT_CONNECT_STATE);            BeckhoffIoSubscribeUpdateVariable( RES1_2_COMM_ERR);            BeckhoffIoSubscribeUpdateVariable( RES1_2_FB_ERR);            BeckhoffIoSubscribeUpdateVariable( RES3_4_HOT_CONNECT_STATE);            BeckhoffIoSubscribeUpdateVariable( RES3_4_COMM_ERR);            BeckhoffIoSubscribeUpdateVariable( RES3_4_FB_ERR);            BeckhoffIoSubscribeUpdateVariable( PLATING1_2_HOT_CONNECT_STATE);            BeckhoffIoSubscribeUpdateVariable( PLATING1_2_COMM_ERR);            BeckhoffIoSubscribeUpdateVariable( PLATING1_2_FB_ERR);            BeckhoffIoSubscribeUpdateVariable( PLATING3_4_HOT_CONNECT_STATE);            BeckhoffIoSubscribeUpdateVariable( PLATING3_4_COMM_ERR);            BeckhoffIoSubscribeUpdateVariable( PLATING3_4_FB_ERR);            BeckhoffIoSubscribeUpdateVariable( SRD_HOT_CONNECT_STATE);            BeckhoffIoSubscribeUpdateVariable( SRD_COMM_ERR);            BeckhoffIoSubscribeUpdateVariable( SRD_FB_ERR);            BeckhoffIoSubscribeUpdateVariable( ERR_ACK);            BeckhoffIoSubscribeUpdateVariable( RUN_STOP);            BeckhoffIoSubscribeUpdateVariable( CASSETE_DOORS_LEFT_LOCKED);            BeckhoffIoSubscribeUpdateVariable( CASSETE_DOORS_RIGHT_LOCKED);            BeckhoffIoSubscribeUpdateVariable( CELL1_2_DOORS_LEFT_LOCKED);            BeckhoffIoSubscribeUpdateVariable( CELL1_2_DOORS_RIGHT_LOCKED);            BeckhoffIoSubscribeUpdateVariable( CELL3_4_DOORS_LEFT_LOCKED);            BeckhoffIoSubscribeUpdateVariable( CELL3_4_DOORS_RIGHT_LOCKED);            BeckhoffIoSubscribeUpdateVariable( VPW_DOOR_CLOSED);            BeckhoffIoSubscribeUpdateVariable( SRD_PANEL_CLOSED);            BeckhoffIoSubscribeUpdateVariable( ALIGNER_DOOR_CLOSED);            BeckhoffIoSubscribeUpdateVariable( PLUMBLING_DOOR_CLOSED);            BeckhoffIoSubscribeUpdateVariable( SRD_PANEL_CLOSED);            BeckhoffIoSubscribeUpdateVariable( FACILITY_STO_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( PLATING_CELL1_2_STO1_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( PLATING_CELL1_2_STO2_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( PLATING_CELL3_4_STO1_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( PLATING_CELL3_4_STO2_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( RES1_2_STO_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( RES3_4_STO_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( SRD_STO_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( VPW_STO_ESTOP_RESTART);            BeckhoffIoSubscribeUpdateVariable( REQ_ALIGNER_DOOR_LOCK);            BeckhoffIoSubscribeUpdateVariable( REQ_CASSETE_DOORS_LOCK);            BeckhoffIoSubscribeUpdateVariable( REQ_CELL1_2_DOORS_LOCK);            BeckhoffIoSubscribeUpdateVariable( REQ_CELL3_4_DOORS_LOCK);            BeckhoffIoSubscribeUpdateVariable(HALT_BUTTON_LEFT);            BeckhoffIoSubscribeUpdateVariable(HALT_BUTTON_RIGHT);                        BeckhoffIoSubscribeUpdateVariable(PLATINGCELL12LEAKDETECTED);            BeckhoffIoSubscribeUpdateVariable(PLATINGCELL34LEAKDETECTED);            BeckhoffIoSubscribeUpdateVariable(VACUUMPREWETLEAKDETECTED);            BeckhoffIoSubscribeUpdateVariable(SAMPLESTATION1LEAKDETECTED);            BeckhoffIoSubscribeUpdateVariable(SAMPLESTATION2LEAKDETECTED);            BeckhoffIoSubscribeUpdateVariable(FRAMECONTAINMENTLEAKDETECTED);            BeckhoffIoSubscribeUpdateVariable(RESERVOIR12CAPUMPEDM);            BeckhoffIoSubscribeUpdateVariable(RESERVOIR34CAPUMPEDM);            BeckhoffIoSubscribeUpdateVariable(RESDEGAS1PUMPEDM);            BeckhoffIoSubscribeUpdateVariable(RESDEGAS2PUMPEDM);            BeckhoffIoSubscribeUpdateVariable(VPWVACUUMPUMPEDM);            BeckhoffIoSubscribeUpdateVariable(VPWBOOSTERPUMPEDM);            BeckhoffIoSubscribeUpdateVariable(EXTFLUDIENABLEEDM);            BeckhoffIoSubscribeUpdateVariable(RESERVOIR1CALEVELHIGH);            BeckhoffIoSubscribeUpdateVariable(RESERVOIR2CALEVELHIGH);            BeckhoffIoSubscribeUpdateVariable(RESERVOIR3CALEVELHIGH);            BeckhoffIoSubscribeUpdateVariable(RESERVOIR4CALEVELHIGH);            BeckhoffIoSubscribeUpdateVariable(VPWCELL1ROTATIONSTOEDM);            BeckhoffIoSubscribeUpdateVariable(VPWCELL2ROTATIONSTOEDM);            BeckhoffIoSubscribeUpdateVariable(PLATINGCELL1ROTATIONSTOEDM);            BeckhoffIoSubscribeUpdateVariable(PLATINGCELL2ROTATIONSTOEDM);            BeckhoffIoSubscribeUpdateVariable(PLATINGCELL3ROTATIONSTOEDM);            BeckhoffIoSubscribeUpdateVariable(PLATINGCELL4ROTATIONSTOEDM);            BeckhoffIoSubscribeUpdateVariable(PLATINGCELL12VERTICALSTOEDM);            BeckhoffIoSubscribeUpdateVariable(PLATINGCELL34VERTICALSTOEDM);            BeckhoffIoSubscribeUpdateVariable(SRD1ROTATIONSTOEDM);            BeckhoffIoSubscribeUpdateVariable(SRD2ROTATIONSTOEDM);        }        /// <summary>        /// 订阅IO变量        /// </summary>        /// <param name="variable"></param>        private void BeckhoffIoSubscribeUpdateVariable(string variable)        {            _variableInitializeDic[variable] = false;            IOModuleManager.Instance.SubscribeModuleVariable(Module,variable, UpdateVariableValue);        }        /// <summary>        /// 更新变量数值        /// </summary>        /// <param name="variable"></param>        /// <param name="value"></param>        private void UpdateVariableValue(string variable, object value)        {            if (!SafetyData.IsDataInitialized)            {                SafetyData.IsDataInitialized = true;            }            PropertyInfo property = SafetyData.GetType().GetProperty(variable);            if (property != null)            {                property.SetValue(SafetyData, value);            }            if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])            {                _variableInitializeDic[variable] = true;            }            CheckIsDataAbonrmal(variable, value);        }        #region 监控指示灯是否异常 方法        /// <summary>        /// 监控指示灯是否异常,是则打印log        /// </summary>        /// <param name="variable"></param>        /// <param name="value"></param>        private void CheckIsDataAbonrmal(string variable,object value)        {            if (variable == "Reservoir1CALevelHigh" && (bool)value == false) //没有触发是false,红灯            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reservoir1CALevelHigh Level Error");            }            else if (variable == "Reservoir2CALevelHigh" && (bool)value == false)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reservoir2CALevelHigh Error");            }            else if (variable == "Reservoir3CALevelHigh" && (bool)value == false)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reservoir3CALevelHigh Error");            }            else if (variable == "Reservoir4CALevelHigh" && (bool)value == false)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reservoir4CALevelHigh Error");            }            else if (variable == "MainCommErr" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "MainCommErr Error");            }            else if (variable == "LoaderPufCommErr" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPufCommErr Error");            }            else if (variable == "SrdCommErr" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdCommErr Error");            }            else if (variable == "TransportCommErr" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "TransportCommErr Error");            }            else if (variable == "MainFunctionBlockErr" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "MainFunctionBlockErr Error");            }            else if (variable == "LoaderPufFunctionBlockErr" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPufFunctionBlockErr Error");            }            else if (variable == "SrdFunctionBlockErr" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdFunctionBlockErr Error");            }            else if (variable == "TransporterFunctionBlockErr" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "TransporterFunctionBlockErr Error");            }            else if (variable == "ProcessHaltButton1" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessHaltButton1 Activate");            }            else if (variable == "ProcessHaltButton2" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessHaltButton2 Activate");            }            else if (variable == "LoaderHaltButton" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderHaltButton Activate");            }            else if (variable == "LoaderPanelRemoved" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPanelRemoved Activate");            }            else if (variable == "BufferPanelRemoved" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "BufferPanelRemoved Activate");            }            else if (variable == "SrdTopPanelRemoved" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdTopPanelRemoved Activate");            }            else if (variable == "SrdLowerPanelRemoved" && (bool)value == true)            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdLowerPanelRemoved Activate");            }            else if (variable == "PlumbingDoorClosed" && (bool)value == false) //信号是反的            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "PlumbingDoorClosed Activate");            }            else if (variable == "ProcessUpperPanelsOn" && (bool)value == false) //信号是反的            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessUpperPanelsOn Activate");            }            else if (variable == "PumpEdm" && (bool)value == false) //信号是反的            {                LOG.WriteLog(eEvent.ERR_SAFETY, Module, "PumpEdm Activate");            }        }        #endregion                #region Reset        /// <summary>        /// Reset Operation        /// </summary>        /// <returns></returns>        private bool ResetOperation()        {            _status = _resetRoutine.Start();            return _status == RState.Running;        }        #endregion        #region All On        /// <summary>        /// All On Operation        /// </summary>        /// <returns></returns>        private bool AllOnOperation()        {            _allOnStatus = _allOnRoutine.Start();            return _allOnStatus == RState.Running;        }        #endregion        #region Lock Door        /// <summary>        /// Lock Aligner Door        /// </summary>        /// <returns></returns>        public bool LockAlignerDoor()        {            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_ALIGNER_DOOR_LOCK}");            return IOModuleManager.Instance.WriteIoValue(ioName, true);        }        /// <summary>        /// Unlock Process Door        /// </summary>        /// <returns></returns>        public bool UnlockAlignerDoor()        {            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_ALIGNER_DOOR_LOCK}");            return IOModuleManager.Instance.WriteIoValue(ioName, false);        }        /// <summary>        /// Lock cassete Door        /// </summary>        /// <returns></returns>        public bool LockCasseteDoor()        {            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CASSETE_DOORS_LOCK}");            return IOModuleManager.Instance.WriteIoValue(ioName, true);        }        /// <summary>        /// Unlock cassete Door        /// </summary>        /// <returns></returns>        public bool UnlockCasseteDoor()        {            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CASSETE_DOORS_LOCK}");            return IOModuleManager.Instance.WriteIoValue(ioName, false);        }        /// <summary>        /// Lock Cell1_2 Door        /// </summary>        /// <returns></returns>        public bool LockCell12Door()        {            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL1_2_DOORS_LOCK}");            return IOModuleManager.Instance.WriteIoValue(ioName, true);        }        /// <summary>        /// Unlock Cell1_2 Door        /// </summary>        /// <returns></returns>        public bool UnlockCell12Door()        {            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL1_2_DOORS_LOCK}");            return IOModuleManager.Instance.WriteIoValue(ioName, false);        }        /// <summary>        /// Lock Cell3_4 Door        /// </summary>        /// <returns></returns>        public bool LockCell34Door()        {            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL3_4_DOORS_LOCK}");            return IOModuleManager.Instance.WriteIoValue(ioName, true);        }        /// <summary>        /// Unlock Cell3_4 Door        /// </summary>        /// <returns></returns>        public bool UnlockCell34Door()        {            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL3_4_DOORS_LOCK}");            return IOModuleManager.Instance.WriteIoValue(ioName, false);        }        #endregion        public void Monitor()        {        }        public void Reset()        {        }        public void Terminate()        {            _periodicJob.Stop(false);        }    }}
 |