|
|
@ -209,7 +209,7 @@ namespace EGFramework{ |
|
|
|
return res; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<ModbusTCP_Response?> WriteOnceTCPAsync(ModbusRegisterType registerType,string serialPort,byte deviceAddress,ushort registerAddress,object value){ |
|
|
|
public async Task<ModbusTCP_Response?> WriteOnceTCPAsync(ModbusRegisterType registerType,string ipPort,byte deviceAddress,ushort registerAddress,object value){ |
|
|
|
if(IsRequestTCP){ |
|
|
|
if(IsRequestTCP){ |
|
|
|
SendPointerTCP++; |
|
|
|
SendPointerTCP++; |
|
|
|
int messageId = SendPointerTCP; |
|
|
|
int messageId = SendPointerTCP; |
|
|
@ -232,7 +232,7 @@ namespace EGFramework{ |
|
|
|
switch(registerType){ |
|
|
|
switch(registerType){ |
|
|
|
case ModbusRegisterType.Coil: |
|
|
|
case ModbusRegisterType.Coil: |
|
|
|
WriteRequest = new ModbusTCP_WriteSingleCoil(deviceAddress,registerAddress,(bool)value); |
|
|
|
WriteRequest = new ModbusTCP_WriteSingleCoil(deviceAddress,registerAddress,(bool)value); |
|
|
|
this.EGSendMessage(WriteRequest,serialPort,ProtocolType.TCPClient); |
|
|
|
this.EGSendMessage(WriteRequest,ipPort,ProtocolType.TCPClient); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case ModbusRegisterType.HoldingRegister: |
|
|
|
case ModbusRegisterType.HoldingRegister: |
|
|
|
if(value.GetType() == typeof(float)){ |
|
|
|
if(value.GetType() == typeof(float)){ |
|
|
@ -241,7 +241,7 @@ namespace EGFramework{ |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
WriteRequest = new ModbusTCP_WriteSingleHoldingRegister(deviceAddress,registerAddress,(ushort)value); |
|
|
|
WriteRequest = new ModbusTCP_WriteSingleHoldingRegister(deviceAddress,registerAddress,(ushort)value); |
|
|
|
} |
|
|
|
} |
|
|
|
this.EGSendMessage(WriteRequest,serialPort,ProtocolType.TCPClient); |
|
|
|
this.EGSendMessage(WriteRequest,ipPort,ProtocolType.TCPClient); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
await Task.Run(async ()=>{ |
|
|
|
await Task.Run(async ()=>{ |
|
|
|