Browse Source

fixed egmessage set delay not effect bugs

master
Z 5 months ago
parent
commit
b2b7cb9adb
  1. 1
      Example/Gateway/Script/View/ViewModbusGateway.cs
  2. 1
      addons/EGFramework/Module/EGMessage.cs
  3. 6
      addons/EGFramework/Module/ProtocolTools/EGModbus.cs

1
Example/Gateway/Script/View/ViewModbusGateway.cs

@ -33,6 +33,7 @@ namespace EGFramework.Examples.Gateway{ @@ -33,6 +33,7 @@ namespace EGFramework.Examples.Gateway{
}
});
this.EGOnMessage<TypeTCPSetRotateData>();
this.GetModule<EGMessage>().SetDelay(0);
}
// Called every frame. 'delta' is the elapsed time since the previous frame.

1
addons/EGFramework/Module/EGMessage.cs

@ -85,6 +85,7 @@ namespace EGFramework @@ -85,6 +85,7 @@ namespace EGFramework
public void SetDelay(int millisecond){
this.SendDelay = millisecond;
RequestTimer.Interval = millisecond;
}
}

6
addons/EGFramework/Module/ProtocolTools/EGModbus.cs

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

Loading…
Cancel
Save