diff --git a/BPASmartClient.AgvApi/Controllers/robotjobController.cs b/BPASmartClient.AgvApi/Controllers/robotjobController.cs index 686278d0..a0c6865d 100644 --- a/BPASmartClient.AgvApi/Controllers/robotjobController.cs +++ b/BPASmartClient.AgvApi/Controllers/robotjobController.cs @@ -15,13 +15,13 @@ namespace BPASmartClient.AgvApi.Controllers /// /// [HttpPost("report")] - public string report(string ent) + public string report(string sign) { - if (ent != null) + if (sign != null) { try { - var res = JsonConvert.DeserializeObject(ent); + var res = JsonConvert.DeserializeObject(sign); if (res != null) { Factory.GetInstance.SendReport(res); @@ -40,19 +40,19 @@ namespace BPASmartClient.AgvApi.Controllers /// /// AGV上下料交互请求接口 /// - /// + /// /// [HttpPost("upstreamrequest")] - public string upstreamrequest(string upstreamrequest) + public string upstreamrequest(string sign) { - if (upstreamrequest != null) + if (sign != null) { try { - var res = JsonConvert.DeserializeObject(upstreamrequest); + var res = JsonConvert.DeserializeObject(sign); if (res != null) { - Factory.GetInstance.SendUpstreamrequest(upstreamrequest); + Factory.GetInstance.SendUpstreamrequest(sign); return "SUCCESS"; } } diff --git a/BPASmartClient.HubHelper/HubHelper.cs b/BPASmartClient.HubHelper/HubHelper.cs index 9b6b1d2a..c5443b3a 100644 --- a/BPASmartClient.HubHelper/HubHelper.cs +++ b/BPASmartClient.HubHelper/HubHelper.cs @@ -13,20 +13,13 @@ namespace BPASmartClient.HubHelper HubConnection hubConnection; - public void Connect() + public void Connect(string ip, int port) { - hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl("http://localhost:8089/personhub").Build();//连接 - hubConnection.On("Report", (s) => - { - Report?.Invoke(s); - //注册接收消息的委托 - }); - //AGV上下料交互请求执行的委托 - hubConnection.On("Upstreamrequest", (s) => - { - Upstreamrequest?.Invoke(s); - //注册接收消息的委托 - }); + hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl($"http://{ip}:{port}/personhub").Build();//连接 + + hubConnection.On("Report", (s) => { Report?.Invoke(s); }); + + hubConnection.On("Upstreamrequest", (s) => { Upstreamrequest?.Invoke(s); }); try { diff --git a/FryPot_DosingSystem/View/MainWindow.xaml.cs b/FryPot_DosingSystem/View/MainWindow.xaml.cs index c058faf3..73691795 100644 --- a/FryPot_DosingSystem/View/MainWindow.xaml.cs +++ b/FryPot_DosingSystem/View/MainWindow.xaml.cs @@ -1,4 +1,7 @@ -using System; +using BPASmartClient.AGV.Feedback; +using BPASmartClient.HubHelper; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -27,7 +30,19 @@ namespace FryPot_DosingSystem.View { InitializeComponent(); Initialize(); + HubHelper.GetInstance.Report = new Action((o) => + { + var res = JsonConvert.DeserializeObject(o.ToString()); + }); + + HubHelper.GetInstance.Upstreamrequest = new Action((o) => + { + var res = JsonConvert.DeserializeObject(o.ToString()); + }); + + HubHelper.GetInstance.Connect("192.168.1.56", 8089); } + protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); @@ -40,7 +55,6 @@ namespace FryPot_DosingSystem.View { this.DragMove(); } - } } @@ -59,6 +73,6 @@ namespace FryPot_DosingSystem.View } - + } } diff --git a/TestDemo/Form1.Designer.cs b/TestDemo/Form1.Designer.cs index e9511821..384634cd 100644 --- a/TestDemo/Form1.Designer.cs +++ b/TestDemo/Form1.Designer.cs @@ -29,6 +29,7 @@ private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 @@ -41,11 +42,22 @@ this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // + // button2 + // + this.button2.Location = new System.Drawing.Point(137, 12); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(88, 43); + this.button2.TabIndex = 1; + this.button2.Text = "button2"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(641, 298); + this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; @@ -56,5 +68,6 @@ #endregion private Button button1; + private Button button2; } } \ No newline at end of file diff --git a/TestDemo/Form1.cs b/TestDemo/Form1.cs index 6a70c030..756670c9 100644 --- a/TestDemo/Form1.cs +++ b/TestDemo/Form1.cs @@ -14,10 +14,19 @@ namespace TestDemo private void button1_Click(object sender, EventArgs e) { - string url = "http://192.168.1.56:8089"; AGVToUpSystem aGVToUpSystem = new AGVToUpSystem(); string value = JsonConvert.SerializeObject(aGVToUpSystem); - var res = APIHelper.GetInstance.HttpRequest(url, "", value, RequestType.POST); + string url = $"http://192.168.1.56:8089/apicallback/quicktron/robotjob/report?sign={value}"; + var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST); + } + + private void button2_Click(object sender, EventArgs e) + { + + Upstreamrequest aGVToUpSystem = new Upstreamrequest(); + string value = JsonConvert.SerializeObject(aGVToUpSystem); + string url = $"http://192.168.1.56:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}"; + var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST); } } } \ No newline at end of file