|
|
@ -1,11 +1,16 @@
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
using SlnMesnac.Config;
|
|
|
|
using SlnMesnac.Model.AirportApiEntity;
|
|
|
|
using SlnMesnac.Model.AirportApiEntity;
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
|
|
|
|
using SlnMesnac.Repository;
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
using SlnMesnac.TouchSocket;
|
|
|
|
using SlnMesnac.TouchSocket;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.Business.@base
|
|
|
|
namespace SlnMesnac.Business.@base
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -16,24 +21,34 @@ namespace SlnMesnac.Business.@base
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private ILogger<BaseAGVBusiness> _logger;
|
|
|
|
private ILogger<BaseAGVBusiness> _logger;
|
|
|
|
private static BaseAGVBusiness instance;
|
|
|
|
private static BaseAGVBusiness instance;
|
|
|
|
|
|
|
|
private AppConfig _appConfig;
|
|
|
|
private AirPorthttpClient _airPorthttpClient;
|
|
|
|
private AirPorthttpClient _airPorthttpClient;
|
|
|
|
private IAGVStateService _AGVStateService;
|
|
|
|
private IAGVStateService _AGVStateService;
|
|
|
|
private IAGVMapPointService _AGVMapPointService;
|
|
|
|
private IAGVMapPointService _AGVMapPointService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BaseAGVBusiness(ILogger<BaseAGVBusiness> logger, AirPorthttpClient airPorthttpClient, IAGVStateService AGVStateService, IAGVMapPointService aGVMapPointService)
|
|
|
|
public BaseAGVBusiness(ILogger<BaseAGVBusiness> logger,
|
|
|
|
|
|
|
|
AirPorthttpClient airPorthttpClient,
|
|
|
|
|
|
|
|
IAGVStateService AGVStateService,
|
|
|
|
|
|
|
|
IAGVMapPointService aGVMapPointService,
|
|
|
|
|
|
|
|
AppConfig appConfig)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
_airPorthttpClient = airPorthttpClient;
|
|
|
|
_airPorthttpClient = airPorthttpClient;
|
|
|
|
_AGVStateService = AGVStateService;
|
|
|
|
_AGVStateService = AGVStateService;
|
|
|
|
_AGVMapPointService = aGVMapPointService;
|
|
|
|
_AGVMapPointService = aGVMapPointService;
|
|
|
|
|
|
|
|
_appConfig = appConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static BaseAGVBusiness GetInstance(ILogger<BaseAGVBusiness> logger, AirPorthttpClient airPorthttpClient, IAGVStateService AGVStateService, IAGVMapPointService aGVMapPointService)
|
|
|
|
public static BaseAGVBusiness GetInstance(ILogger<BaseAGVBusiness> logger,
|
|
|
|
|
|
|
|
AirPorthttpClient airPorthttpClient,
|
|
|
|
|
|
|
|
IAGVStateService AGVStateService,
|
|
|
|
|
|
|
|
IAGVMapPointService aGVMapPointService,
|
|
|
|
|
|
|
|
AppConfig appConfig)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (instance == null)
|
|
|
|
if (instance == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
instance = new BaseAGVBusiness(logger, airPorthttpClient, AGVStateService, aGVMapPointService);
|
|
|
|
instance = new BaseAGVBusiness(logger, airPorthttpClient, AGVStateService, aGVMapPointService, appConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -85,7 +100,7 @@ namespace SlnMesnac.Business.@base
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 发送封装的任务类
|
|
|
|
/// 发送封装的任务类
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns>任务ID</returns>
|
|
|
|
public string DownloadTask(string AGVGUID, string JobGUID, string PointGUID, string ParamName, string TaskName = "AGVCTask", string RobotType = "S800")
|
|
|
|
public string DownloadTask(string AGVGUID, string JobGUID, string PointGUID, string ParamName, string TaskName = "AGVCTask", string RobotType = "S800")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -115,12 +130,14 @@ namespace SlnMesnac.Business.@base
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public bool EndAGVTask(string AGVGUID)
|
|
|
|
public bool EndAGVTask(string AGVGUID)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var agvState = _AGVStateService.GetAGVState(AGVGUID);
|
|
|
|
try
|
|
|
|
if(agvState == null)
|
|
|
|
{
|
|
|
|
|
|
|
|
AGVState agvState = _AGVStateService.GetAGVState(AGVGUID);
|
|
|
|
|
|
|
|
if (agvState == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(agvState.agvworkstate != "待机")
|
|
|
|
if (agvState.agvworkstate != "待机")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var response = _airPorthttpClient.AGVOperationalTaskRequest(new AGVRequestOperationalTaskEntity()
|
|
|
|
var response = _airPorthttpClient.AGVOperationalTaskRequest(new AGVRequestOperationalTaskEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -141,7 +158,7 @@ namespace SlnMesnac.Business.@base
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(agvState.agvworkstate == "待机")
|
|
|
|
else if (agvState.agvworkstate == "待机")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError($"AGV {agvState.agvno} 现在无任务");
|
|
|
|
_logger.LogError($"AGV {agvState.agvno} 现在无任务");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -152,6 +169,12 @@ namespace SlnMesnac.Business.@base
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError($"AGV任务结束失败 ERROR:{ex.Message}");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取活跃地图的点位更新到数据库
|
|
|
|
/// 获取活跃地图的点位更新到数据库
|
|
|
@ -208,6 +231,92 @@ namespace SlnMesnac.Business.@base
|
|
|
|
return _AGVMapPointService.DeleteAndAddAgvMapPoint(list);
|
|
|
|
return _AGVMapPointService.DeleteAndAddAgvMapPoint(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 结束当前任务 清除报警 下发任务
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="agvName"></param>
|
|
|
|
|
|
|
|
/// <param name="jobName"></param>
|
|
|
|
|
|
|
|
/// <returns>新任务GUID</returns>
|
|
|
|
|
|
|
|
public string EndTaskAndClearErrorAndDownloadTask(string agvName, string jobName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//终止小车当前任务
|
|
|
|
|
|
|
|
result = EndTaskAndClearError(agvName);
|
|
|
|
|
|
|
|
var param = _appConfig.JobConfig.Where(x => x.JobName == jobName).First();
|
|
|
|
|
|
|
|
//调用小车到抓取位置
|
|
|
|
|
|
|
|
return DownloadTask(_appConfig.AGVConfig.Where(x => x.AGVName == agvName).First().AGVGUID, param.JobGUID, param.PointGUID, param.PointParamName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 结束任务并清除报警 延迟1s
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public bool EndTaskAndClearError(string agvName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool result1 = false, result2 = false;
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result1 = EndAGVTask(_appConfig.AGVConfig.Where(x => x.AGVName == agvName).First().AGVGUID);
|
|
|
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
|
|
|
result2 = ClaerError(_appConfig.AGVConfig.Where(x => x.AGVName == agvName).First().AGVIp);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return result1 && result2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError("结束任务并清除报警发生异常 " + ex);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 清除报警 延迟500ms
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public bool ClaerError(string agvName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var response = _airPorthttpClient.AGVErrorClear(_appConfig.AGVConfig.Where(x => x.AGVName == agvName).First().AGVIp);
|
|
|
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
|
|
|
if (response == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError("清除报警返回空数据");
|
|
|
|
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(response.code == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError("清除报警成功");
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError("清除报警失败 message:" + response.message);
|
|
|
|
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError("清除报警发生异常 " + ex);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// AGV任务状态代码匹配
|
|
|
|
/// AGV任务状态代码匹配
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|