123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Device.Bases;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TMs;
- using System;
- using IoMfc = Venus_RT.Devices.IODevices.IoMfc;
- using IoPressureMeter = Venus_RT.Devices.IODevices.IoPressureMeter;
- using Venus_Core;
- using Venus_RT.Modules;
- namespace Venus_RT.Devices
- {
- public class HongHuTM : TM
- {
- /// <summary>
- /// 针对VenusSE设计
- /// </summary>
- #region io 信号抽象
- //控制阀信号
- private readonly IoValve _TMFastPumpValve;
- private readonly IoValve _TMSoftPumpValve;
- private readonly IoValve _VCESoftPumpValve;
- private readonly IoValve _VCEFastPumpValve;
- private readonly IoValve _TMFastVentValve;
- private readonly IoValve _TMSoftVentValve;
- private readonly IoValve _VCESoftVentValve;
- private readonly IoValve _VCEFastVentValve;
- //判断信号
- private readonly IoSensor _VCESlitDoorOpen;
- private readonly IoSensor _PMASlitDoorOpen;
- private readonly IoSensor _PMBSlitDoorOpen;
- private readonly IoSensor _PMCSlitDoorOpen;
- private readonly IoSensor _VCESlitDoorOpenEnable;
- private readonly IoSensor _PMASlitDoorOpenEnable;
- private readonly IoSensor _PMBSlitDoorOpenEnable;
- private readonly IoSensor _PMCSlitDoorOpenEnable;
- private readonly IoSensor _TMExtendVCEEnable;
- private readonly IoSensor _TMExtendPMAEnable;
- private readonly IoSensor _TMExtendPMBEnable;
- private readonly IoSensor _TMExtendPMCEnable;
- private readonly IoSensor _TMVACSensor;
- private readonly IoSensor _VCEVACSensor;
- //控制门信号
- private readonly IoCylinder _VCESlitDoor;
- private readonly IoCylinder _PMASlitDoor;
- private readonly IoCylinder _PMBSlitDoor;
- private readonly IoCylinder _PMCSlitDoor;
- private readonly IoMfc _TMMfc;
- private readonly IoPressureMeter _TMPressure;
- private readonly IoPressureMeter _TMPiplinePressure;
- private readonly IoPressureMeter _VCEPressure;
- private readonly IoPressureMeter _VCEPiplinePressure;
- private readonly PumpBase _TMPump;
- //控压
-
- //安装的module
- private string _allInstalledModules { get { return SC.GetStringValue("System.InstalledModules").ToString(); } }
- #endregion
- #region 暴露变量
- //ATM VAC信号
- public bool IsTMATM => _TMPressure.Value >= SC.GetValue<double>($"{Module}.ATMTargetPressure");
- public bool IsVCEATM => _VCEPressure.Value >= SC.GetValue<double>("VCE1.ATMTargetPressure");
- public bool IsTMVAC => _TMVACSensor.Value;
- public bool IsVCEVAC => _VCEVACSensor.Value;
- public bool? IsTMPumpRunning => _TMPump?.IsRunning;
- //valve开关状态
- public bool IsTMFastPumpOpen => _TMFastPumpValve.Status;
- public bool IsTMSoftPumpOpen => _TMSoftPumpValve.Status;
- public bool IsTMFastVentOpen => _TMFastVentValve.Status;
- public bool IsTMSoftVentOpen => _TMSoftVentValve.Status;
- public bool IsVCEFastPumpOpen => _VCEFastPumpValve.Status;
- public bool IsVCESoftPumpOpen => _VCESoftPumpValve.Status;
- public bool IsVCEFastVentOpen => _VCEFastVentValve.Status;
- public bool IsVCESoftVentOpen => _VCESoftVentValve.Status;
- public bool IsTMVentValveOpen => IsTMFastVentOpen && IsTMSoftVentOpen;
- public bool IsVCEVentValveOpen => IsVCEFastVentOpen && IsVCESoftVentOpen;
- //SlitDoor
- public bool VCESlitDoorClosed => _VCESlitDoor.State == CylinderState.Close;
- public bool PMASlitDoorClosed
- {
- get
- {
- if (_allInstalledModules.Contains("PMA"))
- return _PMASlitDoor.State == CylinderState.Close;
- else
- return true;
- }
- }
- public bool PMBSlitDoorClosed
- {
- get
- {
- if (_allInstalledModules.Contains("PMB"))
- return _PMBSlitDoor.State == CylinderState.Close;
- else
- return true;
- }
- }
- public bool PMCSlitDoorClosed
- {
- get
- {
- if (_allInstalledModules.Contains("PMC"))
- return _PMCSlitDoor.State == CylinderState.Close;
- else
- return true;
- }
- }
- public bool AllPMSlitDoorClosed
- {
- get
- {
- if (PMASlitDoorClosed && PMBSlitDoorClosed && PMCSlitDoorClosed)
- return true;
- else
- return false;
- }
- }
- public bool VCESlitDoorOpenEnable => _VCESlitDoorOpenEnable.Value;
- public bool PMASlitDoorOpenEnable => _PMASlitDoorOpenEnable.Value;
- public bool PMBSlitDoorOpenEnable => _PMBSlitDoorOpenEnable.Value;
- public bool PMCSlitDoorOpenEnable => _PMCSlitDoorOpenEnable.Value;
- //Robot动作
- public bool TMExtendVCEEnable => _TMExtendVCEEnable.Value;
- public bool TMExtendPMAEnable => _TMExtendPMAEnable.Value;
- public bool TMExtendPMBEnable => _TMExtendPMBEnable.Value;
- public bool TMExtendPMCEnable => _TMExtendPMCEnable.Value;
- public double TMPressure => _TMPressure.Value;
- public double VCEPressure => _VCEPressure.Value;
- enum PumpState
- {
- Idle,
- TMUsing,
- VCEUsing,
- }
- PumpState _PumpingState = PumpState.Idle;
- #endregion
- public HongHuTM() : base(ModuleName.SETM.ToString())
- {
- Module = ModuleName.SETM.ToString();
- _TMFastPumpValve = DEVICE.GetDevice<IoValve>($"{Module}.{VenusDevice.TMFastPumpValve}");
- _TMSoftPumpValve = DEVICE.GetDevice<IoValve>($"{Module}.{VenusDevice.TMSoftPumpValve}");
- _VCESoftPumpValve = DEVICE.GetDevice<IoValve>($"{Module}.{VenusDevice.VCESoftPumpValve}");
- _VCEFastPumpValve = DEVICE.GetDevice<IoValve>($"{Module}.{VenusDevice.VCEFastPumpValve}");
- _TMFastVentValve = DEVICE.GetDevice<IoValve>($"{Module}.{VenusDevice.TMFastVentValve}");
- _TMSoftVentValve = DEVICE.GetDevice<IoValve>($"{Module}.{VenusDevice.TMSoftVentValve}");
- _VCESoftVentValve = DEVICE.GetDevice<IoValve>($"{Module}.{VenusDevice.VCESoftVentValve}");
- _VCEFastVentValve = DEVICE.GetDevice<IoValve>($"{Module}.{VenusDevice.VCEFastVentValve}");
- _VCESlitDoorOpenEnable = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.VCESlitDoorOpenEnable}");
- _PMASlitDoorOpenEnable = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.PMASlitDoorOpenEnable}");
- _PMBSlitDoorOpenEnable = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.PMBSlitDoorOpenEnable}");
- _PMCSlitDoorOpenEnable = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.PMCSlitDoorOpenEnable}");
- _TMExtendVCEEnable = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.TMExtendVCEEnable}");
- _TMExtendPMAEnable = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.TMExtendPMAEnable}");
- _TMExtendPMBEnable = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.TMExtendPMBEnable}");
- _TMExtendPMCEnable = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.TMExtendPMCEnable}");
- _TMVACSensor = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.TMVACSensor}");
- _VCEVACSensor = DEVICE.GetDevice<IoSensor>($"{Module}.{VenusDevice.VCEVACSensor}");
- _VCESlitDoor = DEVICE.GetDevice<IoCylinder>($"{Module}.{VenusDevice.VCESlitDoor}");
- _PMASlitDoor = DEVICE.GetDevice<IoCylinder>($"{Module}.{VenusDevice.PMASlitDoor}");
- _PMBSlitDoor = DEVICE.GetDevice<IoCylinder>($"{Module}.{VenusDevice.PMBSlitDoor}");
- _PMCSlitDoor = DEVICE.GetDevice<IoCylinder>($"{Module}.{VenusDevice.PMCSlitDoor}");
- _TMMfc = DEVICE.GetDevice<IoMfc>($"{Module}.TM_MFC1");
- _TMPressure = DEVICE.GetDevice<IoPressureMeter>($"{Module}.TMPressure");
- _TMPiplinePressure = DEVICE.GetDevice<IoPressureMeter>($"{Module}.TMPipelinePressure");
- _VCEPressure = DEVICE.GetDevice<IoPressureMeter>($"{Module}.VCEPressure");
- _VCEPiplinePressure = DEVICE.GetDevice<IoPressureMeter>($"{Module}.VCEPipelinePressure");
- if (SC.GetValue<int>($"{Module}.DryPump.CommunicationType") == (int)CommunicationType.RS232)
- {
- if (SC.GetValue<int>($"{Module}.DryPump.MFG") == (int)DryPumpMFG.SKY)
- {
- _TMPump = DEVICE.GetDevice<SkyPump>($"{Module}.{VenusDevice.MainPump}");
- }
- else if (SC.GetValue<int>($"{Module}.DryPump.MFG") == (int)DryPumpMFG.Edwards)
- {
- _TMPump = DEVICE.GetDevice<EdwardsPump>($"{Module}.{VenusDevice.MainPump}");
- }
- }
- DATA.Subscribe($"{Module}.VCESlitDoorClosed", () => VCESlitDoorClosed);
- DATA.Subscribe($"{Module}.PMASlitDoorClosed", () => PMASlitDoorClosed);
- DATA.Subscribe($"{Module}.PMBSlitDoorClosed", () => PMBSlitDoorClosed);
- DATA.Subscribe($"{Module}.PMCSlitDoorClosed", () => PMCSlitDoorClosed);
- DATA.Subscribe($"{Module}.PumpIsRunning", () => IsTMPumpRunning, SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.TMIsATM", ()=> IsTMATM);
- DATA.Subscribe($"{Module}.VCEIsATM", ()=> IsVCEATM);
- OP.Subscribe($"{Module}.ControlPump", (cmd, args) =>
- {
- _TMPump.SetPumpOnOff((bool)args[0]);
- return true;
- });
- OP.Subscribe($"{Module}.SetSlitDoor", (cmd, args) =>
- {
- var module = (ModuleName)Enum.Parse(typeof(ModuleName), args[0].ToString());
- return TurnSlitDoor(module, (bool)args[1]);
- });
- }
- #region IO控制方法
- //slitdoor
- //2023/11/1 增加两边压差比较
- public bool TurnSlitDoor(ModuleName mod, bool bOn)
- {
- double MaxPressureDifference = SC.GetValue<double>("System.PMTMMaxPressureDifference");
- switch (mod)
- {
- case ModuleName.VCE1:
- if (bOn && Math.Abs(_TMPressure.Value - _VCEPressure.Value)> MaxPressureDifference)
- {
- LOG.Write(eEvent.ERR_TM, ModuleName.SETM, $"cannot open door cause pressure, TM Pressure:{_TMPressure.Value} and VCE Pressure:{_VCEPressure.Value}");
- return false;
- }
- return _VCESlitDoor.SetCylinder(bOn, out _);
- case ModuleName.PMA:
- if (bOn && !CanOpenSlitDoor(mod, MaxPressureDifference))
- return false;
- return _PMASlitDoor.SetCylinder(bOn, out _);
- case ModuleName.PMB:
- if (bOn && !CanOpenSlitDoor(mod, MaxPressureDifference))
- return false;
- return _PMBSlitDoor.SetCylinder(bOn, out _);
- case ModuleName.PMC:
- if (bOn && !CanOpenSlitDoor(mod, MaxPressureDifference))
- return false;
- return _PMCSlitDoor.SetCylinder(bOn, out _);
- }
- return false;
- }
- //valve
- public void TurnFastPumpValve(ModuleName mod, bool bOn)
- {
- switch (mod)
- {
- case ModuleName.SETM:
- _TMFastPumpValve.TurnValve(bOn, out string _);
- break;
- case ModuleName.VCE1:
- _VCEFastPumpValve.TurnValve(bOn, out string _);
- break;
- }
- }
- public void TurnSoftPumpValve(ModuleName mod, bool bOn)
- {
- switch (mod)
- {
- case ModuleName.SETM:
- _TMSoftPumpValve.TurnValve(bOn, out string _);
- break;
- case ModuleName.VCE1:
- _VCESoftPumpValve.TurnValve(bOn, out string _);
- break;
- }
- }
- public void TurnFastVentValve(ModuleName mod, bool bOn)
- {
- switch (mod)
- {
- case ModuleName.SETM:
- _TMFastVentValve.TurnValve(bOn, out string _);
- break;
- case ModuleName.VCE1:
- _VCEFastVentValve.TurnValve(bOn, out string _);
- break;
- }
- }
- public void TurnSoftVentValve(ModuleName mod, bool bOn)
- {
- switch (mod)
- {
- case ModuleName.SETM:
- _TMSoftVentValve.TurnValve(bOn, out string _);
- break;
- case ModuleName.VCE1:
- _VCESoftVentValve.TurnValve(bOn, out string _);
- break;
- }
- }
- public bool CloseAllSlitDoor()
- {
- _VCESlitDoor.SetCylinder(false, out _);
- if (_allInstalledModules.Contains("PMA"))
- _PMASlitDoor.SetCylinder(false, out _);
- if (_allInstalledModules.Contains("PMB"))
- _PMBSlitDoor.SetCylinder(false, out _);
- if (_allInstalledModules.Contains("PMC"))
- _PMCSlitDoor.SetCylinder(false, out _);
- return true;
- }
- public void HomeVceSlitDoor()
- {
- //由SlitDoor的状态对其下发同样的指令
- if (VCESlitDoorClosed == true)
- _VCESlitDoor.SetCylinder(false, out _);
- else
- _VCESlitDoor.SetCylinder(true, out _);
- }
- public void CloseVentValve()
- {
- _TMSoftVentValve.TurnValve(false, out _);
- _TMFastVentValve.TurnValve(false, out _);
- _VCESoftVentValve.TurnValve(false, out _);
- _VCEFastVentValve.TurnValve(false, out _);
- }
- public bool CheckPumpValveClosed(ModuleName mod)
- {
- switch (mod)
- {
- case ModuleName.SETM:
- return !IsTMFastPumpOpen && !IsTMSoftPumpOpen;
- case ModuleName.VCE1:
- return !IsVCEFastPumpOpen && !IsVCESoftPumpOpen;
- }
- return true;
- }
- public bool CheckVentValveClosed(ModuleName mod)
- {
- switch (mod)
- {
- case ModuleName.SETM:
- if (IsTMVentValveOpen)
- {
- LOG.Write(eEvent.ERR_TM, ModuleName.SETM, "TM Vent Valve not closed");
- return false;
- }
- break;
- case ModuleName.VCE1:
- if (IsVCEVentValveOpen)
- {
- LOG.Write(eEvent.ERR_TM, ModuleName.VCE1, "VCE1 Vent Valve not closed");
- return false;
- }
- break;
- }
- return true;
- }
- public void SetTMFlow(int flowValue)
- {
- _TMMfc.SetPoint = (flowValue);
- }
- public double GetModulePressure(ModuleName mod)
- {
- switch (mod)
- {
- case ModuleName.SETM:
- return TMPressure;
- case ModuleName.VCE1:
- return VCEPressure;
- }
- return 0.0;
- }
- public bool TryGetPump(ModuleName mod)
- {
- //Self
- if ((mod == ModuleName.VCE1 && _PumpingState == PumpState.VCEUsing) || (mod == ModuleName.SETM && _PumpingState == PumpState.TMUsing))
- return true;
- //Idle
- if (mod == ModuleName.SETM && !IsTMFastPumpOpen && !IsTMSoftPumpOpen && _PumpingState == PumpState.Idle)
- {
- _PumpingState = PumpState.TMUsing;
- return true;
- }
- if (mod == ModuleName.VCE1 && !IsVCEFastPumpOpen && !IsVCESoftPumpOpen && _PumpingState == PumpState.Idle)
- {
- _PumpingState = PumpState.VCEUsing;
- return true;
- }
- LOG.Write(eEvent.WARN_DEFAULT_WARN, mod, "无法打开,另一个泵正在用!");
- //locked
- return false;
- }
- public void ReleasePump(ModuleName Module)
- {
- //release pump (must do it by user)
- if ((Module == ModuleName.SETM && _PumpingState == PumpState.TMUsing) || (Module == ModuleName.VCE1 && _PumpingState == PumpState.VCEUsing))
- _PumpingState = PumpState.Idle;
- }
- #endregion
- #region 工具方法
- private bool CanOpenSlitDoor(ModuleName mod,double MaxPressureDifference)
- {
- if (Singleton<RouteManager>.Instance.GetPM(mod) == null || RouteManager.IsATMMode)
- return true;
- else
- {
- double PMPressure = Singleton<RouteManager>.Instance.GetPM(mod).ChamberPressure;
- if (Math.Abs(_TMPressure.Value - PMPressure) > MaxPressureDifference)
- {
- LOG.Write(eEvent.ERR_TM, $"cannot open door cause pressure, TM Pressure:{_TMPressure.Value} and {mod} pressure:{PMPressure}");
- return false;
- }
- else
- return true;
- }
-
- }
- #endregion
- }
- }
|