From 0de1af69d0e33a44cf40a7613a2c1b5299a48b90 Mon Sep 17 00:00:00 2001 From: CJY Date: Thu, 11 Dec 2025 14:45:58 +0900 Subject: [PATCH] =?UTF-8?q?Ethernet=20/=20Modbus=EC=AA=BD=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- INT69DC_7C/Forms/FormMain.cs | 129 +++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 45 deletions(-) diff --git a/INT69DC_7C/Forms/FormMain.cs b/INT69DC_7C/Forms/FormMain.cs index 69bdf4b..5fcbe28 100644 --- a/INT69DC_7C/Forms/FormMain.cs +++ b/INT69DC_7C/Forms/FormMain.cs @@ -886,7 +886,7 @@ namespace INT69DC_7C.Forms this.CollectionWeightData[index].WeightString = receiveData.Substring(2, 5); this.CollectionWeightData[index].ADCValue = receiveData.Substring(7, 5); - if (this.SystemConfig.EthernetOperationMode == 3) + if (this.SystemConfig.EthernetMode == 3) this.Update30000ModbusData(index); } else @@ -898,7 +898,7 @@ namespace INT69DC_7C.Forms this.CollectionWeightData[index2].WeightString = receiveData.Substring(2, 5); this.CollectionWeightData[index2].ADCValue = receiveData.Substring(7, 5); - if (this.SystemConfig.EthernetOperationMode == 3) + if (this.SystemConfig.EthernetMode == 3) this.Update30000ModbusData(index2); } } @@ -2016,10 +2016,13 @@ namespace INT69DC_7C.Forms } else if (this.SystemConfig.EthernetMode == 3) { - #region Modus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(0), this.SystemConfig.ModbusTcpStartAddress + (1 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + #region Modbus + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(0), this.SystemConfig.ModbusTcpStartAddress + (1 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -2343,9 +2346,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(1), this.SystemConfig.ModbusTcpStartAddress + (2 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(1), this.SystemConfig.ModbusTcpStartAddress + (2 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -2651,9 +2657,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(2), this.SystemConfig.ModbusTcpStartAddress + (3 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(2), this.SystemConfig.ModbusTcpStartAddress + (3 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -2959,9 +2968,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) // Modbus { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(3), this.SystemConfig.ModbusTcpStartAddress + (4 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(3), this.SystemConfig.ModbusTcpStartAddress + (4 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -3267,9 +3279,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(4), this.SystemConfig.ModbusTcpStartAddress + (5 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(4), this.SystemConfig.ModbusTcpStartAddress + (5 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -3575,9 +3590,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(5), this.SystemConfig.ModbusTcpStartAddress + (6 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(5), this.SystemConfig.ModbusTcpStartAddress + (6 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -3883,9 +3901,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(6), this.SystemConfig.ModbusTcpStartAddress + (7 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(6), this.SystemConfig.ModbusTcpStartAddress + (7 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -4189,9 +4210,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(7), this.SystemConfig.ModbusTcpStartAddress + (8 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(7), this.SystemConfig.ModbusTcpStartAddress + (8 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -4492,9 +4516,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(8), this.SystemConfig.ModbusTcpStartAddress + (9 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(8), this.SystemConfig.ModbusTcpStartAddress + (9 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -4794,9 +4821,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(9), this.SystemConfig.ModbusTcpStartAddress + (10 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(9), this.SystemConfig.ModbusTcpStartAddress + (10 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -5094,9 +5124,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(10), this.SystemConfig.ModbusTcpStartAddress + (11 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(10), this.SystemConfig.ModbusTcpStartAddress + (11 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -5389,9 +5422,12 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) // Modbus { #region Modbus - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(11), this.SystemConfig.ModbusTcpStartAddress + (12 * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + if (this.SystemConfig.EthernetOperationMode == 2) // Client + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(11), this.SystemConfig.ModbusTcpStartAddress + (12 * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } #endregion } else if (this.SystemConfig.EthernetMode == 4) @@ -5603,7 +5639,7 @@ namespace INT69DC_7C.Forms this.CollectionWeightData[i].WeightString = receiveData.Substring(i * 12 + 2, 5); this.CollectionWeightData[i].ADCValue = receiveData.Substring(i * 12 + 7, 5); - if (this.SystemConfig.EthernetOperationMode == 3) + if (this.SystemConfig.EthernetMode == 3) this.Update30000ModbusData(i); } #endregion @@ -5643,7 +5679,7 @@ namespace INT69DC_7C.Forms this.CollectionWeightData[this.CollectionWeightData.Count - i].WeightString = receiveData.Substring((i - 1) * 12 + 2, 5); this.CollectionWeightData[this.CollectionWeightData.Count - i].ADCValue = receiveData.Substring((i - 1) * 12 + 7, 5); - if (this.SystemConfig.EthernetOperationMode == 3) + if (this.SystemConfig.EthernetMode == 3) this.Update30000ModbusData(this.CollectionWeightData.Count - i); } #endregion @@ -5736,11 +5772,14 @@ namespace INT69DC_7C.Forms else if (this.SystemConfig.EthernetMode == 3) { #region Modbus - for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++) + if (this.SystemConfig.EthernetOperationMode == 2) // Client { - byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( - this.Protocol_Modbus_Client_Write_Lane_Data(i), this.SystemConfig.ModbusTcpStartAddress + ((i + 1) * 50) + 140); - this.EthernetWeightDataForModbus(etherByteData); + for (int i = 0; i < this.SystemConfig.EquipmentColumns; i++) + { + byte[] etherByteData = this.Modbus.WriteMultipleRegisterTCP( + this.Protocol_Modbus_Client_Write_Lane_Data(i), this.SystemConfig.ModbusTcpStartAddress + ((i + 1) * 50) + 140); + this.EthernetWeightDataForModbus(etherByteData); + } } #endregion }