Commit c7401629 LN

盘点料逻辑修改。增加jison日志

1 个父辈 e835dfd3
......@@ -96,6 +96,16 @@
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<appender name="RunLog" type="log4net.Appender.RollingFileAppender">
<file value="logs/log/RunLog-line.log" />
<param name="Encoding" value="UTF-8" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value=" %m%n" />
</layout>
</appender>
<logger name="RollingLogFileAppender">
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
......@@ -108,6 +118,10 @@
<level value="Info" />
<appender-ref ref="AIOBOX" />
</logger>
<logger name="RunLog">
<level value="Info" />
<appender-ref ref="RunLog" />
</logger>
<!--<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
......
......@@ -54,7 +54,7 @@ namespace OnlineStore.AssemblyLine
[STAThread]
static void Main(string[] Args)
{
//string code = " (X: 380,Y: 148) L00000000000WG9D19055;E20191230 0180;B7H.10618.5B1008082019123004000;R0080820191230E9600";
//string r = CodeManager.ReplaceCode(code);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
......
......@@ -65,6 +65,7 @@
<Compile Include="util\NetTCPServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="util\RunLogUtil.cs" />
<Compile Include="util\TcpClient.cs" />
<Compile Include="util\TcpServer.cs" />
<Compile Include="util\UdpServer.cs" />
......
using log4net;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
namespace OnlineStore.Common
{
public class RunLogUtil
{
public static readonly ILog RunLog = LogManager.GetLogger("RunLog");
public static void ErrorLog(ErrorLog log)
{
string jsonStr = JsonHelper.SerializeObject(log);
RunLog.Error(jsonStr);
}
public static void MoveLog(MoveLog log)
{
//if (log == null || (!log.IsValid()))
//{
// return;
//}
//string jsonStr = JsonHelper.SerializeObject(log);
//RunLog.Info(jsonStr);
}
public static void MoveEndLog(MoveEndLog log)
{
if (log == null || (!log.IsValid()))
{
return;
}
string jsonStr = JsonHelper.SerializeObject(log);
RunLog.Info(jsonStr);
}
public static void AxisLog(AxisMoveLog log)
{
string jsonStr = JsonHelper.SerializeObject(log);
RunLog.Error(jsonStr);
}
}
public class BaseLog
{
[JsonProperty(Order = 0)]
public string Name { get; set; } = "三楼环形线";
[JsonProperty(Order = 1)]
public string DeviceName { get; set; } = "";
[JsonProperty(Order = 2)]
public string LogType { get; set; } = "";
[JsonProperty(Order = 3)]
public string StartTime { get; set; } = "";
[JsonProperty(Order = 4)]
public string EndTime { get; set; } = "";
[JsonProperty(Order = 5)]
public string timeSpan { get; set; } = "";
}
public class ErrorLog : BaseLog
{
public ErrorLog()
{
this.LogType = "Error";
}
public ErrorLog(string deviceName, string errType, string errMsg, DateTime startTime, DateTime endTime, string operType = "", string posid = "", string barcode = "")
{
if (operType == null) { operType = ""; }
if (posid == null) { posid = ""; }
if (barcode == null) { barcode = ""; }
if (errType == null) { errType = ""; }
if (errMsg == null) { errMsg = ""; }
this.LogType = "Error";
this.DeviceName = deviceName.Replace("-Move", "").Replace("-SMove", "").Trim();
this.ErrorType = errType.Trim();
this.ErrorMsg = errMsg.Trim();
this.StartTime = startTime.ToString("yyyy-MM-dd HH:mm:ss");
this.EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss");
this.OperateType = operType.Trim();
this.PosId = posid.Trim();
this.Barcode = barcode.Trim();
TimeSpan span = endTime - startTime;
this.timeSpan = (Math.Round(span.TotalMinutes, 2)).ToString();//两位小数的分钟
}
public bool IsValid()
{
if (string.IsNullOrEmpty(DeviceName) || String.IsNullOrEmpty(LogType) || string.IsNullOrEmpty(ErrorType) || string.IsNullOrEmpty(ErrorMsg))
{
return false;
}
return true;
}
[JsonProperty(Order = 11)]
public string ErrorType { get; set; } = "";
[JsonProperty(Order = 12)]
public string ErrorMsg { get; set; } = "";
[JsonProperty(Order = 13)]
public string OperateType { get; set; } = "";
[JsonProperty(Order = 14)]
public string PosId { get; set; } = "";
[JsonProperty(Order = 15)]
public string Barcode { get; set; } = "";
}
public class MoveLog : BaseLog
{
public MoveLog()
{
this.LogType = "Running";
}
public MoveLog(string deviceName, string moveType, string moveMsg, DateTime startTime, DateTime endTime, string posid = "", string barcode = "")
{
if (posid == null) { posid = ""; }
if (barcode == null) { barcode = ""; }
this.LogType = "Running";
this.DeviceName = deviceName.Replace("-Move", "").Replace("-SMove", "").Trim();
this.MoveType = moveType.Trim();
this.MoveMsg = moveMsg.Trim();
this.StartTime = startTime.ToString("yyyy-MM-dd HH:mm:ss");
this.EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss");
this.PosId = posid.Trim();
this.Barcode = barcode.Trim();
TimeSpan span = endTime - startTime;
this.timeSpan = (Math.Round(span.TotalMinutes, 2)).ToString();//两位小数的分钟
}
public bool IsValid()
{
if (string.IsNullOrEmpty(DeviceName) || String.IsNullOrEmpty(LogType) || string.IsNullOrEmpty(MoveType) || string.IsNullOrEmpty(MoveMsg))
{
return false;
}
return true;
}
[JsonProperty(Order = 11)]
public string MoveType { get; set; } = "";
[JsonProperty(Order = 12)]
public string MoveMsg { get; set; } = "";
[JsonProperty(Order = 13)]
public string PosId { get; set; } = "";
[JsonProperty(Order = 14)]
public string Barcode { get; set; } = "";
}
public class MoveEndLog : BaseLog
{
public MoveEndLog()
{
this.LogType = "InoutEnd";
}
public MoveEndLog(string deviceName, string moveType, DateTime startTime, DateTime endTime, string posid = "", string barcode = "")
{
if (posid == null) { posid = ""; }
if (barcode == null) { barcode = ""; }
this.LogType = "InoutEnd";
this.DeviceName = deviceName.Replace("-Move", "").Replace("-SMove", "").Trim();
this.MoveType = moveType.Trim();
this.StartTime = startTime.ToString("yyyy-MM-dd HH:mm:ss");
this.EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss");
this.PosId = posid.Trim();
this.Barcode = barcode.Trim();
TimeSpan span = endTime - startTime;
this.timeSpan = (Math.Round(span.TotalMinutes, 2)).ToString();//两位小数的分钟
}
public bool IsValid()
{
if (string.IsNullOrEmpty(DeviceName) || string.IsNullOrEmpty(MoveType))
{
return false;
}
return true;
}
[JsonProperty(Order = 11)]
public string MoveType { get; set; } = "";
[JsonProperty(Order = 12)]
public string PosId { get; set; } = "";
[JsonProperty(Order = 13)]
public string Barcode { get; set; } = "";
}
public class AxisMoveLog : BaseLog
{
public AxisMoveLog()
{
this.LogType = "Axis";
}
public AxisMoveLog(string deviceName, string axisName, string moveType, int targetP, int speed, DateTime startTime, DateTime endTime, string posid = "", string barcode = "")
{
if (posid == null) { posid = ""; }
if (barcode == null) { barcode = ""; }
this.LogType = "Axis";
this.DeviceName = deviceName.Replace("-Move", "").Replace("-SMove", "").Trim();
this.MoveType = moveType.Trim();
this.AxisName = axisName;
this.TargetPos = targetP;
this.StartTime = startTime.ToString("yyyy-MM-dd HH:mm:ss");
this.EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss");
this.PosId = posid.Trim();
this.Barcode = barcode.Trim();
TimeSpan span = endTime - startTime;
this.timeSpan = (Math.Round(span.TotalMinutes, 2)).ToString();//两位小数的分钟
this.Speed = speed;
}
public bool IsValid()
{
if (string.IsNullOrEmpty(DeviceName) || string.IsNullOrEmpty(MoveType))
{
return false;
}
return true;
}
[JsonProperty(Order = 11)]
public string AxisName { get; set; } = "";
[JsonProperty(Order = 12)]
public string MoveType { get; set; } = "";
[JsonProperty(Order = 13)]
public int TargetPos { get; set; } = 0;
[JsonProperty(Order = 14)]
public int Speed { get; set; }
[JsonProperty(Order = 15)]
public string PosId { get; set; } = "";
[JsonProperty(Order = 16)]
public string Barcode { get; set; } = "";
}
}
......@@ -182,26 +182,26 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(Name + " BusyMoveProcess 出错:" + ex.ToString());
}
}
protected void MoveTimeOut(LineMoveInfo move, string msg)
{
WarnMsg = move.Name + "[" + move.MoveStep + "] "+ msg + " [" +FormUtil.GetSpanStr( move.StepSpan()) + "]";
int logId = DeviceID * 10000 + (int)move.MoveStep;
LogUtil.error(WarnMsg, logId);
Alarm(LineAlarmType.IoSingleTimeOut);
}
protected void ClearTimeoutAlarm(string msg)
{
if (isInSuddenDown || isNoAirCheck)
{
return;
}
if (WarnMsg.Contains(msg) && alarmType.Equals(LineAlarmType.IoSingleTimeOut))
{
LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 ");
alarmType = LineAlarmType.None;
SetWarnMsg("");
}
}
//protected void MoveTimeOut(LineMoveInfo move, string msg)
//{
// WarnMsg = move.Name + "[" + move.MoveStep + "] "+ msg + " [" +FormUtil.GetSpanStr( move.StepSpan()) + "]";
// int logId = DeviceID * 10000 + (int)move.MoveStep;
// LogUtil.error(WarnMsg, logId);
// Alarm(LineAlarmType.IoSingleTimeOut);
//}
//protected void ClearTimeoutAlarm(string msg)
//{
// if (isInSuddenDown || isNoAirCheck)
// {
// return;
// }
// if (WarnMsg.Contains(msg) && alarmType.Equals(LineAlarmType.IoSingleTimeOut))
// {
// LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 ");
// alarmType = LineAlarmType.None;
// SetWarnMsg("");
// }
//}
protected bool CanStartRun()
{
string canResult = LineManager.Line.CanStart();
......@@ -384,7 +384,7 @@ namespace OnlineStore.DeviceLibrary
{
return true;
}
SetWarnMsg(Name + msg);
SetWarnMsg(Name + msg,axis.Config.DisplayStr+"_轴报警");
Alarm(LineAlarmType.AxisAlarm);
return false;
}
......@@ -423,8 +423,9 @@ namespace OnlineStore.DeviceLibrary
if (alarmIo == 1)
{
WarnMsg = Name + " 运动轴" + axisInfo.Config.Explain + "报警";
LogUtil.error(WarnMsg);
string msg = Name + " 运动轴" + axisInfo.Config.Explain + "报警";
//LogUtil.error(WarnMsg);
SetWarnMsg(msg, axisInfo.Config.Explain + "轴报警");
Alarm(LineAlarmType.AxisAlarm);
isInAlarm = true;
}
......@@ -476,16 +477,25 @@ namespace OnlineStore.DeviceLibrary
if (wait.IsHomeMove)
{
wait.IsEnd = AxisBean.HomeMoveIsEnd(moveInfo, wait.AxisInfo, out msg);
if (wait.IsEnd)
{
RunLogUtil.AxisLog(new AxisMoveLog(Name, wait.AxisInfo.Explain, "回原点", 0, wait.AxisInfo.HomeHighSpeed, moveInfo.LastSetpTime, DateTime.Now, moveInfo.MoveParam.PosId, moveInfo.MoveParam.WareCode));
}
}
else
{
wait.IsEnd = AxisBean.ACAxisMoveIsEnd(moveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
if (wait.IsEnd)
{
RunLogUtil.AxisLog(new AxisMoveLog(Name, wait.AxisInfo.Explain, "绝对运动", wait.TargetPosition, wait.TargetSpeed, moveInfo.LastSetpTime, DateTime.Now, moveInfo.MoveParam.PosId, moveInfo.MoveParam.WareCode));
}
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = Name + msg;
string type = moveInfo.GetStepDes() + "_轴运动报警";
// WarnMsg = Name + msg;
SetWarnMsg(msg, type, moveInfo);
Alarm(LineAlarmType.AxisMoveError);
CheckAlarmProcess(moveInfo, LineAlarmType.AxisMoveError);
LogUtil.error(WarnMsg, DeviceID * 1000 + 14);
......@@ -510,8 +520,8 @@ namespace OnlineStore.DeviceLibrary
if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut && alarmType <= LineAlarmType.IoSingleTimeOut)
{
ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "] 等待" + NotOkMsg + " 超时 " + Math.Round(span.TotalSeconds, 1) + "秒";
string warnmsg= moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "] 等待" + NotOkMsg + " 超时 " + Math.Round(span.TotalSeconds, 1) + "秒";
SetWarnMsg(warnmsg, moveInfo.GetStepDes() + "_超时报警", moveInfo);
LogUtil.error( WarnMsg, DeviceID * 1000 + 13);
if (NoAlarm())
{
......@@ -592,10 +602,11 @@ namespace OnlineStore.DeviceLibrary
if (isOk)
{
moveInfo.EndStepWait();
ClearStepAlarm(moveInfo.GetStepDes());
}
else if (span.TotalSeconds > moveInfo.TimeOutSeconds)
{
WarnMsg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "]等待" + NotOkMsg
string msg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "]等待" + NotOkMsg
+ "超时[" + FormUtil.GetSpanStr(span)+"]";
int second = 10;
if (IsLowAlarm(moveInfo))
......@@ -610,7 +621,9 @@ namespace OnlineStore.DeviceLibrary
{
second = 10;
}
LogUtil.error(WarnMsg, DeviceID * 1000 + 15, second);
string type = moveInfo.GetStepDes() + "_" + "超时报警";
//LogUtil.error(WarnMsg, DeviceID * 1000 + 15, second);
SetWarnMsg(msg, type, moveInfo, second);
Alarm(LineAlarmType.IoSingleTimeOut);
CheckAlarmProcess(moveInfo, LineAlarmType.IoSingleTimeOut);
}
......
......@@ -352,12 +352,12 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut(60))
{
MoveTimeOut(MoveInfo, "启用抓料超时");
MoveTimeoutAlarm(MoveInfo, "启用抓料超时");
}
}
else if (MoveInfo.IsTimeOut(60))
{
MoveTimeOut(MoveInfo, "扫码结束超时");
MoveTimeoutAlarm(MoveInfo, "扫码结束超时");
}
}
else if (MoveInfo.IsStep(LineMoveStep.FI_21_CylinderTake))
......@@ -504,7 +504,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut(120))
{
MoveTimeOut(MoveInfo, "获取库位号超时 "+getPosIdMsg);
MoveTimeoutAlarm(MoveInfo, "获取库位号超时 "+getPosIdMsg);
}
}
else if (MoveInfo.IsStep(LineMoveStep.FI_32_WaitTray))//TODO
......@@ -527,7 +527,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut(180))
{
MoveTimeOut(MoveInfo, "等待空托盘到达超时");
MoveTimeoutAlarm(MoveInfo, "等待空托盘到达超时");
}
}
else if (MoveInfo.IsStep(LineMoveStep.FI_33_CylinderDown))
......@@ -971,7 +971,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut(60))
{
MoveTimeOut(MoveInfo, "预扫码结束超时");
MoveTimeoutAlarm(MoveInfo, "预扫码结束超时");
}
}
else
......
......@@ -802,7 +802,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut(60))
{
MoveTimeOut(MoveInfo, "等待给服务器发送afterPut完成超时");
MoveTimeoutAlarm(MoveInfo, "等待给服务器发送afterPut完成超时");
}
}
}
......
......@@ -544,7 +544,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut())
{
MoveTimeOut(MoveInfo, "等待" + hyout.Name + "可以横移超时");
MoveTimeoutAlarm(MoveInfo, "等待" + hyout.Name + "可以横移超时");
}
}
else if (MoveInfo.IsStep(LineMoveStep.HY13_WaitHY2Ready))
......@@ -562,7 +562,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut())
{
MoveTimeOut(MoveInfo, "等待" + hyout.Name + "顶升上升完成超时");
MoveTimeoutAlarm(MoveInfo, "等待" + hyout.Name + "顶升上升完成超时");
}
......@@ -584,7 +584,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut())
{
MoveTimeOut(MoveInfo, "等待托盘到达" + hyout.Name + "超时");
MoveTimeoutAlarm(MoveInfo, "等待托盘到达" + hyout.Name + "超时");
}
}
else if (MoveInfo.IsStep(LineMoveStep.HY16_WatOutFixture2))
......@@ -603,7 +603,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut())
{
MoveTimeOut(MoveInfo, "等待托盘到达" + hyout.Name + "");
MoveTimeoutAlarm(MoveInfo, "等待托盘到达" + hyout.Name + "");
}
}
else if (MoveInfo.IsStep(LineMoveStep.HY17_TopDown))
......@@ -955,8 +955,23 @@ namespace OnlineStore.DeviceLibrary
if (!instoreId.Contains(storeId))
{
return true;
}
}
}
else if(tray.InOrOutStore.Equals(2) && tray.InoutPar.urgentReel)
{
pandianliao++;
if (pandianliao >= 2)
{
bool needhy = SServerManager.canReelToBelt(Name, tray.InoutPar.WareCode, false);
if (needhy)
{
LogUtil.info(Name + "盘点料["+ pandianliao + "]:需要横移 " + tray.InoutPar.ToShortStr());
pandianliao = 0;
return true;
}
pandianliao = 0;
}
}
}
}
......@@ -997,7 +1012,7 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
private int pandianliao = 0;
private int PreIsToOutCount = 0;
private bool TrayNeedToOutLine(int trayNum)
{
......
......@@ -364,13 +364,13 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut(30))
{
MoveTimeOut(MoveInfo, "等待" + feed.Name + "开始出库超时");
MoveTimeoutAlarm(MoveInfo, "等待" + feed.Name + "开始出库超时");
//如果当前无料串,或者料串已离开,直接放行 托盘
TrayCanLeave();
}
else if (MoveInfo.IsTimeOut(20))
{
MoveTimeOut(MoveInfo, "等待" + feed.Name + "开始出库超时");
MoveTimeoutAlarm(MoveInfo, "等待" + feed.Name + "开始出库超时");
}
}
else
......@@ -414,7 +414,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut())
{
MoveTimeOut(MoveInfo, "等待" + hyOut.Name + "可以横移超时");
MoveTimeoutAlarm(MoveInfo, "等待" + hyOut.Name + "可以横移超时");
}
}
else if (MoveInfo.IsStep(LineMoveStep.HY13_WaitHY2Ready))
......@@ -431,7 +431,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut())
{
MoveTimeOut(MoveInfo, "等待" + hyOut + "顶升上升完成超时");
MoveTimeoutAlarm(MoveInfo, "等待" + hyOut + "顶升上升完成超时");
}
}
......@@ -456,7 +456,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut())
{
MoveTimeOut(MoveInfo, "等待托盘到达" + hyOut.Name + "");
MoveTimeoutAlarm(MoveInfo, "等待托盘到达" + hyOut.Name + "");
}
}
else if (MoveInfo.IsStep(LineMoveStep.HY17_TopDown))
......
......@@ -611,7 +611,7 @@ namespace OnlineStore.DeviceLibrary
Thread.Sleep(300);
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
SetWarnMsg("收到急停信号,报警急停");
SetWarnMsg("收到急停信号,报警急停", "急停报警");
Alarm(LineAlarmType.SuddenStop);
}
}
......@@ -902,9 +902,10 @@ namespace OnlineStore.DeviceLibrary
}
else if (span.TotalSeconds > 120)
{
WarnMsg = Name + "[" + MoveInfo.MoveStep + "][" + msg + "]已等待[" + FormUtil.GetSpanStr(span ) + "]秒";
LogUtil.error(WarnMsg, 903);
string warnmsg = Name + "[" + MoveInfo.MoveStep + "][" + msg + "]已等待[" + FormUtil.GetSpanStr(span ) + "]秒";
//LogUtil.error(WarnMsg, 903);
Alarm(LineAlarmType.IoSingleTimeOut);
MoveTimeoutAlarm(MoveInfo, msg);
}
}
}
......
......@@ -104,9 +104,10 @@ namespace OnlineStore.DeviceLibrary
if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut && NoAlarm())
{
ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = checkWaitInfo.Name + "[" + checkWaitInfo.MoveStep + "]等待" + NotOkMsg + " 超时";
string warnMsg = checkWaitInfo.Name + "[" + checkWaitInfo.MoveStep + "]等待" + NotOkMsg + " 超时";
SetWarnMsg(warnMsg, checkWaitInfo.GetStepDes() + "_超时报警", checkWaitInfo);
Alarm(LineAlarmType.IoSingleTimeOut);
LogUtil.error(WarnMsg, 901);
//LogUtil.error(WarnMsg, 901);
}
//超过报警时长
else if (rwSpan.TotalSeconds > 5 && span.TotalSeconds > 6 && span.TotalSeconds < LineManager.Config.IOSingle_TimerOut * 2)
......@@ -177,11 +178,13 @@ namespace OnlineStore.DeviceLibrary
if (isOk)
{
checkWaitInfo.EndStepWait();
ClearStepAlarm(checkWaitInfo.GetStepDes());
}
else if (span.TotalSeconds > checkWaitInfo.TimeOutSeconds)
{
WarnMsg = checkWaitInfo.Name + "[" + checkWaitInfo.MoveStep + "][" + NotOkMsg + "]已等待[" + FormUtil.GetSpanStr(span) + "] ";
LogUtil.error(WarnMsg, 900);
string warnMsg = checkWaitInfo.Name + "[" + checkWaitInfo.MoveStep + "][" + NotOkMsg + "]已等待[" + FormUtil.GetSpanStr(span) + "] ";
SetWarnMsg(warnMsg, checkWaitInfo.GetStepDes() + "_超时报警", checkWaitInfo);
//LogUtil.error(WarnMsg, 900);
Alarm(LineAlarmType.IoSingleTimeOut);
}
}
......
......@@ -255,7 +255,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsTimeOut(180))
{
MoveTimeOut(MoveInfo, "等待空托盘到达超时");
MoveTimeoutAlarm(MoveInfo, "等待空托盘到达超时");
return false;
}
return false;
......@@ -464,8 +464,9 @@ namespace OnlineStore.DeviceLibrary
if (sendCount >= 3)
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] " + " 等待BOX开始入库超时 已发送" + sendCount + "次";
LogUtil.error(WarnMsg);
SetWarnMsg(MoveInfo.Name + "[" + MoveInfo.MoveStep + "] " + " 等待BOX开始入库超时 已发送" + sendCount + "次", "等待BOX开始入库超时");
//WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] " + " 等待BOX开始入库超时 已发送" + sendCount + "次";
//LogUtil.error(WarnMsg);
Alarm(LineAlarmType.IoSingleTimeOut);
}
}
......@@ -1003,9 +1004,10 @@ namespace OnlineStore.DeviceLibrary
}
else if (SecondMoveInfo.IsTimeOut(120))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待HY8空闲[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID * 1000 + 12);
Alarm(LineAlarmType.IoSingleTimeOut);
MoveTimeoutAlarm(SecondMoveInfo, "等待HY8空闲超时");
//WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待HY8空闲[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
//LogUtil.error(WarnMsg, DeviceID * 1000 + 12);
//Alarm(LineAlarmType.IoSingleTimeOut);
}
}
......
......@@ -34,7 +34,8 @@ namespace OnlineStore.DeviceLibrary
public LineManager()
{
}
public static bool CheckEnum(Type type)
public static Dictionary<string, string> StepDesMap = new Dictionary<string, string>();
public static bool CheckEnum(Type type,bool isStep=false)
{
if (type.IsEnum)
{
......@@ -49,6 +50,13 @@ namespace OnlineStore.DeviceLibrary
return false;
}
valueList.Add(item);
if (isStep)
{
LineMoveStep en = (LineMoveStep)item;
string des = EnumDesHelper.GetStepDes(en);
StepDesMap.Add(en.ToString(), des);
}
}
}
return true;
......@@ -68,7 +76,7 @@ namespace OnlineStore.DeviceLibrary
{
IsConnectServer = true;
}
if (!CheckEnum(typeof(LineMoveStep)))
if (!CheckEnum(typeof(LineMoveStep),true))
{
return false;
}
......
......@@ -637,13 +637,13 @@ namespace OnlineStore.DeviceLibrary
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.debug($"{deviceName }canReelToBelt {FormUtil.GetSpanStr(DateTime.Now - startTime) } 【{ server }】【{resultStr }】");
//{ "code":0,"msg":"ok","data":true}
ReturnData data = JsonHelper.DeserializeJsonToObject<ReturnData>(resultStr);
if (data != null)
{
bool result = Convert.ToBoolean(data.data);
if (data.code.Equals(0) && (!result))
if (data.code.Equals(0))
{
return result;
}
......
......@@ -34,6 +34,8 @@ namespace OnlineStore.DeviceLibrary
public int MoveNum { get; set; }
public DateTime MoveStartTime { get; set; }
public DateTime LastSetpTime { get; set; }
/// <summary>
......@@ -106,6 +108,7 @@ namespace OnlineStore.DeviceLibrary
}
public void NextMoveStep(LineMoveStep step)
{
StepMoveLog();
PreMoveStep = moveStep;
moveStep = step;
LastSetpTime = DateTime.Now;
......@@ -131,7 +134,8 @@ namespace OnlineStore.DeviceLibrary
LastSetpTime = DateTime.Now;
WaitList = new List<WaitResultInfo>();
WriteIoList = new List<WriteIOInfo>();
MoveNum++;
MoveNum++;
MoveStartTime = DateTime.Now;
}
public void NewMove(LineMoveType type, InOutParam param)
{
......@@ -141,9 +145,11 @@ namespace OnlineStore.DeviceLibrary
LastSetpTime = DateTime.Now;
WaitList = new List<WaitResultInfo>();
WriteIoList = new List<WriteIOInfo>();
MoveStartTime = DateTime.Now;
}
public void EndMove()
{
StepMoveLog();
this.moveType = LineMoveType.None;
this.MoveParam = null;
moveStep = LineMoveStep.Wait;
......@@ -174,6 +180,64 @@ namespace OnlineStore.DeviceLibrary
string str = $"[{MoveType}][{MoveStep}]{ MoveParam?.ToStr()}";
return str;
}
public string GetStepDes()
{
string currName = moveStep.ToString();
try
{
if (LineManager.StepDesMap.ContainsKey(currName))
{
string v= LineManager.StepDesMap[currName];
if (String.IsNullOrEmpty(v))
{
return currName;
}
else
{
return v;
}
}
}
catch (Exception ex)
{
LogUtil.error("GetStepDes 出错:" + ex.ToString());
}
return currName;
}
public string GetMoveType()
{
switch (moveType)
{
case LineMoveType.Fixture:
return "托盘处理";
break;
case LineMoveType.InStore:
return "入料";
break;
case LineMoveType.OutStore:
return "出料";
break;
case LineMoveType.Reset:
return "复位";
break;
case LineMoveType.RHome:
return "回原";
break;
}
return "";
}
private void StepMoveLog()
{
try
{
RunLogUtil.MoveLog(new MoveLog(Name, GetMoveType(), GetStepDes(), LastSetpTime, DateTime.Now, MoveParam.PosId, MoveParam.WareCode));
}
catch (Exception ex)
{
}
}
}
public class WriteIOInfo
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!