add - 添加任务全部停止方法,入库满载AGV方法,优化初次AGV调度,优化最优AGV寻找方法,VisionBusiness添加日志,小改动

master
SoulStar 3 months ago
parent 6544e3fd86
commit dc11ee71bc

@ -320,19 +320,36 @@ namespace SlnMesnac.Business.@base
}
/// <summary>
/// 筛选一辆空闲且指定类型剩余可用空间最大的AGV, 返回GUID
/// 筛选一辆空闲且指定类型剩余可用空间最大的AGV, 返回调用的AGVState
/// </summary>
/// <returns></returns>
public AGVState GetBestAGV(AgvType agvType)
{
try
{
//对应类型的待机的agv列表
List<AGVState> lists = _AGVStateService.GetAgvState(agvType).Where(x => x.agvworkstate == "待机").ToList();
if (lists.Count == 0)
{
return null;
}
int min = lists.Min(x => x.stackcount); //小车不可能是满的还空闲
//找到堆筐最少的agv
int min = lists.Min(x => x.stackcount);
//判断堆筐最少的AGV是不是满的, 如果都满返回null
if (agvType == AgvType.AMR)
{
if (min >= BaseTaskInfoBusiness.AMRStackNumber)
{
return null;
}
}
else
{
if (min >= BaseTaskInfoBusiness.DeliverStackNumber)
{
return null;
}
}
AGVState agv = lists.Where(x => x.stackcount == min).FirstOrDefault();
//var list = _AGVStateService
return agv;

@ -64,7 +64,12 @@ namespace SlnMesnac.Business.@base
RefreshTimer = new System.Timers.Timer(1000);
RefreshTimer.Elapsed += (sender, e) => RefreshTaskState();
RefreshTimer.Elapsed += (sender, e) =>
{
//清理满载AGV 刷新状态
ClearFullAGV();
RefreshTaskState();
};
_visionBusiness = visionBusiness;
}
@ -168,32 +173,104 @@ namespace SlnMesnac.Business.@base
_RefreshLogMessageAction?.Invoke("任务数量:" + Task.Count);
foreach (AirportTask taskItem in Task)
{
//查询待执行任务,如果是新任务就下发车辆
if (taskItem.taskstate == "等待" || string.IsNullOrEmpty(taskItem.amragvno))
///////////////////////////////////////////////////// 查询待执行任务,如果是新任务就下发车辆 /////////////////////////////////////////////////////
if (taskItem.taskstate == "等待")
{
//首先调一辆最优AMR
AGVState firstAMR = _baseAGVBusiness.GetBestAGV(AgvType.AMR);
string amrTaskId = _baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(
firstAMR.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("1000入位", taskItem.conveyorno).JobName);
_logger.LogInformation($"为AMR[ {firstAMR.agvno}]分配任务,目标:[ {taskItem.conveyorno} ]号传送带");
taskItem.amragvno = firstAMR.agvno;
taskItem.amragvisarrive = "未到达";
taskItem.taskstate = "派车中";
//需要AGV和AMR才能装下
if (taskItem.totalcount > (AMRStackNumber - firstAMR.stackcount))
/////////////////////////////////////////////////////// 如果AMR还没分配是空的 /////////////////////////////////////////////////////
if (string.IsNullOrEmpty(taskItem.amragvno))
{
//调一辆最优Deliver
AGVState firstDeliver = _baseAGVBusiness.GetBestAGV(AgvType.Deliver);
string deliverTaskID = _baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(
firstDeliver.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入位", taskItem.conveyorno).JobName);
_logger.LogInformation($"为Deliver[ {firstDeliver.agvno} ]分配任务,目标:[ {taskItem.conveyorno} ]号传送带");
taskItem.deliveragvno = firstDeliver.agvno;
taskItem.deliveragvisarrive = "未到达";
// 首先调一辆最优AMR
AGVState firstAMR = _baseAGVBusiness.GetBestAGV(AgvType.AMR);
// 有空闲车辆 赋值 准备看看是否需要deliver
if (firstAMR != null && !string.IsNullOrEmpty(firstAMR.agvno))
{
string amrTaskId = _baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(
firstAMR.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("1000入位", taskItem.conveyorno).JobName);
_logger.LogInformation($"为AMR[ {firstAMR.agvno}]分配任务,目标:[ {taskItem.conveyorno} ]号传送带");
taskItem.amragvno = firstAMR.agvno;
taskItem.amragvisarrive = "未到达";
_Taskservice.UpdateTaskAsync(taskItem);
}
// 如果没调到AMR直接 goto结束
else
{
_logger.LogInformation($"任务 [{taskItem.taskno}] 暂时匹配不到空闲AMR!");
goto OUT_POINT;
}
// 需要Deliver和AMR才能装下
if (taskItem.totalcount > (AMRStackNumber - firstAMR.stackcount))
{
// 调一辆最优Deliver
AGVState firstDeliver = _baseAGVBusiness.GetBestAGV(AgvType.Deliver);
// 如果有Deliver 赋值 调整状态为派车中
if (firstDeliver != null && !string.IsNullOrEmpty(firstDeliver.agvno))
{
string deliverTaskID = _baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(
firstDeliver.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入位", taskItem.conveyorno).JobName);
_logger.LogInformation($"为Deliver[ {firstDeliver.agvno} ]分配任务,目标:[ {taskItem.conveyorno} ]号传送带");
taskItem.deliveragvno = firstDeliver.agvno;
taskItem.deliveragvisarrive = "未到达";
taskItem.taskstate = "派车中";
_Taskservice.UpdateTaskAsync(taskItem);
goto OUT_POINT;
}
// 如果没调到Deliver直接 goto结束
else
{
_logger.LogInformation($"任务 [{taskItem.taskno}] 暂时匹配不到空闲Deliver!");
goto OUT_POINT;
}
}
// 如果不需要直接调整状态为派车 goto结束
else
{
taskItem.taskstate = "派车中";
_Taskservice.UpdateTaskAsync(taskItem);
goto OUT_POINT;
}
}
_Taskservice.UpdateTaskAsync(taskItem);
/////////////////////////////////////////////////////// 如果AMR已分配不是空的 /////////////////////////////////////////////////////
if (!string.IsNullOrEmpty(taskItem.amragvno))
{
AGVState TaskAMR = _AGVStateService.GetSingleAGVState(taskItem.amragvno);
// 看看是否需要AGV和AMR才能装下
if (taskItem.totalcount > (AMRStackNumber - TaskAMR.stackcount))
{
// 调一辆最优Deliver
AGVState firstDeliver = _baseAGVBusiness.GetBestAGV(AgvType.Deliver);
// 如果有Deliver 赋值 调整状态为派车中
if (firstDeliver != null && !string.IsNullOrEmpty(firstDeliver.agvno))
{
string deliverTaskID = _baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(
firstDeliver.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入位", taskItem.conveyorno).JobName);
_logger.LogInformation($"为Deliver[ {firstDeliver.agvno} ]分配任务,目标:[ {taskItem.conveyorno} ]号传送带");
taskItem.deliveragvno = firstDeliver.agvno;
taskItem.deliveragvisarrive = "未到达";
taskItem.taskstate = "派车中";
_Taskservice.UpdateTaskAsync(taskItem);
goto OUT_POINT;
}
// 匹配不到直接goto
else
{
_logger.LogInformation($"任务 [{taskItem.taskno}] 暂时匹配不到空闲Deliver!");
goto OUT_POINT;
}
}
// 不需要Delievr直接改任务状态
else
{
taskItem.taskstate = "派车中";
_Taskservice.UpdateTaskAsync(taskItem);
goto OUT_POINT;
}
}
OUT_POINT:; //未分配成功的退出点
}
//根据小车状态更新任务表中AMR是否到达状态如果到达就改变任务表的状态
@ -226,7 +303,7 @@ namespace SlnMesnac.Business.@base
//只有amr的情况
if (taskItem.amragvisarrive == "已到达" && string.IsNullOrEmpty(taskItem.deliveragvno))
{
int amrStackNo =_AGVStateService.GetSingleAGVState(taskItem.amragvno).stackcount;
int amrStackNo = _AGVStateService.GetSingleAGVState(taskItem.amragvno).stackcount;
//调用机械臂向AMR小车抓取
_visionBusiness.RequestVisionStartWork(StackState.NXAMRNeedPositioning, amrStackNo, _tcpServer.VID);
taskItem.taskstate = "抓取中";
@ -253,6 +330,76 @@ namespace SlnMesnac.Business.@base
_logger.LogError($"查询任务列表初次下发任务发生错误Message{ex.Message}");
}
}
/// <summary>
/// 入库满载AGV
/// </summary>
public void ClearFullAGV()
{
try
{
var list = _AGVStateService.GetAgvState(AgvType.Deliver);
foreach (var record in list)
{
if (record.stackcount >= BaseTaskInfoBusiness.DeliverStackNumber && record.agvworkstate == "待机")
{
//入库代码
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(record.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入库", "0").JobName);
_logger.LogInformation($"Deliver [{record.agvno}] 入库");
}
}
list = _AGVStateService.GetAgvState(AgvType.AMR);
foreach (var record in list)
{
if (record.stackcount >= BaseTaskInfoBusiness.AMRStackNumber && record.agvworkstate == "待机")
{
//入库代码
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(record.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("1000入库", "0").JobName);
_logger.LogInformation($"AMR [{record.agvno}] 入库");
}
}
}
catch (Exception ex)
{
_logger.LogError($"清理满载AGV时发生错误Error: [{ex.Message}]");
}
}

@ -185,8 +185,12 @@ namespace SlnMesnac.Business.@base
VisionSetting record = _visionSettingService.GetList(x => x.VisionID == id).ToList().First();
//大端字节序
Array.Reverse(entity.SN);
AirportTask airportTask = _airportTaskService.GetTaskInfos(x => x.amragvno == record.AMRGUID &&
x.visiontaskno == (BitConverter.ToUInt16(entity.SN, 0) - 1).ToString() && x.taskstate == "抓取中").First();
AirportTask airportTask = _airportTaskService.GetTaskInfos(
x =>
x.amragvno == record.AMRGUID &&
x.visiontaskno == (BitConverter.ToUInt16(entity.SN, 0) - 1).ToString() &&
x.taskstate == "抓取中"
).First();
//成功码垛先码垛计数
StackCount(airportTask, entity.DataBytes[1]);
//取出两辆小车的计数
@ -196,12 +200,12 @@ namespace SlnMesnac.Business.@base
{
DeliverCount = _aGVStateService.GetSingleAGVState(airportTask.deliveragvno).stackcount;
}
//////////////下面是下一次码垛的综合判断条件//////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////下面是下一次码垛的综合判断条件////////////////////////////////////////////////////////////////////////////////////////////////////////
//先判断总数是否需要继续工作
if (airportTask.totalcount > airportTask.loadcount)
{
//如上一次是AMR 如有Deliver 判断是否到达 到达向deliver发送开始工作没就判断amr是否装满 继续向amr
//上一次是AMR
//////////////////////////////////////////////////////上一次是AMR////////////////////////////////////////////////////
if (entity.DataBytes[1] == 0x00)
{
//妹有Deliver的任务小车号和是否已到达都没有amr肯定能抓完 继续amr抓取
@ -209,6 +213,7 @@ namespace SlnMesnac.Business.@base
{
//一直向amr抓直到抓满
RequestVisionStartWork(StackState.NXAMRNoPositioning, AMRCount, id);
_logger.LogInformation($"任务 [{airportTask.taskno}] 继续向AMR [{airportTask.amragvno}] 抓取");
}
//有Delievr任务有任务号且状态为未到达继续amr抓取
else if (!string.IsNullOrEmpty(airportTask.deliveragvno) && airportTask.deliveragvisarrive == "未到达")
@ -218,6 +223,7 @@ namespace SlnMesnac.Business.@base
if (_aGVStateService.GetSingleAGVState(airportTask.amragvno).stackcount < BaseTaskInfoBusiness.AMRStackNumber)
{
RequestVisionStartWork(StackState.NXAMRNoPositioning, AMRCount, id);
_logger.LogInformation($"任务 [{airportTask.taskno}] 继续向AMR [{airportTask.amragvno}] 抓取");
}
//AMR满了
else
@ -228,6 +234,7 @@ namespace SlnMesnac.Business.@base
{
//请求复位
RequestVisionReplace(id);
_logger.LogInformation($"任务 [{airportTask.taskno}] AMR已满停止抓取");
while (true)
{
//循环判断该任务的deliver是否到达
@ -236,6 +243,7 @@ namespace SlnMesnac.Business.@base
if (task.deliveragvisarrive == "已到达")
{
RequestVisionStartWork(StackState.NXAGVNeedPositioning, DeliverCount, id);
_logger.LogInformation($"任务 [{airportTask.taskno}] 向Deliver [{airportTask.deliveragvno}] 抓取");
break;
}
}
@ -246,6 +254,7 @@ namespace SlnMesnac.Business.@base
else if (!string.IsNullOrEmpty(airportTask.deliveragvno) && airportTask.deliveragvisarrive == "已到达")
{
RequestVisionStartWork(StackState.NXAGVNeedPositioning, DeliverCount, id);
_logger.LogInformation($"任务 [{airportTask.taskno}] 向Deliver [{airportTask.deliveragvno}] 抓取");
}
//异常情况
else
@ -254,7 +263,7 @@ namespace SlnMesnac.Business.@base
}
}
//如上一次是deliver-->则判断deliver是否装满-->装满则deliver入库-->判断剩下的数量用不用调新的deliver-->用就调新的deliver然后发向amr抓取(还得判断AMR是否抓满)-->不用就直接向amr抓取
//上一次是Deliver
//////////////////////////////////////////////////////上一次是Deliver////////////////////////////////////////////////////
else if (entity.DataBytes[1] == 0x01)
{
//判断Deliver是否装满,装满就直接入库,未装满继续装
@ -262,6 +271,7 @@ namespace SlnMesnac.Business.@base
if (_aGVStateService.GetSingleAGVState(airportTask.deliveragvno).stackcount < BaseTaskInfoBusiness.DeliverStackNumber)
{
RequestVisionStartWork(StackState.NXAGVNoPositioning, DeliverCount, id);
_logger.LogInformation($"任务 [{airportTask.taskno}] 继续向Deliver [{airportTask.deliveragvno}] 抓取");
}
//deliver满了入库然后判断
else
@ -269,6 +279,7 @@ namespace SlnMesnac.Business.@base
//入库代码
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.deliveragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入库", airportTask.conveyorno).JobName);
_logger.LogInformation($"任务 [{airportTask.taskno}] Deliver [{airportTask.deliveragvno}] 入库");
airportTask.deliveragvno = null;
airportTask.deliveragvisarrive = null;
_airportTaskService.UpdateTaskAsync(airportTask);
@ -278,6 +289,7 @@ namespace SlnMesnac.Business.@base
if (airportTask.totalcount - airportTask.loadcount < amrleft)
{
RequestVisionStartWork(StackState.NXAMRNeedPositioning, AMRCount, id);
_logger.LogInformation($"任务 [{airportTask.taskno}] 向AMR [{airportTask.amragvno}] 抓取");
}
//剩下的数量需要调用并判断向AMR抓取
else
@ -288,9 +300,10 @@ namespace SlnMesnac.Business.@base
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入位", airportTask.conveyorno).JobName);
airportTask.deliveragvno = newagv.agvno;
airportTask.deliveragvisarrive = "未到达";
_logger.LogInformation($"任务 [{airportTask.taskno}] 调用Deliver [{airportTask.deliveragvno}] 入位");
_airportTaskService.UpdateTaskAsync(airportTask);
//amr无容量结束抓取等待Deliver到达
if (amrleft == 0)
if (amrleft <= 0)
{
AirportTask task;
//结束抓取、循环判断deliver是否到达到了就向新的Deliver开始抓取
@ -298,6 +311,7 @@ namespace SlnMesnac.Business.@base
{
//请求复位
RequestVisionReplace(id);
_logger.LogInformation($"任务 [{airportTask.taskno}] AMR已满停止抓取");
while (true)
{
//循环判断该任务的deliver是否到达
@ -306,6 +320,7 @@ namespace SlnMesnac.Business.@base
if (task.deliveragvisarrive == "已到达")
{
RequestVisionStartWork(StackState.NXAGVNeedPositioning, DeliverCount, id);
_logger.LogInformation($"任务 [{airportTask.taskno}] 向Deliver [{airportTask.deliveragvno}] 抓取");
break;
}
}
@ -315,6 +330,7 @@ namespace SlnMesnac.Business.@base
else
{
RequestVisionStartWork(StackState.NXAMRNeedPositioning, AMRCount, id);
_logger.LogInformation($"任务 [{airportTask.taskno}] 向AMR [{airportTask.amragvno}] 抓取");
}
}
}
@ -325,27 +341,32 @@ namespace SlnMesnac.Business.@base
throw new Exception($"任务 {airportTask.taskno} 未知上次码垛代码!请检查视觉系统状态!");
}
}
//总数达标,结束任务,复位机械臂,调回小车,任务状态调整
////////////////////////////////////////////////////总数达标,结束任务,复位机械臂,复位小车,任务状态调整////////////////////////////////////////////////////
else
{
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.amragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("1000入库", airportTask.conveyorno).JobName);
//复位机械臂
RequestVisionReplace(id);
//结束AMR任务
_baseAGVBusiness.EndTaskAndClearError(airportTask.amragvno);
_logger.LogInformation($"任务 [{airportTask.taskno}] AMR [{airportTask.amragvno}] 结束任务");
airportTask.amragvno = null;
airportTask.amragvisarrive = null;
airportTask.visiontaskno = null;
//有Deliver的话结束Deliver任务
if (!string.IsNullOrEmpty(airportTask.deliveragvno))
{
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.deliveragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入库", airportTask.conveyorno).JobName);
_baseAGVBusiness.EndTaskAndClearError(airportTask.deliveragvno);
_logger.LogInformation($"任务 [{airportTask.taskno}] Deliver [{airportTask.deliveragvno}] 结束任务");
airportTask.deliveragvno = null;
airportTask.deliveragvisarrive = null;
}
airportTask.finishtime = DateTime.Now;
airportTask.taskstate = "已完成";
_airportTaskService.UpdateTaskAsync(airportTask);
_logger.LogInformation($"任务 [{airportTask.taskno}] 已完成");
}
}
//码垛过程失败
//////////////////////////////////////////////////////码垛过程失败////////////////////////////////////////////////////
else if (entity.DataBytes[0] == 0x01)
{
VisionSetting record = _visionSettingService.GetList(x => x.VisionID == id).ToList().First();
@ -365,20 +386,20 @@ namespace SlnMesnac.Business.@base
{
//发送向复合机器人AMR码垛的信号
RequestVisionStartWork(StackState.NXAMRNoPositioning, AMRCount, id);
_logger.LogInformation("下一次码垛开始,方向:复合机器人");
_logger.LogInformation($"下一次码垛开始,方向:复合机器人 [{airportTask.amragvno}]");
}
else if (entity.DataBytes[1] == 0x01)
{
//发送向搬运机器人AGVDeliver码垛的信号
RequestVisionStartWork(StackState.NXAGVNoPositioning, DeliverCount, id);
_logger.LogInformation("下一次码垛开始,方向:搬运机器人");
_logger.LogInformation($"下一次码垛开始,方向:搬运机器人 [{airportTask.deliveragvno}]");
}
else
{
_logger.LogError($"码垛失败返回未知码垛结果代码,请手动重新发送码垛信号");
}
}
//码垛检查失败
//////////////////////////////////////////////////////码垛检查失败////////////////////////////////////////////////////
else if (entity.DataBytes[0] == 0x02)
{
_logger.LogError($"视觉系统一次码垛结束,码垛检查失败,请手动矫正并手动开始下一次码垛");
@ -388,7 +409,7 @@ namespace SlnMesnac.Business.@base
x.visiontaskno == (BitConverter.ToInt16(entity.SN, 0) - 1).ToString() && x.taskstate == "抓取中").First();
StackCount(airportTask, entity.DataBytes[1]);
}
//未知代码
//////////////////////////////////////////////////////未知代码////////////////////////////////////////////////////
else
{
_logger.LogError($"视觉系统一次码垛结束,未知返回代码!请检查视觉系统状态!");
@ -404,7 +425,7 @@ namespace SlnMesnac.Business.@base
catch(Exception ex)
{
RequestVisionReplace(id);
_logger.LogError($"接受工作结束再分配状态发生错误 {ex.Message}");
_logger.LogError($"上位机接受工作信号结束再分配状态发生错误 {ex.Message}");
}
}
@ -419,7 +440,7 @@ namespace SlnMesnac.Business.@base
//判断返回结果
if (_aGVStateService.UpdateAsync(aGVState).Result || _airportTaskService.UpdateTaskAsync(airportTask).Result)
{
_logger.LogInformation($"计数更新成功 {airportTask.amragvno} AMR: {aGVState.stackcount} Total: {airportTask.loadcount}");
_logger.LogInformation($"计数更新成功 [{airportTask.amragvno}] AMR: [{aGVState.stackcount}] Task: [{airportTask.taskno}] Total: [{airportTask.loadcount}]");
}
else
{
@ -436,7 +457,7 @@ namespace SlnMesnac.Business.@base
//判断返回结果
if (_aGVStateService.UpdateAsync(aGVState).Result || _airportTaskService.UpdateTaskAsync(airportTask).Result)
{
_logger.LogInformation($"计数更新成功 {airportTask.amragvno} AMR: {aGVState.stackcount} Total: {airportTask.loadcount}");
_logger.LogInformation($"计数更新成功 [{airportTask.amragvno}] Deliver: [{aGVState.stackcount}] Task: [{airportTask.taskno}] Total: [{airportTask.loadcount}]");
}
else
{

@ -22,7 +22,7 @@
<Button Content="结束AGV状态刷新" x:Name="StopAGVStateRefresh" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=StopAGVStateRefresh}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="Green" BorderBrush="#FF36B5C1" Margin="89,405,581,61" />
<Button Content="开始任务状态刷新" x:Name="StartTaskRefresh" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name, ElementName=StartTaskRefresh}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="Green" BorderBrush="#FF36B5C1" Margin="251,342,419,124" />
<Button Content="结束任务状态刷新" x:Name="StopTaskRefresh" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name, ElementName=StopTaskRefresh}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="Green" BorderBrush="#FF36B5C1" Margin="251,405,419,61" />
<Button Content="终止所有的航班任务、小车任务、机械臂复位" x:Name="StopAll" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name, ElementName=StopAGVStateRefresh}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="Green" BorderBrush="#FF36B5C1" Margin="89,517,419,43" RenderTransformOrigin="0.5,0.5" Click="StopAll_Click" >
<Button Content="终止所有的航班任务、小车任务、机械臂复位" x:Name="StopAll" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name, ElementName=StopAll}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="Green" BorderBrush="#FF36B5C1" Margin="89,517,419,43" RenderTransformOrigin="0.5,0.5" Click="StopAll_Click" >
<Button.RenderTransform>
<TransformGroup>
<ScaleTransform/>

