Commit 6848577d 张东亮

20230103

1 个父辈 a1f4eb60
......@@ -31,6 +31,10 @@
<!--是否打开托盘编码界面-->
<add key="DefaultPWD" value="123456" />
<add key="Server_Log_Open" value="0" />
<!--任务限制数量-->
<add key="TaskCnt" value="30" />
<!--横移3出库箱子等待超时时间-->
<add key="HY3_WaitTimeOut" value="30" />
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
......@@ -554,7 +554,8 @@ namespace OnlineStore.AssemblyLine
msg += t.ToStr() + "\r\n";
}
msg += "---------结束打印容器信息----------";
MessageBox.Show(msg, "容器信息列表");
var outTask = ContainerManager.getTrayList().FindAll(s => s.InOrOutStore.Equals(ContainerType.OutStore));
MessageBox.Show(msg, $"容器信息列表[{outTask?.Count??0}]/[{tray?.Count ?? 0}]");
}
......
......@@ -29,7 +29,7 @@ namespace OnlineStore.AssemblyLine
comboxType.Items.Clear();
foreach (EquipBase b in LineManager.Line.AllEquipMap.Values)
{
b.OpenRfid();
//b.OpenRfid();
List<string> value = RFIDManager.GetRFIP(b.DeviceID);
if (value != null && value.Count > 0)
{
......@@ -73,13 +73,13 @@ namespace OnlineStore.AssemblyLine
private void FrmRFIPEdit_FormClosed(object sender, FormClosedEventArgs e)
{
if (LineManager.Line.runStatus <= LineRunStatus.Wait)
{
foreach (EquipBase b in LineManager.Line.AllEquipMap.Values)
{
b.CloseRfid();
}
}
//if (LineManager.Line.runStatus <= LineRunStatus.Wait)
//{
// foreach (EquipBase b in LineManager.Line.AllEquipMap.Values)
// {
// b.CloseRfid();
// }
//}
}
}
}
......@@ -49,5 +49,6 @@ namespace OnlineStore.Common
public static string DisTraySave = "DisTraySave";
public static string ESS_Server = "ESS_Server";
public static string Webservice = "Webservice";
public static string HY3_WaitTimeOut = "HY3_WaitTimeOut";
}
}
......@@ -169,7 +169,7 @@ namespace OnlineStore.Common
{
LogUtil.error("POST [" + url + "] ERROR:" + e.ToString(), 101);
}
if (!resultMsg.Contains("null") && resultMsg.Length != 0)
if (resultMsg.Length != 0)//!resultMsg.Contains("null") &&
{
return true;
}
......
......@@ -81,8 +81,8 @@ namespace OnlineStore.DeviceLibrary.ESS
{
ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.IN_ON_AGV);
}
else if (essModel.status.Equals("cancel"))
ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.ERROR);
//else if (essModel.status.Equals("cancel"))
// ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.ERROR);
}
else if(essModel.eventType?.Equals("task")??false)
{
......@@ -90,8 +90,8 @@ namespace OnlineStore.DeviceLibrary.ESS
{
ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.FINISHED);
}
else if (essModel.status.Equals("cancel"))
ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.ERROR);
//else if (essModel.status.Equals("cancel"))
// ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.WAIT);
}
}
else if (essModel.taskCode?.ToLower().StartsWith("out") ?? false)
......@@ -102,8 +102,8 @@ namespace OnlineStore.DeviceLibrary.ESS
{
ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.OUT_ON_AGV);
}
else if (essModel.status.Equals("cancel"))
ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.ERROR);
//else if (essModel.status.Equals("cancel"))
// ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.ERROR);
}
else if (essModel.eventType?.Equals("task") ?? false)
{
......@@ -117,8 +117,8 @@ namespace OnlineStore.DeviceLibrary.ESS
// LineManager.StartStationInStore(info.InoutParam);
//}
}
else if (essModel.status.Equals("cancel"))
ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.ERROR);
//else if (essModel.status.Equals("cancel"))
// ContainerManager.UpdateTaskStatus(essModel.containerCode, TaskStatus.ERROR);
}
}
......
......@@ -57,7 +57,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.HY_R_01StopMove);
LogInfo("开始复位,横移线体停止 ");
LineStop(MoveInfo);
if (IsHY2() &&IOValue(IO_Type.HY_BoxCheck).Equals(IO_VALUE.HIGH))
if (IsHY2() && IOValue(IO_Type.HY_BoxCheck).Equals(IO_VALUE.HIGH))
{
JackingDown(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
......@@ -275,6 +275,8 @@ namespace OnlineStore.DeviceLibrary
{
UpdateContainerCode();
}
bool hy3ToDischarge = false;
int hy3WaitTime = ConfigAppSettings.GetIntValue(Setting_Init.HY3_WaitTimeOut);
protected override void BoxProcess()
{
if (MoveInfo.IsInWait)
......@@ -327,7 +329,14 @@ namespace OnlineStore.DeviceLibrary
ContainerInfo trayInfo = ContainerManager.GetTrayInfo(CurContainerId);
if (trayInfo?.InOrOutStore == ContainerType.InStore)//入库
{
JackingDown(MoveInfo);
if (IsDischargeIdle())
{
JackingDown(MoveInfo);
}
else
{
JackingUp(MoveInfo);
}
}
else
{
......@@ -337,37 +346,44 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsStep(LineMoveStep.HY34_GetBoxInfo))
{
MoveInfo.NextMoveStep(LineMoveStep.HY35_CheckDownriver);
LogInfo(" 检查下游状态");
ContainerInfo trayInfo = ContainerManager.GetTrayInfo(CurContainerId);
if (trayInfo?.InOrOutStore == ContainerType.InStore)//入库
{
JackingDown(MoveInfo);
if (IsDischargeIdle())
{
MoveInfo.NextMoveStep(LineMoveStep.HY35_CheckDownriver);
LogInfo("入库容器,出料工位空闲,流到出料工位");
JackingDown(MoveInfo);
hy3ToDischarge = true;
}
else if(MoveInfo.IsTimeOut(hy3WaitTime))
{
MoveInfo.NextMoveStep(LineMoveStep.HY35_CheckDownriver);
LogInfo($"入库容器,等待{hy3WaitTime}秒超时,直接流转");
JackingUp(MoveInfo);
hy3ToDischarge = false;
}
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.HY35_CheckDownriver);
LogInfo("出库容器,直接流转");
JackingUp(MoveInfo);
hy3ToDischarge = false;
}
}
else if (MoveInfo.IsStep(LineMoveStep.HY35_CheckDownriver))
{
ContainerInfo trayInfo = ContainerManager.GetTrayInfo(CurContainerId);
if (trayInfo?.InOrOutStore == ContainerType.InStore)//入库
if (hy3ToDischarge)//入库
{
if (IsDischargeIdle())
{
MoveInfo.NextMoveStep(LineMoveStep.HY36_ReleaseBox);
ClearSpecifiedWarnMsg("等待出料工位空闲超时");
LogInfo(" 容器向出料工位流转");
FrontStopUp(1, MoveInfo);
StopDown(MoveInfo);
LineManager.StartDisChargeMove();
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else if (MoveInfo.IsTimeOut(30))
{
SetWarnMsg("等待出料工位空闲超时");
}
MoveInfo.NextMoveStep(LineMoveStep.HY36_ReleaseBox);
ClearSpecifiedWarnMsg("等待出料工位空闲超时");
LogInfo(" 容器向出料工位流转");
FrontStopUp(1, MoveInfo);
StopDown(MoveInfo);
LineManager.StartDisChargeMove();
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else
{
......@@ -386,12 +402,11 @@ namespace OnlineStore.DeviceLibrary
SetWarnMsg("等待横移4空闲超时");
}
}
}
else if (MoveInfo.IsStep(LineMoveStep.HY36_ReleaseBox))
{
ContainerInfo trayInfo = ContainerManager.GetTrayInfo(CurContainerId);
if (trayInfo?.InOrOutStore == ContainerType.InStore)//入库
if (hy3ToDischarge)//入库
{
if (BoxReachDischarge())
{
......@@ -435,7 +450,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.HY21_WaitBoxCheck);
LogInfo($"等待容器到位");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_BoxCheck, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
else if (MoveInfo.IsStep(LineMoveStep.HY21_WaitBoxCheck))
{
......@@ -454,11 +469,11 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.IsStep(LineMoveStep.HY23_WaitBoxLeave))
{
MoveInfo.NextMoveStep(LineMoveStep.HY24_JackingUp);
if (LineManager.IsFeedingHasBox())
{
LogInfo($"入料工位有容器,顶升不动作");
}
else
//if (LineManager.IsFeedingHasBox())
//{
// LogInfo($"入料工位有容器,顶升不动作");
//}
//else
{
LogInfo($"入料工位无容器,顶升上升");
JackingUp(MoveInfo);
......
......@@ -800,99 +800,101 @@ namespace OnlineStore.DeviceLibrary
return msg;
}
private bool conIsPro = false;
private object conIsPro = new object();
private DateTime conLastTime = DateTime.Now;
private DateTime callOutLastTime = DateTime.Now;
private void ServerConTimer_Elapsed(object sender, ElapsedEventArgs e)
{
TimeSpan span = DateTime.Now - conLastTime;
if (conIsPro && span.TotalSeconds < 30)
{
return;
}
try
if(Monitor.TryEnter(conIsPro))
{
conIsPro = true;
conLastTime = DateTime.Now;
#region 异常上报
//List<AlarmMsg> alarmList = new List<AlarmMsg>();
//foreach (EquipBase equip in AllEquipMap.Values)
//{
// if (equip.alarmType.Equals(LineAlarmType.None) || equip.WarnMsg.Contains("等待空托盘到达超时"))
// {
// continue;
// }
// else if (equip.alarmType.Equals(LineAlarmType.None) || equip.WarnMsg.Contains("获取库位号超时"))
// {
// continue;
// }
// else
// {
// alarmList.Add(new AlarmMsg(equip.Name, "line." + equip.Name + "_" + equip.alarmType, equip.WarnMsg));
// }
//}
//SServerManager.updateDeviceAlarmMsg(alarmList);
#endregion
Dictionary<string, string> map = new Dictionary<string, string>();
//工位状态定时上报
foreach (EquipBase equip in AllEquipMap.Values)
try
{
if (equip is StationEquip)
#region 异常上报 未使用
//List<AlarmMsg> alarmList = new List<AlarmMsg>();
//foreach (EquipBase equip in AllEquipMap.Values)
//{
// if (equip.alarmType.Equals(LineAlarmType.None) || equip.WarnMsg.Contains("等待空托盘到达超时"))
// {
// continue;
// }
// else if (equip.alarmType.Equals(LineAlarmType.None) || equip.WarnMsg.Contains("获取库位号超时"))
// {
// continue;
// }
// else
// {
// alarmList.Add(new AlarmMsg(equip.Name, "line." + equip.Name + "_" + equip.alarmType, equip.WarnMsg));
// }
//}
//SServerManager.updateDeviceAlarmMsg(alarmList);
#endregion
Dictionary<string, string> map = new Dictionary<string, string>();
//工位状态定时上报
foreach (EquipBase equip in AllEquipMap.Values)
{
RFIDData data = equip.UpdateStationCode();
if (data.IsValidated())
if (equip is StationEquip)
{
map.Add($"s{equip.DeviceID}", data.StrData);
//自动上传出库料箱被其他工位拿走的状态
if (ContainerManager.GetOutStoreBox(data.ToContainerId()))
RFIDData data = equip.UpdateStationCode();
if (data.IsValidated())
{
ContainerManager.UpdateTaskStatus(data.ToContainerId(), TaskStatus.FINISHED, $"s{equip.DeviceID}");
LogUtil.info($"出库容器被拿上工位s{equip.DeviceID},自动完成:{data.ToContainerId()}");
map.Add($"s{equip.DeviceID}", data.StrData);
//自动上传出库料箱被其他工位拿走的状态
if (ContainerManager.GetOutStoreBox(data.ToContainerId()))
{
ContainerManager.UpdateTaskStatus(data.ToContainerId(), TaskStatus.FINISHED, $"s{equip.DeviceID}");
LogUtil.info($"出库容器被拿上工位s{equip.DeviceID},自动完成:{data.ToContainerId()}");
}
}
else
{
map.Add($"s{equip.DeviceID}", "");
}
}
else
{
map.Add($"s{equip.DeviceID}", "");
}
}
}
List<string> inTask = SServerManager.UploadStationInfo(Name, map);
if (inTask != null && inTask.Count > 0)
{
foreach (var item in inTask)
List<string> inTask = SServerManager.UploadStationInfo(Name, map);
if (inTask != null && inTask.Count > 0)
{
if (map.ContainsKey(item))
foreach (var item in inTask)
{
ContainerManager.AddOrUpdateContainerInfo(item, map[item]);
if (map.ContainsKey(item))
{
ContainerManager.AddOrUpdateContainerInfo(item, map[item]);
}
}
}
}
List<OutTaskData> outTask = SServerManager.GetOutTask(Name);
if (outTask != null && outTask.Count > 0)
{
RobotStates states = SServerManager.GetRobotState();
if (LineManager.RobotIsIdle(states) || LineManager.CheckRobotTrayIsInstore(states))
List<OutTaskData> outTask = SServerManager.GetOutTask(Name);
if (outTask != null && outTask.Count > 0)
{
foreach (var item in outTask)
RobotStates states = SServerManager.GetRobotState();
if (LineManager.RobotIsIdle(states) || LineManager.CheckRobotTrayIsInstore(states))
{
ContainerManager.AddOrUpdateContainerInfo(item.barcode);
TimeSpan span1 = DateTime.Now - callOutLastTime;
if (span1.TotalSeconds > 15)
{
callOutLastTime = DateTime.Now;
foreach (var item in outTask)
{
ContainerManager.AddOrUpdateContainerInfo(item.barcode);
}
}
}
}
}
//发送呼叫任务
ContainerManager.HandlePendingTask();
//上报容器状态
ContainerManager.UpdateContainerStatus();
}
catch (Exception ex)
{
LogUtil.error("ServerConTimer_Elapsed 出错:" + ex.ToString());
}
finally
{
Monitor.Exit(conIsPro);
}
//发送呼叫任务
ContainerManager.HandlePendingTask();
//上报容器状态
ContainerManager.UpdateContainerStatus();
}
catch (Exception ex)
{
LogUtil.error("ServerConTimer_Elapsed 出错:" + ex.ToString());
}
finally
{
conIsPro = false;
}
}
......
......@@ -166,11 +166,22 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.SI_05_WaitBoxLeave);
LogInfo($"等待出库容器被拿走");
AddWaitBoxCheck(false);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(15000));
MoveInfo.OneWaitCanEndStep = true;
}
else if (MoveInfo.IsStep(LineMoveStep.SI_05_WaitBoxLeave))
{
MoveInfo.NextMoveStep(LineMoveStep.SI_06_WaitBoxAtStation);
LogInfo($"出库容器被拿走,等待容器到达工作台");
if(IOValue(IO_Type.Stop_BoxCheck).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(LineMoveStep.SI_08_StopDown);
LogInfo($"出库容器被拿走超时,放行");
StopDown(MoveInfo);
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.SI_06_WaitBoxAtStation);
LogInfo($"出库容器被拿走,等待容器到达工作台");
}
}
else if (MoveInfo.IsStep(LineMoveStep.SI_06_WaitBoxAtStation))
{
......@@ -187,28 +198,30 @@ namespace OnlineStore.DeviceLibrary
}
}
ClearSpecifiedWarnMsg($"等待容器到达下游");
if (MoveInfo.IsTimeOut(30))
if (MoveInfo.IsTimeOut(15))
{
MoveInfo.NextMoveStep(LineMoveStep.SI_07_AllStopDown);
if (ContainerManager.GetInTaskCnt(DeviceID) > 0)
{
LogInfo($"容器到达工作台30秒超时,该工位将有出库容器到达,前阻挡下降");
FrontStopDown(MoveInfo);
//if (ContainerManager.GetInTaskCnt(DeviceID) > 0)
//{
// LogInfo($"容器到达工作台30秒超时,该工位将有出库容器到达,前阻挡下降");
// FrontStopDown(MoveInfo);
}
else if (ContainerManager.GetOutTaskCnt(DeviceID) > 0)
//}
//else if (ContainerManager.GetOutTaskCnt(DeviceID) > 0)
//{
// LogInfo($"容器到达工作台30秒超时,该工位将有入库容器离开,阻挡下降");
// StopDown(MoveInfo);
//}
//else
if(DeviceID==5)
{
LogInfo($"容器到达工作台30秒超时,该工位将有入库容器离开,阻挡下降");
StopDown(MoveInfo);
}
else if(DeviceID==5)
{
LogInfo($"容器到达工作台30秒超时,前阻挡下降");
LogInfo($"容器到达工作台15秒超时,前阻挡下降");
FrontStopDown(MoveInfo);
}
else
{
LogInfo($"容器到达工作台30秒超时,所有阻挡下降");
LogInfo($"容器到达工作台15秒超时,所有阻挡下降");
StopDown(MoveInfo);
FrontStopDown(MoveInfo);
}
......@@ -220,17 +233,19 @@ namespace OnlineStore.DeviceLibrary
if (CurShelfId_Station.Equals(CurContainerId))
{
MoveInfo.NextMoveStep(LineMoveStep.SI_07_AllStopDown);
if (ContainerManager.GetInTaskCnt(DeviceID) > 0)
{
LogInfo($" 容器到达工作台,该工位将有出库容器到达,前阻挡下降");
FrontStopDown(MoveInfo);
}
else if (ContainerManager.GetOutTaskCnt(DeviceID) > 0)
{
LogInfo($"容器到达工作台,该工位将有入库容器离开,阻挡下降");
StopDown(MoveInfo);
}
else if (DeviceID == 5)
//if (ContainerManager.GetInTaskCnt(DeviceID) > 0)
//{
// LogInfo($" 容器到达工作台,该工位将有出库容器到达,前阻挡下降");
// FrontStopDown(MoveInfo);
//}
//else if (ContainerManager.GetOutTaskCnt(DeviceID) > 0)
//{
// LogInfo($"容器到达工作台,该工位将有入库容器离开,阻挡下降");
// StopDown(MoveInfo);
//}
//else
if (DeviceID == 5)
{
LogInfo($"箱子到达工作台,前阻挡下降");
FrontStopDown(MoveInfo);
......@@ -272,17 +287,19 @@ namespace OnlineStore.DeviceLibrary
}
ClearSpecifiedWarnMsg($"等待容器到达下游");
MoveInfo.NextMoveStep(LineMoveStep.SI_10_FrontStopDown);
if (ContainerManager.GetInTaskCnt(DeviceID) > 1)
{
LogInfo($"该工位将有出库容器到达,阻挡上升,前阻挡下降");
StopUp(MoveInfo);
FrontStopDown(MoveInfo);
}
else if (ContainerManager.GetOutTaskCnt(DeviceID) > 0)
{
LogInfo($"该工位将有入库容器离开,前阻挡保持上升");
}
else if (DeviceID == 5)//工位5放行一个容器后前阻挡上升
//if (ContainerManager.GetInTaskCnt(DeviceID) > 1)
//{
// LogInfo($"该工位将有出库容器到达,阻挡上升,前阻挡下降");
// StopUp(MoveInfo);
// FrontStopDown(MoveInfo);
//}
//else if (ContainerManager.GetOutTaskCnt(DeviceID) > 0)
//{
// LogInfo($"该工位将有入库容器离开,前阻挡保持上升");
//}
//else
if (DeviceID == 5)//工位5放行一个容器后前阻挡上升
{
LogInfo($"阻挡上升");
StopUp(MoveInfo);
......
......@@ -39,8 +39,8 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.SO_02_WaitBoxInToLine);
AddWaitBoxCheck(true);
WaitTime(3000);
//MoveInfo.OneWaitCanEndStep = true;
WaitTime(15000);
MoveInfo.OneWaitCanEndStep = true;
LogInfo($"等待箱子离开工作站");
}
else if (MoveInfo.IsStep(LineMoveStep.SO_02_WaitBoxInToLine))
......
......@@ -153,7 +153,7 @@ namespace OnlineStore.DeviceLibrary
Application.Exit();
}
return false;
}
}
/// <summary>
/// 箱子是否可以进入料工位
/// </summary>
......@@ -172,7 +172,7 @@ namespace OnlineStore.DeviceLibrary
}
public static void StartStationInStore(InOutParam inOutParam)
{
if(Line?.AllEquipMap.ContainsKey(inOutParam.DeviceId)??false)
if (Line?.AllEquipMap.ContainsKey(inOutParam.DeviceId) ?? false)
{
Line?.AllEquipMap[inOutParam.DeviceId].StartInStoreMove(inOutParam);
}
......@@ -192,22 +192,26 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
/// <param name="robotStates"></param>
/// <returns>true:空闲</returns>
public static bool RobotIsIdle(RobotStates robotStates)
public static bool RobotIsIdle(RobotStates robotStates)
{
try
{
if(robotStates !=null && robotStates.robots!=null)
if (robotStates != null && robotStates.robots != null)
{
foreach (var item in robotStates.robots)
{
if (!item.state.Equals("IDLE")) continue;
var fullTray = item.trays.FindAll(s => s.containerCode != null);
if (fullTray == null) return true;
if (fullTray == null || fullTray.Count == 0)
{
LogUtil.info($"机器人空闲且背篓为空,允许发送出库任务:【{JsonHelper.SerializeObject(item)}】");
return true;
}
}
}
}
catch(Exception ex)
catch (Exception ex)
{
LogUtil.error("RobotTrayIsEmpty", ex);
}
......@@ -233,7 +237,10 @@ namespace OnlineStore.DeviceLibrary
{
var instore = ContainerManager.GetTrayInfo(tray.containerCode);
if (instore != null && instore.InOrOutStore.Equals(ContainerType.InStore))
{
LogUtil.info($"机器人背篓有入库容器,允许发送出库任务:【{JsonHelper.SerializeObject(item)}】【{JsonHelper.SerializeObject(instore)}】");
return true;
}
}
}
}
......@@ -246,13 +253,18 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
static int taskCnt = ConfigAppSettings.GetIntValue("TaskCnt");
/// <summary>
/// 检查容器任务数是否超限
/// 检查容器出库任务数是否超限
/// </summary>
/// <returns></returns>
public static bool CheckTaskCntIsInLimit()
{
return ContainerManager.getTrayList().Count <= 30;
var outTask = ContainerManager.getTrayList().FindAll(s => s.InOrOutStore.Equals(ContainerType.OutStore));
if (taskCnt > 0)
return outTask?.Count <= taskCnt;//30
else
return outTask?.Count <= 8;//30
}
#endregion
}
......
......@@ -48,18 +48,18 @@ namespace OnlineStore.DeviceLibrary
/// <returns></returns>
public static int CntofContainerOnLine()
{
try
{
List<ContainerInfo> containers= getTrayList().FindAll(s=>(s.Status.Equals(TaskStatus.IN_ON_LINE) || s.Status.Equals(TaskStatus.OUT_ON_LINE)));
if(containers!=null)
{
return containers.Count;
}
}
catch (Exception ex)
{
LogUtil.error($"CntofContainerOnLine", ex);
}
//try
//{
// List<ContainerInfo> containers= getTrayList().FindAll(s=>(s.Status.Equals(TaskStatus.IN_ON_LINE) || s.Status.Equals(TaskStatus.OUT_ON_LINE)));
// if(containers!=null)
// {
// return containers.Count;
// }
//}
//catch (Exception ex)
//{
// LogUtil.error($"CntofContainerOnLine", ex);
//}
return 0;
}
/// <summary>
......@@ -84,7 +84,7 @@ namespace OnlineStore.DeviceLibrary
{
foreach (var item in getTrayList())
{
bool rtn = SServerManager.UpdateLocInfo("ContainerManager", item.ContainerValidCode, item.Status, item.CurLoc);
bool rtn = SServerManager.UpdateLocInfo("ContainerManager", item.ContainerValidCode, item.Status, item.CurLoc,out bool canRemove);
if (rtn)
{
if (item.Status.Equals(TaskStatus.ERROR))
......@@ -95,7 +95,12 @@ namespace OnlineStore.DeviceLibrary
else if (item.Status.Equals(TaskStatus.FINISHED))
{
bool res = containerInfoMap.TryRemove(item.ContainerValidCode, out ContainerInfo containerInfo);
LogUtil.info($"任务完成【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】");
LogUtil.info($"任务完成,自动删除该任务【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】");
}
else if(canRemove)
{
bool res = containerInfoMap.TryRemove(item.ContainerValidCode, out ContainerInfo containerInfo);
LogUtil.info($"任务不存在,自动删除该任务【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】");
}
}
}
......@@ -454,7 +459,6 @@ namespace OnlineStore.DeviceLibrary
static object saveObj = new object();
static void SaveMapToFile()
{
LogUtil.info("SaveMapToFile");
if (Monitor.TryEnter(saveObj, 500))
{
try
......
......@@ -22,12 +22,12 @@ namespace OnlineStore.DeviceLibrary
{
if (RfidMap.ContainsKey(ip))
{
return;
if (RfidMap[ip].IsConn)
RfidMap[ip].Close();
RfidMap.TryRemove(ip, out PuYueRFID_C2S puYueRFID_C2S);
}
PuYueRFID_C2S rfid = new PuYueRFID_C2S(ip, true);
//rfid.StartAddr = 0x20;
//rfid.Length = 16;
rfid.ID_Changed_Event += Rfid_ID_Changed_Event;
//rfid.ID_Changed_Event += Rfid_ID_Changed_Event;
if (rfid.IsConn)
rfid.Close();
else
......
......@@ -12,6 +12,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
namespace OnlineStore.DeviceLibrary
{
......@@ -314,7 +315,6 @@ namespace OnlineStore.DeviceLibrary
}
return list;
}
/// <summary>
/// B 获取出库任务列表
/// </summary>
......@@ -420,9 +420,10 @@ namespace OnlineStore.DeviceLibrary
/// <param name="status">状态</param>
/// <param name="locInfo">位置</param>
/// <returns></returns>
public static bool UpdateLocInfo(string deviceName, string barcode, string status, string locInfo = "")
public static bool UpdateLocInfo(string deviceName, string barcode, string status, string locInfo ,out bool canRemove)
{
string msg = "";
canRemove = false;
try
{
if (String.IsNullOrEmpty(barcode))
......@@ -452,22 +453,25 @@ namespace OnlineStore.DeviceLibrary
}
else if (serverResult.code.Equals(303).Equals(true))
{
canRemove = true;
// code: 0为正常,其他为异常, msg: 消息, data: 为空
msg = deviceName + " UpdateTrayLoc 任务已完成【" + barcode + "】【" + status + "】【" + locInfo + "】 :" + "【" + serverResult.code + "】" + serverResult.msg;
LogUtil.info(msg);
//LogUtil.info(msg);
return true;
}
else if (serverResult.code.Equals(0).Equals(false))
else if (serverResult.code.Equals(0).Equals(true))
{
// code: 0为正常,其他为异常, msg: 消息, data: 为空
msg = deviceName + " UpdateTrayLoc【" + barcode + "】【" + status + "】【" + locInfo + "】 :" + "【" + serverResult.code + "】" + serverResult.msg;
// LogUtil.info(msg);
return true;
}
if (!msg.Equals(""))
{
LogUtil.error(msg);
return false;
}
return true;
}
catch (Exception ex)
{
......@@ -489,7 +493,9 @@ namespace OnlineStore.DeviceLibrary
try
{
string path = ess_server + Addr_GetRobotState;
if (HttpHelper.Post(path, "", out bool isTimueOut, out string outMsg))
Dictionary<string, object> tmp = new Dictionary<string, object>();
string param = JsonHelper.SerializeObject(tmp);
if (HttpHelper.Post(path, param, out bool isTimueOut, out string outMsg))
{
ResultData resultData = JsonHelper.DeserializeJsonToObject<ResultData>(outMsg);
if (resultData != null)
......
......@@ -354,19 +354,23 @@ public class PuYueRFID_C2S
}
}
object locRead = new object();
public bool ReadByte(short address, short length, out byte[] data)
{
if (length > 64)
throw new Exception("最大读取64个字节");
data = null;
byte funCode = 0x03;
byte[] startAddress = BitConverter.GetBytes(address);//0x0255
byte[] startLength = BitConverter.GetBytes((short)Math.Ceiling(length / 2d));//2
var seqhead = BitConverter.GetBytes(seq);
byte[] by = new byte[]
if (Monitor.TryEnter(locRead))
{
try
{
if (length > 64)
throw new Exception("最大读取64个字节");
data = null;
byte funCode = 0x03;
byte[] startAddress = BitConverter.GetBytes(address);//0x0255
byte[] startLength = BitConverter.GetBytes((short)Math.Ceiling(length / 2d));//2
var seqhead = BitConverter.GetBytes(seq);
byte[] by = new byte[]
{
//事物标识符
seqhead[0],
seqhead[1],
......@@ -384,56 +388,63 @@ public class PuYueRFID_C2S
startAddress[0], //起始地址
startLength[1],
startLength[0], //读个数
};
by[5] = (byte)(by.Length - 6);
byte[] result = new byte[1000];
int ulength = 0;
};
by[5] = (byte)(by.Length - 6);
byte[] result = new byte[1000];
int ulength = 0;
lock (tcpClient)
{
try
{
if (tcpClient?.Client?.Available > 0)
tcpClient?.Client?.Receive(result);
lock (tcpClient)
{
try
{
if (tcpClient?.Client?.Available > 0)
tcpClient?.Client?.Receive(result);
seqadd();
tcpClient.Client.Send(by);
Thread.Sleep(5);
ulength = tcpClient?.Client?.Receive(result)??0;
seqadd();
tcpClient.Client.Send(by);
Thread.Sleep(5);
ulength = tcpClient?.Client?.Receive(result) ?? 0;
}
catch (SocketException se)
{
return false;
}
}
var newResult = result.ToList().Take(ulength).ToList();
//aa = BitConverter.ToString(newResult);
//Console.WriteLine(aa);
if (newResult.Count > 6 && newResult[0] == seqhead[0] && newResult[1] == seqhead[1])
{
if (newResult[7] == 0x03)
{
}
catch (SocketException se)
{
return false;
}
}
var newResult = result.ToList().Take(ulength).ToList();
//aa = BitConverter.ToString(newResult);
//Console.WriteLine(aa);
if (newResult.Count > 6 && newResult[0] == seqhead[0] && newResult[1] == seqhead[1])
{
if (newResult[7] == 0x03)
{
var recvlen = BitConverter.ToInt16(new byte[] { newResult[5], newResult[4] }, 0);
if ((recvlen + 6) <= newResult.Count)
var recvlen = BitConverter.ToInt16(new byte[] { newResult[5], newResult[4] }, 0);
if ((recvlen + 6) <= newResult.Count)
{
data = newResult.GetRange(9, recvlen - 3).ToArray();
Console.WriteLine(BitConverter.ToString(newResult.ToArray()));
return true;
}
}
else if (newResult[7] == 0x83)
{
return false;
}
}
else
{
data = newResult.GetRange(9, recvlen - 3).ToArray();
Console.WriteLine(BitConverter.ToString(newResult.ToArray()));
return true;
Thread.Sleep(20);
if (tcpClient.Client.Available > 0)
_ = tcpClient.Client.Receive(result);
}
}
else if (newResult[7] == 0x83)
}finally
{
return false;
Monitor.Exit(locRead);
}
}
else
{
Thread.Sleep(20);
if (tcpClient.Client.Available > 0)
_ = tcpClient.Client.Receive(result);
}
return false;
}
/// <summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!