public string onMainAlarm(string mAlarmCode, params object[] args) { MainAlarm mainAlarm = mainAlarmDao.getMainAlarmByCode(mAlarmCode); bool isAlarm = false; string msg = string.Empty; try { if (mainAlarm != null) { isAlarm = mainAlarm.CODE.StartsWith("A"); msg = string.Format(mainAlarm.DESCRIPTION, args); if (isAlarm) { msg = string.Format("[{0}]{2}", mainAlarm.CODE, Environment.NewLine, msg); BCFApplication.onErrorMsg(msg); } else { msg = string.Format("[{0}]{2}", mainAlarm.CODE, Environment.NewLine, msg); BCFApplication.onWarningMsg(msg); } } else { logger.Warn(string.Format("LFC alarm/warm happen, but no defin remark code:[{0}] !!!", mAlarmCode)); } } catch (Exception ex) { logger.Error(ex, "Exception:"); } return(msg); }
public void doorClosedChange(object sender, PropertyChangedEventArgs e) { try { ANODE node = sender as ANODE; if (sender == null) { return; } if (!node.DoorClosed) { if (!node.SafetyCheckComplete) { BCFApplication.onWarningMsg($"OHCV:[{node.NODE_ID}] door has been open without authorization."); //對CV所在路段的OHT下pause Todo by Kevin scApp.RoadControlService.ProcessOHCVAbnormallyScenario(node); //上報Alarm給MCS Todo by Kevin foreach (var ohcv in node.getSubEqptList()) { if (!ohcv.DoorClosed) { scApp.LineService.ProcessAlarmReport( ohcv.NODE_ID, ohcv.EQPT_ID, ohcv.Real_ID, "", SCAppConstants.SystemAlarmCode.OHCV_Issue.CVDoorAbnormallyOpen, ProtocolFormat.OHTMessage.ErrorStatus.ErrSet); } } } } } catch (Exception ex) { logger.Error(ex, "Exception:"); } }
public void aliveChange(object sender, PropertyChangedEventArgs e) { try { ANODE node = sender as ANODE; if (sender == null) { return; } if (!node.Is_Alive) { BCFApplication.onWarningMsg($"OHCV:[{node.NODE_ID}] alive is not changing."); //對CV所在路段的OHT下pause Todo by Kevin scApp.RoadControlService.ProcessOHCVAbnormallyScenario(node); //上報Alarm給MCS Todo by Kevin foreach (var ohcv in node.getSubEqptList()) { if (!ohcv.Is_Eq_Alive) { scApp.LineService.ProcessAlarmReport( ohcv.NODE_ID, ohcv.EQPT_ID, ohcv.Real_ID, "", SCAppConstants.SystemAlarmCode.OHCV_Issue.CVOfAliveSignalAbnormal, ProtocolFormat.OHTMessage.ErrorStatus.ErrSet); } } } } catch (Exception ex) { logger.Error(ex, "Exception:"); } }
private void cancelSafetyCheckRequest() { if (scApp.getEQObjCacheManager().getLine().ServiceMode != SCAppConstants.AppServiceMode.Active) { return; } if (!node.DoorClosed)//檢查安全門是不是關閉的 { BCFApplication.onWarningMsg($"OHCV:[{eqpt.EQPT_ID}] send safety check request cancel to OHTC,but door is open now."); return; } if (!node.Is_Alive)//檢查Alive有沒有變化 { BCFApplication.onWarningMsg($"OHCV:[{eqpt.EQPT_ID}] send safety check request cancel to OHTC,but OHCV alive is not changing."); return; } if (node.SafetyCheckComplete)//確定是否有通知過其它門,現在是可以開啟的 { return; } //enable 該CV所在路段 Todo by Kevin scApp.RoadControlService.doEnableDisableSegment (eqpt.SegmentLocation, E_PORT_STATUS.InService, ASEGMENT.DisableType.Safety, Data.SECS.CSOT.SECSConst.LANECUTTYPE_LaneCutOnHMI); }
private void connectionCheck(AVEHICLE vh) { if (!vh.isTcpIpConnect) { vh.isTcpIpConnect = true; BCFApplication.onWarningMsg($"vh:{vh.VEHICLE_ID} Force change connection status to connection !"); LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(EQTcpIpMapAction), Device: "AGVC", Data: "Force change connection status to connection !", VehicleID: vh.VEHICLE_ID, CarrierID: vh.CST_ID); } }
//private void checkSegmentStatus() //{ // if (Interlocked.Exchange(ref checkSyncPoint, 1) == 0) // { // try // { // bool hasPrepare = false; // bcApp.SCApplication.LineBLL.BegingOrEndSegmentPreDisableExcute(true); // do // { // foreach (ASEGMENT seg in segment_List) // { // if (seg.PRE_DISABLE_FLAG) // { // bool canDisable = false; // if (IsRealTime) // { // List<string> will_be_pass_cmd_ids = null; // bool HasCmdWillPass = bcApp.SCApplication.CMDBLL.HasCmdWillPassSegment(seg.SEG_NUM, out will_be_pass_cmd_ids); // if (HasCmdWillPass) // { // foreach (string cmd_id in will_be_pass_cmd_ids) // { // ACMD_OHTC will_pass_cmd = bcApp.SCApplication.CMDBLL.getExcuteCMD_OHTCByCmdID(cmd_id); // if (will_pass_cmd == null) // continue; // AVEHICLE excute_vh = bcApp.SCApplication.getEQObjCacheManager().getVehicletByVHID(will_pass_cmd.VH_ID); // sc.ProtocolFormat.OHTMessage.CMDCancelType cMDCancelType = default(sc.ProtocolFormat.OHTMessage.CMDCancelType); // E_CMD_STATUS e_CMD_STATUS = default(E_CMD_STATUS); // ASECTION crtSection = bcApp.SCApplication.MapBLL.getSectiontByID(excute_vh.CUR_SEC_ID); // if (SCUtility.isMatche(crtSection.SEG_NUM, seg.SEG_NUM)) // { // continue; // } // if (excute_vh.HAS_CST == 0) // { // e_CMD_STATUS = E_CMD_STATUS.Canceling; // cMDCancelType = sc.ProtocolFormat.OHTMessage.CMDCancelType.CmdCancel; // } // else // { // e_CMD_STATUS = E_CMD_STATUS.Aborting; // cMDCancelType = sc.ProtocolFormat.OHTMessage.CMDCancelType.CmdAbout; // } // if (excute_vh.sned_Str37(will_pass_cmd.CMD_ID, cMDCancelType)) // { // bcApp.SCApplication.CMDBLL.updateCommand_OHTC_StatusByCmdID(will_pass_cmd.CMD_ID, e_CMD_STATUS); // } // } // } // canDisable = !HasCmdWillPass; // if (canDisable) // { // List<ACMD_MCS> lstACMD_MCS = bcApp.SCApplication.CMDBLL.loadCMD_MCS_IsExcute(seg.PRE_DISABLE_TIME.Value); // if (lstACMD_MCS != null && lstACMD_MCS.Count > 0) // { // List<string> adrs_SourceAndDestination = new List<string>(); // foreach (ACMD_MCS cmd in lstACMD_MCS) // { // string fromAdr = string.Empty; // string toAdr = string.Empty; // if (bcApp.SCApplication.MapBLL.getAddressID(cmd.HOSTSOURCE, out fromAdr)) // adrs_SourceAndDestination.Add(fromAdr); // if (bcApp.SCApplication.MapBLL.getAddressID(cmd.HOSTDESTINATION, out toAdr)) // adrs_SourceAndDestination.Add(toAdr); // } // List<ASECTION> sections_SourceAndDestination = // bcApp.SCApplication.MapBLL.loadSectionByToAdrs(adrs_SourceAndDestination); // List<string> segments_SourceAndDestination = sections_SourceAndDestination.Select(sec => sec.SEG_NUM.Trim()).ToList(); // canDisable = !segments_SourceAndDestination.Contains(seg.SEG_NUM.Trim()); // } // } // } // else // { // //1.確認是否有在Disable前的命令還沒執行完 // canDisable = bcApp.SCApplication.CMDBLL.getCMD_MCSIsRunningCount(seg.PRE_DISABLE_TIME.Value) == 0; // //2.確認是否還有命令還會通過這裡 // if (canDisable) // { // List<string> will_be_pass_cmd_ids = null; // canDisable = !bcApp.SCApplication.CMDBLL.HasCmdWillPassSegment(seg.SEG_NUM, out will_be_pass_cmd_ids); // } // //3.確認是否還有VH在管制道路上 // if (canDisable) // { // List<AVEHICLE> listVH = bcApp.SCApplication.getEQObjCacheManager().getAllVehicle(); // foreach (AVEHICLE vh in listVH) // { // ASECTION vh_current_sec = bcApp.SCApplication.MapBLL.getSectiontByID(vh.CUR_SEC_ID); // if (SCUtility.isMatche(vh_current_sec.SEG_NUM, seg.SEG_NUM)) // { // canDisable = false; // break; // } // } // } // } // if (canDisable) // { // int index = segment_List.IndexOf(seg); // string seg_num = seg.SEG_NUM; // var newSeg = bcApp.SCApplication.RouteGuide.CloseSegment(seg_num.Trim()); // var orderSeg = segment_List[index]; // BCFUtility.setValueToPropety(ref newSeg, ref orderSeg); // Adapter.Invoke((obj) => // { // dgv_segment.Refresh(); // }, null); // hasPrepare = false; // } // else // { // hasPrepare = true; // } // } // } // SpinWait.SpinUntil(() => false, 1000); // } // while (hasPrepare); // } // catch (Exception ex) // { // logger.Error(ex, "Exection:"); // } // finally // { // Interlocked.Exchange(ref checkSyncPoint, 0); // bcApp.SCApplication.LineBLL.BegingOrEndSegmentPreDisableExcute(false); // } // } //} #endregion 保留 private void RoadControlForm_FormClosing(object sender, FormClosingEventArgs e) { if (bcApp.SCApplication.getEQObjCacheManager().getLine().SegmentPreDisableExcuting) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Segment is changing state to disable. please wait or cancel.") .AppendLine("segment num:"); foreach (ASEGMENT seg in segment_List) { if (seg.PRE_DISABLE_FLAG) { sb.Append(seg.SEG_NUM.Trim()).Append(','); } } BCFApplication.onWarningMsg(sb.ToString()); e.Cancel = true; } }
private void Pre_control_segment_ControlComplete(object sender, EventArgs e) { ASEGMENT control_complete_segment = sender as ASEGMENT; try { //再次確認是否Safety check=true、door closed=true、alive=true if (!eqpt.SafetyCheckRequest) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV, Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," + $"but cv:{eqpt.EQPT_ID} of {nameof(eqpt.SafetyCheckRequest)} is {eqpt.SafetyCheckRequest}", VehicleID: eqpt.EQPT_ID); return; } if (!eqpt.DoorClosed) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV, Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," + $"but cv:{eqpt.EQPT_ID} of {nameof(eqpt.DoorClosed)} is {eqpt.DoorClosed}", VehicleID: eqpt.EQPT_ID); return; } if (!eqpt.Is_Eq_Alive) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV, Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," + $"but cv:{eqpt.EQPT_ID} of {nameof(eqpt.Is_Eq_Alive)} is {eqpt.Is_Eq_Alive}", VehicleID: eqpt.EQPT_ID); return; } //foreach (var cv in node.getSubEqptList()) //{ // if (!cv.DoorClosed) // { // LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV, // Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," + // $"but cv:{cv.EQPT_ID} of {nameof(cv.DoorClosed)} is {cv.DoorClosed}", // VehicleID: eqpt.EQPT_ID); // return; // } // if (!cv.Is_Eq_Alive) // { // LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV, // Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," + // $"but cv:{cv.EQPT_ID} of {nameof(cv.Is_Eq_Alive)} is {cv.Is_Eq_Alive}", // VehicleID: eqpt.EQPT_ID); // return; // } //} bool completeNotifyResult = sendRoadControlCompleteNotify(); //disable路段後發出Complete Notify if (completeNotifyResult) { //do nothing } else { BCFApplication.onWarningMsg($"OHTC send road control complete notify to OHCV:[{eqpt.EQPT_ID}] with error happend."); //return; } } catch (Exception ex) { logger.Error(ex, "Exection:"); } finally { control_complete_segment.ControlComplete -= Pre_control_segment_ControlComplete; } }
public virtual void SafetyCheckRequestChange(object sender, ValueChangedEventArgs args) { try { string pre_control_segment_id = eqpt.SegmentLocation; ASEGMENT pre_control_segment = scApp.SegmentBLL.cache.GetSegment(pre_control_segment_id); var recevie_function = scApp.getFunBaseObj <OHCVToOHxC_SafetyCheckRequest>(eqpt.EQPT_ID) as OHCVToOHxC_SafetyCheckRequest; recevie_function.Read(bcfApp, eqpt.EqptObjectCate, eqpt.EQPT_ID); LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV, Data: recevie_function.ToString(), VehicleID: eqpt.EQPT_ID); eqpt.SafetyCheckRequest = recevie_function.SafetyCheckRequest; if (recevie_function.SafetyCheckRequest) { //if (!node.DoorClosed)//檢查安全門是不是關閉的 if (!eqpt.DoorClosed)//檢查安全門是不是關閉的 { BCFApplication.onWarningMsg($"OHCV:[{eqpt.EQPT_ID}] send safety check request to OHTC,but door is open now."); return; } //if (!node.Is_Alive)//檢查Alive有沒有變化 if (!eqpt.Is_Eq_Alive)//檢查Alive有沒有變化 { BCFApplication.onWarningMsg($"OHCV:[{eqpt.EQPT_ID}] send safety check request to OHTC,but OHCV alive is not changing."); return; } bool initNotifyResult = sendRoadControlInitialNotify(); if (initNotifyResult) { if (eqpt.SafetyCheckRequest)//沒有被取消 { //如果現在這組CV的狀態是DISABLE而且是由SAFETY_DISABLE而且有通知這組CV已經可以開啟, //就可以直接回覆Complete if (pre_control_segment.DISABLE_FLAG_SAFETY && pre_control_segment.STATUS == E_SEG_STATUS.Closed && node.SafetyCheckComplete) { Pre_control_segment_ControlComplete(pre_control_segment, null); } else { //註冊該segment control complete的事件 pre_control_segment.ControlComplete += Pre_control_segment_ControlComplete; //開始處理CV的OP in request時,要處理的事項 //1.predisable 該CV所在路段 Todo by Kevin //2.確認無車輛會再過該CV路段 Todo by Kevin //3.disable 該CV所在路段 Todo by Kevin //4.當上述條件成功時,會觸發"ControlComplete"的事件 scApp.RoadControlService.ProcessCVOpInRequest(eqpt); } //bool completeNotifyResult = sendRoadControlCompleteNotify(); //disable路段後發出Complete Notify //if (completeNotifyResult) //{ // //do nothing //} //else //{ // BCFApplication.onWarningMsg($"OHTC send road control complete notify to OHCV:[{eqpt.EQPT_ID}] with error happend."); // return; //} } else//被中途取消了 { //do nothing } } else { BCFApplication.onWarningMsg($"OHTC send road control initial notify to OHCV:[{eqpt.EQPT_ID}] with error happend."); return; } } else//SafetyCheckRequest訊號OFF { //當SafetyCheckRequest關閉後,就再次取消註冊的Control complete事件,確保已經不會再收到控制完成的通知。 pre_control_segment.ControlComplete -= Pre_control_segment_ControlComplete; if (eqpt.SafetyCheckComplete) { //donothing } else { cancelSafetyCheckRequest(); } } } catch (Exception ex) { logger.Error(ex, "Exception"); } }