using Aitex.Core.RT.Device; using Aitex.Core.RT.Event; using Aitex.Core.RT.Log; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using EFEM.RT.Modules; using MECF.Framework.Common.Equipment; 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 static readonly bool LoadPort1IsDisable = SC.ContainsItem("LoadPort.LP1.Disable") ? SC.GetValue("LoadPort.LP1.Disable") : true; private static readonly bool LoadPort2IsDisable = SC.ContainsItem("LoadPort.LP2.Disable") ? SC.GetValue("LoadPort.LP2.Disable") : true; 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 (_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 (_airForRobotTrig.R || _airForLoadPortTrig.R || _vacuumErrorTrig.R) Singleton.Instance.PostMsg(RouteManager.MSG.ERROR); //if (_ffu1ErrorTrig.R) EV.PostMessage("System", EventEnum.DefaultAlarm, "FFU1 error"); //if (_ffu2ErrorTrig.R) EV.PostMessage("System", EventEnum.DefaultAlarm, "FFU1 error"); //_fFUSettingKnob = SC.ContainsItem("System.FFUSpeedSet") ? SC.GetValue("System.FFUSpeedSet") : 3; //DeviceModel.TrigRobotAndPreAlignerHold.SetTrigger(!_trigMaintenance.M, out _); //_trigRobotWafer.CLK = DeviceModel.SensorRobotFork1WaferOn.Value; #region Seperate Monitor for EFEM Num string efemNum = SC.GetStringValue("System.EFEMNUM") ?? ""; MonitorByEfemNum(efemNum); #endregion Seperate Monitor for EFEM Num #region Common Monitor //Maintance Mode监控 if (!_noMaintenanceSignal && !_noNoDoorOpenSignal) { _trigMaintenance.CLK = (_MaintenanceMode ? DeviceModel.SensorMaintenanceMode.Value : !DeviceModel.SensorMaintenanceMode.Value) || (_EfemDoorOpen ? DeviceModel.SensorEFEMSideDoorClosed.Value : !DeviceModel.SensorEFEMSideDoorClosed.Value) /*|| DeviceModel.SensorTeachingPendantInUse.Value*/; } if (_trigMaintenance.R) Singleton.Instance.PostMsg(RouteManager.MSG.SetMaintenanceMode); if (_trigMaintenance.T) Singleton.Instance.PostMsg(RouteManager.MSG.SetManualMode); _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 _); } } } //IonizerInterrupt 监控 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; } } if (DeviceModel.TrigIonizerInterrupt != null && DeviceModel.TrigIonizerInterrupt.Value != StopIonizerWork) { DeviceModel.TrigIonizerInterrupt.SetTrigger(StopIonizerWork, out _); } //Online Mode 监控 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); } } //IONCDAPressureSW 监控 if (DeviceModel.SensorIONCDAPressureSW != null) { 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; } } //WaterFlowSW 监控 if (DeviceModel.SensorWaterFlowSW != null) { 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; } } //SignalTower监控 if (signalTowerTrig.Q) { data2 = Singleton.Instance.GetSigStatData2(ModuleName.System); signalTowerTrig.RST = true; if (Singleton.Instance.IsOnlineMode) Singleton.Instance.SendSigStatEvent(ModuleName.System); } #endregion Common Monitor } 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(); // }); } /// /// 不同型号的EFEM监控 /// private void MonitorByEfemNum(string efemNum) { if (efemNum.Equals("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 _); } } else if (efemNum.Equals("006")) { //DO_RobotSafetyToLP1触发逻辑 if (!LoadPort1IsDisable && DeviceModel.SensorLP1OperationStatus != null && DeviceModel.SensorLP1FoupOpen != null && DeviceModel.SensorLP1FoupPlacement != null && DeviceModel.SensorLP1Presence != null && DeviceModel.SensorLP1Ready != null && DeviceModel.SensorRobotEMStoEFEM != null && DeviceModel.SensorGratingSensorIN1 != null && DeviceModel.TrigSafetytoSMIF1 != null) { if (DeviceModel.SensorLP1OperationStatus.Value && DeviceModel.SensorLP1FoupOpen.Value && DeviceModel.SensorLP1FoupPlacement.Value && DeviceModel.SensorLP1Presence.Value && DeviceModel.SensorLP1Ready.Value && DeviceModel.SensorRobotEMStoEFEM.Value && DeviceModel.SensorGratingSensorIN1.Value) { if (!DeviceModel.TrigSafetytoSMIF1.Value) { DeviceModel.TrigSafetytoSMIF1.SetTrigger(true, out _); LOG.Write("Sensor LP1 related signal change,set DO_RobotSafetyToLP1 signal on."); } } else { if (DeviceModel.TrigSafetytoSMIF1.Value) { DeviceModel.TrigSafetytoSMIF1.SetTrigger(false, out _); LOG.Write("Sensor LP1 related signal change,set DO_RobotSafetyToLP1 signal off."); } } } //DO_RobotSafetyToLP2触发逻辑 if (!LoadPort2IsDisable && DeviceModel.SensorLP2OperationStatus != null && DeviceModel.SensorLP2FoupOpen != null && DeviceModel.SensorLP2FoupPlacement != null && DeviceModel.SensorLP2Presence != null && DeviceModel.SensorLP2Ready != null && DeviceModel.SensorRobotEMStoEFEM != null && DeviceModel.SensorGratingSensorIN1 != null && DeviceModel.TrigSafetytoSMIF2 != null) { if (DeviceModel.SensorLP2OperationStatus.Value && DeviceModel.SensorLP2FoupOpen.Value && DeviceModel.SensorLP2FoupPlacement.Value && DeviceModel.SensorLP2Presence.Value && DeviceModel.SensorLP2Ready.Value && DeviceModel.SensorRobotEMStoEFEM.Value && DeviceModel.SensorGratingSensorIN1.Value) { if (!DeviceModel.TrigSafetytoSMIF2.Value) { DeviceModel.TrigSafetytoSMIF2.SetTrigger(true, out _); LOG.Write("Sensor LP2 related signal change,set DO_RobotSafetyToLP2 signal on."); } } else { if (DeviceModel.TrigSafetytoSMIF2.Value) { DeviceModel.TrigSafetytoSMIF2.SetTrigger(false, out _); LOG.Write("Sensor LP2 related signal change,set DO_RobotSafetyToLP2 signal off."); } } } //DO_EnableToOperateLP1触发逻辑 if (!LoadPort1IsDisable && DeviceModel.TrigEnableToOperateLP1 != null) { if ((SC.ContainsItem("LoadPort.LP1.Disable") ? !SC.GetValue("LoadPort.LP1.Disable") : false) && Singleton.Instance.IsRunning) { if (!DeviceModel.TrigEnableToOperateLP1.Value) { DeviceModel.TrigEnableToOperateLP1.SetTrigger(true, out _); LOG.Write("Sensor LP1 related signal change,set DO_EnableToOperateLP1 signal on."); } } else { if (DeviceModel.TrigEnableToOperateLP1.Value) { DeviceModel.TrigEnableToOperateLP1.SetTrigger(false, out _); LOG.Write("Sensor LP1 related signal change,set DO_EnableToOperateLP1 signal on."); } } } //DO_EnableToOperateLP2触发逻辑 if (!LoadPort2IsDisable && DeviceModel.TrigEnableToOperateLP2 != null) { if ((SC.ContainsItem("LoadPort.LP2.Disable") ? !SC.GetValue("LoadPort.LP2.Disable") : false) && Singleton.Instance.IsRunning) { if (!DeviceModel.TrigEnableToOperateLP2.Value) { DeviceModel.TrigEnableToOperateLP2.SetTrigger(true, out _); LOG.Write("Sensor LP2 related signal change,set DO_EnableToOperateLP2 signal on."); } } else { if (DeviceModel.TrigEnableToOperateLP2.Value) { DeviceModel.TrigEnableToOperateLP2.SetTrigger(false, out _); LOG.Write("Sensor LP2 related signal change,set DO_EnableToOperateLP2 signal on."); } } } //Pause / Resume to Robot触发逻辑(----------待完善----------) //if (DeviceModel.SensorGratingSensorIN1 != null && DeviceModel.SensorRBNotExtendSIMF1 != null && DeviceModel.SensorRBNotExtendSIMF1 != null // && DeviceModel.SensorPAorFLPDoorClosed != null) //{ // if (true) // { // if (DeviceModel.TrigPauseResumetoRobot.Value) // { // DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out _); // } // if (!DeviceModel.TrigPauseResumetoRobot.Value) // { // DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out _); // } // } //} } } } }