|
|
|
@ -15,11 +15,13 @@ using TouchSocket.Rpc;
|
|
|
|
|
using TouchSocket.Sockets;
|
|
|
|
|
using TouchSocket.WebApi;
|
|
|
|
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
|
|
|
|
using Serilog;
|
|
|
|
|
using Serilog.Events;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.TouchSocket
|
|
|
|
|
{
|
|
|
|
|
public class AirPorthttpClient : BackgroundService
|
|
|
|
|
public class AirPorthttpClient
|
|
|
|
|
{
|
|
|
|
|
private readonly AppConfig _appConfig;
|
|
|
|
|
private readonly ILogger<AirPorthttpClient> _logger;
|
|
|
|
@ -37,18 +39,19 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
var client = new WebApiClient();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("正在连接:" + IpHost);
|
|
|
|
|
client.Connect(IpHost);
|
|
|
|
|
_logger.LogInformation(IpHost + "连接成功");
|
|
|
|
|
return client;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("ERROR: " + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return client;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
|
|
|
|
public void init()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -57,143 +60,119 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("ERROR: " + ex.Message);
|
|
|
|
|
return Task.FromException(ex);
|
|
|
|
|
}
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// AGV下发任务请求
|
|
|
|
|
/// 获取到的JToken类型转换为实体类
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="aGVStateRequest"></param>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static AGVResponseEntity<ResponseAddTaskDataEntity> AGVAddTaskRequest(AGVRequestAddTaskEntity requestValue)
|
|
|
|
|
public T JTokenToEntity<T>(JToken value) where T : class
|
|
|
|
|
{
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:/api/task/addTask", null, requestValue);
|
|
|
|
|
if (responseValue == null)
|
|
|
|
|
if (value == null)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<ResponseAddTaskDataEntity>();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
string json = responseValue.ToString();
|
|
|
|
|
string json = value.ToString();
|
|
|
|
|
if (string.IsNullOrEmpty(json))
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<ResponseAddTaskDataEntity>();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
AGVResponseEntity<ResponseAddTaskDataEntity> responseEntity;
|
|
|
|
|
responseEntity = JsonSerializer.Deserialize<AGVResponseEntity<ResponseAddTaskDataEntity>>(json);
|
|
|
|
|
return responseEntity;
|
|
|
|
|
T ResponseEntity;
|
|
|
|
|
ResponseEntity = JsonSerializer.Deserialize<T>(json);
|
|
|
|
|
return ResponseEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 取消/终止任务请求
|
|
|
|
|
/// AGV下发任务请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="requestValue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static AGVResponseEntity<object> AGVOperationalTaskRequest(AGVRequestOperationalTaskEntity requestValue)
|
|
|
|
|
public AGVResponseEntity<ResponseAddTaskDataEntity> AGVAddTaskRequest(AGVRequestAddTaskEntity requestValue)
|
|
|
|
|
{
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:/api/task/operationalTask", null, requestValue);
|
|
|
|
|
if (responseValue == null)
|
|
|
|
|
if (AirportAGVClient == null)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<object>();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
string json = responseValue.ToString();
|
|
|
|
|
if (string.IsNullOrEmpty(json))
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:/api/task/addTask", null, requestValue);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<ResponseAddTaskDataEntity>>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 取消/终止任务请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="requestValue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public AGVResponseEntity<object> AGVOperationalTaskRequest(AGVRequestOperationalTaskEntity requestValue)
|
|
|
|
|
{
|
|
|
|
|
if (AirportAGVClient == null)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<object>();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
AGVResponseEntity<object> responseEntity;
|
|
|
|
|
responseEntity = JsonSerializer.Deserialize<AGVResponseEntity<object>>(json);
|
|
|
|
|
return responseEntity;
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:/api/task/operationalTask", null, requestValue);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<object>>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询任务状态请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="aGVStateRequest"></param>
|
|
|
|
|
/// <param name="requestValue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static AGVResponseEntity<ResponseTaskStateDetailDataEntity> AGVGetTaskStateDetailRequest(AGVRequestTaskStateDetailEntity requestValue)
|
|
|
|
|
{
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("PUT:/api/task/getTaskStateDetail", null, requestValue);
|
|
|
|
|
if (responseValue == null)
|
|
|
|
|
public AGVResponseEntity<ResponseTaskStateDetailDataEntity> AGVGetTaskStateDetailRequest(AGVRequestTaskStateDetailEntity requestValue)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<ResponseTaskStateDetailDataEntity>();
|
|
|
|
|
}
|
|
|
|
|
string json = responseValue.ToString();
|
|
|
|
|
if (string.IsNullOrEmpty(json))
|
|
|
|
|
if (AirportAGVClient == null)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<ResponseTaskStateDetailDataEntity>();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
AGVResponseEntity<ResponseTaskStateDetailDataEntity> ResponseEntity;
|
|
|
|
|
ResponseEntity = JsonSerializer.Deserialize<AGVResponseEntity<ResponseTaskStateDetailDataEntity>>(json);
|
|
|
|
|
return ResponseEntity;
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("PUT:/api/task/getTaskStateDetail", null, requestValue);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<ResponseTaskStateDetailDataEntity>>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取所有AGV信息请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="aGVStateRequest"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>> AGVAllStateRequest()
|
|
|
|
|
public AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>> AGVAllStateRequest()
|
|
|
|
|
{
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/task/robot/getRobot", null);
|
|
|
|
|
if (responseValue == null)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>>();
|
|
|
|
|
}
|
|
|
|
|
string json = responseValue.ToString();
|
|
|
|
|
if (string.IsNullOrEmpty(json))
|
|
|
|
|
if (AirportAGVClient == null)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>>();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>> ResponseEntity;
|
|
|
|
|
ResponseEntity = JsonSerializer.Deserialize<AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>>>(json);
|
|
|
|
|
return ResponseEntity;
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/task/robot/getRobot", null);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>>>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前激活地图信息请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="aGVStateRequest"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static AGVResponseEntity<ResponseActiveMapDataEntity> AGVMapActiveRequest()
|
|
|
|
|
public AGVResponseEntity<ResponseActiveMapDataEntity> AGVMapActiveRequest()
|
|
|
|
|
{
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/v1.0.0/Maps/mapActive", null);
|
|
|
|
|
if (responseValue == null)
|
|
|
|
|
if (AirportAGVClient == null)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<ResponseActiveMapDataEntity>();
|
|
|
|
|
}
|
|
|
|
|
string json = responseValue.ToString();
|
|
|
|
|
if (string.IsNullOrEmpty(json))
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<ResponseActiveMapDataEntity>();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
AGVResponseEntity<ResponseActiveMapDataEntity> ResponseEntity;
|
|
|
|
|
ResponseEntity = JsonSerializer.Deserialize<AGVResponseEntity<ResponseActiveMapDataEntity>>(json);
|
|
|
|
|
return ResponseEntity;
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/v1.0.0/Maps/mapActive", null);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<ResponseActiveMapDataEntity>>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前地图所有位置点请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="aGVStateRequest"></param>
|
|
|
|
|
/// <param name="requestValue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static AGVResponseEntity<List<ResponseMapPositionDataEntity>> AGVMapPositionRequest(string requestValue)
|
|
|
|
|
{
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/v1.0.0/Positions?mapId={0}", null, requestValue);
|
|
|
|
|
if (responseValue == null)
|
|
|
|
|
public AGVResponseEntity<List<ResponseMapPositionDataEntity>> AGVMapPositionRequest(string requestValue)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<List<ResponseMapPositionDataEntity>>();
|
|
|
|
|
}
|
|
|
|
|
string json = responseValue.ToString();
|
|
|
|
|
if (string.IsNullOrEmpty(json))
|
|
|
|
|
if (AirportAGVClient == null)
|
|
|
|
|
{
|
|
|
|
|
return new AGVResponseEntity<List<ResponseMapPositionDataEntity>>();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
AGVResponseEntity<List<ResponseMapPositionDataEntity>> ResponseEntity;
|
|
|
|
|
ResponseEntity = JsonSerializer.Deserialize<AGVResponseEntity<List<ResponseMapPositionDataEntity>>>(json);
|
|
|
|
|
return ResponseEntity;
|
|
|
|
|
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:/api/v1.0.0/Positions?mapId={0}", null, requestValue);
|
|
|
|
|
return JTokenToEntity<AGVResponseEntity<List<ResponseMapPositionDataEntity>>>(responseValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|