add - 自动逻辑完善

master
SoulStar 3 months ago
parent 35118ff75d
commit 6544e3fd86

@ -126,7 +126,7 @@ namespace SlnMesnac.Business.@base
/// AGV状态查询控制
/// </summary>
/// <param name="state"></param>
public void AGVStateUpdateTimerOperation(TimerControl state)
public void TaskStateUpdateTimerOperation(TimerControl state)
{
try
{
@ -226,8 +226,9 @@ namespace SlnMesnac.Business.@base
//只有amr的情况
if (taskItem.amragvisarrive == "已到达" && string.IsNullOrEmpty(taskItem.deliveragvno))
{
int amrStackNo =_AGVStateService.GetSingleAGVState(taskItem.amragvno).stackcount;
//调用机械臂向AMR小车抓取
_visionBusiness.RequestVisionStartWork(StackState.AMRNeedPositioning, _tcpServer.VID);
_visionBusiness.RequestVisionStartWork(StackState.NXAMRNeedPositioning, amrStackNo, _tcpServer.VID);
taskItem.taskstate = "抓取中";
_Taskservice.UpdateTaskAsync(taskItem);
_logger.LogInformation($"[ {taskItem.conveyorno} ]号传送带开始工作");
@ -236,8 +237,9 @@ namespace SlnMesnac.Business.@base
//amr和deliver都用的情况
if (taskItem.amragvisarrive == "已到达" && taskItem.deliveragvisarrive == "已到达")
{
int agvStackNo = _AGVStateService.GetSingleAGVState(taskItem.deliveragvno).stackcount;
//调用机械臂向Deliver小车抓取
_visionBusiness.RequestVisionStartWork(StackState.AGVNeedPositioning, _tcpServer.VID);
_visionBusiness.RequestVisionStartWork(StackState.NXAGVNeedPositioning, agvStackNo, _tcpServer.VID);
taskItem.taskstate = "抓取中";
_Taskservice.UpdateTaskAsync(taskItem);
_logger.LogInformation($"[ {taskItem.conveyorno} ]号传送带开始工作");

@ -43,7 +43,7 @@ namespace SlnMesnac.Business.@base
//视觉系统回复开始码垛
_tcpServer.ReceiveVisionStartWorkEvent += GetVisionWorkState;
//视觉系统通知一次码垛完成结果
_tcpServer.ReceiveStackWorkDoneEvent += StackResultSend;
_tcpServer.ReceiveStackWorkDoneEvent += AutoStackResultSend;
//_tcpServer.ReceiveStackWorkDoneEvent += AutoStackResultSend;
//视觉系统通知人工异常处理完成
_tcpServer.ReceiveManualExceptionDealDoneEvent += GetManualExceptionDealDone;
@ -64,17 +64,17 @@ namespace SlnMesnac.Business.@base
/// <summary>
/// AMR就绪请求视觉开始工作
/// </summary>
public void RequestVisionStartWork(StackState state, string id)
public void RequestVisionStartWork(StackState state, int count, string id)
{
_tcpServer.SendAMRRequestVisionStartWork(new byte[1] { (byte)state }, id);
_tcpServer.SendAMRRequestVisionStartWork(new byte[2] { (byte)state, (byte)count }, id);
}
/// <summary>
/// 码垛结束,请求视觉系统复位
/// </summary>
public void RequestVisionReplace(string port)
public void RequestVisionReplace(string ip)
{
_tcpServer.SendStackOverRequestVisionSysReplace(port);
_tcpServer.SendStackOverRequestVisionSysReplace(ip);
VDCount = 1;
VACount = 0;
TotalJudge = false;
@ -100,24 +100,68 @@ namespace SlnMesnac.Business.@base
/// <param name="id"></param>
private void GetVisionWorkState(TcpVisionEntity entity, string id)
{
if (entity.DataLength == 1)
try
{
if (entity.DataBytes[0] == 0x00)
{
_logger.LogInformation($"视觉系统收到开始工作状态:正常开始工作");
}
else if (entity.DataBytes[0] == 0x01)
if (entity.DataLength == 3)
{
_logger.LogError($"视觉系统收到开始工作状态:异常不能开始工作");
//正常开始工作
if (entity.DataBytes[0] == 0x00)
{
_logger.LogInformation($"视觉系统收到开始工作状态:正常开始工作");
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();
//判断视觉计数和上位机技术是否一致,如果不一致,向视觉计数统一
//如果这次码垛是AMR
if (entity.DataBytes[2] == 00)
{
AGVState AMR = _aGVStateService.GetSingleAGVState(airportTask.amragvno);
//如果不一样
if (entity.DataBytes[1] != AMR.stackcount)
{
AMR.stackcount = entity.DataBytes[1];
_aGVStateService.UpdateAsync(AMR);
}
}
//如果这次码垛是Deliver
else if (entity.DataBytes[2] == 01)
{
AGVState Deliver = _aGVStateService.GetSingleAGVState(airportTask.deliveragvno);
//如果不一样
if (entity.DataBytes[1] != Deliver.stackcount)
{
Deliver.stackcount = entity.DataBytes[1];
_aGVStateService.UpdateAsync(Deliver);
}
}
//内容
else
{
_logger.LogError($"视觉系统收到开始工作状态:返回未知代码");
}
}
else if (entity.DataBytes[0] == 0x01)
{
_logger.LogError($"视觉系统收到开始工作状态:异常不能开始工作");
}
else
{
_logger.LogError($"视觉系统收到开始工作状态:返回未知代码");
}
}
else
{
_logger.LogError($"视觉系统收到开始工作状态:返回未知代码");
_logger.LogError($"视觉系统收到开始工作状态:数据返回格式错误");
}
}
else
catch (Exception ex)
{
_logger.LogError($"视觉系统收到开始工作状态:数据返回格式错误");
RequestVisionReplace(id);
_logger.LogError($"接受开始工作状态发生错误 {ex.Message}");
}
}
@ -129,113 +173,54 @@ namespace SlnMesnac.Business.@base
/// <exception cref="Exception"></exception>
public void AutoStackResultSend(TcpVisionEntity entity, string id)
{
if (entity.DataLength == 1)
try
{
if (entity.DataBytes[0] == 0x00)
if (entity.DataLength == 2)
{
_logger.LogInformation($"视觉系统一次码垛结束,码垛完成 Deliver:{VDCount} AMR:{VACount}");
//上位机回复收到码垛结果
_tcpServer.SendReplayStackResult(id);
VisionSetting record = _visionSettingService.GetList(x => x.VisionID == id).ToList().First();
AirportTask airportTask = _airportTaskService.GetTaskInfos(x => x.amragvno == record.AMRGUID &&
x.visiontaskno == (BitConverter.ToInt16(entity.SN, 0) - 1).ToString() && x.taskstate == "抓取中").First();
//成功码垛先码垛计数
StackCount(airportTask, entity.DataBytes[1]);
//////////////下面是下一次码垛的综合判断条件//////////////
//先判断总数是否需要继续工作
if (airportTask.totalcount > airportTask.loadcount)
if (entity.DataBytes[0] == 0x00)
{
//如上一次是AMR 如有Deliver 判断是否到达 到达向deliver发送开始工作没就判断amr是否装满 继续向amr
//上一次是AMR
if (entity.DataBytes[1] == 0x01)
_logger.LogInformation($"视觉系统一次码垛结束,码垛完成 Deliver:{VDCount} AMR:{VACount}");
//上位机回复收到码垛结果
_tcpServer.SendReplayStackResult(id);
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();
//成功码垛先码垛计数
StackCount(airportTask, entity.DataBytes[1]);
//取出两辆小车的计数
int AMRCount = _aGVStateService.GetSingleAGVState(airportTask.amragvno).stackcount;
int DeliverCount = 0;
if (!string.IsNullOrEmpty(airportTask.deliveragvno))
{
//妹有Deliver的任务小车号和是否已到达都没有amr肯定能抓完 继续amr抓取
if (string.IsNullOrEmpty(airportTask.deliveragvno) && string.IsNullOrEmpty(airportTask.deliveragvisarrive))
{
//一直向amr抓直到抓满
RequestVisionStartWork(StackState.AMRNoPositioning, id);
}
//有Delievr任务有任务号且状态为未到达继续amr抓取
else if (!string.IsNullOrEmpty(airportTask.deliveragvno) && airportTask.deliveragvisarrive == "未到达")
{
//判断AMR小车是否装满没满就开装满了就结束开始循环判断deliver是否到达
//amr没满 继续装amr
if (_aGVStateService.GetSingleAGVState(airportTask.amragvno).stackcount < BaseTaskInfoBusiness.AMRStackNumber)
{
RequestVisionStartWork(StackState.AMRNoPositioning, id);
}
//AMR满了
else
{
AirportTask task;
//结束抓取、循环判断deliver是否到达到了就向新的Deliver开始抓取
Task.Run(() =>
{
//请求复位
RequestVisionReplace(id);
while (true)
{
//循环判断该任务的deliver是否到达
Task.Delay(1000);
task = _airportTaskService.GetTaskInfos(x => x.amragvno == record.AMRGUID && x.taskstate == "抓取中").First();
if (task.deliveragvisarrive == "已到达")
{
RequestVisionStartWork(StackState.AGVNeedPositioning, id);
break;
}
}
});
}
}
//有Deliver任务有任务号且已到达向Deliver发送开始抓取
else if (!string.IsNullOrEmpty(airportTask.deliveragvno) && airportTask.deliveragvisarrive == "已到达")
{
RequestVisionStartWork(StackState.AGVNeedPositioning, id);
}
//异常情况
else
{
throw new Exception($"任务 {airportTask.taskno} 状态异常!请清除任务并重新下发任务!");
}
DeliverCount = _aGVStateService.GetSingleAGVState(airportTask.deliveragvno).stackcount;
}
//如上一次是deliver-->则判断deliver是否装满-->装满则deliver入库-->判断剩下的数量用不用调新的deliver-->用就调新的deliver然后发向amr抓取(还得判断AMR是否抓满)-->不用就直接向amr抓取
//上一次是Deliver
else if (entity.DataBytes[1] == 0x00)
//////////////下面是下一次码垛的综合判断条件//////////////
//先判断总数是否需要继续工作
if (airportTask.totalcount > airportTask.loadcount)
{
//判断Deliver是否装满,装满就直接入库,未装满继续装
//deliver没满继续装
if (_aGVStateService.GetSingleAGVState(airportTask.deliveragvno).stackcount < BaseTaskInfoBusiness.DeliverStackNumber)
{
RequestVisionStartWork(StackState.AGVNoPositioning, id);
}
//deliver满了入库然后判断
else
//如上一次是AMR 如有Deliver 判断是否到达 到达向deliver发送开始工作没就判断amr是否装满 继续向amr
//上一次是AMR
if (entity.DataBytes[1] == 0x00)
{
//入库代码
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.deliveragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入库", airportTask.conveyorno).JobName);
airportTask.deliveragvno = null;
airportTask.deliveragvisarrive = null;
_airportTaskService.UpdateTaskAsync(airportTask);
//判断剩下的数量用不用调用新的deliver
//剩下的数量不用 直接向amr抓取
int amrleft = BaseTaskInfoBusiness.AMRStackNumber - _aGVStateService.GetSingleAGVState(airportTask.amragvno).stackcount;
if (airportTask.totalcount - airportTask.loadcount < amrleft)
//妹有Deliver的任务小车号和是否已到达都没有amr肯定能抓完 继续amr抓取
if (string.IsNullOrEmpty(airportTask.deliveragvno) && string.IsNullOrEmpty(airportTask.deliveragvisarrive))
{
RequestVisionStartWork(StackState.AMRNeedPositioning, id);
//一直向amr抓直到抓满
RequestVisionStartWork(StackState.NXAMRNoPositioning, AMRCount, id);
}
//剩下的数量需要调用并判断向AMR抓取
else
//有Delievr任务有任务号且状态为未到达继续amr抓取
else if (!string.IsNullOrEmpty(airportTask.deliveragvno) && airportTask.deliveragvisarrive == "未到达")
{
//调新的deliver
AGVState newagv = _baseAGVBusiness.GetBestAGV(AgvType.Deliver);
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(newagv.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入位", airportTask.conveyorno).JobName);
airportTask.deliveragvno = newagv.agvno;
airportTask.deliveragvisarrive = "未到达";
_airportTaskService.UpdateTaskAsync(airportTask);
//amr无容量结束抓取等待Deliver到达
if (amrleft == 0)
//判断AMR小车是否装满没满就开装满了就结束开始循环判断deliver是否到达
//amr没满 继续装amr
if (_aGVStateService.GetSingleAGVState(airportTask.amragvno).stackcount < BaseTaskInfoBusiness.AMRStackNumber)
{
RequestVisionStartWork(StackState.NXAMRNoPositioning, AMRCount, id);
}
//AMR满了
else
{
AirportTask task;
//结束抓取、循环判断deliver是否到达到了就向新的Deliver开始抓取
@ -250,95 +235,183 @@ namespace SlnMesnac.Business.@base
task = _airportTaskService.GetTaskInfos(x => x.amragvno == record.AMRGUID && x.taskstate == "抓取中").First();
if (task.deliveragvisarrive == "已到达")
{
RequestVisionStartWork(StackState.AGVNeedPositioning, id);
RequestVisionStartWork(StackState.NXAGVNeedPositioning, DeliverCount, id);
break;
}
}
});
}
//amr有容量
}
//有Deliver任务有任务号且已到达向Deliver发送开始抓取
else if (!string.IsNullOrEmpty(airportTask.deliveragvno) && airportTask.deliveragvisarrive == "已到达")
{
RequestVisionStartWork(StackState.NXAGVNeedPositioning, DeliverCount, id);
}
//异常情况
else
{
throw new Exception($"任务 {airportTask.taskno} 状态异常!请清除任务并重新下发任务!");
}
}
//如上一次是deliver-->则判断deliver是否装满-->装满则deliver入库-->判断剩下的数量用不用调新的deliver-->用就调新的deliver然后发向amr抓取(还得判断AMR是否抓满)-->不用就直接向amr抓取
//上一次是Deliver
else if (entity.DataBytes[1] == 0x01)
{
//判断Deliver是否装满,装满就直接入库,未装满继续装
//deliver没满继续装
if (_aGVStateService.GetSingleAGVState(airportTask.deliveragvno).stackcount < BaseTaskInfoBusiness.DeliverStackNumber)
{
RequestVisionStartWork(StackState.NXAGVNoPositioning, DeliverCount, id);
}
//deliver满了入库然后判断
else
{
//入库代码
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.deliveragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入库", airportTask.conveyorno).JobName);
airportTask.deliveragvno = null;
airportTask.deliveragvisarrive = null;
_airportTaskService.UpdateTaskAsync(airportTask);
//判断剩下的数量用不用调用新的deliver
//剩下的数量不用 直接向amr抓取
int amrleft = BaseTaskInfoBusiness.AMRStackNumber - _aGVStateService.GetSingleAGVState(airportTask.amragvno).stackcount;
if (airportTask.totalcount - airportTask.loadcount < amrleft)
{
RequestVisionStartWork(StackState.NXAMRNeedPositioning, AMRCount, id);
}
//剩下的数量需要调用并判断向AMR抓取
else
{
RequestVisionStartWork(StackState.AMRNeedPositioning, id);
//调新的deliver
AGVState newagv = _baseAGVBusiness.GetBestAGV(AgvType.Deliver);
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(newagv.agvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入位", airportTask.conveyorno).JobName);
airportTask.deliveragvno = newagv.agvno;
airportTask.deliveragvisarrive = "未到达";
_airportTaskService.UpdateTaskAsync(airportTask);
//amr无容量结束抓取等待Deliver到达
if (amrleft == 0)
{
AirportTask task;
//结束抓取、循环判断deliver是否到达到了就向新的Deliver开始抓取
Task.Run(() =>
{
//请求复位
RequestVisionReplace(id);
while (true)
{
//循环判断该任务的deliver是否到达
Task.Delay(1000);
task = _airportTaskService.GetTaskInfos(x => x.amragvno == record.AMRGUID && x.taskstate == "抓取中").First();
if (task.deliveragvisarrive == "已到达")
{
RequestVisionStartWork(StackState.NXAGVNeedPositioning, DeliverCount, id);
break;
}
}
});
}
//amr有容量
else
{
RequestVisionStartWork(StackState.NXAMRNeedPositioning, AMRCount, id);
}
}
}
}
//未知代码
else
{
throw new Exception($"任务 {airportTask.taskno} 未知上次码垛代码!请检查视觉系统状态!");
}
}
//未知代码
//总数达标,结束任务,复位机械臂,调回小车,任务状态调整
else
{
throw new Exception($"任务 {airportTask.taskno} 未知上次码垛代码!请检查视觉系统状态!");
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.amragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("1000入库", airportTask.conveyorno).JobName);
airportTask.amragvno = null;
airportTask.amragvisarrive = null;
airportTask.visiontaskno = null;
if (!string.IsNullOrEmpty(airportTask.deliveragvno))
{
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.deliveragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入库", airportTask.conveyorno).JobName);
airportTask.deliveragvno = null;
airportTask.deliveragvisarrive = null;
}
airportTask.finishtime = DateTime.Now;
airportTask.taskstate = "已完成";
_airportTaskService.UpdateTaskAsync(airportTask);
}
}
//总数达标,结束任务,复位机械臂,调回小车,任务状态调整
else
//码垛过程失败
else if (entity.DataBytes[0] == 0x01)
{
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.amragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("1000入库", airportTask.conveyorno).JobName);
airportTask.amragvno = null;
airportTask.amragvisarrive = null;
airportTask.visiontaskno = null;
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();
//取出两辆小车的计数
int AMRCount = _aGVStateService.GetSingleAGVState(airportTask.amragvno).stackcount;
int DeliverCount = 0;
if (!string.IsNullOrEmpty(airportTask.deliveragvno))
{
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(airportTask.deliveragvno,
_AGVJobService.GetAGVJobListByTypeAndConveyorNo("800入库", airportTask.conveyorno).JobName);
airportTask.deliveragvno = null;
airportTask.deliveragvisarrive = null;
DeliverCount = _aGVStateService.GetSingleAGVState(airportTask.deliveragvno).stackcount;
}
_logger.LogError($"视觉系统一次码垛结束,码垛过程失败,重新发送码垛信号");
if (entity.DataBytes[1] == 0x00)
{
//发送向复合机器人AMR码垛的信号
RequestVisionStartWork(StackState.NXAMRNoPositioning, AMRCount, id);
_logger.LogInformation("下一次码垛开始,方向:复合机器人");
}
else if (entity.DataBytes[1] == 0x01)
{
//发送向搬运机器人AGVDeliver码垛的信号
RequestVisionStartWork(StackState.NXAGVNoPositioning, DeliverCount, id);
_logger.LogInformation("下一次码垛开始,方向:搬运机器人");
}
else
{
_logger.LogError($"码垛失败返回未知码垛结果代码,请手动重新发送码垛信号");
}
airportTask.finishtime = DateTime.Now;
airportTask.taskstate = "已完成";
_airportTaskService.UpdateTaskAsync(airportTask);
}
}
//码垛过程失败
else if (entity.DataBytes[0] == 0x01)
{
_logger.LogError($"视觉系统一次码垛结束,码垛过程失败,重新发送码垛信号");
if (entity.DataBytes[1] == 0x01)
{
//发送向复合机器人AMR码垛的信号
RequestVisionStartWork(StackState.AMRNoPositioning, id);
_logger.LogInformation("下一次码垛开始,方向:复合机器人");
}
else if (entity.DataBytes[1] == 0x00)
//码垛检查失败
else if (entity.DataBytes[0] == 0x02)
{
//发送向搬运机器人AGVDeliver码垛的信号
RequestVisionStartWork(StackState.AGVNoPositioning, id);
_logger.LogInformation("下一次码垛开始,方向:搬运机器人");
_logger.LogError($"视觉系统一次码垛结束,码垛检查失败,请手动矫正并手动开始下一次码垛");
//仍然要码垛计数,只是筐码的不准
VisionSetting record = _visionSettingService.GetList(x => x.VisionID == id).ToList().First();
AirportTask airportTask = _airportTaskService.GetTaskInfos(x => x.amragvno == record.AMRGUID &&
x.visiontaskno == (BitConverter.ToInt16(entity.SN, 0) - 1).ToString() && x.taskstate == "抓取中").First();
StackCount(airportTask, entity.DataBytes[1]);
}
//未知代码
else
{
_logger.LogError($"码垛失败返回未知码垛结果代码,请手动重新发送码垛信号");
_logger.LogError($"视觉系统一次码垛结束,未知返回代码!请检查视觉系统状态!");
throw new Exception($"视觉系统 {id}一次码垛结束,未知返回代码!请检查视觉系统状态!");
}
}
//码垛检查失败
else if (entity.DataBytes[0] == 0x02)
{
_logger.LogError($"视觉系统一次码垛结束,码垛检查失败,请手动矫正并手动开始下一次码垛");
//仍然要码垛计数,只是筐码的不准
VisionSetting record = _visionSettingService.GetList(x => x.VisionID == id).ToList().First();
AirportTask airportTask = _airportTaskService.GetTaskInfos(x => x.amragvno == record.AMRGUID &&
x.visiontaskno == (BitConverter.ToInt16(entity.SN, 0) - 1).ToString() && x.taskstate == "抓取中").First();
StackCount(airportTask, entity.DataBytes[1]);
}
//未知代码
//数据格式错误
else
{
_logger.LogError($"视觉系统一次码垛结束,未知返回代码!请检查视觉系统状态!");
throw new Exception($"视觉系统 {id }一次码垛结束,未知返回代码!请检查视觉系统状态!");
_logger.LogError($"视觉系统一次码垛结束,返回数据格式错误,请检查视觉系统状态!");
}
}
//数据格式错误
else
catch(Exception ex)
{
_logger.LogError($"视觉系统一次码垛结束,返回数据格式错误,请检查视觉系统状态!");
RequestVisionReplace(id);
_logger.LogError($"接受工作结束再分配状态发生错误 {ex.Message}");
}
}
public void StackCount(AirportTask airportTask, byte lastCount)
{
//AMR码垛计数
if (lastCount == 0x01)
if (lastCount == 0x00)
{
airportTask.loadcount++;
AGVState aGVState = _aGVStateService.GetSingleAGVState(airportTask.amragvno);
@ -355,7 +428,7 @@ namespace SlnMesnac.Business.@base
}
}
//Deliver码垛计数
else if (lastCount == 0x00)
else if (lastCount == 0x01)
{
airportTask.loadcount++;
AGVState aGVState = _aGVStateService.GetSingleAGVState(airportTask.deliveragvno);
@ -404,7 +477,7 @@ namespace SlnMesnac.Business.@base
if (Vjudge) //这里写向哪个机器人码垛的判断条件
{
//发送向搬运机器人AGVDeliver码垛的信号
RequestVisionStartWork(StackState.AGVNoPositioning, id);
RequestVisionStartWork(StackState.NXAGVNoPositioning, VDCount, id);
_logger.LogInformation("下一次码垛开始,方向:搬运机器人");
VDCount++;
VNow = true;
@ -416,7 +489,7 @@ namespace SlnMesnac.Business.@base
else
{
//发送向复合机器人AMR码垛的信号
RequestVisionStartWork(StackState.AMRNoPositioning, id);
RequestVisionStartWork(StackState.NXAMRNoPositioning, VACount, id);
_logger.LogInformation("下一次码垛开始,方向:复合机器人");
VACount++;
VNow = false;
@ -440,13 +513,13 @@ namespace SlnMesnac.Business.@base
if (VNow) //这里写向哪个机器人码垛的判断条件
{
//发送向搬运机器人AGVDeliver码垛的信号
RequestVisionStartWork(StackState.AGVNoPositioning, id);
RequestVisionStartWork(StackState.NXAGVNoPositioning, VDCount, id);
_logger.LogInformation("下一次码垛开始,方向:搬运机器人");
}
else
{
//发送向复合机器人AMR码垛的信号
RequestVisionStartWork(StackState.AMRNoPositioning, id);
RequestVisionStartWork(StackState.NXAMRNoPositioning, VACount, id);
_logger.LogInformation("下一次码垛开始,方向:复合机器人");
}
}

@ -44,37 +44,37 @@ namespace SlnMesnac.Repository
/// AMRAGV编号
/// </summary>
[SugarColumn(ColumnName = "AMRAGVNo")]
public string amragvno { get; set; }
public string? amragvno { get; set; }
/// <summary>
/// AMRAGV是否到达
/// </summary>
[SugarColumn(ColumnName = "AMRAGVIsArrive")]
public string amragvisarrive { get; set; }
public string? amragvisarrive { get; set; }
/// <summary>
/// 搬运AGV编号
/// </summary>
[SugarColumn(ColumnName = "DeliverAGVNo")]
public string deliveragvno { get; set; }
public string? deliveragvno { get; set; }
/// <summary>
/// 搬运AGV是否到达
/// </summary>
[SugarColumn(ColumnName = "DeliverAGVIsArrive")]
public string deliveragvisarrive { get; set; }
public string? deliveragvisarrive { get; set; }
/// <summary>
/// 总数量
/// </summary>
[SugarColumn(ColumnName = "TotalCount")]
public int? totalcount { get; set; }
public int totalcount { get; set; }
/// <summary>
/// 已装载数量
/// </summary>
[SugarColumn(ColumnName = "LoadCount")]
public int? loadcount { get; set; }
public int loadcount { get; set; }
/// <summary>
/// 任务状态
@ -86,7 +86,7 @@ namespace SlnMesnac.Repository
/// 开始时间
/// </summary>
[SugarColumn(ColumnName = "StartTime")]
public DateTime? starttime { get; set; }
public DateTime starttime { get; set; }
/// <summary>
/// 结束时间

@ -388,27 +388,50 @@ namespace SlnMesnac.TouchSocket
}
}
/// <summary>
/// 请求视觉开始工作码垛信号
/// </summary>
public enum StackState
{
/// <summary>
/// 复合机器人码垛无需定位
/// 复合机器人码垛无需定位位置在X负侧
/// </summary>
AMRNoPositioning = 0x00,
NXAMRNoPositioning = 0x00,
/// <summary>
/// 复合机器人码垛需要定位
/// 复合机器人码垛需要定位位置在X负侧
/// </summary>
AMRNeedPositioning = 0x01,
NXAMRNeedPositioning = 0x01,
/// <summary>
/// 搬运机器人码垛无需定位
/// 搬运机器人码垛无需定位位置在X负侧
/// </summary>
AGVNoPositioning = 0x10,
NXAGVNoPositioning = 0x02,
/// <summary>
/// 搬运机器人码垛需要定位
/// 搬运机器人码垛需要定位位置在X负侧
/// </summary>
AGVNeedPositioning = 0x11,
NXAGVNeedPositioning = 0x03,
/// <summary>
/// 复合机器人码垛无需定位位置在X正侧
/// </summary>
PXAMRNoPositioning = 0x04,
/// <summary>
/// 复合机器人码垛需要定位位置在X正侧
/// </summary>
PXAMRNeedPositioning = 0x05,
/// <summary>
/// 搬运机器人码垛无需定位位置在X正侧
/// </summary>
PXAGVNoPositioning = 0x06,
/// <summary>
/// 搬运机器人码垛需要定位位置在X正侧
/// </summary>
PXAGVNeedPositioning = 0x07,
}
}

@ -58,13 +58,17 @@
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="847*"/>
<ColumnDefinition Width="102*"/>
<ColumnDefinition Width="1227*"/>
<ColumnDefinition Width="671*"/>
</Grid.ColumnDefinitions>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal" Height="30" Margin="10,0,10,0">
<Button Content="首 页" x:Name="Index" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Index}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="10,0,10,0"/>
<Button Content="代码生成" x:Name="Generate" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Generate}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="发送开始抓取" x:Name="TestButton1" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton1}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_1"/>
<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="控 制" x:Name="Control" Command="{Binding ControlOnClickCommand}" CommandParameter="{Binding Name,ElementName=Control}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="Green" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>
<Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>
<!--<Button Content="发送开始抓取" x:Name="TestButton1" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton1}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_1"/>
<Button Content="D无定抓取" x:Name="TestButton11" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton11}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_1"/>
<Button Content="A无定抓取" x:Name="TestButton12" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton12}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_1"/>
<Button Content="发送结束抓取" x:Name="TestButton2" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton2}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_2"/>
@ -75,12 +79,8 @@
<Button Content="复位1000小车" x:Name="TestButton10" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton10}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_4"/>
<Button Content="手动停止任务" x:Name="TestButton5" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton5}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_5"/>
<Button Content="手动清除报警" x:Name="TestButton6" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton6}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_6"/>
<Button Content="流程开始" x:Name="TestButton7" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton7}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_7"/>
<!--<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>-->
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>
<Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>
<Button Content="流程开始" x:Name="TestButton7" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TestButton7}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" Click="Button_Click_7"/>-->
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal" Height="50" Margin="376,0,0,0" Width="253">
<!--多行状态显示-->

