Commit 0aff9dd7 张东亮

timer改为线程

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