@ -130,7 +130,10 @@ namespace SlnMesnac.WPF.Page.ControlPage
private void StopAll_Click(object sender, RoutedEventArgs e)
{
this.StopTaskAction.Invoke();
if(MessageBox.Show("是否确认停止所有任务并归为所有小车?", "确认", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
this.StopTaskAction.Invoke();
}
}
}
}

@ -6,6 +6,7 @@ using Microsoft.Extensions.Logging;
using SlnMesnac.Business.@base;
using SlnMesnac.Config;
using SlnMesnac.Model.AirportApiEntity;
using SlnMesnac.Model.dto;
using SlnMesnac.Repository;
using SlnMesnac.Repository.service;
using SlnMesnac.TouchSocket;
@ -122,8 +123,8 @@ namespace SlnMesnac.WPF.ViewModel
_visionSettingService = App.ServiceProvider.GetService<IVisionSettingService>();
_tcpServer = App.ServiceProvider.GetService<TcpServer>();
_airPorthttpClient = App.ServiceProvider.GetService<AirPorthttpClient>();
_baseTaskInfoBusiness = BaseTaskInfoBusiness.GetInstance(_BaseTaskInfoBusinesslogger,
_Taskservice, _AGVStateService, _AGVMapPointService, _agvJobService,
_baseTaskInfoBusiness = BaseTaskInfoBusiness.GetInstance(_BaseTaskInfoBusinesslogger,
_Taskservice, _AGVStateService, _AGVMapPointService, _agvJobService,
_tcpServer, _airPorthttpClient, _baseAGVBusiness, _visionBusiness);
_baseAGVBusiness = BaseAGVBusiness.GetInstance(_baseAGVBusinessLogger, _airPorthttpClient, _AGVStateService, _AGVMapPointService, _appConfig);
_visionBusiness = VisionBusiness.GetInstance(_VisionBusinessLogger, _tcpServer, _Taskservice, _visionSettingService, _AGVStateService, _agvJobService);
@ -236,6 +237,9 @@ namespace SlnMesnac.WPF.ViewModel
case "StopTaskRefresh":
_baseTaskInfoBusiness.TaskStateUpdateTimerOperation(TimerControl.Stop);
break;
case "StopAll":
//StopAllTaskActionInvoke();
break;
default:
break;
}
@ -252,7 +256,7 @@ namespace SlnMesnac.WPF.ViewModel
{
List<AirportTask> taskList = _Taskservice.GetTaskInfos(x => x.taskstate == "抓取中" && x.taskstate == "派车中").ToList();
//任务状态设置为已终止并且机械臂复位
foreach(var taskInfo in taskList)
foreach (var taskInfo in taskList)
{
_visionBusiness.RequestVisionReplace(_visionSettingService.GetVisionSettingByAMRGUID(taskInfo.amragvno).VisionID);
taskInfo.visiontaskno = null;
@ -262,9 +266,20 @@ namespace SlnMesnac.WPF.ViewModel
taskInfo.deliveragvisarrive = null;
taskInfo.finishtime = DateTime.Now;
taskInfo.taskstate = "已终止";
_logger.LogInformation($"任务 [{taskInfo.taskno}] 已终止");
}
//agv全部停止
_logger.LogInformation("已成功全部停止");
var responseList = _airPorthttpClient.AGVAllStateRequest();
foreach (var response in responseList.Data)
{
if (!string.IsNullOrEmpty(response.TaskID) && response.AgvMoveStatus != 1 && response.AgvMoveStatus != 3)
{
_baseAGVBusiness.EndTaskAndClearError(response.Guid);
_logger.LogInformation($"小车 [{response.Name}] 任务已终止");
}
}
_logger.LogInformation($"全部复位完毕");
};
}

Loading…
Cancel
Save