|
|
|
@ -18,6 +18,8 @@ using JsonSerializer = System.Text.Json.JsonSerializer;
|
|
|
|
|
using Serilog;
|
|
|
|
|
using Serilog.Events;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using static System.Net.WebRequestMethods;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.TouchSocket
|
|
|
|
|
{
|
|
|
|
@ -69,35 +71,46 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public T JTokenToEntity<T>(JToken value) where T : class
|
|
|
|
|
public AGVResponseEntity<T> JTokenToEntity<T>(JToken value) where T : class
|
|
|
|
|
{
|
|
|
|
|
if (value == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("返回空数据!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
string json = value.ToString();
|
|
|
|
|
if (string.IsNullOrEmpty(json))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("解析数据为空!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
AGVResponseEntity<T> ResponseEntity;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ResponseEntity = JsonSerializer.Deserialize<AGVResponseEntity<T>>(json);
|
|
|
|
|
return ResponseEntity;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"Json反序列化发生错误:{ex.Message}");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
T ResponseEntity;
|
|
|
|
|
ResponseEntity = JsonSerializer.Deserialize<T>(json);
|
|
|
|
|
return ResponseEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// AGV下发任务请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="requestValue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
///
|
|
|
|
|
public AGVResponseEntity<ResponseAddTaskDataEntity> AGVAddTaskRequest(AGVRequestAddTaskEntity requestValue)
|
|
|
|
|
{
|
|
|
|
|
if (AirportAGVClient == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:/api/task/addTask", null, requestValue);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<ResponseAddTaskDataEntity>>(responseValue);
|
|
|
|
|
return JTokenToEntity<ResponseAddTaskDataEntity>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -112,7 +125,7 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:/api/task/operationalTask", null, requestValue);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<object>>(responseValue);
|
|
|
|
|
return JTokenToEntity<object>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -127,7 +140,7 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("PUT:/api/task/getTaskStateDetail", null, requestValue);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<ResponseTaskStateDetailDataEntity>>(responseValue);
|
|
|
|
|
return JTokenToEntity<ResponseTaskStateDetailDataEntity>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -141,7 +154,7 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/task/robot/getRobot", null);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>>>(responseValue);
|
|
|
|
|
return JTokenToEntity<List<ResponseRobotAtrributeDataEntity>>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -155,7 +168,7 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/v1.0.0/Maps/mapActive", null);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<ResponseActiveMapDataEntity>>(responseValue);
|
|
|
|
|
return JTokenToEntity<ResponseActiveMapDataEntity>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -170,9 +183,35 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/v1.0.0/Positions?mapId={0}", null, requestValue);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<List<ResponseMapPositionDataEntity>>>(responseValue);
|
|
|
|
|
return JTokenToEntity<List<ResponseMapPositionDataEntity>>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前所有任务模板信息(目前不可用)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public AGVResponseEntity<object> AGVJobRequest()
|
|
|
|
|
{
|
|
|
|
|
if (AirportAGVClient == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/v1.0.0/Positions?mapId={0}", null);
|
|
|
|
|
return JTokenToEntity<object>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//HttpClient client1 = new HttpClient();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//string url = "http://192.168.10.199:5102/api/task/addTask";
|
|
|
|
|
|
|
|
|
|
//string json =Newtonsoft.Json.JsonConvert.SerializeObject(requestValue);
|
|
|
|
|
//var context=new StringContent(json,Encoding.UTF8, "application/json");
|
|
|
|
|
//var httpContent = client1.PostAsync(url, context).ConfigureAwait(false).GetAwaiter().GetResult().Content;
|
|
|
|
|
//var result = httpContent.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
|
|
|
|
//_logger.LogInformation(result);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|