Commit b3c81d79 LN

1

1 个父辈 3800bd60
......@@ -67,10 +67,29 @@
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<root>
<appender name="RfidLog" type="log4net.Appender.RollingFileAppender">
<file value="logs/RFID.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" />
</logger>
<logger name="RfidLog">
<level value="Debug" />
<appender-ref ref="RfidLog" />
</logger>
<!--<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</root>-->
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
......
......@@ -15,7 +15,7 @@ namespace OnlineStore.Common
private static LogUtil instance = new LogUtil();
public delegate void ShowLog(string msg, Color color);
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static readonly ILog rfidLog = LogManager.GetLogger("RfidLog");
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null;
......@@ -74,13 +74,16 @@ namespace OnlineStore.Common
}
}
public static void RfidLog(string msg)
{
rfidLog.Debug(msg);
}
public static void error(string errorMsg, int type)
{
if (lastErrorLogTime.ContainsKey(type))
{
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds > 5)
if (span.TotalSeconds > 10)
{
lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now);
......
......@@ -123,7 +123,7 @@ namespace OnlineStore.DeviceLibrary
}
private DateTime lastProTimer = DateTime.Now;
protected int TimerMaxSeconds = 1;
protected int TimerMaxSeconds = 3;
public void TimerProcess()
{
......@@ -306,7 +306,7 @@ namespace OnlineStore.DeviceLibrary
#region CheckWait处理
private DateTime preCheckAxisTime = DateTime.Now;
protected DateTime preRWTime = DateTime.Now;
internal void CheckWait(LineMoveInfo moveInfo)
{
......@@ -333,24 +333,29 @@ namespace OnlineStore.DeviceLibrary
}
NotOkMsg = wait.ToStr();
if (wait.WaitType.Equals(WaitEnum.W001_AxisMove))
{
string msg = "";
if (wait.IsHomeMove)
{
TimeSpan axisSpan = DateTime.Now - preCheckAxisTime;
if (axisSpan.TotalSeconds > 1)
{
wait.IsEnd = AxisBean.HomeMoveIsEnd(moveInfo, wait.AxisInfo, out msg);
}
else
{
wait.IsEnd = AxisBean.ACAxisMoveIsEnd(moveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = Name + msg;
Alarm(LineAlarmType.AxisMoveError);
LogUtil.error(WarnMsg, DeviceID + 18);
break;
preCheckAxisTime = DateTime.Now;
string msg = "";
if (wait.IsHomeMove)
{
wait.IsEnd = AxisBean.HomeMoveIsEnd(moveInfo, wait.AxisInfo, out msg);
}
else
{
wait.IsEnd = AxisBean.ACAxisMoveIsEnd(moveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = Name + msg;
Alarm(LineAlarmType.AxisMoveError);
LogUtil.error(WarnMsg, DeviceID + 18);
break;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W002_IOValue))
......@@ -406,7 +411,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
else if (wait.WaitType.Equals(WaitEnum.W008_InStoreCheckOK))
......
......@@ -299,10 +299,10 @@ namespace OnlineStore.DeviceLibrary
}
else
{
Task.Factory.StartNew(delegate
{
// Task.Factory.StartNew(delegate
//{
bool result = moveEquip.StartRun();
});
// });
Thread.Sleep(60);
}
......@@ -393,7 +393,7 @@ namespace OnlineStore.DeviceLibrary
mainTimer.Enabled = true;
return true;
}
private void EquipReset(EquipBase equip,bool isNeedAllReset)
private void EquipReset(EquipBase equip, bool isNeedAllReset)
{
//调试状态不再重置
if (!equip.IsDebug)
......@@ -401,9 +401,9 @@ namespace OnlineStore.DeviceLibrary
if (isNeedAllReset || TrayManager.ErrorDeviceId.Equals(equip.DeviceID) || (!NoAlarm()))
{
LogUtil.info(Name + "收到复位信号," + equip.Name + " 需要复位");
Task.Factory.StartNew(delegate {
equip.Reset();
});
// Task.Factory.StartNew(delegate {
equip.Reset();
// });
Thread.Sleep(60);
}
else
......@@ -424,7 +424,8 @@ namespace OnlineStore.DeviceLibrary
IoCheckTimer.Enabled = false;
mainTimer.Enabled = false;
ledProcessTimer.Enabled = false;
WriteDrivetMotorRun(IO_VALUE.LOW);
//停止运行时,把阻挡气缸上升
StopMove();
runStatus = LineRunStatus.Wait;
......
......@@ -68,24 +68,7 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
//internal bool DLineStopOut(int dlineId, int LineNum)
//{
// foreach (DischargeLine line in DisLineMap.Values)
// {
// if ((line.DeviceID % 100).Equals(dlineId))
// {
// if (LineNum.Equals(1) && line.MoveInfo.MoveType.Equals(LineMoveType.OutStore))
// {
// line.MoveInfo.EndMove();
// }
// else if (LineNum.Equals(2) && line.SecondMoveInfo.MoveType.Equals(LineMoveType.OutStore))
// {
// line.SecondMoveInfo.EndMove();
// }
// }
// }
// return false;
//}
private bool isInprocess = false;
private DateTime lastProTime = DateTime.Now;
private void InOutTimerProcess()
......
......@@ -125,7 +125,13 @@ namespace OnlineStore.DeviceLibrary
public static void Close()
{
RfidReader.Close();
try
{
RfidReader.Close();
}catch(Exception ex)
{
LogUtil.error("关闭RFID出错:" + ex.ToString());
}
}
}
public class RFIDData
......
......@@ -393,7 +393,7 @@ namespace OnlineStore.DeviceLibrary
{
return GetActualtPosition(axis.DeviceName, axis.GetAxisValue());
}
public static int GetActualtPosition(string portName, int slvAddr)
public static int GetActualtPosition(string portName, int slvAddr,int rGetCount=2)
{
PreReadAddr = ACCMDManager.ActualPosition;
byte[] dataArray = ACCMDManager.GetWriteData(slvAddr, ACCMDManager.CMD_ReadRegisters, ACCMDManager.ActualPosition, "0000", 2);
......@@ -401,7 +401,7 @@ namespace OnlineStore.DeviceLibrary
byte[] reviceData = SendCommand(portName, dataArray, ReviceOutTimeMS, 9);
int result = -1;
for (int i = 1; i <= 3; i++)
for (int i = 1; i <= rGetCount; i++)
{
result = GetRegisterData(portName, reviceData, ACCMDManager.ActualPosition);
if (!result.Equals(-1))
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!