@ -30,54 +30,5 @@ namespace SlnMesnac.WPF
this.DataContext = new MainWindowViewModel();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
return;
}
/// <summary>
/// 测试1
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MessageBox.Show("开始定位抓取");
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
MessageBox.Show("结束定位抓取");
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
MessageBox.Show("调用小车");
}
private void Button_Click_4(object sender, RoutedEventArgs e)
{
MessageBox.Show("入库小车");
}
private void Button_Click_5(object sender, RoutedEventArgs e)
{
MessageBox.Show("手动停止任务");
}
private void Button_Click_6(object sender, RoutedEventArgs e)
{
MessageBox.Show("手动清除报警");
}
private void Button_Click_7(object sender, RoutedEventArgs e)
{
MessageBox.Show("流程开始");
}
}
}

@ -0,0 +1,13 @@
<Window x:Class="SlnMesnac.WPF.Page.ControlPage.TaskControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page.ControlPage"
mc:Ignorable="d"
Title="TaskControl" Height="450" Width="800" >
<Grid>
<!--<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>-->
</Grid>
</Window>

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace SlnMesnac.WPF.Page.ControlPage
{
/// <summary>
/// TaskControl.xaml 的交互逻辑
/// </summary>
public partial class TaskControl : Window
{
public TaskControl()
{
InitializeComponent();
}
}
}

