change - 入库逻辑修改,PLC应答后即可下发新任务,通过监测PLC在途数量变化实现入库完成监测

collectionStore
wenjy 11 months ago
parent e7d2c05665
commit b554108d24

@ -94,20 +94,24 @@ namespace Aucma.Scada.Business
_baseSpaceDetailService = registerServices.GetService<IBaseSpaceDetailService>();
_baseBomInfoService = registerServices.GetService<IBaseBomInfoService>();
_recordInStore = registerServices.GetService<IRecordInStoreService>();
taskHandle.InStoreFinsihEvent += TaskFeedback;
taskHandle.InStoreFinsihEvent += InStoreFinish;
taskHandle.InStoreAnswerEvent += InStoreAnswer;
grabImage.RefreshMaterialCodeStrEvent += InStore;
grabImage.RefreshLogMessageEvent += PrintLogInfoMessage;
StartPassDown();
Task.Run(() =>
{
Thread.Sleep(6000);
for (int i = 1; i < 12; i++)
for (int i = 1; i < 4; i++)
{
//InStore(appConfig.shellStoreCode, "B2360000078110600" + i.ToString().PadLeft(2, '0'));
//InStore(appConfig.shellStoreCode, "B23600000781110800" + i.ToString().PadLeft(2, '0'));
//Thread.Sleep(1000*60*1);
//InStore(appConfig.linerStoreCode, "L2360000078110600" + i.ToString().PadLeft(2, '0'));
//Thread.Sleep(1000 * 60 * 1);
InStore(appConfig.linerStoreCode, "L23600000781110800" + i.ToString().PadLeft(2, '0'));
Thread.Sleep(1000 * 30);
}
});
@ -159,7 +163,7 @@ namespace Aucma.Scada.Business
private bool CreateInStoreTask(BaseSpaceInfo spaceInfo, string materialCode)
{
bool result = false;
#region 任务赋值
RealTaskInfo realTaskInfo = new RealTaskInfo();
realTaskInfo.taskType = 1;
@ -195,26 +199,28 @@ namespace Aucma.Scada.Business
private SemaphoreSlim linerSemaphore = new SemaphoreSlim(0);
/// <summary>
/// 任务下发
/// </summary>
private void StartPassDown()
{
Thread.Sleep(5000);
Task.Run(() =>
{
Thread.Sleep(5000);
while (true)
{
PassDownShellTask();
Thread.Sleep(1000);
Thread.Sleep(2000);
}
});
Task.Run(() =>
{
Thread.Sleep(5000);
while (true)
{
PassDownLinerTask();
Thread.Sleep(1000);
Thread.Sleep(2000);
}
});
}
@ -227,40 +233,41 @@ namespace Aucma.Scada.Business
/// <param name="e"></param>
private void PassDownShellTask()
{
RealTaskInfo taskInfo = GetAwaitSendTask(appConfig.shellStoreCode);
if (taskInfo != null)
try
{
PrintLogInfoMessage($"下发箱壳入库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
//taskHandle.SendShellTask_InStore(taskInfo);
if (taskHandle.SendShellTask_InStore(taskInfo))
RealTaskInfo taskInfo = taskInfo = _taskInfoService.GetTaskInfoByStoreCode(appConfig.shellStoreCode, appConfig.instoreTaskType);
if (taskInfo != null)
{
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.taskCode}下发成功等待PLC执行反馈");
taskInfo.taskStatus = 2;
PrintLogInfoMessage($"下发箱壳入库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
if (taskHandle.SendShellTask_InStore(taskInfo))
{
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.taskCode}下发成功等待PLC执行反馈");
_taskInfoService.UpdateTaskInfo(taskInfo);
shellSemaphore.Wait(); //一直堵塞直到信号量释放
RefreshInStoreTaskEvent?.Invoke(taskInfo);
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.taskCode};开始执行");
taskHandle.WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
taskInfo.taskStatus = 2;
shellSemaphore.Wait(); //一直堵塞直到信号量释放
_taskInfoService.UpdateTaskInfo(taskInfo);
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.taskCode};执行完成");
RefreshInStoreTaskEvent?.Invoke(taskInfo);
}
else
{
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.taskCode}下发失败请排除PLC连接");
}
RefreshInStoreTaskEvent?.Invoke(taskInfo,true);
}
else
{
PrintLogInfoMessage($"箱壳入库任务{taskInfo.taskCode}下发失败请排除PLC连接");
PrintLogInfoMessage("未获取到需要下发的箱壳入库任务");
}
}
else
}catch(Exception ex)
{
PrintLogInfoMessage("未获取到需要下发的箱壳入库任务");
PrintLogErrorMessage("依次获取箱壳任务队列进行下发逻辑异常", ex);
}
Thread.Sleep(3000);
}
/// <summary>
@ -268,121 +275,99 @@ namespace Aucma.Scada.Business
/// </summary>
private void PassDownLinerTask()
{
RealTaskInfo taskInfo = GetAwaitSendTask(appConfig.linerStoreCode);
if (taskInfo != null)
try
{
PrintLogInfoMessage($"下发内胆入库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
if (taskHandle.SendLinerTask_InStore(taskInfo))
RealTaskInfo taskInfo = taskInfo = _taskInfoService.GetTaskInfoByStoreCode(appConfig.linerStoreCode, appConfig.instoreTaskType);
if (taskInfo != null)
{
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode}下发成功等待PLC执行反馈");
taskInfo.taskStatus = 2;
PrintLogInfoMessage($"下发内胆入库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
_taskInfoService.UpdateTaskInfo(taskInfo);
if (taskHandle.SendLinerTask_InStore(taskInfo))
{
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode}下发成功等待PLC执行反馈");
RefreshInStoreTaskEvent?.Invoke(taskInfo);
linerSemaphore.Wait(); //一直堵塞直到信号量释放
taskHandle.WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode};开始执行");
linerSemaphore.Wait(); //一直堵塞直到信号量释放
taskInfo.taskStatus = 2;
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode};执行完成");
_taskInfoService.UpdateTaskInfo(taskInfo);
RefreshInStoreTaskEvent?.Invoke(taskInfo,true);
RefreshInStoreTaskEvent?.Invoke(taskInfo);
}
else
{
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode}下发失败请排除PLC连接");
}
}
else
{
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode}下发失败请排除PLC连接");
PrintLogInfoMessage("未获取到需要下发的内胆入库任务");
}
}
else
}catch(Exception ex)
{
PrintLogInfoMessage("未获取到需要下发的内胆入库任务");
PrintLogErrorMessage("依次获取内胆任务队列进行下发逻辑异常", ex);
}
Thread.Sleep(3000);
}
#endregion
/// <summary>
/// 获取待执行的入库任务
/// 入库应答PLC收到入库任务后进行应答
/// </summary>
/// <param name="storeCode"></param>
/// <returns></returns>
private RealTaskInfo GetAwaitSendTask(string storeCode)
/// <param name="taskCode"></param>
private void InStoreAnswer(string storeCode, string taskCode)
{
RealTaskInfo taskInfo = null;
try
if (storeCode == appConfig.shellStoreCode)
{
taskInfo = _taskInfoService.GetTaskInfoByStoreCode(storeCode, 1);
PrintLogInfoMessage("箱壳应答成功,自动释放信号量,进行下发新任务");
shellSemaphore.Release();
}
catch (Exception ex)
else
{
PrintLogErrorMessage("获取待执行的入库任务异常", ex);
}
PrintLogInfoMessage("内胆应答成功,自动释放信号量,进行下发新任务");
return taskInfo;
linerSemaphore.Release();
}
}
/// <summary>
/// 任务反馈(入库完成
/// 入库完成
/// </summary>
/// <param name="storeCode"></param>
/// <param name="taskCode"></param>
private void TaskFeedback(string storeCode,string taskCode)
private void InStoreFinish(string storeCode, string taskCode)
{
if(storeCode == appConfig.shellStoreCode)
if (storeCode == appConfig.shellStoreCode)
{
ShellTaskFeedback(taskCode);
PrintLogInfoMessage($"箱壳任务:{taskCode};执行完成");
InStoreFinishHandle(taskCode, appConfig.shellStoreCode);
}
else
{
LinerTaskFeedback(taskCode);
}
}
/// <summary>
/// 箱壳执行反馈
/// </summary>
private void ShellTaskFeedback(string taskCode)
{
PrintLogInfoMessage("箱壳执行完成,自动释放信号量");
InStoreFinish(taskCode, appConfig.shellStoreCode);
shellSemaphore.Release();
}
/// <summary>
/// 内胆执行反馈
/// </summary>
private void LinerTaskFeedback(string taskCode)
{
PrintLogInfoMessage("内胆执行完成,自动释放信号量");
InStoreFinish(taskCode, appConfig.linerStoreCode);
linerSemaphore.Release();
PrintLogInfoMessage($"内胆任务:{taskCode};执行完成");
InStoreFinishHandle(taskCode, appConfig.linerStoreCode);
}
}
#endregion
/// <summary>
/// 入库完成
/// 入库完成逻辑处理
/// </summary>
/// <param name="storeCode"></param>
/// <param name="spaceCode"></param>
/// <param name="materialType"></param>
private void InStoreFinish(string taskCode, string storeCode)
private void InStoreFinishHandle(string taskCode, string storeCode)
{
try
{
var taskInfo = _taskInfoService.GetTaskInfoByTaskCode(taskCode, storeCode);
if (taskInfo != null)
{
var spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(taskInfo.storeCode, taskInfo.spaceCode);
if (spaceInfo != null)
@ -431,7 +416,7 @@ namespace Aucma.Scada.Business
//清除任务信息
_taskInfoService.DeleteTaskInfo(taskCode, storeCode);
}
RefreshInStoreTaskEvent?.Invoke(taskInfo, true);
}
catch (Exception ex)
{
@ -439,27 +424,6 @@ namespace Aucma.Scada.Business
}
}
/// <summary>
/// 日志输出,界面刷新同时记录文件
/// </summary>
/// <param name="message"></param>
private void PrintLogInfoMessage(string message)
{
RefreshLogMessageEvent?.Invoke(message);
logHelper.Info(message);
}
/// <summary>
/// 异常日志输出
/// </summary>
/// <param name="message"></param>
/// <param name="ex"></param>
private void PrintLogErrorMessage(string message, Exception ex = null)
{
RefreshLogMessageEvent?.Invoke(message);
logHelper.Error(message, ex);
}
/// <summary>
/// 截取条码
/// </summary>
@ -476,9 +440,13 @@ namespace Aucma.Scada.Business
return result;
}
/// <summary>
/// 获取已创建的所有入库任务
/// </summary>
/// <returns></returns>
public List<RealTaskInfo> GetInStoreTask()
{
return _taskInfoService.GetTaskInfosByStoreCode(new string[] { appConfig.shellStoreCode,appConfig.linerStoreCode }, 1);
return _taskInfoService.GetTaskInfosByStoreCode(new string[] { appConfig.shellStoreCode,appConfig.linerStoreCode }, appConfig.instoreTaskType);
}
/// <summary>
@ -507,13 +475,14 @@ namespace Aucma.Scada.Business
return _spaceInfoService.GetMaterialStock(appConfig.shellStoreCode, appConfig.linerStoreCode);
}
#region 通过PLC读取货道信息在库、在途、货道状态
/// <summary>
/// 通过PLC读取货道信息在途数量、在库数量、货道状态)
/// </summary>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
/// <returns></returns>
private BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode,string materialType)
private BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType)
{
BaseSpaceInfo result = null;
@ -527,16 +496,17 @@ namespace Aucma.Scada.Business
{
result = GetSpaceInfosByPlc(info);
if(result == null)
if (result == null)
{
var list = _spaceInfoService.GetEmptySpaceInfo(storeCode);
var list = _spaceInfoService.GetEmptySpaceInfo(storeCode);
result = GetSpaceInfosByPlc(list);
}
}
}
}catch (Exception ex)
}
catch (Exception ex)
{
PrintLogErrorMessage("货道信息读取异常", ex);
}
@ -569,7 +539,7 @@ namespace Aucma.Scada.Business
var list = info.Where(x => x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1 && x.spaceStatus == 1).ToList();
if(list.Count > 0)
if (list.Count > 0)
{
result = list.OrderByDescending(x => x.spaceStock).OrderBy(x => x.spaceCode).First();
}
@ -578,5 +548,29 @@ namespace Aucma.Scada.Business
}
return result;
}
#endregion
#region 日志输出
/// <summary>
/// 日志输出,界面刷新同时记录文件
/// </summary>
/// <param name="message"></param>
private void PrintLogInfoMessage(string message)
{
RefreshLogMessageEvent?.Invoke(message);
logHelper.Info(message);
}
/// <summary>
/// 异常日志输出
/// </summary>
/// <param name="message"></param>
/// <param name="ex"></param>
private void PrintLogErrorMessage(string message, Exception ex = null)
{
RefreshLogMessageEvent?.Invoke(message);
logHelper.Error(message, ex);
}
#endregion
}
}

