using System; using System.Collections.Generic; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.IOCore; using Aitex.Core.RT.Log; using Aitex.Core.Util; using Aitex.Core.WCF; using EfemDualSimulator.Devices; using MECF.Framework.Common.Equipment; using MECF.Framework.Simulator.Core.Driver; namespace EfemDualSimulator.Instances { public class SimulatorSystem : Singleton { private PeriodicJob _thread; private Random _rd = new Random(); private RD_TRIG _trigATM = new RD_TRIG(); private RD_TRIG _trigVAC = new RD_TRIG(); private readonly float ATM_THRESHOLD = 750000; private readonly float ATM_PRESSURE = 760000; private readonly uint VAC_SW_PRESSURE = 9500; private readonly uint PROCESS_GAUGE = 10000; private Dictionary _MockDevices = new Dictionary(); public SimulatorSystem() { //_MockDevices.Add(ModuleName.PMB, new SkyPumpMock()); //_MockDevices.Add(ModuleName.PMB, new AdTecGeneratorMock()); //_MockDevices.Add(ModuleName.PMB, new AdTecMatchMock()); // TODO } ~SimulatorSystem() { _thread?.Stop(); } public void Initialize() { SetDefaultValue(ModuleName.PMA); SetDefaultValue(ModuleName.PMB); Singleton.Instance.Initialize(false); WcfServiceManager.Instance.Initialize(new Type[] { typeof(SimulatorPlc0) }); WcfServiceManager.Instance.Initialize(new Type[] { typeof(SimulatorPlc1) }); WcfServiceManager.Instance.Initialize(new Type[] { typeof(SimulatorPlc2) }); _thread = new PeriodicJob(500, OnMonitor, nameof(SimulatorSystem), true); } private void SetDefaultValue(ModuleName mod) { // TM IO.DI[$"System.DI_EFEMRBNotExtendBFA"].Value = true; IO.DI[$"System.DI_EFEMRBNotExtendBFB"].Value = true; IO.DI[$"System.DI_TMRBNotExtendBFA"].Value = true; IO.DI[$"System.DI_TMRBNotExtendBFB"].Value = true; IO.DI[$"System.DI_TMPowerOn"].Value = true; IO.DI[$"System.DI_TMSideDoorClosed"].Value = true; IO.DI[$"System.DI_TMInSafety"].Value = true; IO.DI[$"System.DI_TMBufferOTSW"].Value = true; IO.DI[$"System.DI_WaterFlowSW"].Value = true; IO.DI[$"System.DI_WaterLeakSW"].Value = true; IO.DI[$"System.DI_TMFFUNormal"].Value = true; IO.DI[$"System.DI_EFEMSidePlanClosed"].Value = true; IO.DI[$"System.DI_CDAPressureSW"].Value = true; IO.DI[$"System.DI_VaccumPressureSW"].Value = true; IO.DI[$"System.DI_Buffer_ASmallWaferProtrusion"].Value = false; IO.DI[$"System.DI_Buffer_ABigWaferProtrusion"].Value = false; IO.DI[$"System.DI_Buffer_BSmallWaferProtrusion"].Value = false; IO.DI[$"System.DI_Buffer_BBigWaferProtrusion"].Value = false; IO.DI[$"System.DI_INONormal"].Value = true; IO.DI[$"System.DI_TMRobotAlarm"].Value = true; IO.DI[$"System.DI_Buffer_ATCDeviationOutOfRange"].Value = false; IO.DI[$"System.DI_Buffer_AControlTCBrokenAlarm"].Value = false; IO.DI[$"System.DI_Buffer_AMonitorTCBrokenAlarm"].Value = false; // chamber IO.DI[$"{mod}.DI_LidClosed"].Value = true; IO.DI[$"{mod}.DI_ATMSW"].Value = true; IO.DI[$"{mod}.DI_SouceFan"].Value = true; IO.DI[$"{mod}.DI_1_CoolingWaterFlowSW"].Value = true; IO.DI[$"{mod}.DI_2_CoolingWaterFlowSW"].Value = true; IO.DI[$"{mod}.DI_1_CoolantInletTCBrokenAlarm"].Value = false; IO.DI[$"{mod}.DI_1_CoolantOutletTCBrokenAlarm"].Value = false; IO.DI[$"{mod}.DI_2_CoolantInletTCBrokenAlarm"].Value = false; IO.DI[$"{mod}.DI_2_CoolantOutletTCBrokenAlarm"].Value = false; IO.DI[$"{mod}.DI_WaterLeak"].Value = true; IO.DI[$"{mod}.DI_TMRBNotExtendToPM1"].Value = true; IO.DI[$"{mod}.DI_TMRBNotExtendToPM2"].Value = true; IO.DI[$"{mod}.DI_TMInSafety"].Value = true; IO.DI[$"{mod}.DI_MFC1PressureSW"].Value = true; IO.DI[$"{mod}.DI_MFC2PressureSW"].Value = true; IO.DI[$"{mod}.DI_MFC3PressureSW"].Value = true; IO.DI[$"{mod}.DI_MFC4PressureSW"].Value = true; IO.DI[$"{mod}.DI_MFC5PressureSW"].Value = true; IO.DI[$"{mod}.DI_MFC6PressureSW"].Value = true; IO.DI[$"{mod}.DI_GeneratorHardwareInterlock"].Value = true; IO.DI[$"{mod}.DI_N2PressureSW"].Value = true; // slit door IO.DI[$"{mod}.DI_1_SlitDoorOpenPos"].Value = false; IO.DI[$"{mod}.DI_1_SlitDoorClosePos"].Value = true; IO.DI[$"{mod}.DI_2_SlitDoorOpenPos"].Value = false; IO.DI[$"{mod}.DI_2_SlitDoorClosePos"].Value = true; // lift pin IO.DI[$"{mod}.DI_1_LiftPinUp"].Value = false; IO.DI[$"{mod}.DI_1_LiftPinDown"].Value = true; IO.DI[$"{mod}.DI_2_LiftPinUp"].Value = false; IO.DI[$"{mod}.DI_2_LiftPinDown"].Value = true; // IO.DI[$"{mod}.DI_1_LEOTSW"].Value = false; IO.DI[$"{mod}.DI_2_LEOTSW"].Value = false; IO.DI[$"{mod}.DI_GB_Interlock"].Value = true; //Guide pin IO.DI[$"{mod}.DI_1_GuidePinLifterUpPos"].Value = false; IO.DI[$"{mod}.DI_1_GuidePinLifterDownPos"].Value = true; IO.DI[$"{mod}.DI_2_GuidePinLifterUpPos"].Value = false; IO.DI[$"{mod}.DI_2_GuidePinLifterDownPos"].Value = true; // pressure SetAiValue($"{mod}.AI_ForelinePressure", 5000); SetAiValue($"{mod}.AI_ChamberPressure", ATM_PRESSURE); SetAiValue($"{mod}.AI_ProcessPressure", PROCESS_GAUGE); //SetAiValue($"{mod}.AI_Throttle_Valve_State", 1); //IO.AI[$"{mod}.AI_Throttle_Valve_State"].Value = 1; IO.AI[$"{mod}.AI_ThrottleValveRealPosition"].Value = 10; // Temperature SetAiValue($"{mod}.AI_CHBControlTCTemp", 28); SetAiValue($"{mod}.AI_CHBMonitorTCTemp", 27); SetAiValue($"{mod}.AI_ForelineControlTCTemp", 28); SetAiValue($"{mod}.AI_ForelineMonitorTCTemp", 27); SetAiValue($"{mod}.AI_1_LEControlTCTemp", 28); SetAiValue($"{mod}.AI_1_LEMonitorTCTemp", 27); SetAiValue($"{mod}.AI_2_LEControlTCTemp", 28); SetAiValue($"{mod}.AI_2_LEMonitorTCTemp", 27); SetAiValue($"{mod}.AI_1_CoolantInletTemp", 28); SetAiValue($"{mod}.AI_2_CoolantInletTemp", 28); if (mod == ModuleName.PMA) { SetAiValue($"{mod}.AI_1_CoolantOutletTemp", 29); SetAiValue($"{mod}.AI_2_CoolantOutletTemp", 29); } else if (mod == ModuleName.PMB) { SetAiValue($"{mod}.AI_1_CoolantOutletTemp", 29); SetAiValue($"{mod}.AI_2_CoolantOutletTemp", 29); } // Datetime SetAiValue($"{mod}.AI_Year", DateTime.Today.Year); SetAiValue($"{mod}.AI_Month", DateTime.Today.Month); SetAiValue($"{mod}.AI_Day", DateTime.Today.Day); SetAiValue($"{mod}.AI_Time", DateTime.Today.Hour); SetAiValue($"{mod}.AI_Minute", DateTime.Today.Minute); SetAiValue($"{mod}.AI_Second", DateTime.Today.Second); } private bool OnMonitor() { try { // Buffer IO.DI[$"System.DI_Buffer_AHeatPIDATStart_Fb"].Value = IO.DO[$"System.DO_Buffer_AHeatPIDATStart"].Value; IO.DI[$"System.DI_Buffer_AHeatPIDATStop_Fb"].Value = IO.DO[$"System.DO_Buffer_AHeatPIDATStop"].Value; IO.DI[$"System.DI_WaterInletValve"].Value = IO.DO[$"System.DO_WaterInletValve"].Value; IO.DI[$"System.DI_Buffer_AHeatOn_Fb"].Value = IO.DO[$"System.DO_BufferHeatOn"].Value; if (IO.DO[$"System.DO_BufferHeatOn"].Value && GetAiValue($"System.AI_Buffer_AControlTCTemp") < GetAoValue($"System.AO_Buffer_ATemperatureSetpoint")) { SetAiValue($"System.AI_Buffer_AControlTCTemp", GetAiValue($"System.AI_Buffer_AControlTCTemp") + _rd.Next(1, 2)); SetAiValue($"System.AI_Buffer_AMonitorTCTemp", GetAiValue($"System.AI_Buffer_AMonitorTCTemp") + _rd.Next(1, 2)); } else if (IO.DO[$"System.DO_BufferHeatOn"].Value && GetAiValue($"System.AI_Buffer_AControlTCTemp") > GetAoValue($"System.AO_Buffer_ATemperatureSetpoint")) { SetAiValue($"System.AI_Buffer_AControlTCTemp", GetAiValue($"System.AI_Buffer_AControlTCTemp") - _rd.Next(1, 2)); SetAiValue($"System.AI_Buffer_AMonitorTCTemp", GetAiValue($"System.AI_Buffer_AMonitorTCTemp") - _rd.Next(1, 2)); } ChangeTime(ModuleName.System); // PMA MonitorPID(ModuleName.PMA); MonitorSlitDoor(ModuleName.PMA); MonitorPin(ModuleName.PMA); MonitorPressure(ModuleName.PMA); MonitorTemperature(ModuleName.PMA); MonitorGas(ModuleName.PMA); //MonitorRF(ModuleName.PMA); ChangeTime(ModuleName.PMA); // PMB MonitorPID(ModuleName.PMB); MonitorSlitDoor(ModuleName.PMB); MonitorPin(ModuleName.PMB); MonitorPressure(ModuleName.PMB); MonitorTemperature(ModuleName.PMB); MonitorGas(ModuleName.PMB); //MonitorRF(ModuleName.PMB); ChangeTime(ModuleName.PMB); } catch (Exception e) { LOG.Write(e); } return true; } private void MonitorPID(ModuleName mod) { IO.DI[$"{mod}.DI_CHBHeatPIDATStart_Fb"].Value = IO.DO[$"{mod}.DO_CHBHeatPIDATStart"].Value; IO.DI[$"{mod}.DI_CHBHeatPIDATStop_Fb"].Value = IO.DO[$"{mod}.DO_CHBHeatPIDATStop"].Value; IO.DI[$"{mod}.DI_ForelineHeatPIDATStart_Fb"].Value = IO.DO[$"{mod}.DO_ForelineHeatPIDATStart"].Value; IO.DI[$"{mod}.DI_ForelineHeatPIDATStop_Fb"].Value = IO.DO[$"{mod}.DO_ForelineHeatPIDATStop"].Value; IO.DI[$"{mod}.DI_1_LEHeatPIDATStart_Fb"].Value = IO.DO[$"{mod}.DO_1_LEHeatPIDATStart"].Value; IO.DI[$"{mod}.DI_1_LEHeatPIDATStop_Fb"].Value = IO.DO[$"{mod}.DO_1_LEHeatPIDATStop"].Value; IO.DI[$"{mod}.DI_2_LEHeatPIDATStart_Fb"].Value = IO.DO[$"{mod}.DO_2_LEHeatPIDATStart"].Value; IO.DI[$"{mod}.DI_2_LEHeatPIDATStop_Fb"].Value = IO.DO[$"{mod}.DO_2_LEHeatPIDATStop"].Value; } private void ChangeTime(ModuleName mod) { // Heartbeat with PLC SetAiValue($"{mod}.AI_HeartbeatFB", GetAoValue($"{mod}.AO_Heartbeat")); SetAiValue($"{mod}.AI_Time", DateTime.Now.Hour); SetAiValue($"{mod}.AI_Minute", DateTime.Now.Minute); SetAiValue($"{mod}.AI_Second", DateTime.Now.Second); } void MonitorSlitDoor(ModuleName mod) { // slit door 1 open if (IO.DO[$"{mod}.DO_1_SlitDoorOpen"].Value) { IO.DI[$"{mod}.DI_1_SlitDoorOpenPos"].Value = true; IO.DI[$"{mod}.DI_1_SlitDoorClosePos"].Value = false; } // slit door 1 close if (IO.DO[$"{mod}.DO_1_SlitDoorClose"].Value) { IO.DI[$"{mod}.DI_1_SlitDoorOpenPos"].Value = false; IO.DI[$"{mod}.DI_1_SlitDoorClosePos"].Value = true; } // slit door 2 open if (IO.DO[$"{mod}.DO_2_SlitDoorOpen"].Value) { IO.DI[$"{mod}.DI_2_SlitDoorOpenPos"].Value = true; IO.DI[$"{mod}.DI_2_SlitDoorClosePos"].Value = false; } // slit door 2 close if (IO.DO[$"{mod}.DO_2_SlitDoorClose"].Value) { IO.DI[$"{mod}.DI_2_SlitDoorOpenPos"].Value = false; IO.DI[$"{mod}.DI_2_SlitDoorClosePos"].Value = true; } } void MonitorPin(ModuleName mod) { // lift pin 1 up if (IO.DO[$"{mod}.DO_1_LiftPinUp"].Value != IO.DO[$"{mod}.DO_1_LiftPinDown"].Value) { IO.DI[$"{mod}.DI_1_LiftPinUp"].Value = IO.DO[$"{mod}.DO_1_LiftPinUp"].Value; IO.DI[$"{mod}.DI_1_LiftPinDown"].Value = IO.DO[$"{mod}.DO_1_LiftPinDown"].Value; } // lift pin 2 up if (IO.DO[$"{mod}.DO_2_LiftPinUp"].Value != IO.DO[$"{mod}.DO_2_LiftPinDown"].Value) { IO.DI[$"{mod}.DI_2_LiftPinUp"].Value = IO.DO[$"{mod}.DO_2_LiftPinUp"].Value; IO.DI[$"{mod}.DI_2_LiftPinDown"].Value = IO.DO[$"{mod}.DO_2_LiftPinDown"].Value; } // upper guide pin up if (IO.DO[$"{mod}.DO_1_GuidePinLifterUp"].Value) { IO.DI[$"{mod}.DI_1_GuidePinLifterUpPos"].Value = true; IO.DI[$"{mod}.DI_1_GuidePinLifterDownPos"].Value = false; } // upper guide pin down if (IO.DO[$"{mod}.DO_1_GuidePinLifterDown"].Value) { IO.DI[$"{mod}.DI_1_GuidePinLifterUpPos"].Value = false; IO.DI[$"{mod}.DI_1_GuidePinLifterDownPos"].Value = true; } // upper guide pin up if (IO.DO[$"{mod}.DO_2_GuidePinLifterUp"].Value) { IO.DI[$"{mod}.DI_2_GuidePinLifterUpPos"].Value = true; IO.DI[$"{mod}.DI_2_GuidePinLifterDownPos"].Value = false; } // upper guide pin down if (IO.DO[$"{mod}.DO_2_GuidePinLifterDown"].Value) { IO.DI[$"{mod}.DI_2_GuidePinLifterUpPos"].Value = false; IO.DI[$"{mod}.DI_2_GuidePinLifterDownPos"].Value = true; } } void MonitorPressure(ModuleName mod) { // pressure string sAI_Foreline = "AI_ForelinePressure"; // Foreline if (SkyPumpMockPMA._simPumpStatus == SkyPumpMockPMA.SimPumpStatus.Open || EdwardsPumpMockPMA._simPumpStatus == EdwardsPumpMockPMA.SimEdwardsPumpStatus.Open) { SetAiValue($"{mod}.{sAI_Foreline}", GetAiValue($"{mod}.{sAI_Foreline}") - _rd.Next(500, 600)); } else { SetAiValue($"{mod}.{sAI_Foreline}", GetAiValue($"{mod}.{sAI_Foreline}") + _rd.Next(500, 600)); } // PLC 模拟量范围[0,4000], 电压[0, 10V], 压力[0, 760Torr] string sAI_ChamberPressure = "AI_ChamberPressure"; string sAI_ProcessPressure = "AI_ProcessPressure"; //float chamber_pressure = GetMockChamberPressure(mod); //float process_pressure = GetAiValue($"{mod}.AI_Process_pressure"); // soft pump & fast pump DOAccessor fast_pump_vlv = IO.DO[$"{mod}.DO_FastPumpingValve"]; DOAccessor soft_pump_vlv = IO.DO[$"{mod}.DO_SoftPumpingValve"]; if (fast_pump_vlv.Value || soft_pump_vlv.Value) { if (fast_pump_vlv.Value && soft_pump_vlv.Value) { float getAiValue_ChamberPressure = GetAiValue($"{mod}.{sAI_ChamberPressure}"); float getAiValue_ProcessPressure = GetAiValue($"{mod}.{sAI_ProcessPressure}"); if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure > 10000) { SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") - 30000); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 150); } else if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure <= 10000) { getAiValue_ProcessPressure = getAiValue_ChamberPressure; SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 1500); SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 1500); } //SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") - _rd.Next(15000, 16000)); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - _rd.Next(150, 160)); } else if (fast_pump_vlv.Value) { float getAiValue_ChamberPressure = GetAiValue($"{mod}.{sAI_ChamberPressure}"); float getAiValue_ProcessPressure = GetAiValue($"{mod}.{sAI_ProcessPressure}"); if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure > 10000) { SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") - 25000); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 150); } else if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure <= 10000) { getAiValue_ProcessPressure = getAiValue_ChamberPressure; SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 1300); SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 1300); } //SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") - _rd.Next(12000, 13000)); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - _rd.Next(120, 130)); } else if (soft_pump_vlv.Value) { float getAiValue_ChamberPressure = GetAiValue($"{mod}.{sAI_ChamberPressure}"); float getAiValue_ProcessPressure = GetAiValue($"{mod}.{sAI_ProcessPressure}"); if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure > 10000) { SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") - 22000); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 150); } else if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure <= 10000) { getAiValue_ProcessPressure = getAiValue_ChamberPressure; SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 1100); SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 1100); } //SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") - _rd.Next(13000, 14000)); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - _rd.Next(100, 110)); } } // fast vent & purge DOAccessor vent_vlv = IO.DO[$"{mod}.DO_ChamberVentValve"]; DOAccessor purge_vlv = IO.DO[$"{mod}.DO_ChamberPurgeValve"]; if (vent_vlv.Value || purge_vlv.Value) { if (vent_vlv.Value && purge_vlv.Value) { float getAiValue_ChamberPressure = GetAiValue($"{mod}.{sAI_ChamberPressure}"); float getAiValue_ProcessPressure = GetAiValue($"{mod}.{sAI_ProcessPressure}"); if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure > 10000) { SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") + 30000); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 150); } else if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure <= 10000) { getAiValue_ProcessPressure = getAiValue_ChamberPressure; SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + 1500); SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + 1500); } //SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") + _rd.Next(45000, 50000)); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + _rd.Next(150, 160)); } else if (vent_vlv.Value) { float getAiValue_ChamberPressure = GetAiValue($"{mod}.{sAI_ChamberPressure}"); float getAiValue_ProcessPressure = GetAiValue($"{mod}.{sAI_ProcessPressure}"); if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure > 10000) { SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") + 25000); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 150); } else if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure <= 10000) { getAiValue_ProcessPressure = getAiValue_ChamberPressure; SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + 1300); SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + 1300); } //SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") + _rd.Next(25000, 30000)); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + _rd.Next(130, 150)); } else if (purge_vlv.Value) { float getAiValue_ChamberPressure = GetAiValue($"{mod}.{sAI_ChamberPressure}"); float getAiValue_ProcessPressure = GetAiValue($"{mod}.{sAI_ProcessPressure}"); if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure > 10000) { SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") + 30000); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") - 150); } else if (getAiValue_ProcessPressure <= 10000 && getAiValue_ChamberPressure <= 10000) { getAiValue_ProcessPressure = getAiValue_ChamberPressure; SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + 3100); SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + 3100); } //SetAiValue($"{mod}.{sAI_ChamberPressure}", GetAiValue($"{mod}.{sAI_ChamberPressure}") + _rd.Next(15000, 20000)); //SetAiValue($"{mod}.{sAI_ProcessPressure}", GetAiValue($"{mod}.{sAI_ProcessPressure}") + _rd.Next(100, 120)); } } // 压力值越界,复位 float chamber_pressure1 = GetAiValue($"{mod}.{sAI_ChamberPressure}"); if (chamber_pressure1 > ATM_PRESSURE) { SetAiValue($"{mod}.AI_ChamberPressure", ATM_PRESSURE); } else if (chamber_pressure1 < 20) { SetAiValue($"{mod}.AI_ChamberPressure", 20); } float process_pressure1 = GetAiValue($"{mod}.{sAI_ProcessPressure}"); if (process_pressure1 > PROCESS_GAUGE) { SetAiValue($"{mod}.AI_ProcessPressure", PROCESS_GAUGE); } else if (process_pressure1 < 20) { SetAiValue($"{mod}.AI_ProcessPressure", 20); } float foreline_pressure = GetAiValue($"{mod}.{sAI_Foreline}"); if (foreline_pressure > 10000) { SetAiValue($"{mod}.AI_ForelinePressure", 10000); } else if (foreline_pressure < 150) { SetAiValue($"{mod}.AI_ForelinePressure", 150); } // 模拟压力计漂移 //int p1 = (int)GetMockChamberPressure(mod); //int new_p1 = _rd.Next(p1 - 2, p1 + 2); //SetAiValue($"{mod}.AI_Chamber_pressure", new_p1); //int p2 = (int)GetAiValue($"{mod}.AI_Foreline_pressure"); //int new_p2 = _rd.Next(p2 - 1, p2 + 1); //SetAiValue($"{mod}.AI_Foreline_pressure", new_p2); //int p3 = (int)GetAiValue($"{mod}.AI_Process_pressure"); //int new_p3 = _rd.Next(p3 - 1, p3 + 1); //SetAiValue($"{mod}.AI_Process_pressure", new_p3); // 根据当前压力值设定信号 //float chamber_pressure2 = GetMockChamberPressure(mod); // ATM switch IO.DI[$"{mod}.DI_ATMSW"].Value = GetAiValue($"{mod}.{sAI_ChamberPressure}") > ATM_THRESHOLD; // VAC switch IO.DI[$"{mod}.DI_VACSW"].Value = GetAiValue($"{mod}.{sAI_ChamberPressure}") < VAC_SW_PRESSURE; // Throttle valve //var pos_sp = IO.AO[$"{mod}.AO_ThrottleValvePressureSetpoint"].Value; //var mock_pos_fb = _rd.Next(pos_sp - 2, pos_sp + 2); ////IO.AI[$"{mod}.AI_ThrottleValveRealPressure"].Value = (short)mock_pos_fb; //SetAiValue($"{mod}.AI_ThrottleValveRealPressure", mock_pos_fb); // 压力值 if (GetAiValue($"{mod}.AI_ThrottleValveRealPressure") < GetAoValue($"{mod}.AO_ThrottleValvePressureSetpoint")) { short increase = (short)_rd.Next(20, 30); SetAiValue($"{mod}.AI_ThrottleValveRealPressure", GetAiValue($"{mod}.AI_ThrottleValveRealPressure") + increase); if (GetAiValue($"{mod}.AI_ThrottleValveRealPressure") > GetAoValue($"{mod}.AO_ThrottleValvePressureSetpoint")) { SetAiValue($"{mod}.AI_ThrottleValveRealPressure", GetAoValue($"{mod}.AO_ThrottleValvePressureSetpoint")); } } else { short increase = (short)_rd.Next(20, 30); SetAiValue($"{mod}.AI_ThrottleValveRealPressure", GetAiValue($"{mod}.AI_ThrottleValveRealPressure") - increase); if (GetAiValue($"{mod}.AI_ThrottleValveRealPressure") < GetAoValue($"{mod}.AO_ThrottleValvePressureSetpoint")) { SetAiValue($"{mod}.AI_ThrottleValveRealPressure", GetAoValue($"{mod}.AO_ThrottleValvePressureSetpoint")); } } // 位置值 if (GetAiValue($"{mod}.AI_ThrottleValveRealPosition") < GetAoValue($"{mod}.AO_ThrottleValvePositionSetpoint")) { short increase = (short)_rd.Next(20, 30); SetAiValue($"{mod}.AI_ThrottleValveRealPosition", GetAiValue($"{mod}.AI_ThrottleValveRealPosition") + increase); if (GetAiValue($"{mod}.AI_ThrottleValveRealPosition") > GetAoValue($"{mod}.AO_ThrottleValvePositionSetpoint")) { SetAiValue($"{mod}.AI_ThrottleValveRealPosition", GetAoValue($"{mod}.AO_ThrottleValvePositionSetpoint")); } } else { short increase = (short)_rd.Next(20, 30); SetAiValue($"{mod}.AI_ThrottleValveRealPosition", GetAiValue($"{mod}.AI_ThrottleValveRealPosition") - increase); if (GetAiValue($"{mod}.AI_ThrottleValveRealPosition") < GetAoValue($"{mod}.AO_ThrottleValvePositionSetpoint")) { SetAiValue($"{mod}.AI_ThrottleValveRealPosition", GetAoValue($"{mod}.AO_ThrottleValvePositionSetpoint")); } } } //float GetMockChamberPressure(ModuleName mod) //{ // return GetAiValue($"{mod}.AI_Chamber_pressure"); //} //void SetMockChamberPressure(ModuleName mod, float val) //{ // SetAiValue($"{mod}.AI_Chamber_pressure", val); //} void SetAiValue(string name, float value) { IO.AI[name].FloatValue = value; //byte[] flow = BitConverter.GetBytes(value); //short high1 = BitConverter.ToInt16(flow, 0); //short low1 = BitConverter.ToInt16(flow, 2); //IO.AI[name].Buffer[IO.AI[name].Index] = BitConverter.ToInt16(flow, 0); //IO.AI[name].Buffer[IO.AI[name].Index + 1] = BitConverter.ToInt16(flow, 2); //byte[] high = BitConverter.GetBytes(IO.AI[name].Buffer[IO.AI[name].Index]); //byte[] low = BitConverter.GetBytes(IO.AI[name].Buffer[IO.AI[name].Index + 1]); //float readback = BitConverter.ToSingle(new[] { high[0], high[1], low[0], low[1] }, 0); } float GetAiValue(string name) { return IO.AI[name].FloatValue; //byte[] high = BitConverter.GetBytes(IO.AI[name].Buffer[IO.AI[name].Index]); //byte[] low = BitConverter.GetBytes(IO.AI[name].Buffer[IO.AI[name].Index + 1]); //float flow = BitConverter.ToSingle(new[] { high[0], high[1], low[0], low[1] }, 0); //return flow; } float GetAoValue(string name) { return IO.AO[name].FloatValue; //byte[] high = BitConverter.GetBytes(IO.AO[name].Buffer[IO.AO[name].Index]); //byte[] low = BitConverter.GetBytes(IO.AO[name].Buffer[IO.AO[name].Index + 1]); //float flow = BitConverter.ToSingle(new[] { high[0], high[1], low[0], low[1] }, 0); //return flow; } void MonitorTemperature(ModuleName mod) { SetAiValue($"{mod}.AI_1_CoolantInletTemp", 50); SetAiValue($"{mod}.AI_2_CoolantInletTemp", 50); SetAiValue($"{mod}.AI_1_CoolantOutletTemp", 50); SetAiValue($"{mod}.AI_2_CoolantOutletTemp", 50); IO.DI[$"{mod}.DI_CHBHeaterOn_FB"].Value = IO.DO[$"{mod}.DO_CHBHeaterOn"].Value; IO.DI[$"{mod}.DI_ForelineHeaterOn_FB"].Value = IO.DO[$"{mod}.DO_ForelineHeaterOn"].Value; IO.DI[$"{mod}.DI_1_LEHeaterOn_FB"].Value = IO.DO[$"{mod}.DO_1_LEHeaterOn"].Value; IO.DI[$"{mod}.DI_2_LEHeaterOn_FB"].Value = IO.DO[$"{mod}.DO_2_LEHeaterOn"].Value; IO.DI[$"{mod}.DI_ForelineTCDeviationOutOfRange"].Value = false; IO.DI[$"{mod}.DI_CHBTCDeviationOutOfRange"].Value = false; IO.DI[$"{mod}.DI_1_LETCDeviationOutOfRange"].Value = false; IO.DI[$"{mod}.DI_2_LETCDeviationOutOfRange"].Value = false; // 底座 if (IO.DO[$"{mod}.DO_CHBHeaterOn"].Value && GetAiValue($"{mod}.AI_CHBControlTCTemp") < GetAoValue($"{mod}.AO_CHBTemperatureSetpoint")) { SetAiValue($"{mod}.AI_CHBControlTCTemp", GetAiValue($"{mod}.AI_CHBControlTCTemp") + _rd.Next(1, 2)); SetAiValue($"{mod}.AI_CHBMonitorTCTemp", GetAiValue($"{mod}.AI_CHBMonitorTCTemp") + _rd.Next(1, 2)); } else if (IO.DO[$"{mod}.DO_CHBHeaterOn"].Value && GetAiValue($"{mod}.AI_CHBControlTCTemp") > GetAoValue($"{mod}.AO_CHBTemperatureSetpoint")) { SetAiValue($"{mod}.AI_CHBControlTCTemp", GetAiValue($"{mod}.AI_CHBControlTCTemp") - _rd.Next(1, 2)); SetAiValue($"{mod}.AI_CHBMonitorTCTemp", GetAiValue($"{mod}.AI_CHBMonitorTCTemp") - _rd.Next(1, 2)); } // Foreline if (IO.DO[$"{mod}.DO_ForelineHeaterOn"].Value && GetAiValue($"{mod}.AI_ForelineControlTCTemp") < GetAoValue($"{mod}.AO_ForelineTemperatureSetpoint")) { SetAiValue($"{mod}.AI_ForelineControlTCTemp", GetAiValue($"{mod}.AI_ForelineControlTCTemp") + _rd.Next(1, 2)); SetAiValue($"{mod}.AI_ForelineMonitorTCTemp", GetAiValue($"{mod}.AI_ForelineMonitorTCTemp") + _rd.Next(1, 2)); } else if (IO.DO[$"{mod}.DO_ForelineHeaterOn"].Value && GetAiValue($"{mod}.AI_ForelineControlTCTemp") > GetAoValue($"{mod}.AO_ForelineTemperatureSetpoint")) { SetAiValue($"{mod}.AI_ForelineControlTCTemp", GetAiValue($"{mod}.AI_ForelineControlTCTemp") - _rd.Next(1, 2)); SetAiValue($"{mod}.AI_ForelineMonitorTCTemp", GetAiValue($"{mod}.AI_ForelineMonitorTCTemp") - _rd.Next(1, 2)); } // LE1 if (IO.DO[$"{mod}.DO_1_LEHeaterOn"].Value && GetAiValue($"{mod}.AI_1_LEControlTCTemp") < GetAoValue($"{mod}.AO_1_LETemperatureSetpoint")) { SetAiValue($"{mod}.AI_1_LEControlTCTemp", GetAiValue($"{mod}.AI_1_LEControlTCTemp") + _rd.Next(1, 2)); SetAiValue($"{mod}.AI_1_LEMonitorTCTemp", GetAiValue($"{mod}.AI_1_LEMonitorTCTemp") + _rd.Next(1, 2)); } else if (IO.DO[$"{mod}.DO_1_LEHeaterOn"].Value && GetAiValue($"{mod}.AI_1_LEControlTCTemp") > GetAoValue($"{mod}.AO_1_LETemperatureSetpoint")) { SetAiValue($"{mod}.AI_1_LEControlTCTemp", GetAiValue($"{mod}.AI_1_LEControlTCTemp") - _rd.Next(1, 2)); SetAiValue($"{mod}.AI_1_LEMonitorTCTemp", GetAiValue($"{mod}.AI_1_LEMonitorTCTemp") - _rd.Next(1, 2)); } // LE2 if (IO.DO[$"{mod}.DO_2_LEHeaterOn"].Value && GetAiValue($"{mod}.AI_2_LEControlTCTemp") < GetAoValue($"{mod}.AO_2_LETemperatureSetpoint")) { SetAiValue($"{mod}.AI_2_LEControlTCTemp", GetAiValue($"{mod}.AI_2_LEControlTCTemp") + _rd.Next(1, 2)); SetAiValue($"{mod}.AI_2_LEMonitorTCTemp", GetAiValue($"{mod}.AI_2_LEMonitorTCTemp") + _rd.Next(1, 2)); } else if (IO.DO[$"{mod}.DO_2_LEHeaterOn"].Value && GetAiValue($"{mod}.AI_2_LEControlTCTemp") > GetAoValue($"{mod}.AO_2_LETemperatureSetpoint")) { SetAiValue($"{mod}.AI_2_LEControlTCTemp", GetAiValue($"{mod}.AI_2_LEControlTCTemp") - _rd.Next(1, 2)); SetAiValue($"{mod}.AI_2_LEMonitorTCTemp", GetAiValue($"{mod}.AI_2_LEMonitorTCTemp") - _rd.Next(1, 2)); } } void MonitorGas(ModuleName mod) { // gas this.SimulateMFC(ModuleName.PMA, 1); this.SimulateMFC(ModuleName.PMA, 2); this.SimulateMFC(ModuleName.PMA, 3); this.SimulateMFC(ModuleName.PMA, 4); this.SimulateMFC(ModuleName.PMA, 5); this.SimulateMFC(ModuleName.PMA, 6); this.SimulateMFC(ModuleName.PMB, 1); this.SimulateMFC(ModuleName.PMB, 2); this.SimulateMFC(ModuleName.PMB, 3); this.SimulateMFC(ModuleName.PMB, 4); this.SimulateMFC(ModuleName.PMB, 5); this.SimulateMFC(ModuleName.PMB, 6); } private void SimulateMFC(ModuleName mod, byte gasNum) { var sp = GetAoValue($"{mod}.AO_MFC{gasNum}FlowSetpoint"); var mock_fb = _rd.Next((int)sp - 3, (int)sp + 3) + _rd.NextDouble(); SetAiValue($"{mod}.AI_MFC{gasNum}Flow", (float)mock_fb); } //void MonitorRF(ModuleName mod) //{ // // RF generator // var sp = GetAoValue($"{mod}.AO_BaisRFEnable"); // var mock_fb = _rd.Next((int)sp - 3, (int)sp + 3) + _rd.NextDouble(); // //var mock_sp = _rd.Next(sp - 3, sp + 3); // SetAiValue($"{mod}.AI_Generator_Forward_Power", (float)mock_fb); // //IO.DI[$"{mod}.DI_Generator_Power_Status"].Value = IO.DO[$"{mod}.DO_Generator_Power_ON"].Value; //} public void Terminate() { _thread.Stop(); } } }