@ -0,0 +1,54 @@
<UserControl x:Class="SlnMesnac.WPF.Page.ControlPage.UserTaskControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page.ControlPage"
mc:Ignorable="d" d:DesignWidth="800" Background="Transparent" Height="590">
<Grid HorizontalAlignment="Center" Width="800" Height="590" VerticalAlignment="Center">
<Button Content="发送开始抓取" x:Name="DeliverNeedPosition" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=DeliverNeedPosition}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="615,70,85,396" Click="Button_Click_1"/>
<Button Content="D无定抓取" x:Name="DeilverNoPosition" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=DeilverNoPosition}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="353,70,347,396" Click="Button_Click_1"/>
<Button Content="A无定抓取" x:Name="AMRNoPosition" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=AMRNoPosition}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="353,140,347,326" Click="Button_Click_1"/>
<Button Content="发送结束抓取" x:Name="VisionEnd" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=VisionEnd}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="615,140,85,326" Click="Button_Click_2"/>
<Button Content="调用800小车" x:Name="Get800" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Get800}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="89,277,611,189" Click="Button_Click_3"/>
<Button Content="入库800小车" x:Name="Out800" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Out800}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="89,209,611,257" Click="Button_Click_4"/>
<Button Content="调用1000小车" x:Name="Get1000" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Get1000}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="89,139,611,327" Click="Button_Click_3"/>
<Button Content="入库1000小车" x:Name="Out1000" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Out1000}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="89,69,611,397" Click="Button_Click_4"/>
<Button Content="复位1000小车" x:Name="Reset1000" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Reset1000}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="218,69,482,397" Click="Button_Click_4"/>
<Button Content="手动停止800任务" x:Name="ManualStop800Task" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ManualStop800Task}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="482,70,205,396" Click="Button_Click_5" RenderTransformOrigin="0.504,0.511"/>
<Button Content="手动清除800报警" x:Name="ManualClear800Error" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ManualClear800Error}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="482,140,205,326" Click="Button_Click_6"/>
<Button Content="手动停止1000任务" x:Name="ManualStop1000Task" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ManualStop1000Task}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="482,209,205,257" Click="Button_Click_7"/>
<Button Content="开始AGV状态刷新" x:Name="StartAGVStateRefresh" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=StartAGVStateRefresh}" Style="{StaticResource BUTTON_AGREE}" Height="30" Background="Green" BorderBrush="#FF36B5C1" Margin="89,342,581,124" />
<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.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleY="0"/>
<RotateTransform/>
<TranslateTransform Y="0"/>
</TransformGroup>
</Button.RenderTransform>
</Button>
<Grid Margin="426,324,10,10" Background="White">
<Label Content="任务编号" Width="64" VerticalAlignment="Top" Margin="48,31,252,0"/>
<Label Content="为空自动生成" VerticalAlignment="Top" Margin="176,0,106,0"/>
<TextBox Name="taskNo" Width="188" Height="36" Margin="123,26,53,194"/>
<Label Content="站台编号" Width="64" VerticalAlignment="Top" Margin="48,72,252,0"/>
<ComboBox Name="AreaNo" Width="188" Height="36" DisplayMemberPath="Value" SelectedValuePath="Key" Margin="123,67,53,153" SelectionChanged="AreaNo_SelectionChanged"/>
<Label Content="航班号" Width="64" VerticalAlignment="Top" Margin="48,113,252,0" />
<TextBox Name="AirNo" Width="188" Height="36" Margin="123,108,53,112" />
<Label Content="空筐数量" Width="64" VerticalAlignment="Top" Margin="48,154,252,0" />
<TextBox Name="BoxNo" Width="188" Height="36" Margin="123,149,53,71"/>
<Button x:Name="NewAirportTask" Content="新建任务" Click="NewAirportTask_Click" Margin="122,190,122,30" />
</Grid>
</Grid>
</UserControl>

