Browse Source

fixed type struct

master
Z 9 months ago
parent
commit
a86ba21cff
  1. 23
      Example/Gateway/Script/View/ViewModbusGateway.cs
  2. 1
      addons/EGFramework/Module/ProtocolTools/EGTCPClient.cs

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

@ -6,6 +6,7 @@ using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using System.Threading.Tasks;
namespace EGFramework.Examples.Gateway{ namespace EGFramework.Examples.Gateway{
public partial class ViewModbusGateway : Control,IEGFramework,IGateway public partial class ViewModbusGateway : Control,IEGFramework,IGateway
@ -131,9 +132,17 @@ namespace EGFramework.Examples.Gateway{
} }
} }
} }
string resultJson = JsonConvert.SerializeObject(pushData,Formatting.Indented); string resultJson = JsonConvert.SerializeObject(pushData);
GD.Print(resultJson); resultJson = JsonConvert.SerializeObject(new TypeTCPRotateData(resultJson),Formatting.Indented);
this.EGTCPClient().SendStringData("192.168.1.170",5501,resultJson); // GD.Print(resultJson);
JObject loginData = new JObject
{
{ "type", "SpeedControlDeviceLogin" }
};
this.EGTCPClient().SendStringData("192.168.1.11",9966,loginData.ToString());
await Task.Delay(50);
this.EGTCPClient().SendStringData("192.168.1.11",9966,resultJson);
} }
public async void ReadTest(){ public async void ReadTest(){
@ -227,4 +236,12 @@ namespace EGFramework.Examples.Gateway{
} }
} }
public struct TypeTCPRotateData{
public string type;
public string data;
public TypeTCPRotateData(string data){
this.type = "SendRotationalSpeed";
this.data = data;
}
}
} }

1
addons/EGFramework/Module/ProtocolTools/EGTCPClient.cs

@ -141,6 +141,7 @@ namespace EGFramework{
byte[] receivedByte = new byte[bytesRead]; byte[] receivedByte = new byte[bytesRead];
Array.Copy(buffer, 0, receivedByte, 0, bytesRead); Array.Copy(buffer, 0, receivedByte, 0, bytesRead);
ResponseMsg receivedMsgs = new ResponseMsg(data,receivedByte,ClientName, ProtocolType.TCPClient); ResponseMsg receivedMsgs = new ResponseMsg(data,receivedByte,ClientName, ProtocolType.TCPClient);
Godot.GD.Print("[TCP-R]+("+ClientName+")" + data);
ResponseMsgs.Enqueue(receivedMsgs); ResponseMsgs.Enqueue(receivedMsgs);
//this.EGOnReceivedData(receivedMsgs); //this.EGOnReceivedData(receivedMsgs);
} }

Loading…
Cancel
Save