@@ -15,13 +15,13 @@ namespace BPASmartClient.AgvApi.Controllers | |||||
/// <param name="sign"></param> | /// <param name="sign"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpPost("report")] | [HttpPost("report")] | ||||
public string report(string ent) | |||||
public string report(string sign) | |||||
{ | { | ||||
if (ent != null) | |||||
if (sign != null) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
var res = JsonConvert.DeserializeObject<AGVToUpSystem>(ent); | |||||
var res = JsonConvert.DeserializeObject<AGVToUpSystem>(sign); | |||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
Factory.GetInstance.SendReport(res); | Factory.GetInstance.SendReport(res); | ||||
@@ -40,19 +40,19 @@ namespace BPASmartClient.AgvApi.Controllers | |||||
/// <summary> | /// <summary> | ||||
/// AGV上下料交互请求接口 | /// AGV上下料交互请求接口 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="upstreamrequest"></param> | |||||
/// <param name="sign"></param> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpPost("upstreamrequest")] | [HttpPost("upstreamrequest")] | ||||
public string upstreamrequest(string upstreamrequest) | |||||
public string upstreamrequest(string sign) | |||||
{ | { | ||||
if (upstreamrequest != null) | |||||
if (sign != null) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
var res = JsonConvert.DeserializeObject<Upstreamrequest>(upstreamrequest); | |||||
var res = JsonConvert.DeserializeObject<Upstreamrequest>(sign); | |||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
Factory.GetInstance.SendUpstreamrequest(upstreamrequest); | |||||
Factory.GetInstance.SendUpstreamrequest(sign); | |||||
return "SUCCESS"; | return "SUCCESS"; | ||||
} | } | ||||
} | } | ||||
@@ -13,20 +13,13 @@ namespace BPASmartClient.HubHelper | |||||
HubConnection hubConnection; | HubConnection hubConnection; | ||||
public void Connect() | |||||
public void Connect(string ip, int port) | |||||
{ | { | ||||
hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl("http://localhost:8089/personhub").Build();//连接 | |||||
hubConnection.On<object>("Report", (s) => | |||||
{ | |||||
Report?.Invoke(s); | |||||
//注册接收消息的委托 | |||||
}); | |||||
//AGV上下料交互请求执行的委托 | |||||
hubConnection.On<object>("Upstreamrequest", (s) => | |||||
{ | |||||
Upstreamrequest?.Invoke(s); | |||||
//注册接收消息的委托 | |||||
}); | |||||
hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl($"http://{ip}:{port}/personhub").Build();//连接 | |||||
hubConnection.On<object>("Report", (s) => { Report?.Invoke(s); }); | |||||
hubConnection.On<object>("Upstreamrequest", (s) => { Upstreamrequest?.Invoke(s); }); | |||||
try | try | ||||
{ | { | ||||
@@ -1,4 +1,7 @@ | |||||
using System; | |||||
using BPASmartClient.AGV.Feedback; | |||||
using BPASmartClient.HubHelper; | |||||
using Newtonsoft.Json; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -27,7 +30,19 @@ namespace FryPot_DosingSystem.View | |||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
Initialize(); | Initialize(); | ||||
HubHelper.GetInstance.Report = new Action<object>((o) => | |||||
{ | |||||
var res = JsonConvert.DeserializeObject<AGVToUpSystem>(o.ToString()); | |||||
}); | |||||
HubHelper.GetInstance.Upstreamrequest = new Action<object>((o) => | |||||
{ | |||||
var res = JsonConvert.DeserializeObject<Upstreamrequest>(o.ToString()); | |||||
}); | |||||
HubHelper.GetInstance.Connect("192.168.1.56", 8089); | |||||
} | } | ||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) | protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) | ||||
{ | { | ||||
base.OnMouseLeftButtonDown(e); | base.OnMouseLeftButtonDown(e); | ||||
@@ -40,7 +55,6 @@ namespace FryPot_DosingSystem.View | |||||
{ | { | ||||
this.DragMove(); | this.DragMove(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -59,6 +73,6 @@ namespace FryPot_DosingSystem.View | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -29,6 +29,7 @@ | |||||
private void InitializeComponent() | private void InitializeComponent() | ||||
{ | { | ||||
this.button1 = new System.Windows.Forms.Button(); | this.button1 = new System.Windows.Forms.Button(); | ||||
this.button2 = new System.Windows.Forms.Button(); | |||||
this.SuspendLayout(); | this.SuspendLayout(); | ||||
// | // | ||||
// button1 | // button1 | ||||
@@ -41,11 +42,22 @@ | |||||
this.button1.UseVisualStyleBackColor = true; | this.button1.UseVisualStyleBackColor = true; | ||||
this.button1.Click += new System.EventHandler(this.button1_Click); | 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 | // Form1 | ||||
// | // | ||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); | ||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | ||||
this.ClientSize = new System.Drawing.Size(641, 298); | this.ClientSize = new System.Drawing.Size(641, 298); | ||||
this.Controls.Add(this.button2); | |||||
this.Controls.Add(this.button1); | this.Controls.Add(this.button1); | ||||
this.Name = "Form1"; | this.Name = "Form1"; | ||||
this.Text = "Form1"; | this.Text = "Form1"; | ||||
@@ -56,5 +68,6 @@ | |||||
#endregion | #endregion | ||||
private Button button1; | private Button button1; | ||||
private Button button2; | |||||
} | } | ||||
} | } |
@@ -14,10 +14,19 @@ namespace TestDemo | |||||
private void button1_Click(object sender, EventArgs e) | private void button1_Click(object sender, EventArgs e) | ||||
{ | { | ||||
string url = "http://192.168.1.56:8089"; | |||||
AGVToUpSystem aGVToUpSystem = new AGVToUpSystem(); | AGVToUpSystem aGVToUpSystem = new AGVToUpSystem(); | ||||
string value = JsonConvert.SerializeObject(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); | |||||
} | } | ||||
} | } | ||||
} | } |