临时保存

添加仿真内容
修改旧的仿真调用
This commit is contained in:
hanqiangqiang
2026-07-07 14:58:23 +08:00
parent d930588fc2
commit 9ccbb49746
10 changed files with 952 additions and 25 deletions
+292 -24
View File
@@ -1,13 +1,17 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using Aitex.Common.Util;
using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.IOCore;
using Aitex.Core.RT.Log;
using Aitex.Core.Util;
using Aitex.Core.WCF;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.PLC;
using MECF.Framework.Simulator.Core;
using SicSimulator.Views;
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Threading.Tasks;
namespace SicSimulator.Instances
{
@@ -32,6 +36,10 @@ namespace SicSimulator.Instances
WcfServiceManager.Instance.Initialize(new Type[] { typeof(SimulatorAdsPlcService) });
//Singleton<SimulatorDeviceManager>.Instance.Initialize(PathManager.GetCfgDir() + "DevicePM.xml", "GaN", ModuleName.PM1, "PM1");
//Singleton<SimulatorDeviceManager>.Instance.Initialize(PathManager.GetCfgDir() + "DevicePM.xml", "GaN", ModuleName.PM2, "PM2");
//Singleton<SimulatorDeviceManager>.Instance.Initialize(PathManager.GetCfgDir() + "DeviceTM.xml", "GaN", ModuleName.TM, "TM");
_thread = new PeriodicJob(200, OnMonitor, nameof(SimulatorSystem), true);
}
@@ -350,34 +358,34 @@ namespace SicSimulator.Instances
try
{
MonitorPressureTM();
MonitorPressureLoad();
MonitorPressureUnLoad();
MonitorSlitValveFlow();
MonitorTMValve();
//MonitorPressureLoad();
//MonitorPressureUnLoad();
//MonitorSlitValveFlow();
//MonitorTMValve();
MonitorPm("PM1");
MonitorPm("PM2");
MonitorValve("PM1");
MonitorValve("PM2");
MonitorFlowRamp("PM1");
//MonitorFlowRamp("PM1");
//MonitorFlowRamp("PM2");
MonitorGasConnector("PM1");
MonitorLid("PM1");
MonitorLidSwing("PM1");
MonitorConfinementRing("PM1");
MonitorGasConnector("PM2");
MonitorLid("PM2");
MonitorLidSwing("PM2");
MonitorConfinementRing("PM2");
MonitorChamberMoveBody("PM1");
MonitorChamberMoveBodyUp("PM1");
MonitorHeater("PM1");
MonitorRotation("PM1");
MonitorChamberMoveBody("PM2");
MonitorChamberMoveBodyUp("PM2");
MonitorHeater("PM2");
MonitorRotation("PM2");
//MonitorGasConnector("PM1");
//MonitorLid("PM1");
//MonitorLidSwing("PM1");
//MonitorConfinementRing("PM1");
//MonitorGasConnector("PM2");
//MonitorLid("PM2");
//MonitorLidSwing("PM2");
//MonitorConfinementRing("PM2");
//MonitorChamberMoveBody("PM1");
//MonitorChamberMoveBodyUp("PM1");
//MonitorHeater("PM1");
//MonitorRotation("PM1");
//MonitorChamberMoveBody("PM2");
//MonitorChamberMoveBodyUp("PM2");
//MonitorHeater("PM2");
//MonitorRotation("PM2");
}
catch (Exception e)
{
@@ -915,6 +923,266 @@ namespace SicSimulator.Instances
}
private void PmMotion(string pm)
{
IO.DI[$"{pm}.DI_PMSlitValveCloseCompleted"].Value = IO.DI[$"TM.DI_PM{(pm == "PM1" ? "A" : "B")}SlitValveClose"].Value;
IO.DI[$"{pm}.DI_LockingCylinderLock"].Value = !IO.DO[$"{pm}.DO_LockingCylinderLockUnlock"].Value;
if (IO.DO[$"{pm}.DO_ChamLidMotorAUp"].Value)
{
IO.DI[$"{pm}.DI_PMChamberLidDownpositioning"].Value = true;
Task.Delay(2000).ContinueWith(x =>
{
IO.DI[$"{pm}.DI_PMChamberLidUppositioning"].Value = false;
});
}
if (IO.DO[$"{pm}.DO_ChamLidMotorADown"].Value)
{
IO.DI[$"{pm}.DI_PMChamberLidUppositioning"].Value = true;
Task.Delay(2000).ContinueWith(x =>
{
IO.DI[$"{pm}.DI_PMChamberLidDownpositioning"].Value = false;
});
}
DelaySetDoToDi(pm, "DI_PMChamberLidTighten", "DO_ChamLidTighten");
DelaySetDoToDi(pm, "DI_PMChamberLidLoosen", "DO_ChamLidLoosen");
DelaySetDoToDi(pm, "DI_PMChamberLidSwingLock", "DO_ChamLidSwingLock");
DelaySetDoToDi(pm, "DI_PMChamberLidSwingUnLock", "DO_ChamLidSwingUnLock");
DelaySetDoToDi(pm, "DI_PMChamberLidLock", "DO_ChamLidLockPL");
DelaySetDoToDi(pm, "DI_PMChamberLidUnLock", "DO_ChamLidUnLockPL");
//磁流体仿真
int temp = pm == "PM1" ? 0 : 1;
if (!_pre_DO_SpindleHome[temp] && IO.DO[$"{pm}.DO_SpindleHome"].Value)
{
IO.DI[$"{pm}.DI_SpindleHomeFinish"].Value = false;
Task.Delay(1000).ContinueWith(x =>
{
IO.AI[$"{pm}.AI_SpindleCurrentPosition"].Value = 0;
IO.DI[$"{pm}.DI_SpindleHomeFinish"].Value = true;
});
}
_pre_DO_SpindleHome[temp] = IO.DO[$"{pm}.DO_SpindleHome"].Value;
if (!_pre_DO_SpindleLoadAngleRun[temp] && IO.DO[$"{pm}.DO_SpindleLoadAngleRun"].Value)
{
IO.DI[$"{pm}.DI_SpindlePositionComplete"].Value = false;
Task.Delay(2000).ContinueWith(x =>
{
IO.AI[$"{pm}.AI_SpindleCurrentPosition"].Value += IO.AO[$"{pm}.AO_SpindleLoadAngle"].Value;
if (IO.AI[$"{pm}.AI_SpindleCurrentPosition"].Value >= 360)
{
IO.AI[$"{pm}.AI_SpindleCurrentPosition"].Value -= 360;
}
IO.DI[$"{pm}.DI_SpindlePositionComplete"].Value = true;
});
}
_pre_DO_SpindleLoadAngleRun[temp] = IO.DO[$"{pm}.DO_SpindleLoadAngleRun"].Value;
if (!_pre_DO_SpindleMoveSlot[temp] && IO.DO[$"{pm}.DO_SpindleMoveSlot"].Value)
{
IO.AI[$"{pm}.AI_SpindleActualSlot"].Value = 0;
Task.Delay(2000).ContinueWith(x =>
{
var s = (int)IO.AO[$"{pm}.AO_SpindleSlot"].Value;
if (s > 0 && s < 9)
{
IO.AI[$"{pm}.AI_SpindleCurrentPosition"].Value = IO.AO[$"{pm}.AO_SpindlePosition{s}"].Value;
IO.AI[$"{pm}.AI_SpindleActualSlot"].Value = s;
}
});
}
_pre_DO_SpindleMoveSlot[temp] = IO.DO[$"{pm}.DO_SpindleMoveSlot"].Value;
//shutter仿真
if (IO.DO[$"{pm}.DO_ShutterUp"].Value)
{
Task.Delay(2000).ContinueWith(x =>
{
IO.DI[$"{pm}.DI_ShutterUp"].Value = true;
IO.DI[$"{pm}.DI_ShutterDown"].Value = false;
});
}
if (IO.DO[$"{pm}.DO_ShutterDown"].Value)
{
Task.Delay(2000).ContinueWith(x =>
{
IO.DI[$"{pm}.DI_ShutterUp"].Value = false;
IO.DI[$"{pm}.DI_ShutterDown"].Value = true;
});
}
if (IO.DO[$"{pm}.DO_ShutterForward"].Value)
{
Task.Delay(2000).ContinueWith(x =>
{
IO.DI[$"{pm}.DI_ShutterForward"].Value = true;
IO.DI[$"{pm}.DI_ShutterBackward"].Value = false;
});
}
if (IO.DO[$"{pm}.DO_ShutterBackward"].Value)
{
Task.Delay(2000).ContinueWith(x =>
{
IO.DI[$"{pm}.DI_ShutterForward"].Value = false;
IO.DI[$"{pm}.DI_ShutterBackward"].Value = true;
});
}
////V99仿真
//if (IO.DO[$"{pm}.DO_PMPressureRelief"].Value && !IO.DO[$"{pm}.DO_PMPressureReliefClose"].Value)
//{
// IO.DI[$"{pm}.DI_PMPressureReliefOpenFB"].Value = true;
// IO.DI[$"{pm}.DI_PMPressureReliefCloseFB"].Value = false;
//}
//if (IO.DO[$"{pm}.DO_PMPressureReliefClose"].Value && !IO.DO[$"{pm}.DO_PMPressureRelief"].Value)
//{
// IO.DI[$"{pm}.DI_PMPressureReliefOpenFB"].Value = false;
// IO.DI[$"{pm}.DI_PMPressureReliefCloseFB"].Value = true;
//}
}
private void DelaySetDoToDi(string pm, string diName, string doName)
{
if (!IO.DO[$"{pm}.{doName}"].Value)
{
IO.DI[$"{pm}.{diName}"].Value = false;
return;
}
if (IO.DI[$"{pm}.{diName}"].Value != IO.DO[$"{pm}.{doName}"].Value)
{
Task.Delay(2000).ContinueWith(x =>
{
IO.DI[$"{pm}.{diName}"].Value = IO.DO[$"{pm}.{doName}"].Value;
});
}
}
private void MonitorTVPm(string pm)
{
IO.AI[$"{pm}.AI_ButterflyValveActualMode"].Value = IO.AO[$"{pm}.AO_ButterflyValveSetMode"].Value;
//IO.AI[$"{pm}.AI_HeartBeat"].Value = IO.AO[$"{pm}.AO_HeartBeat"].Value;
IO.AI[$"{pm}.AI_ButterflyValveActualPosition"].Value = IO.AO[$"{pm}.AO_ButterflyValveSetPosition"].Value;
var mode = IO.AO[$"{pm}.AO_ButterflyValveSetMode"].Value;
//蝶阀开启,跟着蝶阀的设置值走
if (IO.DO[$"{pm}.DO_ButterflyEnable"].Value)
{
if (mode == 5)
{
if (IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value > IO.AO[$"{pm}.AO_ButterflyValveSetPressure"].Value)
{
if (IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value - 30 > IO.AO[$"{pm}.AO_ButterflyValveSetPressure"].Value)
{
IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value -= 30;
}
else
{
IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value = IO.AO[$"{pm}.AO_ButterflyValveSetPressure"].Value;
}
}
else if (IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value < IO.AO[$"{pm}.AO_ButterflyValveSetPressure"].Value)
{
if (IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value + 10 < IO.AO[$"{pm}.AO_ButterflyValveSetPressure"].Value)
{
IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value += 10;
}
else
{
IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value = IO.AO[$"{pm}.AO_ButterflyValveSetPressure"].Value;
}
}
IO.AI[$"{pm}.AI_PMChamberPressure"].Value = IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value;
}
if (mode == 2)
{
if (IO.AO[$"{pm}.AO_ButterflyValveSetPosition"].Value > 0)
{
if (IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value > 0)
{
IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value -= (IO.AO[$"{pm}.AO_ButterflyValveSetPosition"].Value) / 8;
}
else
IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value = 0;
}
IO.AI[$"{pm}.AI_PMChamberPressure"].Value = IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value;
}
}
else
{
bool fontMfc = false;
for (int i = 70; i <= 89; i++)
{
if (IO.AI[$"{pm}.AI_M{i}"].Value > 100)
{
fontMfc = true;
continue;
}
}
if (fontMfc)
{
if (IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value < 1200)
{
IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value += 10;
}
IO.AI[$"{pm}.AI_PMChamberPressure"].Value = IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value;
}
}
//蝶阀Ramp有Bug,设置AO值可以化解
//if (IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value >= 1100)
//{
// IO.AO[$"{pm}.AO_ButterflyValveSetPressure"].Value = IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value;
//}
//string s = pm == "PM1" ? "A" : "B";
//if (IO.DI[$"TM.DI_TMPM{s}BanlanceFB"].Value || IO.DI[$"TM.DI_PM{s}GateValveOpen"].Value)
//{
// var v1 = IO.AI[$"{pm}.AI_PMChamberPressure"].Value;
// var v2 = IO.AI[$"TM.AI_TMChamberPressure"].Value;
// if (v1 > v2)
// {
// IO.AI[$"TM.AI_TMChamberPressure"].Value = v1;
// }
// else
// {
// IO.AI[$"{pm}.AI_PMChamberPressure"].Value = v2;
// }
//}
//else
// IO.AI[$"{pm}.AI_PMChamberPressure"].Value = IO.AI[$"{pm}.AI_ButterflyValveActualPressure"].Value;
//V27自动打开
//if (IO.AI[$"{pm}.AI_ChamPress"].Value > 1020 && IO.DO[$"{pm}.DO_PumpBypass(V27)"].Value != true)
//{
// IO.DO[$"{pm}.DO_PumpBypass(V27)"].Value = true;
//}
//if (IO.AI[$"{pm}.AI_ChamPress"].Value < 900 && IO.DO[$"{pm}.DO_PumpBypass(V27)"].Value)
//{
// IO.DO[$"{pm}.DO_PumpBypass(V27)"].Value = false;
//}
if (IO.DO[$"{pm}.DO_SpindleSpeedRun"].Value)
{
IO.AI[$"{pm}.AI_SpindleCurrentSpeed"].Value = IO.AO[$"{pm}.AO_SpindleVelocity"].Value;
}
else
IO.AI[$"{pm}.AI_SpindleCurrentSpeed"].Value = 0;
//设置PT2的压力比PT1的小20
var pt2 = IO.AI[$"{pm}.AI_PMChamberPressure"].Value - 20;
if (pt2 > 0)
{
IO.AI[$"{pm}.AI_ColdtrapExitPressure"].Value = pt2;
}
IO.AI[$"{pm}.AI_ColdtrapExitPressure"].Value = IO.AI[$"{pm}.AI_PMChamberPressure"].Value - 20 > 0 ? IO.AI[$"{pm}.AI_PMChamberPressure"].Value - 20 : 0;
}
private void MonitorValve(string pm)
{