Commit 93e90cea LN

增加运行日志。

1 个父辈 8e2bada4
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
<Compile Include="util\MyWebClient.cs"> <Compile Include="util\MyWebClient.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="util\RunLogUtil.cs" />
<Compile Include="util\ScanCodeManager.cs" /> <Compile Include="util\ScanCodeManager.cs" />
<Compile Include="util\TcpClient.cs" /> <Compile Include="util\TcpClient.cs" />
<Compile Include="util\TcpServer.cs" /> <Compile Include="util\TcpServer.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 InoutEndLog(InoutEndLog 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 (errType == null) { errType = ""; }
if (errMsg == null) { errMsg = ""; }
if (operType == null) { operType = ""; }
if (posid == null) { posid = ""; }
if (barcode == null) { barcode = ""; }
this.LogType = "Error";
this.DeviceName = deviceName.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 (moveMsg == null) { moveMsg = ""; }
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 InoutEndLog : BaseLog
{
public InoutEndLog()
{
this.LogType = "InoutEnd";
}
public InoutEndLog(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 (moveType == null) { moveType = ""; }
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; } = "";
}
}
...@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary
toolTimer.Elapsed += ToolTimer_Elapsed; toolTimer.Elapsed += ToolTimer_Elapsed;
this.box = box; this.box = box;
LogName = box.Name + "校准点位 "; LogName = box.Name + "校准点位 ";
MoveInfo = new StoreMoveInfo(box.DeviceID); MoveInfo = new StoreMoveInfo(box.DeviceID,"点位校准");
MoveInfo.NextMoveStep( StoreMoveStep.Wait); MoveInfo.NextMoveStep( StoreMoveStep.Wait);
} }
......
...@@ -36,6 +36,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -36,6 +36,15 @@ namespace OnlineStore.DeviceLibrary
public BoxBean(BoxConfig config) public BoxBean(BoxConfig config)
{ {
this.DeviceID = config.DeviceID;
this.baseConfig = config;
this.Config = config;
this.CID = config.CID;
//添加调试
IsDebug = config.ISDebug.Equals(1);
UseCompress_Axis = true;
Name = ("左侧BOX_" + config.GetStoreId() + " ").ToUpper();
Init(); Init();
serverConnectTimer = new System.Timers.Timer(); serverConnectTimer = new System.Timers.Timer();
serverConnectTimer.Interval = 1000; serverConnectTimer.Interval = 1000;
...@@ -54,15 +63,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -54,15 +63,6 @@ namespace OnlineStore.DeviceLibrary
readDITimer.Enabled = false; readDITimer.Enabled = false;
readDITimer.Elapsed += ReadDITimer_Elapsed; readDITimer.Elapsed += ReadDITimer_Elapsed;
this.DeviceID = config.DeviceID;
this.baseConfig = config;
this.Config = config;
this.CID = config.CID;
//添加调试
IsDebug = config.ISDebug.Equals(1);
UseCompress_Axis = true;
Name = ("左侧BOX_" + config.GetStoreId() + " ").ToUpper();
if (config.DeviceID.Equals(2)) if (config.DeviceID.Equals(2))
{ {
Name = ("右侧BOX_" + config.GetStoreId() + " ").ToUpper(); Name = ("右侧BOX_" + config.GetStoreId() + " ").ToUpper();
...@@ -239,7 +239,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -239,7 +239,7 @@ namespace OnlineStore.DeviceLibrary
{ {
isNoAirCheck = false; isNoAirCheck = false;
isInSuddenDown = false; isInSuddenDown = false;
WarnMsg = ""; SetWarnMsg();
CurrInOutACount = 0; CurrInOutACount = 0;
CurrInOutCount = 0; CurrInOutCount = 0;
...@@ -289,7 +289,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -289,7 +289,7 @@ namespace OnlineStore.DeviceLibrary
storeRunStatus = StoreRunStatus.Reset; storeRunStatus = StoreRunStatus.Reset;
storeStatus = StoreStatus.ResetMove; storeStatus = StoreStatus.ResetMove;
MoveInfo.NewMove(StoreMoveType.StoreReset); MoveInfo.NewMove(StoreMoveType.StoreReset);
WarnMsg = ""; SetWarnMsg();
if (!OpenAllAxis(true)) if (!OpenAllAxis(true))
{ {
...@@ -382,7 +382,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -382,7 +382,7 @@ namespace OnlineStore.DeviceLibrary
storeStatus = StoreStatus.StoreOnline; storeStatus = StoreStatus.StoreOnline;
if (alarmType.Equals(StoreAlarmType.None)) if (alarmType.Equals(StoreAlarmType.None))
{ {
WarnMsg = ""; SetWarnMsg();
} }
break; break;
...@@ -411,7 +411,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -411,7 +411,7 @@ namespace OnlineStore.DeviceLibrary
storeRunStatus = StoreRunStatus.Runing; storeRunStatus = StoreRunStatus.Runing;
if (alarmType.Equals(StoreAlarmType.None)) if (alarmType.Equals(StoreAlarmType.None))
{ {
WarnMsg = ""; SetWarnMsg();
} }
break; break;
...@@ -508,8 +508,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -508,8 +508,8 @@ namespace OnlineStore.DeviceLibrary
{ {
AxisManager.instance.ServoOff(axis.DeviceName, axis.GetAxisValue()); AxisManager.instance.ServoOff(axis.DeviceName, axis.GetAxisValue());
int alarmCode = GetAlarmCodeByAxis(axis); int alarmCode = GetAlarmCodeByAxis(axis);
WarnMsg = Name + "打开轴" + axis.Explain + "失败 "; string msg = Name + "打开轴" + axis.Explain + "失败 ";
LogInfo( WarnMsg); SetWarnMsg(msg, axis.Explain+"_轴报警");
Alarm(StoreAlarmType.AxisAlarm, GetAlarmCodeByAxis(axis).ToString(), WarnMsg, MoveInfo.MoveType); Alarm(StoreAlarmType.AxisAlarm, GetAlarmCodeByAxis(axis).ToString(), WarnMsg, MoveInfo.MoveType);
return false; return false;
} }
...@@ -554,7 +554,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -554,7 +554,7 @@ namespace OnlineStore.DeviceLibrary
public override void StopRun() public override void StopRun()
{ {
WarnMsg = ""; SetWarnMsg();
autoNext = false; autoNext = false;
IoCheckTimer.Enabled = false; IoCheckTimer.Enabled = false;
serverConnectTimer.Enabled = false; serverConnectTimer.Enabled = false;
...@@ -650,7 +650,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -650,7 +650,7 @@ namespace OnlineStore.DeviceLibrary
isInSuddenDown = true; isInSuddenDown = true;
LogUtil.error(Name + "收到急停信号,报警急停"); LogUtil.error(Name + "收到急停信号,报警急停");
//WarnMsg = Name + "收到急停信号,报警急停"; //WarnMsg = Name + "收到急停信号,报警急停";
SetWarnMsg( "收到急停信号,报警急停"); SetWarnMsg( "收到急停信号,报警急停","报警急停");
//报警时会关闭所有轴 //报警时会关闭所有轴
Alarm(StoreAlarmType.SuddenStop, "1", WarnMsg, StoreMoveType.None); Alarm(StoreAlarmType.SuddenStop, "1", WarnMsg, StoreMoveType.None);
} }
...@@ -707,7 +707,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -707,7 +707,7 @@ namespace OnlineStore.DeviceLibrary
TimeSpan span = DateTime.Now - lastAirCloseTime; TimeSpan span = DateTime.Now - lastAirCloseTime;
if (span.TotalSeconds > StoreManager.Config.AirCheckSeconds) if (span.TotalSeconds > StoreManager.Config.AirCheckSeconds)
{ {
SetWarnMsg( "未检测到气压信号"); SetWarnMsg( "未检测到气压信号", "未检测到气压信号");
preAirValue = IO_VALUE.LOW; preAirValue = IO_VALUE.LOW;
LogInfo( "已持续【" + FormUtil.GetSpanStr(span) + "】未检测到气压信号,报警"); LogInfo( "已持续【" + FormUtil.GetSpanStr(span) + "】未检测到气压信号,报警");
Alarm(StoreAlarmType.NoAirCheck, "2", WarnMsg, StoreMoveType.None); Alarm(StoreAlarmType.NoAirCheck, "2", WarnMsg, StoreMoveType.None);
...@@ -857,7 +857,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -857,7 +857,7 @@ namespace OnlineStore.DeviceLibrary
{ {
LogInfo( "之前有IO超时异常【" + alarmInfo.alarmDetail + "】,但是当前已经没有在等待中,清理信号超时异常!"); LogInfo( "之前有IO超时异常【" + alarmInfo.alarmDetail + "】,但是当前已经没有在等待中,清理信号超时异常!");
alarmType = StoreAlarmType.None; alarmType = StoreAlarmType.None;
WarnMsg = ""; SetWarnMsg();
} }
} }
} }
...@@ -957,7 +957,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -957,7 +957,8 @@ namespace OnlineStore.DeviceLibrary
if (alarmIo == 1) if (alarmIo == 1)
{ {
WarnMsg = Name + " 运动轴" + axisInfo.Explain + "报警"; string msg = Name + " 运动轴" + axisInfo.Explain + "报警";
SetWarnMsg(msg, axisInfo.Explain + "_轴报警");
info.AlarmIoValue = alarmIo; info.AlarmIoValue = alarmIo;
Alarm(StoreAlarmType.AxisAlarm, GetAlarmCodeByAxis(axisInfo).ToString(), WarnMsg, StoreMoveType.None); Alarm(StoreAlarmType.AxisAlarm, GetAlarmCodeByAxis(axisInfo).ToString(), WarnMsg, StoreMoveType.None);
isInAlarm = true; isInAlarm = true;
...@@ -1271,7 +1272,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1271,7 +1272,7 @@ namespace OnlineStore.DeviceLibrary
} }
} }
CodeMsg = ""; CodeMsg = "";
//WarnMsg = ""; //SetWarnMsg();
//状态 //状态
boxStatus.status = (int)storeStatus; boxStatus.status = (int)storeStatus;
if (IsDebug) if (IsDebug)
......
...@@ -164,7 +164,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -164,7 +164,10 @@ namespace OnlineStore.DeviceLibrary
if (wait.IsHomeMove) if (wait.IsHomeMove)
{ {
wait.IsEnd = ACHomeMoveIsEnd(wait.AxisInfo, out msg); wait.IsEnd = ACHomeMoveIsEnd(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.PosInfo.PosId, MoveInfo.MoveParam.PosInfo.barcode));
}
if (!wait.IsEnd && (String.IsNullOrEmpty(msg))) if (!wait.IsEnd && (String.IsNullOrEmpty(msg)))
{ {
//如果原点没完成,且原点亮超过5秒,需要报警 //如果原点没完成,且原点亮超过5秒,需要报警
...@@ -188,11 +191,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -188,11 +191,16 @@ namespace OnlineStore.DeviceLibrary
else else
{ {
wait.IsEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg); wait.IsEnd = ACAxisMoveIsEnd(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.PosInfo.PosId, MoveInfo.MoveParam.PosInfo.barcode));
}
} }
if (!msg.Equals("")) if (!msg.Equals(""))
{ {
isOk = false; isOk = false;
WarnMsg = msg; //WarnMsg = msg;
SetWarnMsg(msg, MoveInfo.GetStepDes() + "_轴运动报警", MoveInfo);
Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, MoveInfo.MoveType); Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, MoveInfo.MoveType);
break; break;
} }
...@@ -216,10 +224,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -216,10 +224,11 @@ namespace OnlineStore.DeviceLibrary
if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs) if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs)
{ {
ConfigIO io = Config.getWaitIO(wait.IoType); ConfigIO io = Config.getWaitIO(wait.IoType);
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待" + io.DisplayStr + "=" + wait.IoValue + "超时 "; string msg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待" + io.DisplayStr + "=" + wait.IoValue + "超时 ";
SetWarnMsg(msg, MoveInfo.GetStepDes() + "_超时报警", MoveInfo);
if (WarnMsg.Contains("CheckPos") || WarnMsg.Contains("X03_点检")) if (WarnMsg.Contains("CheckPos") || WarnMsg.Contains("X03_点检"))
{ {
WarnMsg = ""; SetWarnMsg();;
break; break;
} }
...@@ -305,14 +314,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -305,14 +314,16 @@ namespace OnlineStore.DeviceLibrary
if (isOk) if (isOk)
{ {
MoveInfo.EndStepWait(); MoveInfo.EndStepWait();
ClearStepAlarm(MoveInfo.GetStepDes());
} }
else if (span.TotalSeconds > MoveInfo.TimeOutSeconds) else if (span.TotalSeconds > MoveInfo.TimeOutSeconds)
{ {
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待超时 [" + NotOkMsg string msg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待超时 [" + NotOkMsg
+ "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒"; + "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒";
SetWarnMsg(msg, MoveInfo.GetStepDes() + "_超时报警", MoveInfo);
if (WarnMsg.Contains("CheckPos") || WarnMsg.Contains("X03_点检")) if (WarnMsg.Contains("CheckPos") || WarnMsg.Contains("X03_点检"))
{ {
WarnMsg = ""; SetWarnMsg();;
return; return;
} }
...@@ -595,7 +606,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -595,7 +606,9 @@ namespace OnlineStore.DeviceLibrary
{ {
TimeSpan span = DateTime.Now - startInStoreTime; TimeSpan span = DateTime.Now - startInStoreTime;
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.PosId : ""; string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.PosId : "";
LogInfo( " 【" + posId + "】 整个入库流程结束,耗时【" + FormUtil.GetSpanStr(span) + "】!"); LogInfo( " 【" + posId + "】 整个入库流程结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
RunLogUtil.InoutEndLog(new InoutEndLog(Name, "入库", startInStoreTime, DateTime.Now, MoveInfo.MoveParam.PosInfo.PosId, MoveInfo.MoveParam.PosInfo.barcode));
MoveInfo.EndMove(); MoveInfo.EndMove();
storeRunStatus = StoreRunStatus.Runing; storeRunStatus = StoreRunStatus.Runing;
//设备连接,入库后,BOX恢复原始状态 //设备连接,入库后,BOX恢复原始状态
...@@ -941,6 +954,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -941,6 +954,7 @@ namespace OnlineStore.DeviceLibrary
TimeSpan span = DateTime.Now - startOutStoreTime; TimeSpan span = DateTime.Now - startOutStoreTime;
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.PosId : ""; string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.PosId : "";
RunLogUtil.InoutEndLog(new InoutEndLog(Name, "出库", startOutStoreTime, DateTime.Now, posId, MoveInfo.MoveParam.PosInfo.barcode));
storeStatus = StoreStatus.StoreOnline; storeStatus = StoreStatus.StoreOnline;
LogInfo( " 【" + posId + "】 整个出库流程结束,耗时【" + FormUtil.GetSpanStr(span) + "】!"); LogInfo( " 【" + posId + "】 整个出库流程结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
MoveInfo.EndMove(); MoveInfo.EndMove();
......
...@@ -43,7 +43,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -43,7 +43,7 @@ namespace OnlineStore.DeviceLibrary
this.Config = lineConfig; this.Config = lineConfig;
this.DeviceID = lineConfig.DeviceID; this.DeviceID = lineConfig.DeviceID;
MoveInfo = new StoreMoveInfo(DeviceID); MoveInfo = new StoreMoveInfo(DeviceID,Name);
Name = (" Store_" + Config.CID + " ").ToUpper(); Name = (" Store_" + Config.CID + " ").ToUpper();
List<string> ioList = new List<string>(); List<string> ioList = new List<string>();
...@@ -122,7 +122,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -122,7 +122,7 @@ namespace OnlineStore.DeviceLibrary
isInSuddenDown = false; isInSuddenDown = false;
isNoAirCheck = false; isNoAirCheck = false;
alarmType = StoreAlarmType.None; alarmType = StoreAlarmType.None;
WarnMsg = ""; SetWarnMsg();
foreach (BoxBean box in this.BoxMap.Values) foreach (BoxBean box in this.BoxMap.Values)
{ {
...@@ -187,7 +187,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -187,7 +187,7 @@ namespace OnlineStore.DeviceLibrary
isInSuddenDown = false; isInSuddenDown = false;
isNoAirCheck = false; isNoAirCheck = false;
alarmType = StoreAlarmType.None; alarmType = StoreAlarmType.None;
WarnMsg = ""; SetWarnMsg();
foreach (BoxBean equip in BoxMap.Values) foreach (BoxBean equip in BoxMap.Values)
{ {
......
...@@ -25,11 +25,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -25,11 +25,12 @@ namespace OnlineStore.DeviceLibrary
private static bool isInit = false; private static bool isInit = false;
public static bool IsConnectServer = !ConfigAppSettings.GetValue(Setting_Init.http_server).Equals(""); public static bool IsConnectServer = !ConfigAppSettings.GetValue(Setting_Init.http_server).Equals("");
public static Dictionary<int, BaseConfig> allConfigMap = new Dictionary<int, BaseConfig>(); public static Dictionary<int, BaseConfig> allConfigMap = new Dictionary<int, BaseConfig>();
public static Dictionary<string, string> StepDesMap = new Dictionary<string, string>();
public StoreManager() public StoreManager()
{ {
} }
#region 配置文件加载更新 #region 配置文件加载更新
public static void CheckEnum(Type type) public static void CheckEnum(Type type, bool isStep=false)
{ {
if (type.IsEnum) if (type.IsEnum)
{ {
...@@ -44,6 +45,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -44,6 +45,12 @@ namespace OnlineStore.DeviceLibrary
break; break;
} }
valueList.Add(item); valueList.Add(item);
if (isStep)
{
StoreMoveStep en = (StoreMoveStep)item;
string des = EnumDesHelper.GetStepDes(en);
StepDesMap.Add(en.ToString(), des);
}
} }
} }
} }
...@@ -62,7 +69,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -62,7 +69,7 @@ namespace OnlineStore.DeviceLibrary
{ {
IsConnectServer = false; IsConnectServer = false;
} }
CheckEnum(typeof(StoreMoveStep)); CheckEnum(typeof(StoreMoveStep),true);
CheckEnum(typeof(StoreStatus)); CheckEnum(typeof(StoreStatus));
CheckEnum(typeof(StoreRunStatus)); CheckEnum(typeof(StoreRunStatus));
......
...@@ -291,7 +291,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -291,7 +291,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (!isInit) if (!isInit)
{ {
MoveInfo = new StoreMoveInfo(DeviceID); MoveInfo = new StoreMoveInfo(DeviceID,Name);
mainTimer = new System.Timers.Timer(); mainTimer = new System.Timers.Timer();
mainTimer.Enabled = false; mainTimer.Enabled = false;
...@@ -437,47 +437,143 @@ namespace OnlineStore.DeviceLibrary ...@@ -437,47 +437,143 @@ namespace OnlineStore.DeviceLibrary
} }
public IO_VALUE IOValue(string IoType) public IO_VALUE IOValue(string IoType)
{ {
return IOManager.IOValue(IoType, baseConfig.DeviceID); return IOManager.IOValue(IoType, baseConfig.DeviceID);
} }
protected void SetWarnMsg(string msg) public bool IsDoValue(string ioType, IO_VALUE ioValue)
{ {
if (String.IsNullOrEmpty(WarnMsg).Equals(false)) return IOValue(ioType).Equals(ioValue);
}
public void LogInfo(string logInfo)
{
LogUtil.info(Name + logInfo);
}
private WarnParam warnParam = new WarnParam();
/// <summary>
/// 设置报警消息,报警类型,清除报警时记录日志
/// </summary>
/// <param name="msg"></param>
/// <param name="logtype"></param>
/// <param name="logseconds"></param>
public void SetWarnMsg(string msg = "", string alarmType = "", StoreMoveInfo moveInfo = null, int logseconds = 10)
{
try
{ {
if (WarnMsg.Equals(msg)) int logtype = 801;
if (moveInfo != null)
{
logtype = DeviceID * 10000 + (int)moveInfo.MoveStep;
}
if (String.IsNullOrEmpty(msg).Equals(false))
{ {
if (msg.StartsWith(Name)) if (WarnMsg.Equals(msg) || alarmType.Equals(warnParam.AlarmType))
{ {
LogUtil.error(msg, 105); if (msg.StartsWith(Name))
{
LogUtil.error(msg, logtype, logseconds);
}
else
{
LogUtil.error(Name + msg, logtype, logseconds);
}
} }
else else
{ {
LogUtil.error(Name + msg, 105); if (msg.StartsWith(Name))
{
LogUtil.error(msg);
}
else
{
LogUtil.error(Name + msg);
}
} }
} }
else
if (!warnParam.AlarmType.Equals(alarmType))
{ {
if (msg.StartsWith(Name)) //报警类型不一致,若之前不是空,记录日志
if (!String.IsNullOrEmpty(warnParam.AlarmType))
{ {
LogUtil.error(msg); RunLogUtil.ErrorLog(new ErrorLog(Name, warnParam.AlarmType, WarnMsg, warnParam.StartTime, DateTime.Now, warnParam.OperteType, warnParam.PosId, warnParam.Barcode));
}
//更新开始时间
warnParam.StartTime = DateTime.Now;
if (moveInfo != null)
{
warnParam.PosId = moveInfo.MoveParam?.PosInfo?.PosId;
warnParam.Barcode = moveInfo.MoveParam?.PosInfo?.barcode;
warnParam.OperteType = moveInfo.MoveType.ToString();
} }
else else
{ {
msg = Name + msg; warnParam.PosId = "";
LogUtil.error( msg); warnParam.Barcode = "";
warnParam.OperteType = "";
} }
} }
} }
catch (Exception ex)
{
LogUtil.error("SetWarnMsg Error: " + ex.ToString());
}
WarnMsg = msg; WarnMsg = msg;
warnParam.AlarmType = alarmType;
} }
public bool IsDoValue(string ioType, IO_VALUE ioValue)
protected void ClearStepAlarm(string stepDes)
{ {
return IOValue(ioType).Equals(ioValue); if (isInSuddenDown || isNoAirCheck)
} {
public void LogInfo(string logInfo) return;
}
if (String.IsNullOrEmpty(WarnMsg).Equals(false) && String.IsNullOrEmpty(warnParam.AlarmType).Equals(false))
{
if (alarmType.Equals(StoreAlarmType.IoSingleTimeOut))
{
string alarmTypeStr = stepDes + "_超时报警";
if (warnParam.AlarmType.Equals(alarmTypeStr))
{
LogUtil.info(Name + $"步骤{stepDes}结束,清理【{ WarnMsg }】 ");
alarmType = StoreAlarmType.None;
SetWarnMsg("");
}
}
else if (alarmType.Equals(StoreAlarmType.AxisMoveError))
{
string alarmTypeStr = stepDes + "_轴运动报警";
if (warnParam.AlarmType.Equals(alarmTypeStr))
{
LogUtil.info(Name + $"步骤{stepDes}结束,清理【{ WarnMsg }】 ");
alarmType = StoreAlarmType.None;
SetWarnMsg("");
}
}
}
}
}
public class WarnParam
{
public WarnParam()
{ {
LogUtil.info(Name + logInfo);
} }
public WarnParam(string alarmType, DateTime startTime, string operType, string posId, string barcode)
{
this.AlarmType = alarmType;
this.StartTime = startTime;
this.OperteType = operType;
this.PosId = posId;
this.Barcode = barcode;
}
public string AlarmType = "";
public DateTime StartTime = DateTime.Now;
public string OperteType = "";
public string PosId = "";
public string Barcode = "";
} }
} }
...@@ -4,6 +4,7 @@ using OnlineStore.DeviceLibrary; ...@@ -4,6 +4,7 @@ using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.IO.Ports; using System.IO.Ports;
...@@ -130,24 +131,29 @@ namespace OnlineStore.DeviceLibrary ...@@ -130,24 +131,29 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 料仓原点返回和重置步骤,轴三先相对走3000 /// 料仓原点返回和重置步骤,轴三先相对走3000
/// </summary> /// </summary>
[Description("复位_进出轴原点返回")]
BOX_H_InOutMove = 011, BOX_H_InOutMove = 011,
/// <summary> /// <summary>
/// 料仓原点返回和重置步骤,,轴三进出轴先返回原点 /// 料仓原点返回和重置步骤,,轴三进出轴先返回原点
/// </summary> /// </summary>
[Description("复位_压紧轴,旋转轴,上下轴原点返回")]
BOX_H_InOutBack = 012, BOX_H_InOutBack = 012,
/// <summary> /// <summary>
/// 料仓原点返回和重置步骤,,轴三返回P1点 /// 料仓原点返回和重置步骤,,轴三返回P1点
/// </summary> /// </summary>
[Description("复位_进出轴到待机点P1,关闭舱门")]
BOX_H_InOutToP1 = 013, BOX_H_InOutToP1 = 013,
/// <summary> /// <summary>
/// 料仓原点返回和重置步骤,,升降轴,旋转轴,压紧轴原点返回 /// 料仓原点返回和重置步骤,,压紧轴,旋转轴,上下轴开始 原点返回,关闭舱门
/// </summary> /// </summary>
[Description("复位_压紧轴,旋转轴,上下轴开始 原点返回,关闭舱门")]
BOX_H_OtherAxisBack = 014, BOX_H_OtherAxisBack = 014,
/// <summary> /// <summary>
/// 旋转轴回好原点等待200 /// 旋转轴回好原点等待200
/// </summary> /// </summary>
BOX_H_WaitTime=015, [Description("复位_旋转轴回好原点等待200")]
BOX_H_WaitTime =015,
///// <summary> ///// <summary>
///// 清理轴位置 ///// 清理轴位置
///// </summary> ///// </summary>
...@@ -155,32 +161,39 @@ namespace OnlineStore.DeviceLibrary ...@@ -155,32 +161,39 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 旋转轴返回P1 /// 旋转轴返回P1
/// </summary> /// </summary>
[Description("复位_旋转轴返回P1")]
BOX_H_MiddleAxisToP1 = 016, BOX_H_MiddleAxisToP1 = 016,
/// <summary> /// <summary>
/// 叉子先退回P1 /// 叉子先退回P1
/// </summary> /// </summary>
[Description("复位_叉子先退回P1")]
BOX_M_H_InOutToP1 = 018, BOX_M_H_InOutToP1 = 018,
/// <summary> /// <summary>
/// 旋转轴回原点 /// 旋转轴回原点
/// </summary> /// </summary>
[Description("复位_旋转轴回原点")]
BOX_M_H_MiddleAxisHome = 019, BOX_M_H_MiddleAxisHome = 019,
/// <summary> /// <summary>
/// 旋转轴等待清理位置 /// 旋转轴等待清理位置
/// </summary> /// </summary>
[Description("复位_旋转轴等待清理位置")]
BOX_M_H_MiddleWait = 020, BOX_M_H_MiddleWait = 020,
/// <summary> /// <summary>
/// 叉子走到P1 /// 叉子走到P1
/// </summary> /// </summary>
[Description("复位_叉子走到P1")]
BOX_M_H_TOP1_InOutToP1 = 030, BOX_M_H_TOP1_InOutToP1 = 030,
/// <summary> /// <summary>
/// 压紧轴回原点 /// 压紧轴回原点
/// </summary> /// </summary>
[Description("复位_压紧轴回原点")]
BOX_M_H_TOP1_CompressHome = 031, BOX_M_H_TOP1_CompressHome = 031,
/// <summary> /// <summary>
/// 关闭门,旋转轴到P1,升降轴到P1 /// 关闭门,旋转轴到P1,升降轴到P1
/// </summary> /// </summary>
[Description("复位_关闭门,旋转轴到P1,升降轴到P1")]
BOX_M_H_TOP1_OtherAxisToP1 = 032, BOX_M_H_TOP1_OtherAxisToP1 = 032,
#endregion #endregion
...@@ -190,28 +203,36 @@ namespace OnlineStore.DeviceLibrary ...@@ -190,28 +203,36 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
///料仓出库:叉子先运动到P1 ///料仓出库:叉子先运动到P1
/// </summary> /// </summary>
[Description("出库_取料前_进出轴到P1")]
SO_02_InoutBack = 102, SO_02_InoutBack = 102,
/// <summary> /// <summary>
/// 料仓出库,,所有轴运行到库位, 压紧轴到P3(压紧前点) ,旋转轴到P2( 库位点),升降轴到P5(库位出库前点) /// 料仓出库,,所有轴运行到库位, 压紧轴到P3(压紧前点) ,旋转轴到P2( 库位点),升降轴到P5(库位出库前点)
/// </summary> /// </summary>
[Description("出库_取料_压紧轴至P3(压紧前点) ,旋转轴至P2(库位点),升降轴至P5(库位出库前点) ")]
SO_03_ToBagP, SO_03_ToBagP,
/// <summary> /// <summary>
/// 料仓出库,,叉子进入库位中, 进出轴到P3(库位取放料点) /// 料仓出库,,叉子进入库位中, 进出轴到P3(库位取放料点)
/// </summary> /// </summary>
[Description("出库_取料_进出轴至P3(库位取放料点)")]
SO_04_InoutToP3, SO_04_InoutToP3,
/// <summary> /// <summary>
///料仓出库,, 库位的物品放入叉子上,升降轴到P6( 库位出料缓冲点),压紧轴到P2(压紧点) ///料仓出库,, 库位的物品放入叉子上,升降轴到P6( 库位出料缓冲点),压紧轴到P2(压紧点)
/// </summary> /// </summary>
[Description("出库_取料_升降轴至P6(库位出料缓冲点),压紧轴至P2(压紧点)")]
SO_05_GetWare, SO_05_GetWare,
/// <summary> /// <summary>
///料仓出库,,叉子从 库位返回,进出轴到P1( 待机点) ///料仓出库,,叉子从 库位返回,进出轴到P1( 待机点)
/// </summary> /// </summary>
[Description("出库_取料完成_进出轴至P1(待机点)")]
SO_06_InoutToP1, SO_06_InoutToP1,
/// <summary>
SO_07_TrayCheck , /// 出库:等待叉子料盘检测信号
/// </summary>
[Description("出库_等待叉子料盘检测信号")]
SO_07_TrayCheck,
#region 定位处理:先将料放入定位区,再拿起料到仓门口 #region 定位处理:先将料放入定位区,再拿起料到仓门口
...@@ -219,44 +240,54 @@ namespace OnlineStore.DeviceLibrary ...@@ -219,44 +240,54 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 出库定位:旋转轴 至P2( 库位点)升降轴到P3(库位入库前点) /// 出库定位:旋转轴 至P2( 库位点)升降轴到P3(库位入库前点)
/// </summary> /// </summary>
[Description("出库_取料完成_旋转轴 至P2( 库位点)升降轴到P3(库位入库前点)")]
SOL_11_MoveToBag = 110, SOL_11_MoveToBag = 110,
/// <summary> /// <summary>
/// 出库定位:进出轴到P3(库位取放料点) /// 出库定位:进出轴到P3(库位取放料点)
/// </summary> /// </summary>
[Description("出库_出库定位_进出轴到P3(库位取放料点)")]
SOL_12_InoutToP3, SOL_12_InoutToP3,
/// <summary> /// <summary>
/// 出库定位: 压紧轴到P3( 压紧前点) /// 出库定位: 压紧轴到P3( 压紧前点)
/// </summary> /// </summary>
[Description("出库_出库定位_压紧轴到P3( 压紧前点)")]
SOL_13_ComToP3, SOL_13_ComToP3,
/// <summary> /// <summary>
/// 出库定位:放下物品,升降轴到P4( 库位入料缓冲点) /// 出库定位:放下物品,升降轴到P4( 库位入料缓冲点)
/// </summary> /// </summary>
[Description("出库_出库定位_升降轴到P4( 库位入料缓冲点)")]
SOL_14_UpdownToP4, SOL_14_UpdownToP4,
/// <summary> /// <summary>
/// 出库定位:放下物品后等待200 /// 出库定位:放下物品后等待200
/// </summary> /// </summary>
[Description("出库_出库定位_放下物品后等待200")]
SOL_15_WaitTime, SOL_15_WaitTime,
/// <summary> /// <summary>
/// 出库定位:拿物品,升降轴到P6( 库位出料缓冲点),压紧轴到P2(压紧点) /// 出库定位:拿物品,升降轴到P6( 库位出料缓冲点),压紧轴到P2(压紧点)
/// </summary> /// </summary>
[Description("出库_出库定位_升降轴到P6( 库位出料缓冲点),压紧轴到P2(压紧点)")]
SOL_16_GetWare, SOL_16_GetWare,
/// <summary> /// <summary>
/// 出库定位2:放下物品,升降轴到P4( 库位入料缓冲点) /// 出库定位2:放下物品,升降轴到P4( 库位入料缓冲点)
/// </summary> /// </summary>
[Description("出库_出库定位2_升降轴到P4( 库位入料缓冲点)")]
SOL_17_UpdownToP42, SOL_17_UpdownToP42,
/// <summary> /// <summary>
/// 出库定位2:放下物品后等待200 /// 出库定位2:放下物品后等待200
/// </summary> /// </summary>
[Description("出库_出库定位2_放下物品后等待200")]
SOL_18_WaitTime2, SOL_18_WaitTime2,
/// <summary> /// <summary>
/// 出库定位2:拿物品,升降轴到P6( 库位出料缓冲点),压紧轴到P2(压紧点) /// 出库定位2:拿物品,升降轴到P6( 库位出料缓冲点),压紧轴到P2(压紧点)
/// </summary> /// </summary>
SOL_19_GetWare2, [Description("出库_出库定位2_升降轴到P6( 库位出料缓冲点),压紧轴到P2(压紧点)")]
SOL_19_GetWare2,
/// <summary> /// <summary>
/// 出库定位:叉子从 库位返回,进出轴到P1( 待机点) /// 出库定位:叉子从 库位返回,进出轴到P1( 待机点)
/// </summary> /// </summary>
[Description("出库_出库定位完成_进出轴到P1( 待机点)")]
SOL_20_InoutToP1, SOL_20_InoutToP1,
#endregion #endregion
...@@ -265,38 +296,47 @@ namespace OnlineStore.DeviceLibrary ...@@ -265,38 +296,47 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 料仓出库,,所有设备运行到门,,旋转轴到P1( 待机点)升降轴到P2( 进料口出料前点) /// 料仓出库,,所有设备运行到门,,旋转轴到P1( 待机点)升降轴到P2( 进料口出料前点)
/// </summary> /// </summary>
[Description("出库_放料前_旋转轴至P1(待机点)升降轴至P2(进料口出料前点),打开舱门")]
SO_21_ToDoorP = 121, SO_21_ToDoorP = 121,
/// <summary> /// <summary>
/// 等待门口无料盘 /// 等待门口无料盘
/// </summary> /// </summary>
[Description("出库_放料前_等待门口无料盘信号")]
SO_22_WaitNoTray, SO_22_WaitNoTray,
/// <summary> /// <summary>
/// 料仓出库,,叉子进出料口,,进出轴到P2( 进料口取料点) /// 料仓出库,,叉子进出料口,,进出轴到P2( 进料口取料点)
/// /// </summary> /// /// </summary>
[Description("出库_放料_进出轴到P2( 进料口取料点)")]
SO_23_InoutToP2, SO_23_InoutToP2,
/// <summary> /// <summary>
/// 料仓出库,,把物品放下,,升降轴到P8( 进料口出料缓冲点)压紧轴到P1( 待机点) /// 料仓出库,,把物品放下,,升降轴到P8( 进料口出料缓冲点)压紧轴到P1( 待机点)
/// </summary> /// </summary>
[Description("出库_放料_升降轴到P8( 进料口出料缓冲点)压紧轴到P1( 待机点)")]
SO_24_PutWare, SO_24_PutWare,
/// <summary> /// <summary>
/// 料仓出库,,叉子从出料口返回,,轴3( 叉子) 动作至P1( 待机点) /// 料仓出库,,叉子从出料口返回,,轴3( 叉子) 动作至P1( 待机点)
/// </summary> /// </summary>
[Description("出库_放料_进出轴动作至P1(待机点)")]
SO_25_InoutToP1, SO_25_InoutToP1,
/// <summary> /// <summary>
/// 料仓出库,,升降轴返回,, 轴2至P1( 待机点),关闭仓门 /// 料仓出库,,升降轴返回,, 轴2至P1( 待机点),关闭仓门
/// </summary> /// </summary>
[Description("出库_放料完成_升降轴至P1( 待机点),关闭仓门")]
SO_26_CloseDoor, SO_26_CloseDoor,
/// <summary> /// <summary>
/// 料仓出库,检测料仓门口信号 /// 料仓出库,检测料仓门口信号
/// </summary> /// </summary>
[Description("出库_放料完成_检测料仓门口信号")]
SO_27_CheckTray, SO_27_CheckTray,
/// <summary> /// <summary>
/// 料仓出库,,升降轴返回,, 轴2至P1( 待机点) /// 料仓出库,,升降轴返回,, 轴2至P1( 待机点)
/// </summary> /// </summary>
[Description("出库_放料完成_发送出库完成消息给流水线")]
SO_28_GoBack, SO_28_GoBack,
/// <summary> /// <summary>
/// 等待拿走物品 /// 等待拿走物品
/// </summary> /// </summary>
[Description("出库_放料完成_等待拿走物品")]
SO_29_WaitTake, SO_29_WaitTake,
#endregion #endregion
...@@ -305,6 +345,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -305,6 +345,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 入库检测 /// 入库检测
/// </summary> /// </summary>
[Description("入库_取料前_等待仓门口有料")]
SI_00_TrayCheck = 200, SI_00_TrayCheck = 200,
///// <summary> ///// <summary>
///// 入库,。定位气缸下降 ///// 入库,。定位气缸下降
...@@ -313,56 +354,69 @@ namespace OnlineStore.DeviceLibrary ...@@ -313,56 +354,69 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 入库。。进出轴(叉子)先返回P1 /// 入库。。进出轴(叉子)先返回P1
/// </summary> /// </summary>
[Description("入库_取料_进出轴(叉子)动作至P1,打开舱门")]
SI_02_InOutToP1 = 202, SI_02_InOutToP1 = 202,
/// <summary> /// <summary>
/// 入库。。所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3 /// 入库。。所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3
/// </summary> /// </summary>
[Description("入库_取料_升降轴到P1,旋转轴到P1 ,压紧轴到P3,打开仓门")]
SI_03_AxisToP1 = 203, SI_03_AxisToP1 = 203,
/// <summary> /// <summary>
/// 入库。。压紧物品(有压紧轴的才需要此步骤),压紧轴到P3(压紧前点) /// 入库。。压紧物品(有压紧轴的才需要此步骤),压紧轴到P3(压紧前点)
/// </summary> /// </summary>
[Description("入库_取料_叉子即将取料,发现门未上升到位,重新打开门")]
SI_04_ComToP3 = 204, SI_04_ComToP3 = 204,
/// <summary> /// <summary>
/// 入库。。叉子进入入料口,进出轴到P2( 进料口取料点) /// 入库。。叉子进入入料口,进出轴到P2( 进料口取料点)
/// </summary> /// </summary>
[Description("入库_取料_进出轴至P2(进料口取料点) ")]
SI_05_InoutToP2 = 205, SI_05_InoutToP2 = 205,
/// <summary> /// <summary>
/// 入库。。把物品放入叉子上,升降轴到P7( 进料口取料缓冲点),压紧物品(有压紧轴的才需要此步骤),压紧轴到P2(压紧点) /// 入库。。把物品放入叉子上,升降轴到P7( 进料口取料缓冲点),压紧物品(有压紧轴的才需要此步骤),压紧轴到P2(压紧点)
/// </summary> /// </summary>
[Description("入库_取料_压紧轴至P2(压紧点)),升降轴至P7(进料口取料缓冲点)")]
SI_06_GetReel = 206, SI_06_GetReel = 206,
/// <summary> /// <summary>
/// 入库。。叉子 从入料口抽出,进出轴到P1( 待机点) /// 入库。。叉子 从入料口抽出,进出轴到P1( 待机点)
/// </summary> /// </summary>
[Description("入库_取料_进出轴到P1( 待机点)")]
SI_07_InoutBack = 207, SI_07_InoutBack = 207,
/// <summary> /// <summary>
/// 入库。。,等待检测到料盘 /// 入库。。,等待检测到料盘
/// </summary> /// </summary>
[Description("入库_取料_等待叉子有料")]
SI_08_TrayCheck = 208, SI_08_TrayCheck = 208,
/// <summary> /// <summary>
/// 入库。。移动到库位点,旋转轴到P2( 库位点)升降轴到P3(库位入库前点) /// 入库。。移动到库位点,旋转轴到P2( 库位点)升降轴到P3(库位入库前点)
/// </summary> /// </summary>
[Description("入库_放料_旋转轴至P2(库位点),升降轴至P3(库位入库前点)),关闭舱门")]
SI_09_MoveToBag = 209, SI_09_MoveToBag = 209,
/// <summary> /// <summary>
/// 入库。。叉子进入库位中,进出轴到P3(库位取放料点) /// 入库。。叉子进入库位中,进出轴到P3(库位取放料点)
/// </summary> /// </summary>
[Description("入库_放料_进出轴到P3(库位取放料点)")]
SI_11_InoutToP3 = 211, SI_11_InoutToP3 = 211,
/// <summary> /// <summary>
/// 入库。。放下物品,升降轴到P4( 库位入料缓冲点)压紧轴到P3( 压紧前点) /// 入库。。放下物品,升降轴到P4( 库位入料缓冲点)压紧轴到P3( 压紧前点)
/// </summary> /// </summary>
[Description("入库_放料_升降轴到P4( 库位入料缓冲点)压紧轴到P3( 压紧前点)")]
SI_12_PutReel = 212, SI_12_PutReel = 212,
/// <summary> /// <summary>
/// 入库。。叉子从库位中返回,轴3( 叉子) 动作至P1( 待机点) /// 入库。。叉子从库位中返回,轴3( 叉子) 动作至P1( 待机点)
/// </summary> /// </summary>
[Description("入库_放料_进出轴动作至P1(待机点)")]
SI_13_InoutBack, SI_13_InoutBack,
/// <summary> /// <summary>
/// 入库。。返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始 /// 入库。。返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始
/// </summary> /// </summary>
[Description("入库_放料完成_轴2/轴1/轴4动作至P1(待机点)),检测门关闭")]
SI_14_GoBack, SI_14_GoBack,
/// <summary> /// <summary>
/// 入库。等待叉子无信号 /// 入库。等待叉子无信号
/// </summary> /// </summary>
[Description("入库_放料完成_等待料叉无信号")]
SI_15_WaitNoReel, SI_15_WaitNoReel,
#endregion #endregion
...@@ -371,18 +425,22 @@ namespace OnlineStore.DeviceLibrary ...@@ -371,18 +425,22 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 盘点 料叉回原点P1 /// 盘点 料叉回原点P1
/// </summary> /// </summary>
[Description("盘点_进出轴返回P1")]
SC_01_InOutAxisHome, SC_01_InOutAxisHome,
/// <summary> /// <summary>
/// 料叉背面移动到库位低点 /// 料叉背面移动到库位低点
/// </summary> /// </summary>
[Description("盘点_料叉背面移动到库位低点")]
SC_02_MoveToLBag, SC_02_MoveToLBag,
/// <summary> /// <summary>
/// 料叉背面移动到库位高点 /// 料叉背面移动到库位高点
/// </summary> /// </summary>
[Description("盘点_料叉背面移动到库位高点")]
SC_03_MoveToHBag, SC_03_MoveToHBag,
/// <summary> /// <summary>
/// 盘点仓位 /// 盘点仓位
/// </summary> /// </summary>
[Description("盘点_盘点仓位")]
SC_04_Inventory, SC_04_Inventory,
#endregion #endregion
...@@ -391,30 +449,37 @@ namespace OnlineStore.DeviceLibrary ...@@ -391,30 +449,37 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 校准位置:进出轴回原点 /// 校准位置:进出轴回原点
/// </summary> /// </summary>
AP_01_InoutHome=10001, [Description("校准位置_进出轴回原点")]
AP_01_InoutHome =10001,
/// <summary> /// <summary>
/// 校准位置:升降轴回原点 /// 校准位置:升降轴回原点
/// </summary> /// </summary>
[Description("校准位置_升降轴回原点")]
AP_02_UpdownHome, AP_02_UpdownHome,
/// <summary> /// <summary>
/// 位置校准:升降轴移动到开始位置 /// 位置校准:升降轴移动到开始位置
/// </summary> /// </summary>
[Description("校准位置_升降轴移动到开始位置")]
AP_03_UpdownMove, AP_03_UpdownMove,
/// <summary> /// <summary>
/// 校准位置:旋转轴选择到对应位置 /// 校准位置:旋转轴选择到对应位置
/// </summary> /// </summary>
[Description("校准位置_旋转轴选择到对应位置")]
AP_04_MiddleMove, AP_04_MiddleMove,
/// <summary> /// <summary>
/// 校准位置:进出轴到前进位置 /// 校准位置:进出轴到前进位置
/// </summary> /// </summary>
[Description("校准位置_进出轴到前进位置")]
AP_05_InoutToP, AP_05_InoutToP,
/// <summary> /// <summary>
/// 校准位置:升降轴开始匀速移动到目标位置 /// 校准位置:升降轴开始匀速移动到目标位置
/// </summary> /// </summary>
[Description("校准位置_升降轴开始匀速移动到目标位置")]
AP_06_UpdownMove, AP_06_UpdownMove,
/// <summary> /// <summary>
/// 校准位置:保存当前列位置 /// 校准位置:保存当前列位置
/// </summary> /// </summary>
[Description("校准位置_保存当前列位置")]
AP_07_SaveAndNext, AP_07_SaveAndNext,
#endregion #endregion
......
...@@ -3,6 +3,7 @@ using OnlineStore.DeviceLibrary; ...@@ -3,6 +3,7 @@ using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -14,12 +15,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -14,12 +15,14 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
public class StoreMoveInfo public class StoreMoveInfo
{ {
private string Name;
/// <summary> /// <summary>
/// 超时时间 /// 超时时间
/// </summary> /// </summary>
public int TimeOutSeconds = 60; public int TimeOutSeconds = 60;
public StoreMoveInfo(int storeId) public StoreMoveInfo(int storeId,string name)
{ {
this.Name = name;
moveType = StoreMoveType.None; moveType = StoreMoveType.None;
MoveParam = new InOutParam(); MoveParam = new InOutParam();
...@@ -96,6 +99,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -96,6 +99,7 @@ namespace OnlineStore.DeviceLibrary
public void NextMoveStep(StoreMoveStep step) public void NextMoveStep(StoreMoveStep step)
{ {
stepMoveLog();
PreMoveStep = moveStep; PreMoveStep = moveStep;
moveStep = step; moveStep = step;
LastSetpTime = DateTime.Now; LastSetpTime = DateTime.Now;
...@@ -131,6 +135,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -131,6 +135,7 @@ namespace OnlineStore.DeviceLibrary
} }
public void EndMove() public void EndMove()
{ {
stepMoveLog();
this.moveType = StoreMoveType.None; this.moveType = StoreMoveType.None;
this.MoveParam = null; this.MoveParam = null;
moveStep = StoreMoveStep.Wait; moveStep = StoreMoveStep.Wait;
...@@ -153,8 +158,73 @@ namespace OnlineStore.DeviceLibrary ...@@ -153,8 +158,73 @@ namespace OnlineStore.DeviceLibrary
moveStep = PreMoveStep; moveStep = PreMoveStep;
IsInWait = false; IsInWait = false;
} }
private void stepMoveLog()
{
try
{
RunLogUtil.MoveLog(new MoveLog(Name, GetMoveType(), GetStepDes(), LastSetpTime, DateTime.Now, MoveParam.PosInfo?.PosId, MoveParam.PosInfo?.barcode));
}
catch (Exception ex)
{
}
}
public string GetStepDes()
{
string currName = moveStep.ToString();
try
{
if (StoreManager.StepDesMap.ContainsKey(currName))
{
return StoreManager.StepDesMap[currName];
}
}
catch (Exception ex)
{
LogUtil.error("GetStepDes 出错:" + ex.ToString());
}
return currName;
}
public string GetMoveType()
{
switch (moveType)
{
case StoreMoveType.InStore:
return "入料";
break;
case StoreMoveType.OutStore:
return "出料";
break;
case StoreMoveType.StoreReset:
return "复位";
break;
case StoreMoveType.ReturnHome:
return "回原";
break;
}
return "";
}
} }
public static class EnumDesHelper
{
public static string GetStepDes(this Enum val)
{
var type = val.GetType();
var memberInfo = type.GetMember(val.ToString());
var attributes = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attributes == null || attributes.Length != 1)
{
//如果没有定义描述,就把当前枚举值的对应名称返回
return val.ToString();
}
return (attributes.Single() as DescriptionAttribute).Description;
}
}
public class WaitResultInfo public class WaitResultInfo
{ {
private WaitResultInfo() private WaitResultInfo()
......
...@@ -66,14 +66,32 @@ ...@@ -66,14 +66,32 @@
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n" />
</layout> </layout>
</appender> </appender>
<appender name="RunLog" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="logs/log/RunLog-%property{fname}.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="InOutStore"> <logger name="InOutStore">
<level value="Info" /> <level value="Info" />
<appender-ref ref="InOutStore" /> <appender-ref ref="InOutStore" />
</logger> </logger>
<root> <!--<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
</root>-->
<logger name="RollingLogFileAppender">
<level value="Info" /> <level value="Info" />
<appender-ref ref="RollingLogFileAppender" /> <appender-ref ref="RollingLogFileAppender" />
</root> </logger>
<logger name="RunLog">
<level value="Info" />
<appender-ref ref="RunLog" />
</logger>
</log4net> </log4net>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!