修改PLC的IO配置后,仿真无法运行问题修改

This commit is contained in:
hanqiangqiang
2026-05-21 15:23:06 +08:00
parent 3a8f3d0ab1
commit 176cd7b598
6 changed files with 544 additions and 485 deletions
@@ -32,12 +32,18 @@ namespace SicSimulator.Instances
case "GVL_IO.PM1_AI_G_2":
data = IoManager.Instance.GetAiBuffer("PM1.PLC")[1];
break;
case "GVL_IO.PM1_AI_G_3":
data = IoManager.Instance.GetAiBuffer("PM1.PLC")[2];
break;
case "GVL_IO.PM1_AO_G":
data = IoManager.Instance.GetAoBuffer("PM1.PLC")[0];
break;
case "GVL_IO.PM1_AO_G_2":
data = IoManager.Instance.GetAoBuffer("PM1.PLC")[1];
break;
case "GVL_IO.PM1_AO_G_3":
data = IoManager.Instance.GetAoBuffer("PM1.PLC")[2];
break;
case "GVL_IO.PM2_DI_G":
data = IoManager.Instance.GetDiBuffer("PM2.PLC")[0];
@@ -51,12 +57,18 @@ namespace SicSimulator.Instances
case "GVL_IO.PM2_AI_G_2":
data = IoManager.Instance.GetAiBuffer("PM2.PLC")[1];
break;
case "GVL_IO.PM2_AI_G_3":
data = IoManager.Instance.GetAiBuffer("PM2.PLC")[2];
break;
case "GVL_IO.PM2_AO_G":
data = IoManager.Instance.GetAoBuffer("PM2.PLC")[0];
break;
case "GVL_IO.PM2_AO_G_2":
data = IoManager.Instance.GetAoBuffer("PM2.PLC")[1];
break;
case "GVL_IO.PM2_AO_G_3":
data = IoManager.Instance.GetAoBuffer("PM2.PLC")[2];
break;
}
return true;
@@ -73,6 +85,13 @@ namespace SicSimulator.Instances
IoManager.Instance.GetDoBuffer("PM1.PLC")[0][index] = (bool)value;
break;
case "GVL_IO.PM1_AI_G":
IoManager.Instance.GetAiBuffer("PM1.PLC")[0][index] = (float)value;
break;
case "GVL_IO.PM1_AI_G_2":
IoManager.Instance.GetAiBuffer("PM1.PLC")[1][index] = (float)value;
break;
case "GVL_IO.PM1_AI_G_3":
IoManager.Instance.GetAiBuffer("PM1.PLC")[2][index] = (float)value;
break;
case "GVL_IO.PM1_AO_G":
IoManager.Instance.GetAoBuffer("PM1.PLC")[0][index] = (float)value;
@@ -80,20 +99,37 @@ namespace SicSimulator.Instances
case "GVL_IO.PM1_AO_G_2":
IoManager.Instance.GetAoBuffer("PM1.PLC")[1][index] = (float)value;
break;
case "GVL_IO.PM1_AO_G_3":
IoManager.Instance.GetAoBuffer("PM1.PLC")[2][index] = (float)value;
break;
case "GVL_IO.PM2_DI_G":
break;
case "GVL_IO.PM2_DO_G":
IoManager.Instance.GetDoBuffer("PM2.PLC")[0][index] = (bool)value;
break;
case "GVL_IO.PM2_AI_G":
IoManager.Instance.GetAiBuffer("PM2.PLC")[0][index] = (float)value;
break;
case "GVL_IO.PM2_AI_G_2":
IoManager.Instance.GetAiBuffer("PM2.PLC")[1][index] = (float)value;
break;
case "GVL_IO.PM2_AI_G_3":
IoManager.Instance.GetAiBuffer("PM2.PLC")[2][index] = (float)value;
break;
case "GVL_IO.PM2_AO_G":
IoManager.Instance.GetAoBuffer("PM2.PLC")[0][index] = (float)value;
break;
case "GVL_IO.PM2_AO_G_2":
IoManager.Instance.GetAoBuffer("PM2.PLC")[1][index] = (float)value;
break;
case "GVL_IO.PM2_AO_G_3":
IoManager.Instance.GetAoBuffer("PM2.PLC")[2][index] = (float)value;
break;
}
return true;
}
@@ -38,6 +38,8 @@ namespace SicSimulator.Instances
_buffers.Add(new PlcBuffer() { Buffer = new byte[BufferSize], Type = IoType.AO, Offset = 0, Size = BufferSize, FloatValue = new float[BufferSize] });
_buffers.Add(new PlcBuffer() { Buffer = new byte[BufferSize], Type = IoType.AI, Offset = 1, Size = BufferSize, FloatValue = new float[BufferSize] });
_buffers.Add(new PlcBuffer() { Buffer = new byte[BufferSize], Type = IoType.AO, Offset = 1, Size = BufferSize, FloatValue = new float[BufferSize] });
_buffers.Add(new PlcBuffer() { Buffer = new byte[BufferSize], Type = IoType.AI, Offset = 2, Size = BufferSize, FloatValue = new float[BufferSize] });
_buffers.Add(new PlcBuffer() { Buffer = new byte[BufferSize], Type = IoType.AO, Offset = 2, Size = BufferSize, FloatValue = new float[BufferSize] });
List<IoBlockItem> lstBuffers = new List<IoBlockItem>();
lstBuffers.Add(new IoBlockItem() { Type = IoType.DI, Index = 0, Size = BufferSize });
@@ -46,6 +48,8 @@ namespace SicSimulator.Instances
lstBuffers.Add(new IoBlockItem() { Type = IoType.AO, Index = 0, Size = BufferSize });
lstBuffers.Add(new IoBlockItem() { Type = IoType.AI, Index = 1, Size = BufferSize });
lstBuffers.Add(new IoBlockItem() { Type = IoType.AO, Index = 1, Size = BufferSize });
lstBuffers.Add(new IoBlockItem() { Type = IoType.AI, Index = 2, Size = BufferSize });
lstBuffers.Add(new IoBlockItem() { Type = IoType.AO, Index = 2, Size = BufferSize });
SimulatorIoManager.Instance.CreateBuffer(source, lstBuffers);
SimulatorIoManager.Instance.SetIoMap(source, ioMapPathFile, module);