|
@@ -46,7 +46,14 @@ namespace CyberX8_Simulator.Devices
|
|
|
/// 写AO锁
|
|
|
/// </summary>
|
|
|
private object _writeAOLocker = new object();
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// Festo Data Buffer
|
|
|
+ /// </summary>
|
|
|
+ private Dictionary<string, bool> _festoDataBuffer = new Dictionary<string, bool>();
|
|
|
+ /// <summary>
|
|
|
+ /// 定时器
|
|
|
+ /// </summary>
|
|
|
+ private PeriodicJob _periodicJob;
|
|
|
public WagoSocketSimulator(int port):base(port)
|
|
|
{
|
|
|
SimulatorCommManager.Instance.OnUpdateVariableValueChanged += UpdataDataCausedByOtherModule;
|
|
@@ -57,6 +64,7 @@ namespace CyberX8_Simulator.Devices
|
|
|
private void UpdataDataCausedByOtherModule(string name, bool value, bool invert)
|
|
|
{
|
|
|
value = invert ? !value : value;
|
|
|
+ //AI Data
|
|
|
if (AINameIndexDic.ContainsKey(name))
|
|
|
{
|
|
|
switch (name)
|
|
@@ -79,11 +87,12 @@ namespace CyberX8_Simulator.Devices
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
- //DI
|
|
|
+ //DI Data
|
|
|
UpdataDIBytes(name, value ? 1 : 0);
|
|
|
+ //Festo Data
|
|
|
+ if (name == "FlowTestClamp") _festoDataBuffer[name] = value;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 触发Wago对应数据更新
|
|
@@ -117,6 +126,10 @@ namespace CyberX8_Simulator.Devices
|
|
|
{
|
|
|
if (port == config.Port)
|
|
|
{
|
|
|
+ if(config.Module == "Loader" && _periodicJob == null)
|
|
|
+ {
|
|
|
+ _periodicJob = new PeriodicJob(100, OnTimer, $"Wago {config.Module} timer",true);
|
|
|
+ }
|
|
|
//加载DO
|
|
|
int i = 0;
|
|
|
DONameIndexDic = new Dictionary<string, int>();
|
|
@@ -125,6 +138,7 @@ namespace CyberX8_Simulator.Devices
|
|
|
foreach (var item in group.WagoDOs)
|
|
|
{
|
|
|
DONameIndexDic[item.Name] = i;
|
|
|
+ i++;
|
|
|
}
|
|
|
}
|
|
|
//加载DI
|
|
@@ -462,7 +476,39 @@ namespace CyberX8_Simulator.Devices
|
|
|
bytes[8] = error;
|
|
|
return bytes;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 定时器
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool OnTimer()
|
|
|
+ {
|
|
|
+ LeakTestSimulator();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 模拟方法
|
|
|
+ /// <summary>
|
|
|
+ /// Loader LeakTest模拟
|
|
|
+ /// </summary>
|
|
|
+ private void LeakTestSimulator()
|
|
|
+ {
|
|
|
+ if (DOBytes[DONameIndexDic["c_VACUUM_TEST"]] == 1 && _festoDataBuffer["FlowTestClamp"] && AIShorts[AINameIndexDic["r_LOADER_GasFlowSensor_FLOW"]] == 0)
|
|
|
+ {
|
|
|
+ AIShorts[AINameIndexDic["r_LOADER_GasFlowSensor_FLOW"]] = 15000;
|
|
|
+ }
|
|
|
+ else if (DOBytes[DONameIndexDic["c_VACUUM_TEST"]] == 0 && !_festoDataBuffer["FlowTestClamp"])
|
|
|
+ {
|
|
|
+ AIShorts[AINameIndexDic["r_LOADER_GasFlowSensor_FLOW"]] = 0;
|
|
|
+ }
|
|
|
+ if (DOBytes[DONameIndexDic["c_VACUUM_TEST"]] == 1 && _festoDataBuffer["FlowTestClamp"] && AIShorts[AINameIndexDic["r_LOADER_GasFlowSensor_FLOW"]] > 3500)
|
|
|
+ {
|
|
|
+ AIShorts[AINameIndexDic["r_LOADER_GasFlowSensor_FLOW"]] -= 40;
|
|
|
+ if (AIShorts[AINameIndexDic["r_LOADER_GasFlowSensor_FLOW"]] < 14000)
|
|
|
+ {
|
|
|
+ AIShorts[AINameIndexDic["r_LOADER_GasFlowSensor_FLOW"]] -= 140;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|