@ -0,0 +1,136 @@
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Repository;
using SlnMesnac.Repository.service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SlnMesnac.WPF.Page.ControlPage
{
/// <summary>
/// UserTaskControl.xaml 的交互逻辑
/// </summary>
public partial class UserTaskControl : UserControl
{
private IAirportTaskService _taskservice;
public Action StopTaskAction;
public UserTaskControl()
{
InitializeComponent();
_taskservice = App.ServiceProvider.GetService<IAirportTaskService>();
Init();
}
private void Init()
{
Dictionary<int, string> dicItem = new Dictionary<int, string>();
dicItem.Add(1, "1号站台");
dicItem.Add(2, "2号站台");
dicItem.Add(3, "3号站台");
dicItem.Add(4, "4号站台");
dicItem.Add(5, "5号站台");
dicItem.Add(6, "6号站台");
AreaNo.ItemsSource = dicItem;
AreaNo.SelectedIndex = 0;
}
/// <summary>
/// 测试1
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MessageBox.Show("开始定位抓取");
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
MessageBox.Show("结束定位抓取");
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
MessageBox.Show("调用小车");
}
private void Button_Click_4(object sender, RoutedEventArgs e)
{
MessageBox.Show("入库小车");
}
private void Button_Click_5(object sender, RoutedEventArgs e)
{
MessageBox.Show("手动停止任务");
}
private void Button_Click_6(object sender, RoutedEventArgs e)
{
MessageBox.Show("手动清除报警");
}
private void Button_Click_7(object sender, RoutedEventArgs e)
{
MessageBox.Show("流程开始");
}
/// <summary>
/// 新建任务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void NewAirportTask_Click(object sender, RoutedEventArgs e)
{
//判空
if (string.IsNullOrEmpty(BoxNo.Text.Trim()) || string.IsNullOrEmpty(AreaNo.Text.Trim()))
{
MessageBox.Show("请输入完整任务信息!");
return;
}
//判断站台任务是否结束
AirportTask airportTask = new AirportTask()
{
taskno = string.IsNullOrEmpty(taskNo.Text.Trim()) ? Guid.NewGuid().ToString("N") : taskNo.Text.Trim(),
conveyorno = AreaNo.SelectedValue.ToString(),
flightno = AirNo.Text,
totalcount = Convert.ToInt32(BoxNo.Text),
loadcount = 0,
taskstate = "等待",
starttime = DateTime.Now
};
if (_taskservice.AddTaskAsync(airportTask).Result)
{
MessageBox.Show($"{AirNo.Text} 航班任务添加成功");
}
else
{
MessageBox.Show($"{AirNo.Text} 航班任务添加失败");
}
}
private void AreaNo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void StopAll_Click(object sender, RoutedEventArgs e)
{
this.StopTaskAction.Invoke();
}
}
}