@ -4,6 +4,7 @@ using HighWayIot.Log4net;
using HighWayIot.Plc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -39,6 +40,8 @@ namespace Aucma.Scada.Business
#region 私有变量
private Dictionary<string, IPlc> _plcDictionary = new Dictionary<string, IPlc>();
private Dictionary<string, int> shellKeyValuePairs = new Dictionary<string, int>();
private Dictionary<string, int> linerKeyValuePairs = new Dictionary<string, int>();
/// <summary>
/// 箱壳任务编号,PLC反馈后进行赋值
@ -49,6 +52,12 @@ namespace Aucma.Scada.Business
/// 内胆任务编号,PLC反馈后进行赋值
/// </summary>
private string linerTaskCode = string.Empty;
/// <summary>
/// 已下传的任务信息
/// </summary>
private List<RealTaskInfo> shellTaskInfos = new List<RealTaskInfo>();
private List<RealTaskInfo> linerTaskInfos = new List<RealTaskInfo>();
#endregion
#region 委托事件
@ -59,11 +68,21 @@ namespace Aucma.Scada.Business
/// <param name="taskCode"></param>
public delegate void InStoreFinsih(string storeCode, string taskCode);
public event InStoreFinsih InStoreFinsihEvent;
/// <summary>
/// 入库应答PLC收到下发的入库任务后进行应答
/// </summary>
/// <param name="storeCode"></param>
/// <param name="taskCode"></param>
public delegate void InStoreAnswer(string storeCode, string taskCode);
public event InStoreAnswer InStoreAnswerEvent;
#endregion
private InStoreTaskHandle()
{
_plcDictionary = _pool.GetAll();
RealReadPlcSpace();
}
#region 箱壳入库任务下发处理
@ -86,7 +105,7 @@ namespace Aucma.Scada.Business
_plc.writeStringByAddress(plcConfig.in_shell_task, taskInfo.taskCode);
//写入完成后读取应答字进行复位
ReadShellAnswer_InStore(taskInfo.taskCode);
ReadShellAnswer_InStore(taskInfo);
result = true;
}
@ -111,7 +130,7 @@ namespace Aucma.Scada.Business
/// <summary>
/// 读取箱壳入库应答
/// </summary>
private void ReadShellAnswer_InStore(string taskCode)
private void ReadShellAnswer_InStore(RealTaskInfo taskInfo)
{
lock (string.Empty)
{
@ -138,60 +157,12 @@ namespace Aucma.Scada.Business
_plc.writeStringByAddress(plcConfig.in_shell_task, string.Empty);
isFlag = false;
ReadShellFinish_InStore(taskCode);
}
Thread.Sleep(1000);
} while (isFlag);
}
else
{
logHelper.Info($"仓库{appConfig.shellStoreCode}PLC未连接");
}
}
else
{
logHelper.Info($"PLC信息为空通过{appConfig.shellStoreCode}未获取到该仓库对应的PLC信息");
}
});
}
catch (Exception ex)
{
logHelper.Error("读取箱壳入库应答字异常", ex);
}
}
}
/// <summary>
/// 读取箱壳入库完成
/// </summary>
private void ReadShellFinish_InStore(string taskCode)
{
lock (string.Empty)
{
bool isFlag = true;
IPlc _plc = _plcDictionary[appConfig.shellStoreCode];
shellTaskCode = taskCode;
try
{
Task.Run(() =>
{
if (_plc != null)
{
if (_plc.IsConnected)
{
do
{
//读取PLC入库任务完成
if (_plc.readInt32ByAddress(plcConfig.in_shell_finish) == 1)
{
_plc.writeInt32ByAddress(plcConfig.in_shell_finish, 0);
//string taskCode = _plc.readStringByAddress(plcConfig.out_shell_task, 10);
WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
InStoreFinsihEvent?.Invoke(appConfig.shellStoreCode, taskCode);
//ReadShellFinish_InStore(taskCode);
InStoreAnswerEvent?.Invoke(appConfig.shellStoreCode, taskInfo.taskCode);
isFlag = false;
shellTaskInfos.Add(taskInfo);
}
Thread.Sleep(1000);
@ -210,7 +181,7 @@ namespace Aucma.Scada.Business
}
catch (Exception ex)
{
logHelper.Error("读取箱壳入库完成异常", ex);
logHelper.Error("读取箱壳入库应答字异常", ex);
}
}
}
@ -240,7 +211,7 @@ namespace Aucma.Scada.Business
_plc.writeStringByAddress(plcConfig.in_liner_task, taskInfo.taskCode);
//写入完成后读取应答字进行复位
ReadLinerAnswer_InStore(taskInfo.taskCode);
ReadLinerAnswer_InStore(taskInfo);
result = true;
}
@ -264,13 +235,12 @@ namespace Aucma.Scada.Business
/// <summary>
/// 读取内胆入库应答
/// </summary>
private void ReadLinerAnswer_InStore(string taskCode)
private void ReadLinerAnswer_InStore(RealTaskInfo taskInfo)
{
lock (string.Empty)
{
bool isFlag = true;
IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
linerTaskCode = taskCode;
try
{
Task.Run(() =>
@ -293,7 +263,12 @@ namespace Aucma.Scada.Business
_plc.writeStringByAddress(plcConfig.in_liner_task, string.Empty);
isFlag = false;
ReadLinerFinish_InStore(taskCode);
//ReadLinerFinish_InStore(taskCode);
WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
InStoreAnswerEvent?.Invoke(appConfig.linerStoreCode, taskInfo.taskCode);
linerTaskInfos.Add(taskInfo);
}
Thread.Sleep(1000);
@ -316,11 +291,66 @@ namespace Aucma.Scada.Business
}
}
}
#endregion
#region 读取PLC入库完成 Delete By Wenjy 2023-11-08 15:05:00经讨论入库完成改为监测在途数量变化
/// <summary>
/// 读取箱壳入库完成
/// </summary>
/*private void ReadShellFinish_InStore(string taskCode)
{
lock (string.Empty)
{
bool isFlag = true;
IPlc _plc = _plcDictionary[appConfig.shellStoreCode];
shellTaskCode = taskCode;
try
{
Task.Run(() =>
{
if (_plc != null)
{
if (_plc.IsConnected)
{
do
{
//读取PLC入库任务完成
if (_plc.readInt32ByAddress(plcConfig.in_shell_finish) == 1)
{
_plc.writeInt32ByAddress(plcConfig.in_shell_finish, 0);
//string taskCode = _plc.readStringByAddress(plcConfig.out_shell_task, 10);
InStoreFinsihEvent?.Invoke(appConfig.shellStoreCode, taskCode);
isFlag = false;
}
Thread.Sleep(1000);
} while (isFlag);
}
else
{
logHelper.Info($"仓库{appConfig.shellStoreCode}PLC未连接");
}
}
else
{
logHelper.Info($"PLC信息为空通过{appConfig.shellStoreCode}未获取到该仓库对应的PLC信息");
}
});
}
catch (Exception ex)
{
logHelper.Error("读取箱壳入库完成异常", ex);
}
}
}*/
/// <summary>
/// 读取内胆入库完成
/// </summary>
private void ReadLinerFinish_InStore(string taskCode)
/*private void ReadLinerFinish_InStore(string taskCode)
{
lock (string.Empty)
{
@ -368,6 +398,137 @@ namespace Aucma.Scada.Business
logHelper.Error("读取内胆入库完成异常", ex);
}
}
}*/
#endregion
#region 监测PLC在途数量变化完成入库任务
private void RealReadPlcSpace()
{
Thread.Sleep(5000);
Task.Run(() =>
{
while (true)
{
RealReadShellPlcSpace();
Thread.Sleep(500);
}
});
Task.Run(() =>
{
while (true)
{
RealReadLinerPlcSpace();
Thread.Sleep(500);
}
});
}
/// <summary>
/// 读取箱壳已下发任务的货道信息读取后将货道编号及在途数量写入Dictionary进行比较在途数减少则入库完成
/// </summary>
private void RealReadShellPlcSpace()
{
if (shellTaskInfos != null)
{
List<string> spaceCodes = shellTaskInfos.Select(x => x.spaceCode).Distinct().ToList();
for (int i = 0; i < spaceCodes.Count; i++)
{
string spaceCode = spaceCodes[i];
BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { storeCode = appConfig.shellStoreCode, spaceCode = spaceCode };
spaceInfo = ReadSpaceInfoByPlc(spaceInfo);
if (shellKeyValuePairs.ContainsKey(spaceInfo.spaceCode))
{
shellKeyValuePairs.TryGetValue(spaceInfo.spaceCode, out int value);
//判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成
//如果前次数据不大于当前数据则更新字典中存放的数据
if (value > spaceInfo.onRouteAmount)
{
//筛选任务
var list = shellTaskInfos.Where(x => x.spaceCode == spaceInfo.spaceCode).ToList();
if (list.Count > 0)
{
RealTaskInfo taskInfo = list.OrderBy(x => x.createTime).First();
InStoreFinsihEvent?.Invoke(taskInfo.storeCode, taskInfo.taskCode);
shellTaskInfos.Remove(taskInfo);
}
shellKeyValuePairs.Remove(spaceInfo.spaceCode);
}
else
{
shellKeyValuePairs[spaceInfo.spaceCode] = spaceInfo.onRouteAmount;
}
}
else
{
shellKeyValuePairs.Add(spaceInfo.spaceCode, spaceInfo.onRouteAmount);
}
}
}
}
/// <summary>
/// 读取内胆已下发任务的货道信息读取后将货道编号及在途数量写入Dictionary进行比较在途数减少则入库完成
/// </summary>
private void RealReadLinerPlcSpace()
{
if (linerTaskInfos != null)
{
List<string> spaceCodes = linerTaskInfos.Select(x => x.spaceCode).Distinct().ToList();
for (int i = 0; i < spaceCodes.Count; i++)
{
string spaceCode = spaceCodes[i];
BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { storeCode = appConfig.linerStoreCode, spaceCode = spaceCode };
spaceInfo = ReadSpaceInfoByPlc(spaceInfo);
if (linerKeyValuePairs.ContainsKey(spaceInfo.spaceCode))
{
linerKeyValuePairs.TryGetValue(spaceInfo.spaceCode, out int value);
//判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成
//如果前次数据不大于当前数据则更新字典中存放的数据
if (value > spaceInfo.onRouteAmount)
{
//筛选任务
var list = linerTaskInfos.Where(x => x.spaceCode == spaceInfo.spaceCode).ToList();
if (list.Count > 0)
{
RealTaskInfo taskInfo = list.OrderBy(x => x.createTime).First();
InStoreFinsihEvent?.Invoke(taskInfo.storeCode, taskInfo.taskCode);
linerTaskInfos.Remove(taskInfo);
}
linerKeyValuePairs.Remove(spaceInfo.spaceCode);
}
else
{
linerKeyValuePairs[spaceInfo.spaceCode] = spaceInfo.onRouteAmount;
}
}
else
{
linerKeyValuePairs.Add(spaceInfo.spaceCode, spaceInfo.onRouteAmount);
}
}
}
}
#endregion
@ -415,7 +576,7 @@ namespace Aucma.Scada.Business
if (flag)
{
_plc.writeInt32ByAddress(spaceAddress.onStore, spaceStock + 1);
_plc.writeInt32ByAddress(spaceAddress.onRoute, onRouteAmount - 1);
//_plc.writeInt32ByAddress(spaceAddress.onRoute, onRouteAmount - 1);
}
else
{

@ -8,14 +8,12 @@
[shell_inStore_address]
入库货道号=D7000
入库应答字=D7010
入库完成=D7020
入库任务号=
备用字=D7020
#内胆入库地址
[liner_inStore_address]
入库货道号=D7000
入库应答字=D7010
入库完成=D7020
入库完成=
备用字=D7020
#箱壳出库地址
[shell_outStore_address]
出库货道号=D7100
@ -23,7 +21,6 @@
出库完成=D7120
出库应答字=D7130
备用字=D7140
出库任务号=
#内胆出库地址
[liner_outStore_address]
出库货道号=D7100
@ -31,4 +28,3 @@
出库完成=D7120
出库应答字=D7130
备用字=D7140
出库任务号=

Loading…
Cancel
Save