/// <summary> /// Timer Action的執行動作 /// </summary> /// <param name="obj">The object.</param> public override void doProcess(object obj) { if (System.Threading.Interlocked.Exchange(ref synPoint, 1) == 0) { try { doCheckIPLinkStatus(); //doCheckIPLinkStatusParallel(); doCheckEQAliveStatus(); scApp.CheckSystemEventHandler.CheckCheckSystemIsExist(); ALINE line = scApp.getEQObjCacheManager().getLine(); InlineEfficiencyMonitor(line); Task.Run(() => { CheckLinkStatus(line); }); if (SCUtility.getCallContext <bool>(ALINE.CONTEXT_KEY_WORD_LINE_STATUS_HAS_CHANGE)) { line.NotifyLineStatusChange(); SCUtility.setCallContext(ALINE.CONTEXT_KEY_WORD_LINE_STATUS_HAS_CHANGE, null); } } catch (Exception ex) { logger.Error(ex, "Exception"); } finally { System.Threading.Interlocked.Exchange(ref synPoint, 0); } } }
/// <summary> /// Timer Action的執行動作 /// </summary> /// <param name="obj">The object.</param> public override void doProcess(object obj) { if (System.Threading.Interlocked.Exchange(ref syncPoint, 1) == 0) { try { doCheckIPLinkStatus(); scApp.CheckSystemEventHandler.CheckCheckSystemIsExist(); InlineEfficiencyMonitor(); if (SCUtility.getCallContext <bool>(ALINE.CONTEXT_KEY_WORD_LINE_STATUS_HAS_CHANGE)) { line.NotifyLineStatusChange(); SCUtility.setCallContext(ALINE.CONTEXT_KEY_WORD_LINE_STATUS_HAS_CHANGE, null); } } catch (Exception ex) { logger.Error(ex, "Exception"); } finally { System.Threading.Interlocked.Exchange(ref syncPoint, 0); } } //if (++excute_count % 2 == 0) // Task.Run(() => doChcekPLCLinkStatus()); //Task.Run(() => doReadPLCAlive()); }
private void CheckLinkStatus(ALINE line) { if (System.Threading.Interlocked.Exchange(ref syncCheckLink_Point, 1) == 0) { try { bool is_connection_success = false; foreach (var device in line.DeviceConnectionInfos) { switch (device.Type) { case ProtocolFormat.OHTMessage.DeviceConnectionType.Ap: var ap_setting_info = scApp.LineBLL.getAPSetting(device.Name); is_connection_success = PingIt(ap_setting_info.REMOTE_IP); break; case ProtocolFormat.OHTMessage.DeviceConnectionType.Mcs: var secs_agent = scApp.getBCFApplication().getSECSAgent(device.Name); is_connection_success = secs_agent.IsSelected; break; case ProtocolFormat.OHTMessage.DeviceConnectionType.Plc: var plc_agent = scApp.getBCFApplication().getMPLCSMControl(device.Name); is_connection_success = plc_agent.isAlive(); break; } ProtocolFormat.OHTMessage.ConnectionStatus new_status = is_connection_success ? ProtocolFormat.OHTMessage.ConnectionStatus.Success : ProtocolFormat.OHTMessage.ConnectionStatus.Unsuccess; if (device.Status != new_status) { device.Status = new_status; SCUtility.setCallContext(ALINE.CONTEXT_KEY_WORD_LINE_STATUS_HAS_CHANGE, true); } } } catch (Exception ex) { logger.Error(ex, "Exception"); } finally { System.Threading.Interlocked.Exchange(ref syncCheckLink_Point, 0); } } }