|
|
|
@ -37,6 +37,7 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
private IAGVJobService _AGVJobService;
|
|
|
|
|
private AirPorthttpClient _airpttpClient;
|
|
|
|
|
private BaseAGVBusiness _baseAGVBusiness;
|
|
|
|
|
private VisionBusiness _visionBusiness;
|
|
|
|
|
System.Timers.Timer RefreshTimer;
|
|
|
|
|
public BaseTaskInfoBusiness(
|
|
|
|
|
ILogger<BaseTaskInfoBusiness> logger,
|
|
|
|
@ -46,7 +47,8 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
IAGVJobService agvJobService,
|
|
|
|
|
TcpServer tcpServer,
|
|
|
|
|
AirPorthttpClient airPorthttpClient,
|
|
|
|
|
BaseAGVBusiness baseAGVBusiness)
|
|
|
|
|
BaseAGVBusiness baseAGVBusiness,
|
|
|
|
|
VisionBusiness visionBusiness)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_tcpServer = tcpServer;
|
|
|
|
@ -55,11 +57,16 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
_airpttpClient = airPorthttpClient;
|
|
|
|
|
InitClearTimer();
|
|
|
|
|
//doWhileGetAGVTaskInfo();
|
|
|
|
|
RefreshTimer = new System.Timers.Timer(1000);
|
|
|
|
|
RefreshTimer.Elapsed += (sender, e) => RefreshTaskState();
|
|
|
|
|
_baseAGVBusiness = baseAGVBusiness;
|
|
|
|
|
_AGVMapPointService = aGVMapPointService;
|
|
|
|
|
_AGVJobService = agvJobService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RefreshTimer = new System.Timers.Timer(1000);
|
|
|
|
|
RefreshTimer.Elapsed += (sender, e) => RefreshTaskState();
|
|
|
|
|
|
|
|
|
|
_visionBusiness = visionBusiness;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static BaseTaskInfoBusiness GetInstance(
|
|
|
|
@ -70,11 +77,14 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
IAGVJobService aAGVJobService,
|
|
|
|
|
TcpServer tcpServer,
|
|
|
|
|
AirPorthttpClient airPorthttpClient,
|
|
|
|
|
BaseAGVBusiness baseAGVBusiness)
|
|
|
|
|
BaseAGVBusiness baseAGVBusiness,
|
|
|
|
|
VisionBusiness visionBusiness)
|
|
|
|
|
{
|
|
|
|
|
if (instance == null)
|
|
|
|
|
{
|
|
|
|
|
instance = new BaseTaskInfoBusiness(logger, Taskservice, agvService, aGVMapPointService, aAGVJobService, tcpServer, airPorthttpClient, baseAGVBusiness);
|
|
|
|
|
instance = new BaseTaskInfoBusiness(logger,
|
|
|
|
|
Taskservice, agvService, aGVMapPointService, aAGVJobService,
|
|
|
|
|
tcpServer, airPorthttpClient, baseAGVBusiness, visionBusiness);
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
@ -99,8 +109,6 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
taskstate = "等待", //需要判断,更新 任务状态
|
|
|
|
|
starttime = DateTime.Now,
|
|
|
|
|
finishtime = null,
|
|
|
|
|
deliveragvTaskNo = string.Empty, //需要判断,更新
|
|
|
|
|
amragvTaskNo = string.Empty, //需要判断,更新
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
@ -146,7 +154,7 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Timer刷新任务状态, 有新任务初次下发AGV
|
|
|
|
|
/// Timer刷新任务状态, 有新任务初次下发AGV,Timer执行
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void RefreshTaskState()
|
|
|
|
|
{
|
|
|
|
@ -158,9 +166,10 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
{
|
|
|
|
|
//更新前端
|
|
|
|
|
_RefreshLogMessageAction?.Invoke("任务数量:" + Task.Count);
|
|
|
|
|
foreach(AirportTask taskItem in Task)
|
|
|
|
|
foreach (AirportTask taskItem in Task)
|
|
|
|
|
{
|
|
|
|
|
//查询待执行任务
|
|
|
|
|
|
|
|
|
|
//查询待执行任务,如果是新任务就下发车辆
|
|
|
|
|
if (taskItem.taskstate == "等待" || string.IsNullOrEmpty(taskItem.amragvno))
|
|
|
|
|
{
|
|
|
|
|
//首先调一辆最优AMR
|
|
|
|
@ -168,10 +177,10 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
string amrTaskId = _baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(
|
|
|
|
|
firstAMR.agvno,
|
|
|
|
|
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("1000入位", taskItem.conveyorno).JobName);
|
|
|
|
|
taskItem.amragvTaskNo = amrTaskId;
|
|
|
|
|
_logger.LogInformation($"为AMR[ {firstAMR.agvno}]分配任务,目标:[ {taskItem.conveyorno} ]号传送带");
|
|
|
|
|
taskItem.amragvno = firstAMR.agvno;
|
|
|
|
|
taskItem.amragvisarrive = "未到达";
|
|
|
|
|
taskItem.taskstate = "执行中";
|
|
|
|
|
taskItem.taskstate = "派车中";
|
|
|
|
|
//需要AGV和AMR才能装下
|
|
|
|
|
if (taskItem.totalcount > (AMRStackNumber - firstAMR.stackcount))
|
|
|
|
|
{
|
|
|
|
@ -180,12 +189,60 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
string deliverTaskID = _baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(
|
|
|
|
|
firstDeliver.agvno,
|
|
|
|
|
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入位", taskItem.conveyorno).JobName);
|
|
|
|
|
taskItem.deliveragvTaskNo = amrTaskId;
|
|
|
|
|
_logger.LogInformation($"为Deliver[ {firstDeliver.agvno} ]分配任务,目标:[ {taskItem.conveyorno} ]号传送带");
|
|
|
|
|
taskItem.deliveragvno = firstDeliver.agvno;
|
|
|
|
|
taskItem.deliveragvisarrive = "未到达";
|
|
|
|
|
}
|
|
|
|
|
_Taskservice.UpdateTaskAsync(taskItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据小车状态更新任务表中AMR是否到达状态,如果到达就改变任务表的状态
|
|
|
|
|
if (!string.IsNullOrEmpty(taskItem.amragvno) && taskItem.amragvisarrive == "未到达")
|
|
|
|
|
{
|
|
|
|
|
AGVState agvstate = _AGVStateService.GetSingleAGVState(taskItem.amragvno);
|
|
|
|
|
if (agvstate.taskstate == "已暂停")
|
|
|
|
|
{
|
|
|
|
|
taskItem.amragvisarrive = "已到达";
|
|
|
|
|
_logger.LogInformation($"[ {taskItem.conveyorno} ]号传送带AMR[ {agvstate.agvno} ]已到达");
|
|
|
|
|
}
|
|
|
|
|
_Taskservice.UpdateTaskAsync(taskItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据小车状态更新任务表中Deliver是否到达状态,如果到达就改变任务表的状态
|
|
|
|
|
if (!string.IsNullOrEmpty(taskItem.deliveragvno) && taskItem.deliveragvisarrive == "未到达")
|
|
|
|
|
{
|
|
|
|
|
AGVState agvstate = _AGVStateService.GetSingleAGVState(taskItem.deliveragvno);
|
|
|
|
|
if (agvstate.taskstate == "已暂停")
|
|
|
|
|
{
|
|
|
|
|
taskItem.deliveragvisarrive = "已到达";
|
|
|
|
|
_logger.LogInformation($"[ {taskItem.conveyorno} ]号传送带Deliver[ {agvstate.agvno} ]已到达");
|
|
|
|
|
}
|
|
|
|
|
_Taskservice.UpdateTaskAsync(taskItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询执行中的任务车辆是否到达,如果指派的车都到达就开始抓取
|
|
|
|
|
if (taskItem.taskstate == "派车中")
|
|
|
|
|
{
|
|
|
|
|
//只有amr的情况
|
|
|
|
|
if (taskItem.amragvisarrive == "已到达" && string.IsNullOrEmpty(taskItem.deliveragvno))
|
|
|
|
|
{
|
|
|
|
|
//调用机械臂向AMR小车抓取
|
|
|
|
|
_visionBusiness.RequestVisionStartWork(StackState.AMRNeedPositioning, _tcpServer.VID);
|
|
|
|
|
taskItem.taskstate = "抓取中";
|
|
|
|
|
_Taskservice.UpdateTaskAsync(taskItem);
|
|
|
|
|
_logger.LogInformation($"[ {taskItem.conveyorno} ]号传送带开始工作");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//amr和deliver都用的情况
|
|
|
|
|
if (taskItem.amragvisarrive == "已到达" && taskItem.deliveragvisarrive == "已到达")
|
|
|
|
|
{
|
|
|
|
|
//调用机械臂向Deliver小车抓取
|
|
|
|
|
_visionBusiness.RequestVisionStartWork(StackState.AGVNeedPositioning, _tcpServer.VID);
|
|
|
|
|
taskItem.taskstate = "抓取中";
|
|
|
|
|
_Taskservice.UpdateTaskAsync(taskItem);
|
|
|
|
|
_logger.LogInformation($"[ {taskItem.conveyorno} ]号传送带开始工作");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -193,9 +250,17 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"查询任务列表初次下发任务发生错误Message:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取任务列表,向待执行任务派发AGV (定期执行)
|
|
|
|
|
/// </summary>
|
|
|
|
|