Commit 7bbe83b1 张东亮

20220730 进仓门口连续流入托盘问题处理

1 个父辈 6595b475
......@@ -364,8 +364,7 @@ namespace OnlineStore.AssemblyLine
{
MessageBox.Show(lineBean.Name + "当前状态:" + lineBean.runStatus + ",不能启动!");
return;
}
RFIDManager.ClearAllBuff();
}
LogUtil.info("点击 开始启动");
startTimer.Interval = 300;
startTimer.Elapsed += timer_Elapsed;
......@@ -447,7 +446,6 @@ namespace OnlineStore.AssemblyLine
MessageBox.Show(lineBean.Name + "流水线未启动,无法复位");
return;
}
RFIDManager.ClearAllBuff();
LogUtil.info(lineBean.Name + "点击:复位");
lineBean.Reset();
}
......
......@@ -205,7 +205,7 @@ namespace OnlineStore.DeviceLibrary
if (Config.SidesWayNum <= 0)
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_Stop2Down);
CheckLog("托盘检测:" + SecondMoveInfo.SLog + "阻挡1上升,等待FL_TrayCheck=1 ,最多等待30秒");
CheckLog("托盘检测:" + SecondMoveInfo.SLog + "阻挡1上升,等待FL_TrayCheck=1");//,最多等待30秒
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.FL_TrayCheck, IO_VALUE.HIGH));
//SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
//SecondMoveInfo.OneWaitCanEndStep = true;
......
......@@ -107,10 +107,12 @@ namespace OnlineStore.DeviceLibrary
{
ShuntTrayNum = ShuntWaitTrayNum;
ShuntWaitTrayNum = -1;
LogUtil.debug($"UpateShuntTrayNum:ShuntTrayNum={ShuntTrayNum},ShuntWaitTrayNum=-1");
}
public void ShuntStop()
{
ShuntWaitTrayNum = -1;
LogUtil.debug($"ShuntWaitTrayNum=-1");
ShuntCheck1Watch.Stop();
shuntCheck4Watch.Stop();
......@@ -249,18 +251,22 @@ namespace OnlineStore.DeviceLibrary
else
{
Shunt_MoveInfo.NextMoveStep(LineMoveStep.Shunt04_Stop1Down);
LogUtil.info(Name + "[" + ShuntTrayNum + "]" + "分流横移: 不需要分流,直接放行,Shunt_StopDown1_Front 下降1200 ");
IOMove(IO_Type.Shunt_StopDown1_Front, IO_VALUE.HIGH, 1200);
LogUtil.info(Name + "[" + ShuntTrayNum + "]" + "分流横移: 不需要分流,直接放行,Shunt_StopDown1_Front ");
IOMove(IO_Type.Shunt_StopDown1_Front, IO_VALUE.HIGH);//1200
Shunt_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Shunt_StopDown1_Front, IO_VALUE.HIGH));
Shunt_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Shunt_Check1_Front, IO_VALUE.LOW));
}
}
else if (Shunt_MoveInfo.MoveStep.Equals(LineMoveStep.Shunt04_Stop1Down))
{
Shunt_MoveInfo.NextMoveStep(LineMoveStep.Shunt05_WaitCheck1Low);
ShuntLog("分流横移: 不需要分流,等待检测1信号消失 ");
ShuntLog("分流横移: 不需要分流,等待检测1信号消失300ms ");
Shunt_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
Shunt_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Shunt_Check1_Front, IO_VALUE.LOW));
}
else if (Shunt_MoveInfo.MoveStep.Equals(LineMoveStep.Shunt05_WaitCheck1Low))
{
IOMove(IO_Type.Shunt_StopDown1_Front, IO_VALUE.LOW);
Shunt_MoveInfo.EndMove();
ShuntLog("分流横移: 已离开 ");
}
......
......@@ -61,6 +61,11 @@ namespace OnlineStore.DeviceLibrary
ClampNeedCheck = config.DIList.ContainsKey(IO_Type.ClampCylinder_Check);
UpdownAxis = new AxisBean(config.UpDown_Axis, Name);
readBuffRfidTimer = new System.Timers.Timer();
readBuffRfidTimer.Enabled = false;
readBuffRfidTimer.Interval = 300;
readBuffRfidTimer.Elapsed += ReadRfidBuff;
readBuffRfidTimer.AutoReset = true;
}
public override bool StartRun(bool isDebug = false)
......@@ -177,6 +182,11 @@ namespace OnlineStore.DeviceLibrary
}
private void ResetEnd()
{
//启动rfid监听
//readBuffRfidThread = new Thread(ReadRfidBuff);
//readBuffRfidThread.IsBackground = true;
//readBuffRfidThread.Start();
readBuffRfidTimer.Enabled = true;
LogInfo(MoveInfo.MoveType + " 完成!");
runStatus = LineRunStatus.Runing;
MoveInfo.EndMove();
......@@ -232,6 +242,7 @@ namespace OnlineStore.DeviceLibrary
CheckAndMove(IO_Type.ClampCylinder_Slack, IO_VALUE.LOW);
CheckAndMove(IO_Type.ClampCylinder_Tighten, IO_VALUE.LOW);
runStatus = LineRunStatus.Wait;
readBuffRfidTimer.Enabled = false;
}
......
......@@ -7,6 +7,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
......@@ -14,7 +15,7 @@ namespace OnlineStore.DeviceLibrary
{
public class RFIDManager
{
private static int DefaultTrayNum = ConfigAppSettings.GetIntValue(Setting_Init.DefaultTrayNum);
public static int DefaultTrayNum = ConfigAppSettings.GetIntValue(Setting_Init.DefaultTrayNum);
private static ReadAll readAll = new ReadAll("TheRFID");
private static bool IsOpen = false;
private static ConcurrentDictionary<string, string> LastRfidMap = new ConcurrentDictionary<string, string>();
......@@ -40,53 +41,6 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("Open 出错:" + ex.ToString());
}
}
public static ConcurrentDictionary<string, ConcurrentQueue<RFIDBuff>> RfidBuff = new ConcurrentDictionary<string, ConcurrentQueue<RFIDBuff>>();
static int getFirstTrayNum(string ip, int curNum)
{
RFIDBuff rFIDBuff = new RFIDBuff() { TrayNum = curNum, UpdateTime = DateTime.Now };
if (!RfidBuff.ContainsKey(ip))
{
RfidBuff.TryAdd(ip, new ConcurrentQueue<RFIDBuff>());
RfidBuff[ip].Enqueue(rFIDBuff);
}
else
{
if (!RfidBuff[ip].Contains(rFIDBuff))
RfidBuff[ip].Enqueue(rFIDBuff);
}
LogUtil.info($"[{ip}]加入缓存:{JsonHelper.SerializeObject(rFIDBuff)}");
if (RfidBuff[ip].TryDequeue(out RFIDBuff rFID))
{
LogUtil.info($"[{ip}]取第一个RFID:{JsonHelper.SerializeObject(rFID)}");
return rFID.TrayNum;
}
else
return 0;
}
static void clearTrayNumBuff(string ip)
{
//if (RfidBuff.ContainsKey(ip))
//{
// if (RfidBuff[ip].Count>0)
// RfidBuff[ip] = new ConcurrentQueue<RFIDBuff>();
//}
//LogUtil.info($"[{ip}]清除RFID缓存");
}
public static void ClearAllBuff()
{
//RfidBuff = new ConcurrentDictionary<string, ConcurrentQueue<RFIDBuff>>();
//LogUtil.info($"清除所有RFID缓存");
}
public static bool CheckHasSecond(int subType)
{
//string ip = GetRFIP(subType);
//if (RfidBuff.ContainsKey(ip))
//{
// if (RfidBuff[ip].Count > 0)
// return true;
//}
return false;
}
public static int GetTrayNum(int subType, bool isClear = false)
{
if (DefaultTrayNum > 0)
......@@ -109,7 +63,7 @@ namespace OnlineStore.DeviceLibrary
{
if (data.RFType.Equals('E'))
{
return data.Num;// return getFirstTrayNum(ip, data.Num);
return data.Num;
}
else if (data.RFType > 0)
{
......@@ -139,7 +93,6 @@ namespace OnlineStore.DeviceLibrary
string ip = GetRFIP(subType);
RFIDData data = ReadRFID(ip, true);
clearTrayNumBuff(ip);
}
catch (Exception ex)
{
......@@ -210,16 +163,8 @@ namespace OnlineStore.DeviceLibrary
}
public class RFIDBuff
{
public int TrayNum { get; set; }
public DateTime UpdateTime { get; set; }
public override bool Equals(object obj)
{
RFIDBuff buf = obj as RFIDBuff;
if (buf == null)
return false;
return this.TrayNum.Equals(buf.TrayNum);
}
public RFIDData FIDData { get; set; }
public int TrayNum { get { return FIDData.Num; } }
}
public class RFIDData
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!