Commit 0522a86d 几米阳光

修改日志打印

1 个父辈 f1e41247
......@@ -105,152 +105,259 @@ namespace OnlineStore.DeviceLibrary
List<WaitResultInfo> list = StoreMove.WaitList;
//当等待超过一分钟时,需要打印提示
TimeSpan span = DateTime.Now - StoreMove.LastSetpTime;
if (span.TotalMinutes > 5)
string NotOkMsg = "";
if (list.Count <= 0)
{
WarnMsg = StoreName + "等待超时【" + StoreMove.MoveType + "】【" + StoreMove.MoveStep + "】已等待【" + Math.Round(span.TotalMinutes) + "】分钟,";
foreach (WaitResultInfo wait in list)
{
WarnMsg = WarnMsg + "\r\n" + wait.ToStr();
}
LogUtil.error(LOGGER, WarnMsg, 12);
Alarm(StoreAlarmType.IoSingleTimeOut, "", WarnMsg, StoreMove.MoveType);
StoreMove.EndStepWait();
return;
}
bool isOk = true;
if (StoreMove.OneWaitCanEndStep)
{
isOk = false;
}
if (list.Count > 0)
foreach (WaitResultInfo wait in list)
{
bool isOk = true;
foreach (WaitResultInfo wait in list)
if (wait.IsEnd)
{
if (wait.WaitType == 1)
{
string msg = "";
if (wait.IsHomeMove)
{
if (wait.IsEnd.Equals(false) && (!ACHomeMoveIsEnd(wait.AxisInfo, out msg)))
{
if (!msg.Equals(""))
{
WarnMsg = msg;
Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, StoreMove.MoveType);
}
isOk = false;
break;
}
else
{
wait.IsEnd = true;
}
}
else
{
if (!wait.IsEnd)
{
bool isEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = msg;
Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, StoreMove.MoveType);
break;
}
else if (!isEnd)
{
isOk = false;
break;
}
else
{
wait.IsEnd = true;
}
}
else
{
}
}
}
else if (wait.WaitType == 2)
{
if (!KNDIOValue(wait.IoType).Equals(wait.IoValue))
{
//一分钟还未检测到
if (span.TotalMilliseconds > Config.IOSingle_TimerOut)
{
ConfigIO io = Config.getWaitIO(wait.IoType);
WarnMsg = StoreName + " 等待信号" + io.DisplayStr + "=" + wait.IoValue + "超时!";
//SendAlarmCode(StoreID, LineAlarm.IoNotOk, wait.IoType);
Alarm(StoreAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, StoreMove.MoveType);
LogUtil.error(LOGGER, StoreName + wait.IoType + "等待信号(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", 14);
}
isOk = false;
if (StoreMove.OneWaitCanEndStep.Equals(false))
{
break;
}
}
else if (StoreMove.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else if (wait.WaitType == 3)
{
if (span.TotalMilliseconds < wait.TimeMSeconds)
{
isOk = false;
if (StoreMove.OneWaitCanEndStep.Equals(false))
{
break;
}
}
else if (StoreMove.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else if (wait.WaitType == 5)
{
if (wait.IsHomeMove)
{
if (!ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime))
{
ShuoKeControls.GetStatus(wait.SlvAddr);
isOk = false;
break;
}
else if (StoreMove.OneWaitCanEndStep)
{
isOk = true; break;
}
}
else
{
if (!ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime))
{
ShuoKeControls.GetStatus(wait.SlvAddr);
isOk = false;
break;
}
else if (StoreMove.OneWaitCanEndStep)
{
isOk = true; break;
}
}
}
continue;
}
NotOkMsg = wait.ToStr();
if (wait.WaitType == 1)
{
string msg = "";
if (wait.IsHomeMove)
{
wait.IsEnd = ACHomeMoveIsEnd(wait.AxisInfo, out msg);
}
else
{
wait.IsEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = msg;
Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, StoreMove.MoveType);
break;
}
}
else if (wait.WaitType == 2)
{
wait.IsEnd = KNDIOValue(wait.IoType).Equals(wait.IoValue);
int timeOutMs = Config.IOSingle_TimerOut;
if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs)
{
ConfigIO io = Config.getWaitIO(wait.IoType);
WarnMsg = StoreName + " 等待信号" + io.DisplayStr + "=" + wait.IoValue + "超时!";
Alarm(StoreAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, StoreMove.MoveType);
LogUtil.error(LOGGER, StoreName + wait.IoType + "等待信号(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", 14);
isOk = false;
break;
}
}
else if (wait.WaitType == 3)
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
if (isOk)
else if (wait.WaitType == 5)
{
StoreMove.EndStepWait();
if (wait.IsHomeMove)
{
wait.IsEnd = ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime);
}
else
{
wait.IsEnd = ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime);
}
if (!wait.IsEnd)
{
ShuoKeControls.GetStatus(wait.SlvAddr);
}
}
if (wait.IsEnd)
{
if (StoreMove.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else
{
if (!StoreMove.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
else
if (isOk)
{
StoreMove.EndStepWait();
}
else if (span.TotalSeconds > 120)
{
WarnMsg = StoreName + "【" + StoreMove.MoveType + "】【" + StoreMove.MoveStep + "】等待超时 [" + NotOkMsg
+ "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒";
LogUtil.error(LOGGER, WarnMsg);
Alarm(StoreAlarmType.IoSingleTimeOut, "", WarnMsg, StoreMove.MoveType);
}
}
//private void CheckWait()
//{
// List<WaitResultInfo> list = StoreMove.WaitList;
// //当等待超过一分钟时,需要打印提示
// TimeSpan span = DateTime.Now - StoreMove.LastSetpTime;
// if (span.TotalMinutes > 5)
// {
// WarnMsg = StoreName + "等待超时【" + StoreMove.MoveType + "】【" + StoreMove.MoveStep + "】已等待【" + Math.Round(span.TotalMinutes) + "】分钟,";
// foreach (WaitResultInfo wait in list)
// {
// WarnMsg = WarnMsg + "\r\n" + wait.ToStr();
// }
// LogUtil.error(LOGGER, WarnMsg, 12);
// Alarm(StoreAlarmType.IoSingleTimeOut, "", WarnMsg, StoreMove.MoveType);
// }
// if (list.Count > 0)
// {
// bool isOk = true;
// foreach (WaitResultInfo wait in list)
// {
// if (wait.WaitType == 1)
// {
// string msg = "";
// if (wait.IsHomeMove)
// {
// if (wait.IsEnd.Equals(false) && (!ACHomeMoveIsEnd(wait.AxisInfo, out msg)))
// {
// if (!msg.Equals(""))
// {
// WarnMsg = msg;
// Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, StoreMove.MoveType);
// }
// isOk = false;
// break;
// }
// else
// {
// wait.IsEnd = true;
// }
// }
// else
// {
// if (!wait.IsEnd)
// {
// bool isEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
// if (!msg.Equals(""))
// {
// isOk = false;
// WarnMsg = msg;
// Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, StoreMove.MoveType);
// break;
// }
// else if (!isEnd)
// {
// isOk = false;
// break;
// }
// else
// {
// wait.IsEnd = true;
// }
// }
// else
// {
// }
// }
// }
// else if (wait.WaitType == 2)
// {
// if (!KNDIOValue(wait.IoType).Equals(wait.IoValue))
// {
// //一分钟还未检测到
// if (span.TotalMilliseconds > Config.IOSingle_TimerOut)
// {
// ConfigIO io = Config.getWaitIO(wait.IoType);
// WarnMsg = StoreName + " 等待信号" + io.DisplayStr + "=" + wait.IoValue + "超时!";
// //SendAlarmCode(StoreID, LineAlarm.IoNotOk, wait.IoType);
// Alarm(StoreAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, StoreMove.MoveType);
// LogUtil.error(LOGGER, StoreName + wait.IoType + "等待信号(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", 14);
// }
// isOk = false;
// if (StoreMove.OneWaitCanEndStep.Equals(false))
// {
// break;
// }
// }
// else if (StoreMove.OneWaitCanEndStep)
// {
// isOk = true;
// break;
// }
// }
// else if (wait.WaitType == 3)
// {
// if (span.TotalMilliseconds < wait.TimeMSeconds)
// {
// isOk = false;
// if (StoreMove.OneWaitCanEndStep.Equals(false))
// {
// break;
// }
// }
// else if (StoreMove.OneWaitCanEndStep)
// {
// isOk = true;
// break;
// }
// }
// else if (wait.WaitType == 5)
// {
// if (wait.IsHomeMove)
// {
// if (!ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime))
// {
// ShuoKeControls.GetStatus(wait.SlvAddr);
// isOk = false;
// break;
// }
// else if (StoreMove.OneWaitCanEndStep)
// {
// isOk = true; break;
// }
// }
// else
// {
// if (!ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime))
// {
// ShuoKeControls.GetStatus(wait.SlvAddr);
// isOk = false;
// break;
// }
// else if (StoreMove.OneWaitCanEndStep)
// {
// isOk = true; break;
// }
// }
// }
// }
// if (isOk)
// {
// StoreMove.EndStepWait();
// }
// }
// else
// {
// StoreMove.EndStepWait();
// }
//}
#endregion
#region 入库
......
......@@ -263,8 +263,8 @@ namespace OnlineStore.DeviceLibrary
{
moveAxis.TargetPosition = targetPosition;
AddAxisMoveTime(moveAxis);
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition,targetSpeed);
StoreMove.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, targetPosition, targetSpeed));
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
}
/// <summary>
......
......@@ -234,11 +234,11 @@ namespace OnlineStore.DeviceLibrary
{
if (IsHomeMove)
{
return "轴【" + AxisInfo.DisplayStr + "】原点返回";
return "轴【" + AxisInfo.DisplayStr + "】原点返回";
}
else
{
return "轴【" + AxisInfo.DisplayStr + "】绝对运动,目标位置【" + TargetPosition + "】";
return "轴【" + AxisInfo.DisplayStr + "】绝对运动【" + TargetPosition + "】";
}
}
else if (WaitType == 2)
......@@ -259,8 +259,9 @@ namespace OnlineStore.DeviceLibrary
}
else if (WaitType == 6)
{
return "轴【" + AxisInfo.DisplayStr + "】ORG信号:【" + IoValue + "】 ";
return "轴【" + AxisInfo.DisplayStr + "】ORG信号:【" + IoValue + "】 ";
}
else
{
return "Wait位置类型:WaitType=【" + WaitType + "】";
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!