Commit 97338d73 LN

增加入库任务队列

1 个父辈 b37b7f38
...@@ -66,6 +66,8 @@ namespace OnlineStore.ACSquareStore ...@@ -66,6 +66,8 @@ namespace OnlineStore.ACSquareStore
InitPosDebugBox(); InitPosDebugBox();
axisMoveControl1.LoadData(StoreManager.Store.moveAxisList.ToArray()); axisMoveControl1.LoadData(StoreManager.Store.moveAxisList.ToArray());
tabControl1.TabPages.Remove(tabPage1); tabControl1.TabPages.Remove(tabPage1);
StoreManager.CameraA.camera_event += CameraA_camera_event;
LoadOk = true; LoadOk = true;
} }
#region 库位调试 #region 库位调试
...@@ -895,8 +897,9 @@ namespace OnlineStore.ACSquareStore ...@@ -895,8 +897,9 @@ namespace OnlineStore.ACSquareStore
{ {
store.autoNext = false; store.autoNext = false;
btnStartAuTo.Text = "开始自动出入库"; btnStartAuTo.Text = "开始自动出入库";
if (store.waitOutStoreList.Count > 0)
store.waitOutStoreList.Clear(); LogUtil.info("停止自动出入库,清空队列中的出库任务");
store.clearOutList();
} }
else else
{ {
......
...@@ -1049,7 +1049,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1049,7 +1049,7 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
bool noInStore = waitOutStoreList.Count <= 0; bool noInStore = waitOutStoreList.Count <= 0;
if (CurrInOutACount >= this.Config.Box_ResetACount &&noInStore) if (CurrInOutACount >= this.Config.Box_ResetACount && noInStore)
{ {
if (storeRunStatus < StoreRunStatus.Runing || StoreMove.MoveType == StoreMoveType.InStore || StoreMove.MoveType == StoreMoveType.OutStore) if (storeRunStatus < StoreRunStatus.Runing || StoreMove.MoveType == StoreMoveType.InStore || StoreMove.MoveType == StoreMoveType.OutStore)
{ {
...@@ -1075,16 +1075,27 @@ namespace OnlineStore.DeviceLibrary ...@@ -1075,16 +1075,27 @@ namespace OnlineStore.DeviceLibrary
// else if (LineConnect.CanStartOut() || IsDebug) // else if (LineConnect.CanStartOut() || IsDebug)
else else
{ {
InOutPosInfo currInOutFixture = null; InOutPosInfo currInOutFixture = null;
lock (waitOutListLock)
bool inOk = waitInStoreList.TryDequeue(out currInOutFixture);
//优先执行入库
if (inOk&&currInOutFixture!=null)
{ {
if (waitOutStoreList.Count > 0 && CanStarInOut()) LogUtil.info(LOGGER, StoreName + "开始执行排队中的入库【" + currInOutFixture.ToStr() + "】");
bool result = StartInStoreMove(new InOutParam(currInOutFixture));
if (!result)
{ {
currInOutFixture = waitOutStoreList[0]; LogUtil.info(LOGGER, StoreName + " 执行排队中的入库【" + currInOutFixture.ToStr() + "】失败,重新加入等待队列");
waitOutStoreList.RemoveAt(0); AddWaiInInfo(currInOutFixture);
} }
} }
if (currInOutFixture != null) else
{
bool outOk = waitOutStoreList.TryDequeue(out currInOutFixture);
if (outOk&&currInOutFixture != null)
{ //出库 { //出库
LogUtil.info(LOGGER, StoreName + "开始执行排队中的出库【" + currInOutFixture.ToStr() + "】"); LogUtil.info(LOGGER, StoreName + "开始执行排队中的出库【" + currInOutFixture.ToStr() + "】");
...@@ -1098,6 +1109,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1098,6 +1109,7 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LOGGER, "处理出入库排队列表出错:" + ex.ToString()); LogUtil.error(LOGGER, "处理出入库排队列表出错:" + ex.ToString());
...@@ -1218,7 +1230,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1218,7 +1230,7 @@ namespace OnlineStore.DeviceLibrary
string plateW = data[ParamDefine.plateW]; string plateW = data[ParamDefine.plateW];
string plateH = data[ParamDefine.plateH]; string plateH = data[ParamDefine.plateH];
int door = Convert.ToInt32(data[ParamDefine.door]); int door = Convert.ToInt32(data[ParamDefine.door]);
InOutPosInfo inoutInfo = new InOutPosInfo(message, posId, plateH, plateW,door); InOutPosInfo inoutInfo = new InOutPosInfo(message, posId, plateH, plateW, door);
//根据发送的posId获取位置列表 //根据发送的posId获取位置列表
ACSquareSPosition position = CSVPositionReader<ACSquareSPosition>.GetPositon(posId); ACSquareSPosition position = CSVPositionReader<ACSquareSPosition>.GetPositon(posId);
...@@ -1235,11 +1247,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -1235,11 +1247,17 @@ namespace OnlineStore.DeviceLibrary
//如果当前正在出入库中,需要记录下来,等待空闲时执行 //如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:【" + inoutInfo.ToStr() + "】开始入库!"); LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:【" + inoutInfo.ToStr() + "】开始入库!");
InOutParam param = new InOutParam(inoutInfo); InOutParam param = new InOutParam(inoutInfo);
StartInStoreMove(param); bool result = StartInStoreMove(param);
if (!result)
{
AddWaiInInfo(inoutInfo);
LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:【" + inoutInfo.ToStr() + "】执行失败,加入等待队列 ");
}
} }
else else
{ {
LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:【" + inoutInfo.ToStr() + "】 正在忙碌中,无法入库!"); AddWaiInInfo(inoutInfo);
LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:【" + inoutInfo.ToStr() + "】 正在忙碌中,无法入库,加入等待队列");
} }
} }
......
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -258,7 +259,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -258,7 +259,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 开始入库移动移动 /// 开始入库移动移动
/// </summary> /// </summary>
public override void StartInStoreMove(InOutParam param) public override bool StartInStoreMove(InOutParam param)
{ {
startInStoreTime = DateTime.Now; startInStoreTime = DateTime.Now;
string posId = param != null ? param.PosInfo.PosId : ""; string posId = param != null ? param.PosInfo.PosId : "";
...@@ -268,24 +269,24 @@ namespace OnlineStore.DeviceLibrary ...@@ -268,24 +269,24 @@ namespace OnlineStore.DeviceLibrary
if (!LoadParamPosition(param)) if (!LoadParamPosition(param))
{ {
LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,找不到库位信息"); LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,找不到库位信息");
return; return false;
} }
if (param.PosInfo.ShelfType <= 0) if (param.PosInfo.ShelfType <= 0)
{ {
LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,未设置入口位置"); LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,未设置入口位置");
return; return false;
} }
if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH)) if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{ {
LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,货叉物料检测有料"); LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,货叉物料检测有料");
WarnMsg = $"启动入库[{posId}]失败:货叉物料检测有料"; WarnMsg = $"启动入库[{posId}]失败:货叉物料检测有料";
return; return false;
} }
string doorMsg = DoorIsClose(); string doorMsg = DoorIsClose();
if (!String.IsNullOrEmpty(doorMsg)) if (!String.IsNullOrEmpty(doorMsg))
{ {
LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错, " + doorMsg); LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错, " + doorMsg);
return; return false;
} }
clearWarmMsg("启动出库"); clearWarmMsg("启动出库");
...@@ -296,6 +297,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -296,6 +297,7 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NewMove(StoreMoveType.InStore, param); StoreMove.NewMove(StoreMoveType.InStore, param);
//料盘检测 //料盘检测
StoreMove.NextMoveStep(StoreMoveStep.SI_00_TrayCheck); StoreMove.NextMoveStep(StoreMoveStep.SI_00_TrayCheck);
return true;
//if (StoreManager.UseShelfCheck) //if (StoreManager.UseShelfCheck)
//{ //{
// if (param.PosInfo.ShelfType.Equals(1)) // if (param.PosInfo.ShelfType.Equals(1))
...@@ -315,6 +317,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -315,6 +317,7 @@ namespace OnlineStore.DeviceLibrary
else else
{ {
LogUtil.error(LOGGER, StoreName + " 启动【" + posId + "】入库出错,当前状态,storeStatus=" + storeRunStatus); LogUtil.error(LOGGER, StoreName + " 启动【" + posId + "】入库出错,当前状态,storeStatus=" + storeRunStatus);
return false;
} }
} }
private void SI_02_Move() private void SI_02_Move()
...@@ -841,8 +844,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -841,8 +844,12 @@ namespace OnlineStore.DeviceLibrary
} }
#endregion #endregion
public List<InOutPosInfo> waitOutStoreList = new List<InOutPosInfo>(); public ConcurrentQueue<InOutPosInfo> waitOutStoreList = new ConcurrentQueue<InOutPosInfo>();
public object waitOutListLock = "";
public ConcurrentQueue<InOutPosInfo> waitInStoreList = new ConcurrentQueue<InOutPosInfo>();
private void WaitNoTray(StoreMoveStep step) private void WaitNoTray(StoreMoveStep step)
{ {
...@@ -866,13 +873,34 @@ namespace OnlineStore.DeviceLibrary ...@@ -866,13 +873,34 @@ namespace OnlineStore.DeviceLibrary
StoreMove.OneWaitCanEndStep = true; StoreMove.OneWaitCanEndStep = true;
} }
} }
public void AddWaitOutInfo(InOutPosInfo code) public void AddWaitOutInfo(InOutPosInfo param)
{
List<InOutPosInfo> list = (from m in waitOutStoreList where m.PosId.Equals(param.PosId) select m).ToList<InOutPosInfo>();
if (list.Count > 0)
{
LogUtil.error(StoreName + "出库【" + param.ToStr() + "】加入等待队列失败,此库位已存在列表中");
}
waitOutStoreList.Enqueue(param);
}
public void AddWaiInInfo(InOutPosInfo param)
{ {
lock (waitOutListLock) List<InOutPosInfo> list = (from m in waitInStoreList where m.PosId.Equals(param.PosId) select m).ToList<InOutPosInfo>();
if (list.Count > 0)
{ {
waitOutStoreList.Add(code); LogUtil.error(StoreName + "入库【" + param.ToStr() + "】加入等待队列失败,此库位已存在列表中");
}
waitInStoreList.Enqueue(param);
} }
public void clearOutList()
{
LogUtil.info(StoreName + "重置 waitOutStoreList");
waitOutStoreList = new ConcurrentQueue<InOutPosInfo>();
} }
private string autoInoutCode = "AUTOINOUT"; private string autoInoutCode = "AUTOINOUT";
private void InOutEndProcess(StoreMoveType storeMoveType,string posId) private void InOutEndProcess(StoreMoveType storeMoveType,string posId)
{ {
......
...@@ -398,7 +398,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -398,7 +398,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 开始入库移动移动 /// 开始入库移动移动
/// </summary> /// </summary>
public abstract void StartInStoreMove(InOutParam param); public abstract bool StartInStoreMove(InOutParam param);
protected abstract void InStoreProcess(); protected abstract void InStoreProcess();
#endregion #endregion
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!