using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Device; using Aitex.Core.RT.Event; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using EFEM.RT.Modules; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase; namespace EFEM.RT.Devices { public class EquipmentMonitor : BaseDevice, IDevice { private readonly RD_TRIG _trigMaintenance = new RD_TRIG(); private readonly RD_TRIG _airForRobotTrig = new RD_TRIG(); private readonly RD_TRIG _airForLoadPortTrig = new RD_TRIG(); private readonly RD_TRIG _vacuumErrorTrig = new RD_TRIG(); private readonly RD_TRIG _ffu1ErrorTrig = new RD_TRIG(); private readonly RD_TRIG _ffu2ErrorTrig = new RD_TRIG(); private readonly RD_TRIG _ionizorErrorTrig = new RD_TRIG(); private readonly RD_TRIG _flowWarningTrig = new RD_TRIG(); private readonly RD_TRIG _leakWarningTrig = new RD_TRIG(); private readonly R_TRIG signalTowerTrig = new R_TRIG(); private readonly RD_TRIG _cassetleChangeLP1Trig = new RD_TRIG(); private readonly RD_TRIG _cassetleChangeLP2Trig = new RD_TRIG(); private readonly RD_TRIG _trigIONAlarmSIGNAL = new RD_TRIG(); private readonly RD_TRIG _trigCassetteDoor = new RD_TRIG(); private readonly RD_TRIG _trigRobotWafer = new RD_TRIG(); private readonly bool _dOLEDLight = DeviceDefineManager.Instance.GetValue("DOLEDLight") ?? false; private readonly bool _noMaintenanceSignal = DeviceDefineManager.Instance.GetValue("NoMaintenanceSignal") ?? false; private readonly bool _noNoDoorOpenSignal = DeviceDefineManager.Instance.GetValue("NoDoorOpenSignal") ?? false; private readonly bool _MaintenanceMode = DeviceDefineManager.Instance.GetValue("MaintenanceSignal") ?? false; private readonly bool _EfemDoorOpen = DeviceDefineManager.Instance.GetValue("EfemDoorOpenSignal") ?? false; private readonly RD_TRIG _trigWaterLeakNormalTOPM = new RD_TRIG(); private readonly RD_TRIG _trigCDAPressureOKTOPM = new RD_TRIG(); private readonly R_TRIG _trigIONCDAPressureON = new R_TRIG(); private readonly R_TRIG _trigIONAlarmSIGNALON = new R_TRIG(); private readonly R_TRIG _trigWaterFlowSWON = new R_TRIG(); private readonly R_TRIG _trigIONCDAPressureOFF = new R_TRIG(); private readonly R_TRIG _trigIONAlarmSIGNALOFF = new R_TRIG(); private readonly R_TRIG _trigWaterFlowSWOFF = new R_TRIG(); private uint data2; private int _fFUSettingKnob; private readonly int[] _speedTable = new[] { 0,200,300,400,500,550,600,650,700,750,800 }; public int IONCDAPressureSWHandler { get { return SC.GetValue("System.IONCDAPressureSWHandler"); } } public int IONAlarmSIGNALHandler { get { return SC.GetValue("System.IONAlarmSIGNALHandler"); } } public int WaterFlowSWHandler { get { return SC.GetValue("System.WaterFlowSWHandler"); } } public RD_TRIG TrigMaintenance { get { return _trigMaintenance; } } public RD_TRIG AirForRobotTrig { get { return _airForRobotTrig; } } public RD_TRIG AirForLoadPortTrig { get { return _airForLoadPortTrig; } } public RD_TRIG VacuumErrorTrig { get { return _vacuumErrorTrig; } } public RD_TRIG FfuErrorTrig { get { return _ffu1ErrorTrig.R || _ffu1ErrorTrig.T ? _ffu1ErrorTrig : _ffu2ErrorTrig; } } public RD_TRIG IonizorErrorTrig { get { return _ionizorErrorTrig; } } public RD_TRIG SensorFlowWarning { get { return _flowWarningTrig; } } public RD_TRIG LeakWarningTrig { get { return _leakWarningTrig; } } public R_TRIG SignalTowerTrig { get { return signalTowerTrig; } } public enum HandlerState { ByPass, ON, OFF } public EquipmentMonitor() : base("System", "EquipmentMonitor", "EquipmentMonitor", "EquipmentMonitor") { } public bool Initialize() { //if (_dOLEDLight) //{ // DeviceModel.TrigLEDLight.SetTrigger(true, out _); //} Subscriptions(); return true; } private bool _StopIonizerWork; public bool StopIonizerWork { get { if(SC.ContainsItem("System.StopIonizerWorkingEnable")) return SC.GetValue("System.StopIonizerWorkingEnable"); return false; } set { _StopIonizerWork = value; } } private readonly R_TRIG _trigStopIonizerAtFirst = new R_TRIG(); public void Monitor() { if (!_noMaintenanceSignal && !_noNoDoorOpenSignal) { _trigMaintenance.CLK = (_MaintenanceMode ? DeviceModel.SensorMaintenanceMode.Value : !DeviceModel.SensorMaintenanceMode.Value) || (_EfemDoorOpen ? DeviceModel.SensorEFEMSideDoorClosed.Value : !DeviceModel.SensorEFEMSideDoorClosed.Value) /*|| DeviceModel.SensorTeachingPendantInUse.Value*/; } if (_flowWarningTrig.T) EV.PostMessage("System", EventEnum.DefaultAlarm, "Flow Warning"); if (_leakWarningTrig.R) EV.PostMessage("System", EventEnum.DefaultAlarm, "Leak Warning"); if (_airForRobotTrig.R) EV.PostMessage("System", EventEnum.DefaultAlarm, "Air supply for Robot pressure error"); if (_airForLoadPortTrig.R) EV.PostMessage("System", EventEnum.DefaultAlarm, "Air supply for Load Port pressure error"); if (_vacuumErrorTrig.R) EV.PostMessage("System", EventEnum.DefaultAlarm, "Vacuum supply for system pressure error"); //if (_ffu1ErrorTrig.R) EV.PostMessage("System", EventEnum.DefaultAlarm, "FFU1 error"); //if (_ffu2ErrorTrig.R) EV.PostMessage("System", EventEnum.DefaultAlarm, "FFU1 error"); if(_airForRobotTrig.R || _airForLoadPortTrig.R || _vacuumErrorTrig.R) Singleton.Instance.PostMsg(RouteManager.MSG.ERROR); if (_trigMaintenance.R) Singleton.Instance.PostMsg(RouteManager.MSG.SetMaintenanceMode); if (_trigMaintenance.T) Singleton.Instance.PostMsg(RouteManager.MSG.SetManualMode); if (SC.GetStringValue("System.EFEMNUM") == "005") { _trigWaterLeakNormalTOPM.CLK = DeviceModel.SensorEFEMPowerON.Value && DeviceModel.SensorWaterLeakSW.Value; if (_trigWaterLeakNormalTOPM.R) { DeviceModel.TrigWaterLeakOkToPM.SetTrigger(true, out _); } if (_trigWaterLeakNormalTOPM.T) { DeviceModel.TrigWaterLeakOkToPM.SetTrigger(false, out _); } _trigCDAPressureOKTOPM.CLK = DeviceModel.SensorEFEMPowerON.Value && DeviceModel.SensorCDAPressureSW.Value; if (_trigCDAPressureOKTOPM.R) { DeviceModel.TrigCDAPressureOkToPM.SetTrigger(true, out _); } if (_trigCDAPressureOKTOPM.T) { DeviceModel.TrigCDAPressureOkToPM.SetTrigger(false, out _); } } _fFUSettingKnob = SC.ContainsItem("System.FFUSpeedSet") ? SC.GetValue("System.FFUSpeedSet") : 3; //DeviceModel.TrigRobotAndPreAlignerHold.SetTrigger(!_trigMaintenance.M, out _); //_trigRobotWafer.CLK = DeviceModel.SensorRobotFork1WaferOn.Value; _trigStopIonizerAtFirst.CLK = true; if (_trigStopIonizerAtFirst.Q) { //if (DeviceModel.TrigIonizerInterrupt!=null&& SC.ContainsItem("System.StopIonizerWorkingEnable")) //{ // if (DeviceModel.TrigIonizerInterrupt.Value != SC.GetValue("System.StopIonizerWorkingEnable")) // SC.SetItemValue("System.StopIonizerWorkingEnable", DeviceModel.TrigIonizerInterrupt.Value); //} if (SC.GetValue("LoadPort.LP1.CstType")==1) { if (DeviceModel.SensorCstDoorClosed.Value && !DEVICE.GetDevice(ModuleName.LP1.ToString()).IsWaferProtrude) { DeviceModel.TrigSafetytoSMIF1.SetTrigger(true, out _); } } } if (DeviceModel.TrigIonizerInterrupt != null && !DeviceModel.TrigIonizerInterrupt.Value) { //_trigIONAlarmSIGNAL.CLK = DeviceModel.SensorIONAlarmSIGNAL == null ? false : !DeviceModel.SensorIONAlarmSIGNAL.Value; //if (_trigIONAlarmSIGNAL.R) //{ // EV.PostMessage("System", EventEnum.DefaultAlarm, "IONAlarmSIGNAL occur error"); //} switch (IONAlarmSIGNALHandler) { case (int)HandlerState.ON: { _trigIONAlarmSIGNALON.CLK = DeviceModel.SensorIONAlarmSIGNAL.Value; if (_trigIONAlarmSIGNALON.Q) { EV.PostMessage("System", EventEnum.DefaultAlarm, "IONAlarmSIGNAL occur error"); } } break; case (int)HandlerState.OFF: { _trigIONAlarmSIGNALON.CLK = !DeviceModel.SensorIONAlarmSIGNAL.Value; if (_trigIONAlarmSIGNALON.Q) { EV.PostMessage("System", EventEnum.DefaultAlarm, "IONAlarmSIGNAL occur error"); } } break; } } //else // _trigIONAlarmSIGNAL.RST = true; if (DeviceModel.TrigIonizerInterrupt != null && DeviceModel.TrigIonizerInterrupt.Value != StopIonizerWork) { DeviceModel.TrigIonizerInterrupt.SetTrigger(StopIonizerWork, out _); } if (Singleton.Instance.IsOnlineMode) { if(_trigMaintenance.R || _trigMaintenance.T || _airForLoadPortTrig.R || _airForLoadPortTrig.T || _airForRobotTrig.R || _airForRobotTrig.T || _vacuumErrorTrig.R || _vacuumErrorTrig.T || _ffu1ErrorTrig.R || _ffu1ErrorTrig.T || _ffu2ErrorTrig.R || _ffu2ErrorTrig.T || _ionizorErrorTrig.R || _ionizorErrorTrig.T || _flowWarningTrig.T || _leakWarningTrig.R || _trigCassetteDoor.T || _trigRobotWafer.R || _trigRobotWafer.T ) { Singleton.Instance.SendSigStatEvent(ModuleName.System); } } switch (IONCDAPressureSWHandler) { case (int)HandlerState.ON: { _trigIONCDAPressureON.CLK = DeviceModel.SensorIONCDAPressureSW.Value; if (_trigIONCDAPressureON.Q) { EV.PostMessage("System", EventEnum.DefaultAlarm, "IONCDAPressureSW occur error"); } } break; case (int)HandlerState.OFF: { _trigIONCDAPressureOFF.CLK = !DeviceModel.SensorIONCDAPressureSW.Value; if (_trigIONCDAPressureOFF.Q) { EV.PostMessage("System", EventEnum.DefaultAlarm, "IONCDAPressureSW occur error"); } } break; } switch (WaterFlowSWHandler) { case (int)HandlerState.ON: { _trigWaterFlowSWON.CLK = DeviceModel.SensorWaterFlowSW.Value; if (_trigWaterFlowSWON.Q) { EV.PostMessage("System", EventEnum.DefaultAlarm, "WaterFlowSW occur error"); } } break; case (int)HandlerState.OFF: { _trigWaterFlowSWOFF.CLK = !DeviceModel.SensorWaterFlowSW.Value; if (_trigWaterFlowSWOFF.Q) { EV.PostMessage("System", EventEnum.DefaultAlarm, "WaterFlowSW occur error"); } } break; } if (signalTowerTrig.Q) { data2 = Singleton.Instance.GetSigStatData2(ModuleName.System); signalTowerTrig.RST = true; if (Singleton.Instance.IsOnlineMode) Singleton.Instance.SendSigStatEvent(ModuleName.System); } } public void Terminate() { //if (_dOLEDLight) //{ // DeviceModel.TrigLEDLight.SetTrigger(false, out _); //} } public void Reset() { _trigWaterFlowSWOFF.RST = true; _trigWaterFlowSWON.RST = true; _trigIONCDAPressureOFF.RST = true; _trigIONCDAPressureON.RST = true; _trigIONAlarmSIGNALON.RST = true; _trigIONAlarmSIGNALOFF.RST = true; } private void Subscriptions() { //DATA.Subscribe("Robot.WaferSize", () => // { // return WaferManager.Instance.GetWaferSize(ModuleName.Robot, 0).ToString(); // }); } } }