Commit 0aff9dd7 张东亮

timer改为线程

1 个父辈 7290c4f8
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
<Reference Include="CodeLibrary"> <Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath> <HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference> </Reference>
<Reference Include="ConfigHelper">
<HintPath>..\..\..\..\..\..\SharedRefDll\Neotel\ConfigHelper\Debug\net461\ConfigHelper.dll</HintPath>
</Reference>
<Reference Include="halcondotnet"> <Reference Include="halcondotnet">
<HintPath>..\..\dll\halcondotnet.dll</HintPath> <HintPath>..\..\dll\halcondotnet.dll</HintPath>
</Reference> </Reference>
......
...@@ -36,7 +36,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -36,7 +36,7 @@ namespace OnlineStore.DeviceLibrary
protected abstract void BaseTimerProcess(); protected abstract void BaseTimerProcess();
protected abstract void FixtureProcess(); protected abstract void FixtureProcess();
protected override void mainTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) protected override void mainThread_Process()
{ {
TimerProcess(); TimerProcess();
} }
...@@ -61,12 +61,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -61,12 +61,12 @@ namespace OnlineStore.DeviceLibrary
} }
this.alarmType = alarmType; this.alarmType = alarmType;
if (alarmType.Equals(LineAlarmType.SuddenStop) || alarmType.Equals(LineAlarmType.NoAirCheck) if (alarmType.Equals(LineAlarmType.SuddenStop) || alarmType.Equals(LineAlarmType.NoAirCheck)
||alarmType.Equals(LineAlarmType.AxisAlarm)||alarmType.Equals(LineAlarm.AxisErrorStop)) || alarmType.Equals(LineAlarmType.AxisAlarm) || alarmType.Equals(LineAlarm.AxisErrorStop))
{ {
StopMove(alarmType+"报警"); StopMove(alarmType + "报警");
} }
} }
public virtual void CheckAlarmProcess(LineMoveInfo moveInfo,LineAlarmType alarmType) public virtual void CheckAlarmProcess(LineMoveInfo moveInfo, LineAlarmType alarmType)
{ {
} }
...@@ -74,7 +74,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -74,7 +74,7 @@ namespace OnlineStore.DeviceLibrary
{ {
List<string> doList = new List<string>(baseConfig.DOList.Keys); List<string> doList = new List<string>(baseConfig.DOList.Keys);
foreach(string doType in doList) foreach (string doType in doList)
{ {
if (doType.Equals(IO_Type.SL_AlarmLed) || doType.Equals(IO_Type.SL_HddLed)) if (doType.Equals(IO_Type.SL_AlarmLed) || doType.Equals(IO_Type.SL_HddLed))
{ {
...@@ -116,7 +116,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -116,7 +116,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(Name + "TimerProcess出错:",ex); LogUtil.error(Name + "TimerProcess出错:", ex);
} }
isInPro = false; isInPro = false;
...@@ -136,7 +136,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -136,7 +136,7 @@ namespace OnlineStore.DeviceLibrary
return; return;
} }
//若BOX和出料都没有在等待Io的过程中则此Io超时异常可能已经处理过 //若BOX和出料都没有在等待Io的过程中则此Io超时异常可能已经处理过
if (MoveInfo.MoveType.Equals(LineMoveType.None)&& SecondMoveInfo.MoveType.Equals(LineMoveType.None)&& MoveInfo.IsInWait.Equals(false) && SecondMoveInfo.IsInWait.Equals(false)) if (MoveInfo.MoveType.Equals(LineMoveType.None) && SecondMoveInfo.MoveType.Equals(LineMoveType.None) && MoveInfo.IsInWait.Equals(false) && SecondMoveInfo.IsInWait.Equals(false))
{ {
LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 "); LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 ");
alarmType = LineAlarmType.None; alarmType = LineAlarmType.None;
...@@ -146,7 +146,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -146,7 +146,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("IOTimeOutProcess出错:",ex); LogUtil.error("IOTimeOutProcess出错:", ex);
} }
} }
protected override void BusyMoveProcess() protected override void BusyMoveProcess()
...@@ -178,7 +178,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -178,7 +178,8 @@ namespace OnlineStore.DeviceLibrary
{ {
ResetProcess(); ResetProcess();
} }
}catch(Exception ex) }
catch (Exception ex)
{ {
LogUtil.error(Name + " BusyMoveProcess 出错:" + ex.ToString()); LogUtil.error(Name + " BusyMoveProcess 出错:" + ex.ToString());
} }
...@@ -208,7 +209,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -208,7 +209,7 @@ namespace OnlineStore.DeviceLibrary
string canResult = LineManager.Line.CanStart(); string canResult = LineManager.Line.CanStart();
if (String.IsNullOrEmpty(canResult).Equals(false)) if (String.IsNullOrEmpty(canResult).Equals(false))
{ {
SetWarnMsg(Name+ canResult); SetWarnMsg(Name + canResult);
return false; return false;
} }
return true; return true;
...@@ -280,7 +281,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -280,7 +281,7 @@ namespace OnlineStore.DeviceLibrary
internal virtual void OpenStopBlock() internal virtual void OpenStopBlock()
{ {
preRWTime = DateTime.Now; preRWTime = DateTime.Now;
if (baseConfig.DType.Equals(DeviceType.MoveEquip) ) if (baseConfig.DType.Equals(DeviceType.MoveEquip))
{ {
LogInfo("OpenStopCylinder: 下降阻挡气缸,上下气缸上升,顶升气缸下降"); LogInfo("OpenStopCylinder: 下降阻挡气缸,上下气缸上升,顶升气缸下降");
IOMove(IO_Type.StopDown1, IO_VALUE.HIGH); IOMove(IO_Type.StopDown1, IO_VALUE.HIGH);
...@@ -293,7 +294,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -293,7 +294,8 @@ namespace OnlineStore.DeviceLibrary
//顶升气缸下降 //顶升气缸下降
CylinderMove(null, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down); CylinderMove(null, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
Thread.Sleep(30); Thread.Sleep(30);
} else if (baseConfig.DType.Equals(DeviceType.FeedingEquip)) }
else if (baseConfig.DType.Equals(DeviceType.FeedingEquip))
{ {
} }
...@@ -301,7 +303,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -301,7 +303,7 @@ namespace OnlineStore.DeviceLibrary
internal virtual bool OpenStopBlockOk(TimeSpan span) internal virtual bool OpenStopBlockOk(TimeSpan span)
{ {
TimeSpan rwSpan = DateTime.Now - preRWTime; TimeSpan rwSpan = DateTime.Now - preRWTime;
if (baseConfig.DType.Equals(DeviceType.MoveEquip) ) if (baseConfig.DType.Equals(DeviceType.MoveEquip))
{ {
if (IOValue(IO_Type.StopDown1).Equals(IO_VALUE.HIGH) && if (IOValue(IO_Type.StopDown1).Equals(IO_VALUE.HIGH) &&
IOValue(IO_Type.StopDown2).Equals(IO_VALUE.HIGH)) IOValue(IO_Type.StopDown2).Equals(IO_VALUE.HIGH))
...@@ -323,7 +325,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -323,7 +325,7 @@ namespace OnlineStore.DeviceLibrary
} }
internal virtual void CloseStopBlock() internal virtual void CloseStopBlock()
{ {
if (baseConfig.DType.Equals(DeviceType.MoveEquip) ) if (baseConfig.DType.Equals(DeviceType.MoveEquip))
{ {
LogInfo("CloseCylinderStop: 上升阻挡气缸,关闭上下气缸,顶升气缸IO"); LogInfo("CloseCylinderStop: 上升阻挡气缸,关闭上下气缸,顶升气缸IO");
...@@ -398,20 +400,20 @@ namespace OnlineStore.DeviceLibrary ...@@ -398,20 +400,20 @@ namespace OnlineStore.DeviceLibrary
{ {
return true; return true;
} }
SetWarnMsg(Name + msg,axis.Config.DisplayStr+"_轴报警"); SetWarnMsg(Name + msg, axis.Config.DisplayStr + "_轴报警");
Alarm(LineAlarmType.AxisAlarm); Alarm(LineAlarmType.AxisAlarm);
return false; return false;
} }
public void CloseAxis(AxisBean axis) public void CloseAxis(AxisBean axis)
{ {
LogUtil.info(Name + "关闭伺服 "+axis.AxisName); LogUtil.info(Name + "关闭伺服 " + axis.AxisName);
axis.ServoOff(); axis.ServoOff();
Thread.Sleep(100); Thread.Sleep(100);
} }
private DateTime checkAlarmTime = DateTime.Now; private DateTime checkAlarmTime = DateTime.Now;
public bool CheckAxisAlarm(params AxisBean[] axisList ) public bool CheckAxisAlarm(params AxisBean[] axisList)
{ {
if (!NoErrorAlarm()) if (!NoErrorAlarm())
{ {
...@@ -534,9 +536,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -534,9 +536,9 @@ namespace OnlineStore.DeviceLibrary
if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut && alarmType <= LineAlarmType.IoSingleTimeOut) if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut && alarmType <= LineAlarmType.IoSingleTimeOut)
{ {
ConfigIO io = baseConfig.getWaitIO(wait.IoType); ConfigIO io = baseConfig.getWaitIO(wait.IoType);
string 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); SetWarnMsg(warnmsg, moveInfo.GetStepDes() + "_超时报警", moveInfo);
LogUtil.error( WarnMsg, DeviceID * 1000 + 13); LogUtil.error(WarnMsg, DeviceID * 1000 + 13);
if (NoAlarm()) if (NoAlarm())
{ {
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
...@@ -586,7 +588,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -586,7 +588,7 @@ namespace OnlineStore.DeviceLibrary
else if (wait.WaitType.Equals(WaitEnum.W009_BoxCanInstore)) else if (wait.WaitType.Equals(WaitEnum.W009_BoxCanInstore))
{ {
int storeId = moveInfo.MoveParam.GetStoreId(); int storeId = moveInfo.MoveParam.GetStoreId();
wait.IsEnd = LineServer.BoxCanReviceTray(storeId,out NotOkMsg); wait.IsEnd = LineServer.BoxCanReviceTray(storeId, out NotOkMsg);
} }
else else
{ {
...@@ -681,7 +683,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -681,7 +683,7 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.debug(Name + "" + msg); LogUtil.debug(Name + "" + msg);
} }
protected void InLog(string msg ) protected void InLog(string msg)
{ {
string posId = MoveInfo.MoveParam != null ? "[" + currTrayNum + "][" + MoveInfo.MoveParam.PosId + "][" + MoveInfo.MoveParam.WareCode + "]" : ""; string posId = MoveInfo.MoveParam != null ? "[" + currTrayNum + "][" + MoveInfo.MoveParam.PosId + "][" + MoveInfo.MoveParam.WareCode + "]" : "";
//baseConfig.DType.Equals(DeviceType.HYEquip) //baseConfig.DType.Equals(DeviceType.HYEquip)
......
...@@ -45,7 +45,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -45,7 +45,8 @@ namespace OnlineStore.DeviceLibrary
RFIDIP = RFIDManager.GetRFIP(DeviceID); RFIDIP = RFIDManager.GetRFIP(DeviceID);
HasOutLine = config.DOList.ContainsKey(IO_Type.SL_OutLine_Run); HasOutLine = config.DOList.ContainsKey(IO_Type.SL_OutLine_Run);
addLastDI(IO_Type.SL_Reset_BTN, IO_VALUE.LOW); addLastDI(IO_Type.SL_Reset_BTN, IO_VALUE.LOW);
mainTimer.Enabled = true; //mainTimer.Enabled = true;
mainStart();
} }
public override bool StartRun(bool isDebug = false) public override bool StartRun(bool isDebug = false)
...@@ -68,7 +69,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -68,7 +69,8 @@ namespace OnlineStore.DeviceLibrary
} }
if (RunAxis(true, BatchAxis) && RunAxis(true, UpdownAxis)) if (RunAxis(true, BatchAxis) && RunAxis(true, UpdownAxis))
{ {
mainTimer.Enabled = false; //mainTimer.Enabled = false;
mainStop();
MoveInfo.EndMove(); MoveInfo.EndMove();
SecondMoveInfo.EndMove(); SecondMoveInfo.EndMove();
runStatus = LineRunStatus.HomeMoving; runStatus = LineRunStatus.HomeMoving;
...@@ -81,7 +83,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -81,7 +83,8 @@ namespace OnlineStore.DeviceLibrary
if (isDebug) if (isDebug)
{ {
LogInfo("开始调试,启动定时器 "); LogInfo("开始调试,启动定时器 ");
mainTimer.Start(); //mainTimer.Start();
mainStart();
} }
return true; return true;
} }
...@@ -335,10 +338,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -335,10 +338,11 @@ namespace OnlineStore.DeviceLibrary
public override void StopRun() public override void StopRun()
{ {
runStatus = LineRunStatus.Wait; runStatus = LineRunStatus.Wait;
if (mainTimer != null) //if (mainTimer != null)
{ //{
mainTimer.Enabled = false; // mainTimer.Enabled = false;
} //}
mainStop();
StopMove(); StopMove();
CloseLed(); CloseLed();
AgvClient.SetStatus(Config.AgvInName, "", ClientAction.None, ClientLevel.Low, true); AgvClient.SetStatus(Config.AgvInName, "", ClientAction.None, ClientLevel.Low, true);
...@@ -364,7 +368,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -364,7 +368,8 @@ namespace OnlineStore.DeviceLibrary
if (!isOk) if (!isOk)
{ {
LogUtil.error("启动失败,等待下次启动"); LogUtil.error("启动失败,等待下次启动");
mainTimer.Enabled = true; // mainTimer.Enabled = true;
mainStart();
} }
} }
return; return;
......
...@@ -28,14 +28,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -28,14 +28,16 @@ namespace OnlineStore.DeviceLibrary
{ {
return false; return false;
} }
mainTimer.Enabled = false; //mainTimer.Enabled = false;
mainStop();
MoveInfo.EndMove(); MoveInfo.EndMove();
runStatus = LineRunStatus.HomeMoving; runStatus = LineRunStatus.HomeMoving;
MoveInfo.NewMove(LineMoveType.RHome); MoveInfo.NewMove(LineMoveType.RHome);
StartReset(); StartReset();
if (isDebug) if (isDebug)
{ {
mainTimer.Enabled = true; //mainTimer.Enabled = true;
mainStart();
} }
return true; return true;
} }
...@@ -132,10 +134,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -132,10 +134,11 @@ namespace OnlineStore.DeviceLibrary
public override void StopRun() public override void StopRun()
{ {
if (mainTimer != null) //if (mainTimer != null)
{ //{
mainTimer.Enabled = false; // mainTimer.Enabled = false;
} //}
mainStop();
StopMove(); StopMove();
runStatus = LineRunStatus.Wait; runStatus = LineRunStatus.Wait;
......
...@@ -29,14 +29,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -29,14 +29,16 @@ namespace OnlineStore.DeviceLibrary
return false; return false;
} }
mainTimer.Enabled = false; //mainTimer.Enabled = false;
mainStop();
MoveInfo.EndMove(); MoveInfo.EndMove();
runStatus = LineRunStatus.HomeMoving; runStatus = LineRunStatus.HomeMoving;
MoveInfo.NewMove(LineMoveType.RHome); MoveInfo.NewMove(LineMoveType.RHome);
StartReset(); StartReset();
if (isDebug) if (isDebug)
{ {
mainTimer.Enabled = true; //mainTimer.Enabled = true;
mainStart();
} }
return true; return true;
} }
...@@ -126,10 +128,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -126,10 +128,11 @@ namespace OnlineStore.DeviceLibrary
public override void StopRun() public override void StopRun()
{ {
if (mainTimer != null) //if (mainTimer != null)
{ //{
mainTimer.Enabled = false; // mainTimer.Enabled = false;
} //}
mainStop();
StopMove(); StopMove();
runStatus = LineRunStatus.Wait; runStatus = LineRunStatus.Wait;
......
...@@ -43,16 +43,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -43,16 +43,18 @@ namespace OnlineStore.DeviceLibrary
{ {
return false; return false;
} }
mainTimer.Enabled = false; // mainTimer.Enabled = false;
mainStop();
MoveInfo.EndMove(); MoveInfo.EndMove();
runStatus = LineRunStatus.HomeMoving; runStatus = LineRunStatus.HomeMoving;
MoveInfo.NewMove(LineMoveType.RHome); MoveInfo.NewMove(LineMoveType.RHome);
StartReset(); StartReset();
if (isDebug) if (isDebug)
{ {
mainTimer.Interval = 300; //mainTimer.Interval = 300;
mainTimer.Enabled = true; //mainTimer.Enabled = true;
LogInfo("StartRun 设置 Interval=180 ,启动定时器"); mainStart();
LogInfo("StartRun 设置 Interval=300,启动定时器");
} }
return true; return true;
} }
...@@ -120,12 +122,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -120,12 +122,15 @@ namespace OnlineStore.DeviceLibrary
} }
else if (MoveInfo.IsStep(LineMoveStep.JHY_R05_ClampCheck)) else if (MoveInfo.IsStep(LineMoveStep.JHY_R05_ClampCheck))
{ {
if (!mainTimer.Enabled) if (!IsMainStarted)
{ {
mainTimer.Enabled = true; //mainTimer.Enabled = true;
mainStart();
SetInterval(180);
LogInfo("复位完成 设置 mainTimer.Enabled = true "); LogInfo("复位完成 设置 mainTimer.Enabled = true ");
} }
mainTimer.Interval = 180; //mainTimer.Interval = 180;
SetInterval(180);
LogInfo("复位完成 设置 Interval=180 "); LogInfo("复位完成 设置 Interval=180 ");
LogInfo(MoveInfo.MoveType + " 完成!"); LogInfo(MoveInfo.MoveType + " 完成!");
MoveEndS(); MoveEndS();
...@@ -154,10 +159,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -154,10 +159,11 @@ namespace OnlineStore.DeviceLibrary
} }
public override void StopRun() public override void StopRun()
{ {
if (mainTimer != null) //if (mainTimer != null)
{ //{
mainTimer.Enabled = false; // mainTimer.Enabled = false;
} //}
mainStop();
StopMove(); StopMove();
//CheckAndMove(IO_Type.HY_ClampCylinder_Work, IO_VALUE.LOW); //CheckAndMove(IO_Type.HY_ClampCylinder_Work, IO_VALUE.LOW);
//CheckAndMove(IO_Type.HY_ClampCylinder_Relax, IO_VALUE.LOW); //CheckAndMove(IO_Type.HY_ClampCylinder_Relax, IO_VALUE.LOW);
......
...@@ -93,8 +93,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -93,8 +93,8 @@ namespace OnlineStore.DeviceLibrary
//CheckStopWatch(trayCheckWait, TrayWaitTime, false) && //CheckStopWatch(trayCheckWait, TrayWaitTime, false) &&
if (check2IsOk && canpro) if (check2IsOk && canpro)
{ {
StartTrayCheck(); //StartTrayCheck();
Start_JHY_05_TrayCheck();
} }
} }
// else // else
...@@ -191,9 +191,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -191,9 +191,8 @@ namespace OnlineStore.DeviceLibrary
SecondMoveInfo.NewMove(LineMoveType.Fixture); SecondMoveInfo.NewMove(LineMoveType.Fixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.JHY_05_TrayCheck); SecondMoveInfo.NextMoveStep(LineMoveStep.JHY_05_TrayCheck);
CheckLog("接驳台托盘" + SecondMoveInfo.SLog + "前阻挡下降1.2s,等待托盘到位 "); CheckLog("接驳台托盘" + SecondMoveInfo.SLog + "前阻挡上升,等待托盘到位 ");
//IOMove(IO_Type.HY_FrontStopDown, IO_VALUE.LOW); IOMove(IO_Type.HY_FrontStopDown, IO_VALUE.LOW);
IOMove(IO_Type.HY_FrontStopDown, IO_VALUE.HIGH, 1200);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_FrontStopDown, IO_VALUE.LOW)); SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_FrontStopDown, IO_VALUE.LOW));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_TrayCheck, IO_VALUE.HIGH)); SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.HY_TrayCheck, IO_VALUE.HIGH));
......
...@@ -24,14 +24,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -24,14 +24,16 @@ namespace OnlineStore.DeviceLibrary
{ {
return false; return false;
} }
mainTimer.Enabled = false; //mainTimer.Enabled = false;
mainStop();
MoveInfo.EndMove(); MoveInfo.EndMove();
runStatus = LineRunStatus.HomeMoving; runStatus = LineRunStatus.HomeMoving;
MoveInfo.NewMove(LineMoveType.RHome); MoveInfo.NewMove(LineMoveType.RHome);
StartReset(); StartReset();
if (isDebug) if (isDebug)
{ {
mainTimer.Enabled = true; //mainTimer.Enabled = true;
mainStart();
} }
return true; return true;
} }
...@@ -95,10 +97,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -95,10 +97,11 @@ namespace OnlineStore.DeviceLibrary
public override void StopRun() public override void StopRun()
{ {
if (mainTimer != null) //if (mainTimer != null)
{ //{
mainTimer.Enabled = false; // mainTimer.Enabled = false;
} //}
mainStop();
StopMove(); StopMove();
runStatus = LineRunStatus.Wait; runStatus = LineRunStatus.Wait;
......
...@@ -85,7 +85,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -85,7 +85,7 @@ namespace OnlineStore.DeviceLibrary
} }
foreach (HYEquip_Config config in hyConfigMap.Values) foreach (HYEquip_Config config in hyConfigMap.Values)
{ {
HYEquipBase equip =HYEquipBase.GetHY( lineConfig.CID, config); HYEquipBase equip = HYEquipBase.GetHY(lineConfig.CID, config);
LogUtil.info(Name + $" {equip.Name} DeviceID: {equip.DeviceID} "); LogUtil.info(Name + $" {equip.Name} DeviceID: {equip.DeviceID} ");
AddDeviceName(ioList, config.IOIPList); AddDeviceName(ioList, config.IOIPList);
HYEquipMap.Add(config.Id, equip); HYEquipMap.Add(config.Id, equip);
...@@ -111,7 +111,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -111,7 +111,8 @@ namespace OnlineStore.DeviceLibrary
addLastDI(IO_Type.SuddenStop_BTN, IOValue(IO_Type.SuddenStop_BTN)); addLastDI(IO_Type.SuddenStop_BTN, IOValue(IO_Type.SuddenStop_BTN));
addLastDI(IO_Type.Reset_BTN, IOValue(IO_Type.Reset_BTN)); addLastDI(IO_Type.Reset_BTN, IOValue(IO_Type.Reset_BTN));
mainTimer.Enabled = true; // mainTimer.Enabled = true;
mainStart();
IoCheckTimer.Enabled = true; IoCheckTimer.Enabled = true;
AgvClient.Init(); AgvClient.Init();
canStart = true; canStart = true;
...@@ -201,7 +202,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -201,7 +202,8 @@ namespace OnlineStore.DeviceLibrary
{ {
// ledProcessTimer.Enabled = false; // ledProcessTimer.Enabled = false;
IoCheckTimer.Enabled = false; IoCheckTimer.Enabled = false;
mainTimer.Enabled = false; //mainTimer.Enabled = false;
mainStop();
ledProcessTimer.Enabled = true; ledProcessTimer.Enabled = true;
runStatus = LineRunStatus.HomeMoving; runStatus = LineRunStatus.HomeMoving;
...@@ -236,7 +238,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -236,7 +238,8 @@ namespace OnlineStore.DeviceLibrary
RFIDManager.Open(); RFIDManager.Open();
// WriteDrivetMotorRun(IO_VALUE.LOW); // WriteDrivetMotorRun(IO_VALUE.LOW);
IoCheckTimer.Enabled = true; IoCheckTimer.Enabled = true;
mainTimer.Enabled = true; //mainTimer.Enabled = true;
mainStart();
serverConTimer.Enabled = true; serverConTimer.Enabled = true;
return true; return true;
} }
...@@ -247,23 +250,25 @@ namespace OnlineStore.DeviceLibrary ...@@ -247,23 +250,25 @@ namespace OnlineStore.DeviceLibrary
{ {
moveEquip.OpenStopBlock(); moveEquip.OpenStopBlock();
} }
else if(moveEquip.runStatus.Equals(LineRunStatus.Wait)) else if (moveEquip.runStatus.Equals(LineRunStatus.Wait))
{ {
bool result = moveEquip.StartRun(); bool result = moveEquip.StartRun();
Thread.Sleep(60); Thread.Sleep(60);
} }
else else
{ {
LogUtil.info(Name + " EquipStartRun:" + moveEquip.Name+" 已启动,不需要重复启动"); LogUtil.info(Name + " EquipStartRun:" + moveEquip.Name + " 已启动,不需要重复启动");
} }
} }
private void RHomeOp() private void RHomeOp()
{ {
mainTimer.Interval = 1000; //mainTimer.Interval = 1000;
SetInterval(1000);
maxSeconds = 10; maxSeconds = 10;
// TrayManager.SidesWayStateMap = new System.Collections.Concurrent.ConcurrentDictionary<int, int>() ; // TrayManager.SidesWayStateMap = new System.Collections.Concurrent.ConcurrentDictionary<int, int>() ;
alarmType = LineAlarmType.None; alarmType = LineAlarmType.None;
mainTimer.Enabled = false; // mainTimer.Enabled = false;
mainStop();
IoCheckTimer.Enabled = false; IoCheckTimer.Enabled = false;
isInSuddenDown = false; isInSuddenDown = false;
isNoAirCheck = false; isNoAirCheck = false;
...@@ -287,11 +292,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -287,11 +292,12 @@ namespace OnlineStore.DeviceLibrary
public override bool Reset() public override bool Reset()
{ {
mainTimer.Enabled = false; // mainTimer.Enabled = false;
mainStop();
IoCheckTimer.Enabled = false; IoCheckTimer.Enabled = false;
bool isNeedAllReset = false; bool isNeedAllReset = false;
if (isInSuddenDown || isNoAirCheck||alarmType.Equals(LineAlarmType.SuddenStop)||alarmType.Equals(LineAlarmType.NoAirCheck)) if (isInSuddenDown || isNoAirCheck || alarmType.Equals(LineAlarmType.SuddenStop) || alarmType.Equals(LineAlarmType.NoAirCheck))
{ {
//TrayManager.LineNeedEmptyTrayNum = 0; //TrayManager.LineNeedEmptyTrayNum = 0;
isNeedAllReset = true; isNeedAllReset = true;
...@@ -336,7 +342,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -336,7 +342,8 @@ namespace OnlineStore.DeviceLibrary
if (runStatus.Equals(LineRunStatus.Wait)) if (runStatus.Equals(LineRunStatus.Wait))
{ return false; } { return false; }
IoCheckTimer.Enabled = true; IoCheckTimer.Enabled = true;
mainTimer.Enabled = true; //mainTimer.Enabled = true;
mainStart();
serverConTimer.Enabled = true; serverConTimer.Enabled = true;
return true; return true;
} }
...@@ -345,7 +352,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -345,7 +352,7 @@ namespace OnlineStore.DeviceLibrary
//调试状态不再重置 //调试状态不再重置
if (!equip.IsDebug) if (!equip.IsDebug)
{ {
if (isNeedAllReset || TrayManager.ErrorDeviceId.Equals(equip.DeviceID) || (!NoAlarm())||(!equip.NoAlarm()) ) if (isNeedAllReset || TrayManager.ErrorDeviceId.Equals(equip.DeviceID) || (!NoAlarm()) || (!equip.NoAlarm()))
{ {
LogUtil.info(Name + "收到复位信号," + equip.Name + " 需要复位"); LogUtil.info(Name + "收到复位信号," + equip.Name + " 需要复位");
equip.Reset(); equip.Reset();
...@@ -367,8 +374,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -367,8 +374,9 @@ namespace OnlineStore.DeviceLibrary
public override void StopRun() public override void StopRun()
{ {
IoCheckTimer.Enabled = false; IoCheckTimer.Enabled = false;
mainTimer.Enabled = false; // mainTimer.Enabled = false;
serverConTimer.Enabled = false ; mainStop();
serverConTimer.Enabled = false;
AgvClient.SetCancelState(true); AgvClient.SetCancelState(true);
RFIDManager.Close(); RFIDManager.Close();
//停止运行时,把阻挡气缸上升 //停止运行时,把阻挡气缸上升
...@@ -428,7 +436,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -428,7 +436,7 @@ namespace OnlineStore.DeviceLibrary
if (alarmType.Equals(LineAlarmType.SuddenStop) || alarmType.Equals(LineAlarmType.NoAirCheck)) if (alarmType.Equals(LineAlarmType.SuddenStop) || alarmType.Equals(LineAlarmType.NoAirCheck))
{ {
LogUtil.error(WarnMsg+":所有模块停止运行并报警:"+alarmType); LogUtil.error(WarnMsg + ":所有模块停止运行并报警:" + alarmType);
MoveInfo.EndMove(); MoveInfo.EndMove();
WriteDrivetMotorRun(IO_VALUE.LOW); WriteDrivetMotorRun(IO_VALUE.LOW);
T3C1_Stop(); T3C1_Stop();
...@@ -511,11 +519,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -511,11 +519,11 @@ namespace OnlineStore.DeviceLibrary
{ {
yellowShanShuo = true; yellowShanShuo = true;
} }
if (isInSuddenDown||isNoAirCheck||alarmType>LineAlarmType.AxisAlarm ) if (isInSuddenDown || isNoAirCheck || alarmType > LineAlarmType.AxisAlarm)
{ {
isNeedAlarmLed = true; isNeedAlarmLed = true;
} }
else if(alarmType.Equals(LineAlarmType.None).Equals(false)||TrayManager.TrayErrorMsg!="") else if (alarmType.Equals(LineAlarmType.None).Equals(false) || TrayManager.TrayErrorMsg != "")
{ {
yellowShanShuo = true; yellowShanShuo = true;
} }
...@@ -668,7 +676,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -668,7 +676,7 @@ namespace OnlineStore.DeviceLibrary
} }
Thread.Sleep(1); Thread.Sleep(1);
} }
protected override void mainTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) protected override void mainThread_Process()
{ {
try try
{ {
...@@ -685,12 +693,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -685,12 +693,13 @@ namespace OnlineStore.DeviceLibrary
if (isAutoStart && fuweiValue.Equals(IO_VALUE.HIGH) && lastFuwei.Equals(IO_VALUE.LOW)) if (isAutoStart && fuweiValue.Equals(IO_VALUE.HIGH) && lastFuwei.Equals(IO_VALUE.LOW))
{ {
//没有启动时收到启动按钮 //没有启动时收到启动按钮
LogUtil.info( Name + "没有启动时收到启动按钮,开始调用启动方法!"); LogUtil.info(Name + "没有启动时收到启动按钮,开始调用启动方法!");
bool isOk = StartRun(); bool isOk = StartRun();
if (!isOk) if (!isOk)
{ {
LogUtil.error("启动失败,等待下次启动"); LogUtil.error("启动失败,等待下次启动");
mainTimer.Enabled = true; //mainTimer.Enabled = true;
mainStart();
} }
} }
return; return;
...@@ -702,7 +711,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -702,7 +711,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (!moveEquip.IsDebug) if (!moveEquip.IsDebug)
{ {
if (!moveEquip.mainTimerStart) if (!moveEquip.IsMainStarted)
{ {
moveEquip.TimerProcess(); moveEquip.TimerProcess();
} }
...@@ -720,11 +729,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -720,11 +729,11 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(Name + "主定时器出错:",ex); LogUtil.error(Name + "主定时器出错:", ex);
} }
Thread.Sleep(1); Thread.Sleep(1);
} }
private bool busyPro = false ; private bool busyPro = false;
private DateTime busyProTime = DateTime.Now; private DateTime busyProTime = DateTime.Now;
private int maxSeconds = 3; private int maxSeconds = 3;
private void LineTimerPro() private void LineTimerPro()
...@@ -788,10 +797,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -788,10 +797,10 @@ namespace OnlineStore.DeviceLibrary
{ {
if ((DateTime.Now - lastAirCloseTime).TotalSeconds > Config.AirCheckSeconds) if ((DateTime.Now - lastAirCloseTime).TotalSeconds > Config.AirCheckSeconds)
{ {
SetWarnMsg("持续"+Config.AirCheckSeconds+"秒未检测到气压信号"); SetWarnMsg("持续" + Config.AirCheckSeconds + "秒未检测到气压信号");
//SendAlarmCode(0, LineAlarm.NoAirCheck); //SendAlarmCode(0, LineAlarm.NoAirCheck);
airValue = IO_VALUE.LOW; airValue = IO_VALUE.LOW;
Alarm(LineAlarmType.NoAirCheck ); Alarm(LineAlarmType.NoAirCheck);
} }
} }
else else
...@@ -834,9 +843,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -834,9 +843,10 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
}catch(Exception ex) }
catch (Exception ex)
{ {
LogUtil.error("IsReviceInPosId【"+ posId + "】出错:" + ex.ToString()); LogUtil.error("IsReviceInPosId【" + posId + "】出错:" + ex.ToString());
} }
return isReviceInfo; return isReviceInfo;
} }
...@@ -937,14 +947,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -937,14 +947,15 @@ namespace OnlineStore.DeviceLibrary
//所有原点重置完成 //所有原点重置完成
runStatus = LineRunStatus.Runing; runStatus = LineRunStatus.Runing;
MoveInfo.EndMove(); MoveInfo.EndMove();
mainTimer.Interval = 300; //mainTimer.Interval = 300;
SetInterval(300);
maxSeconds = 3; maxSeconds = 3;
AgvClient.SetCancelState(AgvClient.CurrCancelState); AgvClient.SetCancelState(AgvClient.CurrCancelState);
LogUtil.info(Name + "所有移栽模块复位完成,打开流水线,开始运转,定时器改为300,耗时 [" + FormUtil.GetSpanStr(span) + "]"); LogUtil.info(Name + "所有移栽模块复位完成,打开流水线,开始运转,定时器改为300,耗时 [" + FormUtil.GetSpanStr(span) + "]");
} }
else if (span.TotalSeconds > 120) else if (span.TotalSeconds > 120)
{ {
string warnmsg = Name + "[" + MoveInfo.MoveStep + "][" + msg + "]已等待[" + FormUtil.GetSpanStr(span ) + "]秒"; string warnmsg = Name + "[" + MoveInfo.MoveStep + "][" + msg + "]已等待[" + FormUtil.GetSpanStr(span) + "]秒";
//LogUtil.error(WarnMsg, 903); //LogUtil.error(WarnMsg, 903);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
MoveTimeoutAlarm(MoveInfo, msg); MoveTimeoutAlarm(MoveInfo, msg);
...@@ -1082,9 +1093,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -1082,9 +1093,9 @@ namespace OnlineStore.DeviceLibrary
} }
} }
return false ; return false;
} }
public bool noReel=false; public bool noReel = false;
private DateTime trayNoReelTime = DateTime.Now; private DateTime trayNoReelTime = DateTime.Now;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -70,7 +70,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -70,7 +70,8 @@ namespace OnlineStore.DeviceLibrary
return false; return false;
} }
mainTimer.Enabled = false; //mainTimer.Enabled = false;
mainStop();
MoveInfo.EndMove(); MoveInfo.EndMove();
SecondMoveInfo.EndMove(); SecondMoveInfo.EndMove();
runStatus = LineRunStatus.HomeMoving; runStatus = LineRunStatus.HomeMoving;
...@@ -79,7 +80,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -79,7 +80,8 @@ namespace OnlineStore.DeviceLibrary
StartReset(); StartReset();
if (isDebug) if (isDebug)
{ {
mainTimer.Enabled = true; // mainTimer.Enabled = true;
mainStart();
} }
return true; return true;
} }
...@@ -205,10 +207,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -205,10 +207,11 @@ namespace OnlineStore.DeviceLibrary
public override void StopRun() public override void StopRun()
{ {
if (mainTimer != null) //if (mainTimer != null)
{ //{
mainTimer.Enabled = false; // mainTimer.Enabled = false;
} //}
mainStop();
StopMove(); StopMove();
//停止运行时,把所有IO 置零 //停止运行时,把所有IO 置零
//CheckAndMove(IO_Type.StopDown1, IO_VALUE.LOW); //CheckAndMove(IO_Type.StopDown1, IO_VALUE.LOW);
......
...@@ -24,11 +24,30 @@ namespace OnlineStore.DeviceLibrary ...@@ -24,11 +24,30 @@ namespace OnlineStore.DeviceLibrary
public int DeviceID { get; set; } public int DeviceID { get; set; }
protected System.Timers.Timer mainTimer; protected System.Timers.Timer mainTimer;
protected Thread mainThread;
protected bool loop;
protected bool pause = false;
protected int threadInterval = 300;
private bool isInit = false; private bool isInit = false;
/// <summary>
public bool mainTimerStart { get => mainTimer.Enabled; } /// 使用timer定时器
/// </summary>
protected bool useTimer = ConfigHelper.Config.Get("Device_MainThreadUseTimer", true);
public bool IsMainStarted
{
get
{
if (useTimer)
{
return mainTimer.Enabled;
}
else
{
return !pause;
}
}
}
//public bool mainTimerStart { get => mainTimer.Enabled; }
/// <summary> /// <summary>
/// 托盘检测信号需要持续时间 /// 托盘检测信号需要持续时间
...@@ -37,6 +56,62 @@ namespace OnlineStore.DeviceLibrary ...@@ -37,6 +56,62 @@ namespace OnlineStore.DeviceLibrary
public KTK_Store() public KTK_Store()
{ {
} }
~KTK_Store()
{
if (useTimer)
{
}
else
{
loop = false;
}
}
/// <summary>
/// 主进程启动
/// </summary>
public void mainStart()
{
if (useTimer)
{
if (mainTimer != null)
{
mainTimer.Start();
}
}
else
{
// pause = false;
}
}
public void SetInterval(int interval = 300)
{
if (useTimer)
{
if (mainTimer != null)
{
mainTimer.Interval = interval;
}
}
else
{
threadInterval = interval;
}
}
/// <summary>
/// 主进程停止
/// </summary>
public void mainStop()
{
if (useTimer)
{
mainTimer?.Stop();
}
else
{
//pause = true;
}
}
/// <summary> /// <summary>
/// 开始运行的时间 /// 开始运行的时间
/// </summary> /// </summary>
...@@ -203,18 +278,60 @@ namespace OnlineStore.DeviceLibrary ...@@ -203,18 +278,60 @@ namespace OnlineStore.DeviceLibrary
{ {
if (!isInit) if (!isInit)
{ {
if (useTimer)
{
mainTimer = new System.Timers.Timer(); mainTimer = new System.Timers.Timer();
mainTimer.Enabled = false; mainTimer.Enabled = false;
mainTimer.Interval = 300; mainTimer.Interval = 300;
mainTimer.Elapsed += mainTimer_Elapsed; mainTimer.Elapsed += mainTimer_Elapsed;
mainTimer.AutoReset = true; mainTimer.AutoReset = true;
}
else
{
mainThread = new Thread(mainThread_Handle);
mainThread.IsBackground = true;
threadInterval = 300;
loop = true;
GC.KeepAlive(mainThread);
mainThread.Start();
}
isInit = true; isInit = true;
} }
} }
public LineMoveInfo MoveInfo = null; public LineMoveInfo MoveInfo = null;
string threadInfo = "";
void mainThread_Handle()
{
while (loop)
{
if (pause)
{
Thread.Sleep(1000);
}
else
{
mainThread_Process();
Thread.Sleep(threadInterval);
try
{
string curStr = $"{Name}-{DeviceID}:Thread ID: {Thread.CurrentThread.ManagedThreadId}";
if (!curStr.Equals(threadInfo))
{
threadInfo = curStr;
LogUtil.LOGGER.Info(curStr);
}
}
finally { }
protected abstract void mainTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e); }
}
}
protected abstract void mainThread_Process();
void mainTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
mainThread_Process();
}
#region 出库 #region 出库
/// <summary> /// <summary>
...@@ -642,7 +759,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -642,7 +759,8 @@ namespace OnlineStore.DeviceLibrary
warnParam.OperteType = ""; warnParam.OperteType = "";
} }
} }
}catch(Exception ex) }
catch (Exception ex)
{ {
LogUtil.error("SetWarnMsg Error: " + ex.ToString()); LogUtil.error("SetWarnMsg Error: " + ex.ToString());
} }
...@@ -656,7 +774,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -656,7 +774,7 @@ namespace OnlineStore.DeviceLibrary
SetWarnMsg(move.Name + "[" + move.GetMoveType() + "][" + move.SLog + "] " + alarmType + " [" + FormUtil.GetSpanStr(move.StepSpan()) + "]", alarmType, move); SetWarnMsg(move.Name + "[" + move.GetMoveType() + "][" + move.SLog + "] " + alarmType + " [" + FormUtil.GetSpanStr(move.StepSpan()) + "]", alarmType, move);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
} }
catch(Exception ex) catch (Exception ex)
{ {
} }
...@@ -689,7 +807,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -689,7 +807,7 @@ namespace OnlineStore.DeviceLibrary
string alarmTypeStr = stepDes + "_超时报警"; string alarmTypeStr = stepDes + "_超时报警";
if (warnParam.AlarmType.Equals(alarmTypeStr)) if (warnParam.AlarmType.Equals(alarmTypeStr))
{ {
LogUtil.info(Name + $"步骤{stepDes}结束,清理【{ WarnMsg }】 "); LogUtil.info(Name + $"步骤{stepDes}结束,清理【{WarnMsg}】 ");
alarmType = LineAlarmType.None; alarmType = LineAlarmType.None;
SetWarnMsg(""); SetWarnMsg("");
} }
...@@ -699,7 +817,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -699,7 +817,7 @@ namespace OnlineStore.DeviceLibrary
string alarmTypeStr = stepDes + "_轴运动报警"; string alarmTypeStr = stepDes + "_轴运动报警";
if (warnParam.AlarmType.Equals(alarmTypeStr)) if (warnParam.AlarmType.Equals(alarmTypeStr))
{ {
LogUtil.info(Name + $"步骤{stepDes}结束,清理【{ WarnMsg }】 "); LogUtil.info(Name + $"步骤{stepDes}结束,清理【{WarnMsg}】 ");
alarmType = LineAlarmType.None; alarmType = LineAlarmType.None;
SetWarnMsg(""); SetWarnMsg("");
} }
......
...@@ -116,7 +116,7 @@ namespace HuichuanLibrary ...@@ -116,7 +116,7 @@ namespace HuichuanLibrary
} }
else else
{ {
LOGGER.Debug("ShowLogPro【" + msg + "】失败,未得到锁"); //LOGGER.Debug("ShowLogPro【" + msg + "】失败,未得到锁");
} }
} }
private static List<string> logList = new List<string>(); private static List<string> logList = new List<string>();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!