master
liuwf 1 year ago
parent 9d616def1d
commit ca5da53564

@ -43,6 +43,56 @@ namespace Khd.Core.Wcs.Wcs
_logger.Info("二楼AGV上件扫描监听启动成功"); _logger.Info("二楼AGV上件扫描监听启动成功");
} }
/// <summary>
/// 开启线程监听2分钟小包出口光电信号如果小包出口到位信号消失即取托盘完成发送信号通知线体
/// </summary>
/// <param name="timeoutMinutes"></param>
public static void ListenForSignal(int timeoutMinutes = 2)
{
// 创建一个 CancellationTokenSource 来控制超时
var cts = new CancellationTokenSource(TimeSpan.FromMinutes(timeoutMinutes));
Task.Run(async () =>
{
var agvGetPoint = StaticData.BasePlcpointList.First(t => t.id == 53);
var agvGetValue = StaticData.PlcDic[2].Read(agvGetPoint.plcpointAddress);
while (!cts.Token.IsCancellationRequested)
{
// 每隔 1 秒检查一次小包出口光电信号
await Task.Delay(1000, cts.Token);
agvGetValue = StaticData.PlcDic[2].Read(agvGetPoint.plcpointAddress);
if (agvGetValue != null && Convert.ToInt32(agvGetValue) == 0)
{
// 信号消失20s后执行相关操作
Thread.Sleep(1000*20);
// 取托盘确认信号DB4.DBX310.1写true
BasePlcpoint secondOutGetOverPoint = StaticData.BasePlcpointList.First(t => t.id == 71);
StaticData.PlcDic[2].WriteToPoint(secondOutGetOverPoint.plcpointAddress, true, secondOutGetOverPoint.plcpointLength.ToString());
// 清空小包出口RFID
BasePlcpoint rfid2001Point = StaticData.BasePlcpointList.First(t => t.id == 52);
StaticData.PlcDic[2].WriteRFID(rfid2001Point.plcpointAddress, "", 12);
// 满足条件后退出循环
break;
}
}
// 任务被取消或者超时
if (cts.Token.IsCancellationRequested)
{
Console.WriteLine("任务超时或被取消");
}
}).Wait();
}
public void MonitorInLocatorPoint() public void MonitorInLocatorPoint()
{ {
using var scope = _host.Services.CreateScope(); using var scope = _host.Services.CreateScope();
@ -538,8 +588,16 @@ namespace Khd.Core.Wcs.Wcs
{ {
dbContext.WcsTask.Where(t => t.objid == item.objid).Update(t => new WcsTask() { taskStatus = 4 }); dbContext.WcsTask.Where(t => t.objid == item.objid).Update(t => new WcsTask() { taskStatus = 4 });
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 });
// 开启线程监听2分钟小包出口光电信号如果小包出口到位信号消失即取托盘完成发送信号通知线体
ListenForSignal(2);
} }
} }
} }
else else
{ {
@ -557,6 +615,9 @@ namespace Khd.Core.Wcs.Wcs
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 });
} }
} }
} }
else if (item.taskStatus == 5) else if (item.taskStatus == 5)
{ {
@ -594,12 +655,6 @@ namespace Khd.Core.Wcs.Wcs
if (item.taskType == StaticTaskType.SecondSmallPackageToStorage) if (item.taskType == StaticTaskType.SecondSmallPackageToStorage)
{ {
//取托盘确认信号DB4.DBX310.1写true
BasePlcpoint SecondOutGetOverPoint = StaticData.BasePlcpointList.First(t => t.id == 71);
StaticData.PlcDic[2].WriteToPoint(SecondOutGetOverPoint.plcpointAddress, true, SecondOutGetOverPoint.plcpointLength.ToString());
// 清空小包出口RFID
BasePlcpoint RFID2001Point = StaticData.BasePlcpointList.First(t => t.id == 52);
StaticData.PlcDic[2].WriteRFID(RFID2001Point.plcpointAddress,"", 12);//小包出口的RFID
//WmsProductInstock? wmsProductInstock = dbContext.WmsProductInstock.FirstOrDefault(t => t.productInstockId == item.orderId); //WmsProductInstock? wmsProductInstock = dbContext.WmsProductInstock.FirstOrDefault(t => t.productInstockId == item.orderId);
//if (wmsProductInstock != null) //if (wmsProductInstock != null)

@ -1374,6 +1374,7 @@ namespace Khd.Core.Wpf.Form
{ {
if (HandyControl.Controls.MessageBox.Show("是否确认关闭程序", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) if (HandyControl.Controls.MessageBox.Show("是否确认关闭程序", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{ {
Application.Current.Shutdown();
System.Environment.Exit(System.Environment.ExitCode); System.Environment.Exit(System.Environment.ExitCode);
} }
} }

Loading…
Cancel
Save