123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- 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<bool>("DOLEDLight") ?? false;
- private readonly bool _noMaintenanceSignal = DeviceDefineManager.Instance.GetValue<bool>("NoMaintenanceSignal") ?? false;
- private readonly bool _noNoDoorOpenSignal = DeviceDefineManager.Instance.GetValue<bool>("NoDoorOpenSignal") ?? false;
- private readonly bool _MaintenanceMode = DeviceDefineManager.Instance.GetValue<bool>("MaintenanceSignal") ?? false;
- private readonly bool _EfemDoorOpen = DeviceDefineManager.Instance.GetValue<bool>("EfemDoorOpenSignal") ?? false;
- private static readonly bool LoadPort1IsDisable = SC.ContainsItem("LoadPort.LP1.Disable") ? SC.GetValue<bool>("LoadPort.LP1.Disable") : true;
- private static readonly bool LoadPort2IsDisable = SC.ContainsItem("LoadPort.LP2.Disable") ? SC.GetValue<bool>("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<int>("System.IONCDAPressureSWHandler");
- }
- }
- public int IONAlarmSIGNALHandler
- {
- get
- {
- return SC.GetValue<int>("System.IONAlarmSIGNALHandler");
- }
- }
- public int WaterFlowSWHandler
- {
- get
- {
- return SC.GetValue<int>("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<bool>("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<RouteManager>.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<int>("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<RouteManager>.Instance.PostMsg(RouteManager.MSG.SetMaintenanceMode);
- if (_trigMaintenance.T) Singleton<RouteManager>.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<bool>("System.StopIonizerWorkingEnable"))
- // SC.SetItemValue("System.StopIonizerWorkingEnable", DeviceModel.TrigIonizerInterrupt.Value);
- //}
- if (SC.GetValue<int>("LoadPort.LP1.CstType") == 1)
- {
- if (DeviceModel.SensorCstDoorClosed.Value && !DEVICE.GetDevice<LoadPortBaseDevice>(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<EfemEntity>.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<EfemEntity>.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<EfemEntity>.Instance.GetSigStatData2(ModuleName.System);
- signalTowerTrig.RST = true;
- if (Singleton<EfemEntity>.Instance.IsOnlineMode)
- Singleton<EfemEntity>.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();
- // });
- }
- /// <summary>
- /// 不同型号的EFEM监控
- /// </summary>
- 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<bool>("LoadPort.LP1.Disable") : false)
- && Singleton<RouteManager>.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<bool>("LoadPort.LP2.Disable") : false)
- && Singleton<RouteManager>.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 _);
- // }
- // }
- //}
- }
- }
- }
- }
|