|
@@ -51,6 +51,14 @@ namespace CyberX8_Simulator.Devices
|
|
|
/// </summary>
|
|
|
private Dictionary<string, bool> _festoDataBuffer = new Dictionary<string, bool>();
|
|
|
/// <summary>
|
|
|
+ /// Name-WagoDO dictionary
|
|
|
+ /// </summary>
|
|
|
+ private Dictionary<string, WagoDO> _doNameWagoDODic = new Dictionary<string, WagoDO>();
|
|
|
+ /// <summary>
|
|
|
+ /// Name-WagoDI dictionary
|
|
|
+ /// </summary>
|
|
|
+ private Dictionary<string, WagoDI> _diNameWagoDIDic = new Dictionary<string, WagoDI>();
|
|
|
+ /// <summary>
|
|
|
/// 定时器
|
|
|
/// </summary>
|
|
|
private PeriodicJob _LoaderPeriodicJob;
|
|
@@ -64,6 +72,8 @@ namespace CyberX8_Simulator.Devices
|
|
|
private bool _rinse3DumpValve = false;
|
|
|
private bool _rinse4FillValve = false;
|
|
|
private bool _rinse4DumpValve = false;
|
|
|
+ private int _srd1currentVacuumValue;
|
|
|
+ private int _srd2currentVacuumValue;
|
|
|
//delegate
|
|
|
#region Delegate
|
|
|
public delegate void VariableValueChanged(object obj);
|
|
@@ -158,23 +168,121 @@ namespace CyberX8_Simulator.Devices
|
|
|
/// <param name="value"></param>
|
|
|
private void UpdateDataCausedByWago(int position, bool value)
|
|
|
{
|
|
|
+ //Puf Simulator
|
|
|
if (DONameIndexDic.ContainsKey("c_PUF_CHUCK") && position == DONameIndexDic["c_PUF_CHUCK"])
|
|
|
{
|
|
|
+ value = _doNameWagoDODic["c_PUF_CHUCK"].Invert? !value : value;
|
|
|
UpdataDIBytes("r_PUF_A_CHUCK_OUT", value ? 1 : 0);
|
|
|
UpdataDIBytes("r_PUF_B_CHUCK_OUT", value ? 1 : 0);
|
|
|
UpdataDIBytes("r_PUF_A_CHUCK_IN", !value ? 1 : 0);
|
|
|
UpdataDIBytes("r_PUF_B_CHUCK_IN", !value ? 1 : 0);
|
|
|
}
|
|
|
+ //HVD Simulator
|
|
|
if (DONameIndexDic.ContainsKey("c_HVD_1_HIGH") && position == DONameIndexDic["c_HVD_1_HIGH"])
|
|
|
{
|
|
|
+ value = _doNameWagoDODic["c_HVD_1_HIGH"].Invert ? !value : value;
|
|
|
UpdataAIShorts("r_HVD_1_ANALOG", value ? 4500 : 0);
|
|
|
}
|
|
|
|
|
|
if (DONameIndexDic.ContainsKey("c_HVD_2_HIGH") && position == DONameIndexDic["c_HVD_2_HIGH"])
|
|
|
{
|
|
|
+ value = _doNameWagoDODic["c_HVD_2_HIGH"].Invert ? !value : value;
|
|
|
UpdataAIShorts("r_HVD_2_ANALOG", value ? 4500 : 0);
|
|
|
}
|
|
|
-
|
|
|
+ //SRD Simulator
|
|
|
+ //Lift UP
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD1_LIFT_UP") && position == DONameIndexDic["c_SRD1_LIFT_UP"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD1_LIFT_UP"].Invert ^ _diNameWagoDIDic["r_SRD1_LIFT_UP"].Invert) ? !value : value;
|
|
|
+ UpdataDIBytes("r_SRD1_LIFT_UP", value ? 1 : 0);
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD2_LIFT_UP") && position == DONameIndexDic["c_SRD2_LIFT_UP"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD2_LIFT_UP"].Invert ^ _diNameWagoDIDic["r_SRD2_LIFT_UP"].Invert) ? !value : value;
|
|
|
+ UpdataDIBytes("r_SRD2_LIFT_UP", value ? 1 : 0);
|
|
|
+ }
|
|
|
+ //Flippers
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD1_150_FLIPPERS_IN") && position == DONameIndexDic["c_SRD1_150_FLIPPERS_IN"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD1_150_FLIPPERS_IN"].Invert ^ _diNameWagoDIDic["r_SRD1_150_FLIPPER1_OUT"].Invert) ? !value : value;
|
|
|
+ UpdataDIBytes("r_SRD1_150_FLIPPER1_OUT", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD1_150_FLIPPER2_OUT", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD1_150_FLIPPER3_OUT", value ? 0 : 1);
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD2_150_FLIPPERS_IN") && position == DONameIndexDic["c_SRD2_150_FLIPPERS_IN"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD2_150_FLIPPERS_IN"].Invert ^ _diNameWagoDIDic["r_SRD2_150_FLIPPER1_OUT"].Invert) ? !value : value;
|
|
|
+ UpdataDIBytes("r_SRD2_150_FLIPPER1_OUT", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD2_150_FLIPPER2_OUT", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD2_150_FLIPPER3_OUT", value ? 0 : 1);
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD1_200_FLIPPERS_IN") && position == DONameIndexDic["c_SRD1_200_FLIPPERS_IN"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD1_200_FLIPPERS_IN"].Invert ^ _diNameWagoDIDic["r_SRD1_200_FLIPPER1_OUT"].Invert) ? !value : value;
|
|
|
+ UpdataDIBytes("r_SRD1_200_FLIPPER1_OUT", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD1_200_FLIPPER2_OUT", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD1_200_FLIPPER3_OUT", value ? 0 : 1);
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD2_200_FLIPPERS_IN") && position == DONameIndexDic["c_SRD2_200_FLIPPERS_IN"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD2_200_FLIPPERS_IN"].Invert ^ _diNameWagoDIDic["r_SRD2_200_FLIPPER1_OUT"].Invert) ? !value : value;
|
|
|
+ UpdataDIBytes("r_SRD2_200_FLIPPER1_OUT", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD2_200_FLIPPER2_OUT", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD2_200_FLIPPER3_OUT", value ? 0 : 1);
|
|
|
+ }
|
|
|
+ //Shuttle
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD1_Shutter_Close") && position == DONameIndexDic["c_SRD1_Shutter_Close"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD1_Shutter_Close"].Invert ^ _diNameWagoDIDic["r_SRD1_SHUTTER_OPEN"].Invert) ? !value : value;
|
|
|
+ UpdataDIBytes("r_SRD1_SHUTTER_OPEN", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD1_SHUTTER_CLOSED", value ? 1 : 0);
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD2_Shutter_Close") && position == DONameIndexDic["c_SRD2_Shutter_Close"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD2_Shutter_Close"].Invert ^ _diNameWagoDIDic["r_SRD2_SHUTTER_OPEN"].Invert) ? !value : value;
|
|
|
+ UpdataDIBytes("r_SRD2_SHUTTER_OPEN", value ? 0 : 1);
|
|
|
+ UpdataDIBytes("r_SRD2_SHUTTER_CLOSED", value ? 1 : 0);
|
|
|
+ }
|
|
|
+ //Vacuum
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD1_CHUCK_VACUUM") && position == DONameIndexDic["c_SRD1_CHUCK_VACUUM"])
|
|
|
+ {
|
|
|
+ value = (_doNameWagoDODic["c_SRD1_CHUCK_VACUUM"].Invert ) ? !value : value;
|
|
|
+ _srd1currentVacuumValue = value ? 5000 : 15000;
|
|
|
+ UpdataAIShorts("r_SRD1_CHUCK_VACUUM_anlg", _srd1currentVacuumValue);
|
|
|
+ UpdataDIBytes("r_SRD1_CHUCK_VAC_OK", value ? 0 : 1);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD2_CHUCK_VACUUM") && position == DONameIndexDic["c_SRD2_CHUCK_VACUUM"])
|
|
|
+ {
|
|
|
+ value = _doNameWagoDODic["c_SRD2_CHUCK_VACUUM"].Invert ? !value : value;
|
|
|
+ _srd2currentVacuumValue = value ? 5000 : 15000;
|
|
|
+ UpdataAIShorts("r_SRD2_CHUCK_VACUUM_anlg", _srd2currentVacuumValue);
|
|
|
+ UpdataDIBytes("r_SRD2_CHUCK_VAC_OK", value ? 0 : 1);
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD1_CHUCK_ATM_ON") && position == DONameIndexDic["c_SRD1_CHUCK_ATM_ON"])
|
|
|
+ {
|
|
|
+ value = _doNameWagoDODic["c_SRD1_CHUCK_ATM_ON"].Invert ? !value : value;
|
|
|
+ _srd1currentVacuumValue = value ? 5000 : 15000;
|
|
|
+ UpdataAIShorts("r_SRD1_CHUCK_VACUUM_anlg", _srd1currentVacuumValue);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD2_CHUCK_ATM_ON") && position == DONameIndexDic["c_SRD2_CHUCK_ATM_ON"])
|
|
|
+ {
|
|
|
+ value = _doNameWagoDODic["c_SRD2_CHUCK_ATM_ON"].Invert ? !value : value;
|
|
|
+ _srd2currentVacuumValue = value ? 5000 : 15000;
|
|
|
+ UpdataAIShorts("r_SRD2_CHUCK_VACUUM_anlg", _srd2currentVacuumValue);
|
|
|
+ }
|
|
|
+ //Water
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD1_WATER_ON") && position == DONameIndexDic["c_SRD1_WATER_ON"])
|
|
|
+ {
|
|
|
+ value = _doNameWagoDODic["c_SRD1_WATER_ON"].Invert ? !value : value;
|
|
|
+ UpdataAIShorts("r_SRD1_WATER_FLOW", value ? 30000 : 3277);
|
|
|
+ }
|
|
|
+ if (DONameIndexDic.ContainsKey("c_SRD2_WATER_ON") && position == DONameIndexDic["c_SRD2_WATER_ON"])
|
|
|
+ {
|
|
|
+ value = _doNameWagoDODic["c_SRD2_WATER_ON"].Invert ? !value : value;
|
|
|
+ UpdataAIShorts("r_SRD2_WATER_FLOW", value ? 30000 : 3277);
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 初始化字典
|
|
@@ -212,6 +320,7 @@ namespace CyberX8_Simulator.Devices
|
|
|
{
|
|
|
DONameIndexDic[item.Name] = i;
|
|
|
i++;
|
|
|
+ _doNameWagoDODic[item.Name] = item;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -226,6 +335,7 @@ namespace CyberX8_Simulator.Devices
|
|
|
{
|
|
|
DINameIndexDic[item.Name] = i;
|
|
|
i++;
|
|
|
+ _diNameWagoDIDic[item.Name] = item;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -279,6 +389,28 @@ namespace CyberX8_Simulator.Devices
|
|
|
if (AINameIndexDic.ContainsKey("r_QDRD2_WATER_LEVEL")) AIShorts[AINameIndexDic["r_QDRD2_WATER_LEVEL"]] = 4000;
|
|
|
if (AINameIndexDic.ContainsKey("r_QDRD3_WATER_LEVEL")) AIShorts[AINameIndexDic["r_QDRD3_WATER_LEVEL"]] = 4000;
|
|
|
if (AINameIndexDic.ContainsKey("r_QDRD4_WATER_LEVEL")) AIShorts[AINameIndexDic["r_QDRD4_WATER_LEVEL"]] = 4000;
|
|
|
+ //SRD
|
|
|
+ if (AINameIndexDic.ContainsKey("r_SRD1_CHUCK_VACUUM_anlg")) AIShorts[AINameIndexDic["r_SRD1_CHUCK_VACUUM_anlg"]] = 15000;
|
|
|
+ if (AINameIndexDic.ContainsKey("r_SRD2_CHUCK_VACUUM_anlg")) AIShorts[AINameIndexDic["r_SRD2_CHUCK_VACUUM_anlg"]] = 15000;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_SHUTTER_OPEN")) DIBytes[DINameIndexDic["r_SRD1_SHUTTER_OPEN"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_SHUTTER_CLOSED")) DIBytes[DINameIndexDic["r_SRD1_SHUTTER_CLOSED"]] = 0;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_SHUTTER_OPEN")) DIBytes[DINameIndexDic["r_SRD2_SHUTTER_OPEN"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_SHUTTER_CLOSED")) DIBytes[DINameIndexDic["r_SRD2_SHUTTER_CLOSED"]] = 0;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD_FLUID_LEVEL")) DIBytes[DINameIndexDic["r_SRD_FLUID_LEVEL"]] = 0;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_CHUCK_VAC_OK")) DIBytes[DINameIndexDic["r_SRD1_CHUCK_VAC_OK"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_CHUCK_VAC_OK")) DIBytes[DINameIndexDic["r_SRD2_CHUCK_VAC_OK"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_150_FLIPPER1_OUT")) DIBytes[DINameIndexDic["r_SRD1_150_FLIPPER1_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_150_FLIPPER2_OUT")) DIBytes[DINameIndexDic["r_SRD1_150_FLIPPER2_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_150_FLIPPER3_OUT")) DIBytes[DINameIndexDic["r_SRD1_150_FLIPPER3_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_200_FLIPPER1_OUT")) DIBytes[DINameIndexDic["r_SRD1_200_FLIPPER1_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_200_FLIPPER2_OUT")) DIBytes[DINameIndexDic["r_SRD1_200_FLIPPER2_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD1_200_FLIPPER3_OUT")) DIBytes[DINameIndexDic["r_SRD1_200_FLIPPER3_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_150_FLIPPER1_OUT")) DIBytes[DINameIndexDic["r_SRD2_150_FLIPPER1_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_150_FLIPPER2_OUT")) DIBytes[DINameIndexDic["r_SRD2_150_FLIPPER2_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_150_FLIPPER3_OUT")) DIBytes[DINameIndexDic["r_SRD2_150_FLIPPER3_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_200_FLIPPER1_OUT")) DIBytes[DINameIndexDic["r_SRD2_200_FLIPPER1_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_200_FLIPPER2_OUT")) DIBytes[DINameIndexDic["r_SRD2_200_FLIPPER2_OUT"]] = 1;
|
|
|
+ if (DINameIndexDic.ContainsKey("r_SRD2_200_FLIPPER3_OUT")) DIBytes[DINameIndexDic["r_SRD2_200_FLIPPER3_OUT"]] = 1;
|
|
|
|
|
|
}
|
|
|
#region 公共方法
|