123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733 |
- 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<SimulatorSystem>
- {
- 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<ModuleName, DeviceSimulator> _MockDevices = new Dictionary<ModuleName, DeviceSimulator>();
- 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<DataManager>.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();
- }
- }
- }
|