@ -75,7 +75,7 @@ namespace SlnMesnac.WPF.Page.IndexPage
string ss = AreaNo.SelectedIndex.ToString();
//判断站台任务是否结束
AirportTask AirportTask = new AirportTask()
AirportTask airportTask = new AirportTask()
{
taskno = taskNo.Text,
conveyorno = AreaNo.SelectedValue.ToString(),
@ -85,14 +85,19 @@ namespace SlnMesnac.WPF.Page.IndexPage
starttime = DateTime.Now
};
bool iflag = await _taskservice.AddTaskAsync(AirportTask);
bool iflag = await _taskservice.AddTaskAsync(airportTask);
if (iflag)
{
_Taskaction?.Invoke(AirportTask);
_Taskaction?.Invoke(airportTask);
this.Close();
}
}
private void AreaNo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}
}

@ -194,6 +194,18 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
}
/// <summary>
/// 机械臂复位,停止所有任务,复位所有小车
/// </summary>
public void StopAllTask()
{
//机械臂复位
//所有任务设置为已终止
//所有小车任务结束
}
public async void RefreshTaskItems(AirportTask airportTask)
{
try

@ -9,6 +9,7 @@ using SlnMesnac.Model.AirportApiEntity;
using SlnMesnac.Repository;
using SlnMesnac.Repository.service;
using SlnMesnac.TouchSocket;
using SlnMesnac.WPF.Page.ControlPage;
using SlnMesnac.WPF.Page.Generate;
using SlnMesnac.WPF.Page.IndexPage;
using System;
@ -37,6 +38,7 @@ namespace SlnMesnac.WPF.ViewModel
//代码生成
private readonly GenerateControl generateControl = new GenerateControl();
private IndexContent indexContent = new IndexContent();
private UserTaskControl taskControl = new UserTaskControl();
private AppConfig _appConfig;
private AirPorthttpClient _airPorthttpClient;
private BaseTaskInfoBusiness _baseTaskInfoBusiness;
@ -128,6 +130,7 @@ namespace SlnMesnac.WPF.ViewModel
_baseStateRefreshBusiness = BaseStateRefreshBusiness.GetInstance(_StateRefreshBusinessLogger, _AGVStateService, _airPorthttpClient, _AGVSettingService);
ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj));
FormControlCommand = new RelayCommand<object>(x => FormControl(x));
StopAllTaskActionInvoke();
_tcpServer.RefreshStateAction += (_clientIP, _state) =>
{
if (_clientIP == _appConfig.AMRIP)
@ -135,7 +138,7 @@ namespace SlnMesnac.WPF.ViewModel
ShellScannerStatus = _state ? 1 : 2;
}
};
_baseStateRefreshBusiness.AGVStateUpdateTimerOperation(TimerControl.Start);
//
UserContent = indexContent;
}
@ -176,51 +179,63 @@ namespace SlnMesnac.WPF.ViewModel
case "Minimized":
Application.Current.MainWindow.WindowState = WindowState.Minimized;
break;
case "TestButton1":
case "DeliverNeedPosition":
//AMR就绪请求视觉初步开始工作
_visionBusiness.TotalJudge = true;
_visionBusiness.RequestVisionStartWork(StackState.AGVNeedPositioning, _tcpServer.VID);
_visionBusiness.RequestVisionStartWork(StackState.NXAGVNeedPositioning, 0, _tcpServer.VID);
break;
case "TestButton11":
case "DeilverNoPosition":
//AMR就绪请求无定向AGV开始工作
_visionBusiness.TotalJudge = true;
_visionBusiness.RequestVisionStartWork(StackState.AGVNoPositioning, _tcpServer.VID);
_visionBusiness.RequestVisionStartWork(StackState.NXAGVNoPositioning, 0, _tcpServer.VID);
break;
case "TestButton12":
case "AMRNoPosition":
//AMR就绪请求无定向AMR开始工作
_visionBusiness.TotalJudge = true;
_visionBusiness.RequestVisionStartWork(StackState.AMRNoPositioning, _tcpServer.VID);
_visionBusiness.RequestVisionStartWork(StackState.NXAMRNoPositioning, 0, _tcpServer.VID);
break;
case "TestButton2":
case "VisionEnd":
//码垛结束,请求视觉系统复位
_visionBusiness.RequestVisionReplace(_tcpServer.VID);
break;
case "TestButton3":
case "Get800":
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(_appConfig.AGVConfig.Where(x => x.AGVName == "S800-B").First().AGVGUID, "800小车进入位置任务pause");
break;
case "TestButton4":
case "Out800":
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(_appConfig.AGVConfig.Where(x => x.AGVName == "S800-B").First().AGVGUID, "800小车入库任务pause");
break;
case "TestButton8":
case "Get1000":
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(_appConfig.AGVConfig.Where(x => x.AGVName == "S1000-A").First().AGVGUID, "1000小车进入位置任务pause");
break;
case "TestButton9":
case "Out1000":
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(_appConfig.AGVConfig.Where(x => x.AGVName == "S1000-A").First().AGVGUID, "1000小车入库任务pause");
break;
case "TestButton10":
case "Reset1000":
_baseAGVBusiness.EndTaskAndClearErrorAndDownloadTask(_appConfig.AGVConfig.Where(x => x.AGVName == "S1000-A").First().AGVGUID, "1000校正模板");
break;
case "TestButton5":
case "ManualStop800Task":
//手动停止任务
_baseAGVBusiness.EndTaskAndClearError("S800-B");
break;
case "TestButton6":
case "ManualClear800Error":
//手动清除报警
_baseAGVBusiness.ClaerError("S800-B");
break;
case "TestButton7":
case "ManualStop1000Task":
_baseAGVBusiness.EndTaskAndClearError("S1000-A");
break;
case "StartAGVStateRefresh":
_baseStateRefreshBusiness.AGVStateUpdateTimerOperation(TimerControl.Start);
break;
case "StopAGVStateRefresh":
_baseStateRefreshBusiness.AGVStateUpdateTimerOperation(TimerControl.Stop);
break;
case "StartTaskRefresh":
_baseTaskInfoBusiness.TaskStateUpdateTimerOperation(TimerControl.Start);
break;
case "StopTaskRefresh":
_baseTaskInfoBusiness.TaskStateUpdateTimerOperation(TimerControl.Stop);
break;
default:
break;
}
@ -231,6 +246,28 @@ namespace SlnMesnac.WPF.ViewModel
}
}
public void StopAllTaskActionInvoke()
{
taskControl.StopTaskAction = () =>
{
List<AirportTask> taskList = _Taskservice.GetTaskInfos(x => x.taskstate == "抓取中" && x.taskstate == "派车中").ToList();
//任务状态设置为已终止并且机械臂复位
foreach(var taskInfo in taskList)
{
_visionBusiness.RequestVisionReplace(_visionSettingService.GetVisionSettingByAMRGUID(taskInfo.amragvno).VisionID);
taskInfo.visiontaskno = null;
taskInfo.amragvisarrive = null;
taskInfo.amragvno = null;
taskInfo.deliveragvno = null;
taskInfo.deliveragvisarrive = null;
taskInfo.finishtime = DateTime.Now;
taskInfo.taskstate = "已终止";
}
//agv全部停止
_logger.LogInformation("已成功全部停止");
};
}
/// <summary>
/// 界面跳转
/// </summary>
@ -244,6 +281,9 @@ namespace SlnMesnac.WPF.ViewModel
case "Index":
UserContent = indexContent;
break;
case "Control":
UserContent = taskControl;
break;
default: break;
}
}

Loading…
Cancel
Save