protected void secsDisconnected(object sender, SECSEventArgs e) { if (line.Secs_Link_Stat == SCAppConstants.LinkStatus.LinkFail) return; //not implement Dictionary<string, CommuncationInfo> dicCommunactionInfo = scApp.getEQObjCacheManager().CommonInfo.dicCommunactionInfo; if (dicCommunactionInfo.ContainsKey("MCS")) { dicCommunactionInfo["MCS"].IsConnectinoSuccess = false; } isOnlineWithMcs = false; line.Secs_Link_Stat = SCAppConstants.LinkStatus.LinkFail; line.connInfoUpdate_Disconnection(); SCUtility.RecodeConnectionInfo ("MCS", SCAppConstants.RecodeConnectionInfo_Type.Disconnection.ToString(), line.StopWatch_mcsConnectionTime.Elapsed.TotalSeconds); }
public bool NoticeBlockVhPassByEntrySecID(string entry_sec_id) { bool isSuccess = true; ABLOCKZONEMASTER blockMaster = scApp.MapBLL.getBlockZoneMasterByEntrySecID(entry_sec_id); if (!SCUtility.isEmpty(blockMaster.LEAVE_ADR_ID_1)) { isSuccess &= scApp.MapBLL.CheckAndNoticeBlockVhPassByAdrID(blockMaster.LEAVE_ADR_ID_1); if (isSuccess) { return(isSuccess); } } if (!SCUtility.isEmpty(blockMaster.LEAVE_ADR_ID_2)) { isSuccess &= scApp.MapBLL.CheckAndNoticeBlockVhPassByAdrID(blockMaster.LEAVE_ADR_ID_2); } return(isSuccess); }
public void TrafficControlRelease(string trafficControlID, string vhID) { string traffic_control_id = trafficControlID.Trim(); string traffic_control_reserve_info = string.Format(SCAppConstants.REDIS_KEY_TRAFFIC_CONTROL_INFO_0, traffic_control_id); string reserve_vh_address_id = redisCacheManager.StringGet(traffic_control_reserve_info); string[] reserve_vh_section_array = reserve_vh_address_id.Split('#'); string reserve_vh = reserve_vh_section_array[0]; bool is_success = false; if (SCUtility.isMatche(vhID, reserve_vh)) { is_success = redisCacheManager.KeyDelete(traffic_control_reserve_info); } LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(TrafficControlBLL), Device: "AGVC", Details: $"Excute traffic control id:{traffic_control_id} release by vh id:{vhID},result:{is_success}"); }
protected virtual void S2F31ReceiveDateTimeSetReq(object sender, SECSEventArgs e) { try { S2F31 s2f31 = ((S2F31)e.secsHandler.Parse<S2F31>(e)); SCUtility.secsActionRecordMsg(scApp, true, s2f31); SCUtility.actionRecordMsg(scApp, s2f31.StreamFunction, line.Real_ID, "Receive Date Time Set Request From MES.", ""); if (!isProcess(s2f31)) { return; } S2F32 s2f32 = new S2F32(); s2f32.SECSAgentName = scApp.EAPSecsAgentName; s2f32.SystemByte = s2f31.SystemByte; s2f32.TIACK = SECSConst.TIACK_Accepted; string timeStr = s2f31.TIME; DateTime mesDateTime = DateTime.Now; try { mesDateTime = DateTime.ParseExact(timeStr.Trim(), SCAppConstants.TimestampFormat_14, CultureInfo.CurrentCulture); } catch (Exception dtEx) { s2f32.TIACK = SECSConst.TIACK_Error_not_done; } SCUtility.secsActionRecordMsg(scApp, false, s2f32); ISECSControl.replySECS(bcfApp, s2f32); if (!DebugParameter.DisableSyncTime) { SCUtility.updateSystemTime(mesDateTime); } //TODO 與設備同步 } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "S2F31_Receive_Date_Time_Set_Req", ex.ToString()); } }
public bool VhNetworkQualityTest(string vh_id, string adr_id, string sec_id, int acc_dist) { bool isSuccess = false; //Equipment eq = scApp.getEQObjCacheManager().getEquipmentByEQPTID(vh_id); AVEHICLE eq = scApp.getEQObjCacheManager().getVehicletByVHID(vh_id); string remote_ip = eq.getIPAddress(scApp.getBCFApplication()); PingReply reply = null; if (SCUtility.PingIt(remote_ip, out reply)) { //saveAndUpdate(vh_id, adr_id, sec_id, acc_dist, reply.RoundtripTime); int randomMax = 0; int randomMin = 0; if (SCUtility.isMatche(sec_id, "041") || SCUtility.isMatche(sec_id, "043") || SCUtility.isMatche(sec_id, "021") || SCUtility.isMatche(sec_id, "035")) { randomMax = 150; randomMin = 101; } else if (SCUtility.isMatche(sec_id, "006") || SCUtility.isMatche(sec_id, "202")) { randomMax = 99; randomMin = 51; } else { randomMax = 49; randomMin = 0; } if (SCUtility.isMatche(vh_id, "OHT03")) { randomMax = 150; randomMin = 101; } addNetworkQuality(vh_id, adr_id, sec_id, acc_dist, rnd.Next(randomMin, randomMax)); isSuccess = true; } return(isSuccess); }
private Task <(bool is_success, object result)> findInculdCycleTestPort(string zoneID, string byPassAdrID) { var all_port_in_zone = scApp.PortStationBLL.OperateCatch.loadAllPortStation(zoneID); APORTSTATION port = null; if (all_port_in_zone == null) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(RandomGeneratesCommandTimerActionTiming), Device: string.Empty, Data: $"No find any port,{zoneID}"); } else { port = all_port_in_zone.Where(station => station.IncludeCycleTest && !SCUtility.isMatche(station.ADR_ID, byPassAdrID)). OrderBy(station => station.TestTimes). FirstOrDefault(); } return(Task.FromResult((port != null, (object)port))); }
private void updatePortStatusByRedis() { var ports_plc_info = scApp.PortStationBLL.redis.getCurrentPortsInfo(); var port_stations = scApp.PortStationBLL.OperateCatch.loadAGVPortStation().ToList(); foreach (var port_station in port_stations) { var port_plc_info = ports_plc_info.Where(port => SCUtility.isMatche(port.PortID, port_station.PORT_ID)). FirstOrDefault(); if (port_plc_info != null) { port_station.SetPortInfo(port_plc_info); } else { port_station.ResetPortInfo(); } } }
private AVEHICLE findTheOrtherKeyBlockVhID(AVEHICLE avoidVh, AVEHICLE reservedVh, ref int findCount) { if (findCount > MAX_FIND_COUNT) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(DeadlockCheck), Device: "OHBC", Data: $"dead lock happend ,find key block fail. over find times:{findCount}", VehicleID: avoidVh.VEHICLE_ID, CarrierID: avoidVh.CST_ID); return(null); } if (SCUtility.isMatche(avoidVh.VEHICLE_ID, reservedVh.VEHICLE_ID)) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(DeadlockCheck), Device: "OHBC", Data: $"dead lock happend ,find key block fail. avoid and blocked vh is same.vh id:{avoidVh.VEHICLE_ID}", VehicleID: avoidVh.VEHICLE_ID, CarrierID: avoidVh.CST_ID); return(null); } if (reservedVh.CanNotReserveInfo == null) { return(null); } if (SCUtility.isMatche(avoidVh.VEHICLE_ID, reservedVh.CanNotReserveInfo.ReservedVhID)) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(DeadlockCheck), Device: "OHBC", Data: $"dead lock happend ,find key blocked vh(orther).avoid vh:{avoidVh.VEHICLE_ID} ,blocked vh:{reservedVh.VEHICLE_ID}", VehicleID: avoidVh.VEHICLE_ID, CarrierID: avoidVh.CST_ID); return(reservedVh); } else { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(DeadlockCheck), Device: "OHBC", Data: $"dead lock happend ,no find key blocked vh ," + $"find next block vh id:{reservedVh.CanNotReserveInfo.ReservedVhID} blocking vh:{reservedVh.VEHICLE_ID}", VehicleID: avoidVh.VEHICLE_ID, CarrierID: avoidVh.CST_ID); AVEHICLE orther_reserved_vh = scApp.VehicleBLL.cache.getVhByID(reservedVh.CanNotReserveInfo.ReservedVhID); findCount++; return(findTheOrtherKeyBlockVhID(avoidVh, orther_reserved_vh, ref findCount)); } }
/// <summary> /// Does the share memory initialize. /// </summary> /// <param name="runLevel">The run level.</param> public override void doShareMemoryInit(BCFAppConstants.RUN_LEVEL runLevel) { try { switch (runLevel) { case BCFAppConstants.RUN_LEVEL.ZERO: //scApp.MapBLL.addVehicle(eqpt.VEHICLE_ID); //eqpt.VID_Collection.VID_70_VehicleID.VEHILCE_ID = eqpt.VEHICLE_ID; if (eqpt != null) { if (!SCUtility.isEmpty(eqpt.OHTC_CMD)) { ACMD_OHTC aCMD_OHTC = scApp.CMDBLL.getExcuteCMD_OHTCByCmdID(eqpt.OHTC_CMD); string[] PredictPath = scApp.CMDBLL.loadPassSectionByCMDID(eqpt.OHTC_CMD); scApp.CMDBLL.setVhExcuteCmdToShow(aCMD_OHTC, this.eqpt, PredictPath, null); } } //先讓車子一開始都當作是"VehicleInstall"的狀態 //之後要從DB得知上次的狀態,是否為Remove if (eqpt.IS_INSTALLED) { eqpt.VehicleInstall(); } break; case BCFAppConstants.RUN_LEVEL.ONE: break; case BCFAppConstants.RUN_LEVEL.TWO: break; case BCFAppConstants.RUN_LEVEL.NINE: break; } } catch (Exception ex) { logger.Error(ex, "Exection:"); } }
private async void excuteUnloadCommand() { string toAdr = string.Empty; string vehicleId = string.Empty; string cmd_id = string.Empty; vehicleId = cmb_Vehicle.Text; toAdr = cmb_toAddress.Text; if (BCFUtility.isEmpty(vehicleId)) { MessageBox.Show("No find vehile."); return; } AVEHICLE vh = scApp.getEQObjCacheManager().getVehicletByVHID(vehicleId); cmd_id = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual); string cst_id = SCUtility.Trim(vh.CST_ID); sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null; await Task.Run(() => { //if (SCUtility.isMatche(vh.CUR_ADR_ID, toAdr)) //{ // scApp.VehicleService.TransferRequset(vehicleId, cmd_id, ActiveType.Unload, "CST02", new string[0], new string[0], new string[0], new string[0], new string[0], new string[0], "", toAdr); //} //else { scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id, E_CMD_TYPE.Unload, string.Empty, toAdr, 0, 0); } check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult> (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT); }); if (check_result_info != null && !check_result_info.IsSuccess) { MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning); //bcf.App.BCFApplication.onWarningMsg(this, new LogEventArgs("Command create fail.", check_result_info.Num)); } }
public bool canExcuteUnloadTransferToAGVStation(IAGVStationType agvStation, int unfinishCmdCount, bool isEmergency) { //if (DebugParameter.CanUnloadToAGVStationTest) // return true; //else // return false; string result = ""; string url = ""; try { string agv_url = agvStation.RemoveURI; url = SCUtility.Trim(agv_url, true); string agv_station_id = agvStation.getAGVStationID(); string[] action_targets = new string[] { "TransferManagement", "TransferCheck", "AGVStation" }; string[] param = new string[] { agv_station_id, $"?{nameof(unfinishCmdCount)}={unfinishCmdCount}", $"&{nameof(isEmergency)}={isEmergency}", }; LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(TransferBLL), Device: "AGVC", Data: $"Try to reserve agv station to unload,uri:{agv_url} station id:{agv_station_id} unfinishCmdCount:{unfinishCmdCount} isEmergency:{isEmergency}..."); result = webClientManager.GetInfoFromServer(agv_url, action_targets, param); LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(TransferBLL), Device: "AGVC", Data: $"Try to reserve agv station to unload,uri:{agv_url} station id:{agv_station_id} unfinishCmdCount:{unfinishCmdCount} isEmergency:{isEmergency},result:{result}"); result = result.ToUpper(); agvStation.LastAskTime = DateTime.Now; } catch (Exception ex) { logger.Error(ex, $"Exception:{url}"); throw ex; } //return SCUtility.isMatche(result, UNLOAD_CHECK_RESULT_OK); return(result.Contains(UNLOAD_CHECK_RESULT_OK)); }
protected virtual void S1F1ReceiveAreYouThere(object sender, SECSEventArgs e) { try { S1F1 s1f1 = ((S1F1)e.secsHandler.Parse <S1F1>(e)); SCUtility.secsActionRecordMsg(scApp, true, s1f1); SCUtility.actionRecordMsg(scApp, s1f1.StreamFunction, line.Real_ID, "Receive Are You There From MES.", ""); scApp.TransferService.TransferServiceLogger.Info( DateTime.Now.ToString("HH:mm:ss.fff ") + "MCS >> OHB|s1f1:\n" + s1f1.toSECSString()); //if (!isProcess(s1f1)) { return; } S1F2 s1f2 = new S1F2() { SECSAgentName = scApp.EAPSecsAgentName, SystemByte = s1f1.SystemByte, MDLN = bcfApp.BC_ID, SOFTREV = SCApplication.getMessageString("SYSTEM_VERSION") }; SCUtility.secsActionRecordMsg(scApp, false, s1f2); TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s1f2); SCUtility.actionRecordMsg(scApp, s1f1.StreamFunction, line.Real_ID, "Reply Are You There To MES.", rtnCode.ToString()); scApp.TransferService.TransferServiceLogger.Info(DateTime.Now.ToString("HH:mm:ss.fff ") + "MCS >> OHB|s1f2 MDLN:" + s1f2.MDLN + " SCES_ReturnCode:" + rtnCode); if (rtnCode != TrxSECS.ReturnCode.Normal) { logger.Warn("Reply EAP S1F2 Error:{0}", rtnCode); } } catch (Exception ex) { scApp.TransferService.TransferServiceLogger.Error( DateTime.Now.ToString("HH:mm:ss.fff ") + " S1F1ReceiveAreYouThere\n" + ex); logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "S1F1_Receive_AreYouThere", ex.ToString()); } }
protected virtual void S5F3ReceiveEnableDisableAlarm(object sender, SECSEventArgs e) { try { bool isSuccess = true; S5F3 s5f3 = ((S5F3)e.secsHandler.Parse <S5F3>(e)); SCUtility.secsActionRecordMsg(scApp, true, s5f3); //if (isProcess(s5f3)) { return; } //Boolean isEnable = SCUtility.isMatche(s5f3.ALED, SECSConst.ALED_Enable); Boolean isEnable = s5f3.ALED[0] == 1; string alarm_code = s5f3.ALID; scApp.TransferService.TransferServiceLogger.Info( DateTime.Now.ToString("HH:mm:ss.fff ") + "MCS >> OHB|s5f3:\n" + s5f3.toSECSString()); isSuccess = scApp.AlarmBLL.enableAlarmReport(alarm_code, isEnable); S5F4 s5f4 = null; s5f4 = new S5F4(); s5f4.SystemByte = s5f3.SystemByte; s5f4.SECSAgentName = scApp.EAPSecsAgentName; s5f4.ACKC5 = isSuccess ? SECSConst.ACKC5_Accepted : SECSConst.ACKC5_Not_Accepted; TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s5f4); SCUtility.secsActionRecordMsg(scApp, false, s5f4); scApp.TransferService.TransferServiceLogger.Info(DateTime.Now.ToString("HH:mm:ss.fff ") + "MCS >> OHB|s5f4 ACKC5:" + s5f4.ACKC5 + " SCES_ReturnCode:" + rtnCode); if (rtnCode != TrxSECS.ReturnCode.Normal) { logger.Warn("Reply EQPT S2F18 Error:{0}", rtnCode); } } catch (Exception ex) { scApp.TransferService.TransferServiceLogger.Error( DateTime.Now.ToString("HH:mm:ss.fff ") + " S5F3ReceiveEnableDisableAlarm\n" + ex); logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "S2F17_Receive_Date_Time_Req", ex.ToString()); } }
public Boolean checkUserPassword(string user_id, string password) { DBConnection_EF conn = null; Boolean result = false; try { conn = DBConnection_EF.GetContext(); conn.BeginTransaction(); UASUSR loginUser = userDao.getUser(conn, false, user_id); if (loginUser == null) { result = false; } else if (SCUtility.isMatche(loginUser.PASSWD, password)) { result = true; } conn.Commit(); } catch (Exception ex) { logger.Warn("Load User Function Failed from UASUFNC [user_id:{0}]", user_id, ex); result = false; } finally { if (conn != null) { try { conn.Close(); } catch (Exception exception) { logger.Warn("Close Connection Failed.", exception); } } } return(result); }
private void Button_Click(object sender, RoutedEventArgs e) { //((MainViewModel)DataContext).IsProgressing = true; //Thread tr = new Thread(delegate() { Progress(); }); //tr.Start(); ((MainViewModel)DataContext).Children.Clear(); ((MainViewModel)DataContext).CurrentViewItem = null; //DoubleAnimation da = new DoubleAnimation(100, new Duration(new TimeSpan(0, 0, 2))); //da.FillBehavior = FillBehavior.Stop; //bar.BeginAnimation(BreadcrumbBar.ProgressValueProperty, da); SCUtility.LoadDefualtItem(((MainViewModel)DataContext)); OnRefreshGovSession(e); //((MainViewModel)DataContext).IsProgressing = false; }
private Task <(bool is_success, object result)> findIdleForCycleVehicle(string zoneID) { List <AVEHICLE> vhs = scApp.VehicleBLL.cache.loadAllVh(); var result = vhs.Where(vh => vh.isTcpIpConnect && !SCUtility.isEmpty(vh.CUR_ADR_ID) && //SCUtility.isMatche(vh.CUR_ZONE_ID, zoneID) && SCUtility.isMatche(vh.getZoneID(scApp.SectionBLL), zoneID) && vh.MODE_STATUS == ProtocolFormat.OHTMessage.VHModeStatus.AutoRemote && vh.ACT_STATUS == ProtocolFormat.OHTMessage.VHActionStatus.NoCommand && //scApp.CMDBLL.canAssignCmdNew(vh.VEHICLE_ID, E_CMD_TYPE.Move).canAssign). scApp.CMDBLL.canAssignCmdNew(vh, E_CMD_TYPE.Move).canAssign). ToList(); if (result == null) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(RandomGeneratesCommandTimerActionTiming), Device: string.Empty, Data: $"Can't find idle vh.,{zoneID}"); } return(Task.FromResult((result != null && result.Count != 0, (object)result))); }
public bool IsBlockControlStatus(string vh_id, string queue_status) { string set_key_word = string.Format(REDIS_BLOCK_CONTROL_KEY_VHID, vh_id); var blockInfo = redisCacheManager.StringGet(set_key_word); string sec_id = string.Empty; string status = string.Empty; bool isInStatus = false; if (blockInfo.HasValue) { string[] blockInfos = ((string)blockInfo).Split(','); sec_id = blockInfos[0]; status = blockInfos[1]; isInStatus = SCUtility.isMatche(queue_status, status); } LogCollection.BlockControlLogger.Trace ($"Check block zone status is in status, VH_ID [{vh_id}],block status [{queue_status}] " + $"is in stauts [{isInStatus}],redis block id:{sec_id},redis block status:{status}"); return(isInStatus); }
private void whenObstacleFinish() { AVEHICLE vh = scApp.VehicleBLL.getVehicleByID(eqpt.VEHICLE_ID); if (eqpt.ObstacleStatus == VhStopSingle.StopSingleOff && !SCUtility.isEmpty(vh.MCS_CMD)) { double OCSTime_ms = eqpt.watchObstacleTime.ElapsedMilliseconds; double OCSTime_s = OCSTime_ms / 1000; OCSTime_s = Math.Round(OCSTime_s, 1); if (eqpt.HAS_CST == 0) { scApp.SysExcuteQualityBLL.updateSysExecQity_OCSTime2SurceOnTheWay(vh.MCS_CMD, OCSTime_s); } else { scApp.SysExcuteQualityBLL.updateSysExecQity_OCSTime2DestnOnTheWay(vh.MCS_CMD, OCSTime_s); } } }
public bool IsInMaintainDeviceRangeOfAddress(BLL.SegmentBLL segmentBLL, string adrID) { string adr_id = SCUtility.Trim(adrID, true); var maintain_device = eqObjCacheManager.getAllEquipment(). Where(device => device is IMaintainDevice). ToList(); foreach (IMaintainDevice device in maintain_device) { ASEGMENT device_segment = segmentBLL.cache.GetSegment(device.DeviceSegment); string[] segment_of_section_from_address = device_segment.Sections.Select(section => section.FROM_ADR_ID.Trim()).ToArray(); string[] segment_of_section_to_address = device_segment.Sections.Select(section => section.TO_ADR_ID.Trim()).ToArray(); string[] segment_include_address = segment_of_section_from_address.Concat(segment_of_section_to_address).ToArray(); if (segment_include_address.Contains(adr_id)) { return(true); } } return(false); }
private async void btn_force_finish_Click(object sender, EventArgs e) { try { if (selection_index == -1) { return; } btn_force_finish.Enabled = false; var mcs_cmd = cmdMCSList[selection_index]; AVEHICLE excute_cmd_of_vh = mainform.BCApp.SCApplication.VehicleBLL.cache.getVehicleByMCSCmdID(mcs_cmd.CMD_ID); await Task.Run(() => { try { if (excute_cmd_of_vh != null) { mainform.BCApp.SCApplication.VehicleBLL.doTransferCommandFinish(excute_cmd_of_vh.VEHICLE_ID, excute_cmd_of_vh.OHTC_CMD, CompleteStatus.CmpStatusForceFinishByOp); mainform.BCApp.SCApplication.VIDBLL.initialVIDCommandInfo(excute_cmd_of_vh.VEHICLE_ID); } mainform.BCApp.SCApplication.CMDBLL.updateCMD_MCS_TranStatus2Complete(mcs_cmd.CMD_ID, E_TRAN_STATUS.Aborted); mainform.BCApp.SCApplication.ReportBLL.newReportTransferCommandNormalFinish(mcs_cmd.cmd_mcs, excute_cmd_of_vh, sc.Data.SECS.CSOT.SECSConst.CMD_Result_Unsuccessful, null); mainform.BCApp.SCApplication.SysExcuteQualityBLL.doCommandFinish(mcs_cmd.CMD_ID, CompleteStatus.CmpStatusForceFinishByOp, E_CMD_STATUS.AbnormalEndByOHTC); } catch { } } ); Common.LogHelper.Log(logger: NLog.LogManager.GetCurrentClassLogger(), LogLevel: LogLevel.Info, Class: nameof(TransferCommandQureyListForm), Device: "OHTC", Data: $"Fource mcs command finish success, vh id:{SCUtility.Trim(excute_cmd_of_vh?.VEHICLE_ID, true)}, cst id:{SCUtility.Trim(excute_cmd_of_vh?.CST_ID, true)}, " + $"mcs command id:{SCUtility.Trim(mcs_cmd.CMD_ID, true)},source:{SCUtility.Trim(mcs_cmd.HOSTSOURCE, true)},dest:{SCUtility.Trim(mcs_cmd.HOSTDESTINATION, true)}"); updateTransferCommand(); } catch { } finally { btn_force_finish.Enabled = true; } }
public T StringGet <T>(string key) { IDatabase db = Database(); if (db == null) { return(default(T)); } key = $"{productID}_{key}"; var value = db.StringGet(key); UsingCount(); if (!value.HasValue) { // logger.Warn($"redis key not exist:{key}"); return(default(T)); } var deserialization_obj = (T)SCUtility.ToObject(value); return(deserialization_obj); }
private AVEHICLE findTheKeyBlockVhID(AVEHICLE avoidVh, AVEHICLE blockedVh) { if (SCUtility.isMatche(avoidVh.CanNotReserveInfo.ReservedVhID, blockedVh.VEHICLE_ID) && SCUtility.isMatche(blockedVh.CanNotReserveInfo.ReservedVhID, avoidVh.VEHICLE_ID)) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(DeadlockCheck), Device: "AGVC", Data: $"dead lock happend ,find key blocked vh .avoid vh:{avoidVh.VEHICLE_ID} ,blocked vh:{blockedVh.VEHICLE_ID}", VehicleID: avoidVh.VEHICLE_ID); return(blockedVh); } else { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(DeadlockCheck), Device: "AGVC", Data: $"dead lock happend ,can't find key blocked vh .avoid vh:{avoidVh.VEHICLE_ID} ,blocked vh:{blockedVh.VEHICLE_ID}. start find orther block vh", VehicleID: avoidVh.VEHICLE_ID); AVEHICLE orther_reserved_vh = scApp.VehicleBLL.cache.getVehicle(blockedVh.CanNotReserveInfo.ReservedVhID); int find_count = 0; return(findTheOrtherKeyBlockVhID(avoidVh, orther_reserved_vh, ref find_count)); } }
/// <summary> /// Pings it. /// </summary> /// <param name="ip">The ip.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> private bool PingIt(String ip) { PingReply r; try { if (SCUtility.isEmpty(ip)) { return(false); } Ping p = new Ping(); r = p.Send(ip); } catch (Exception ex) { logger.Error(ex, "Exception:"); return(false); } return(r.Status == IPStatus.Success); }
private bool IsInZone(AVEHICLE vh, string zoneID) { string current_adr = SCUtility.Trim(vh.CUR_ADR_ID, true); if (SCUtility.isEmpty(current_adr)) { return(false); } if (current_adr.StartsWith("9")) { current_adr = current_adr.Remove(0, 1); current_adr = "1" + current_adr; } var sections = scApp.SectionBLL.cache.GetSectionsByFromAddress(current_adr); //濾掉9開頭的路段 sections = sections. Where(sec => !sec.SEC_ID.StartsWith("9")). ToList(); return(true); }
protected virtual void S2F33ReceiveDefineReport(object sender, SECSEventArgs e) { try { S2F33 s2f33 = ((S2F33)e.secsHandler.Parse <S2F33>(e)); SCUtility.secsActionRecordMsg(scApp, true, s2f33); //if (!isProcess(s2f33)) { return; } S2F34 s2f34 = null; s2f34 = new S2F34(); s2f34.SystemByte = s2f33.SystemByte; s2f34.SECSAgentName = scApp.EAPSecsAgentName; s2f34.DRACK = "0"; TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s2f34); SCUtility.secsActionRecordMsg(scApp, false, s2f34); if (rtnCode != TrxSECS.ReturnCode.Normal) { logger.Warn("Reply EQPT S2F18 Error:{0}", rtnCode); } scApp.CEIDBLL.DeleteRptInfoByBatch(); if (s2f33.RPTITEMS != null && s2f33.RPTITEMS.Length > 0) { scApp.CEIDBLL.buildRptsFromMCS(s2f33.RPTITEMS); } SECSConst.setDicRPTIDAndVID(scApp.CEIDBLL.loadDicRPTIDAndVID()); } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "S2F17_Receive_Date_Time_Req", ex.ToString()); } }
public List <ALARM> loadAlarmByConditions(DBConnection_EF conn, DateTime startDatetime, DateTime endDatetime, bool includeSet = false, bool includeClear = false, string eqptID = null, string alarmCode = null) { try { var alarms = conn.ALARM.Where(a => a.RPT_DATE_TIME > startDatetime && a.RPT_DATE_TIME < endDatetime); if (includeSet && includeClear) { alarms = alarms.Where(a => a.ALAM_STAT == ProtocolFormat.OHTMessage.ErrorStatus.ErrSet || a.ALAM_STAT == ProtocolFormat.OHTMessage.ErrorStatus.ErrReset); } else if (includeSet) { alarms = alarms.Where(a => a.ALAM_STAT == ProtocolFormat.OHTMessage.ErrorStatus.ErrSet); } else if (includeClear) { alarms = alarms.Where(a => a.ALAM_STAT == ProtocolFormat.OHTMessage.ErrorStatus.ErrReset); } else { //沒有限定的話就全撈 } if (!SCUtility.isEmpty(eqptID)) { alarms = alarms.Where(a => a.EQPT_ID == eqptID.Trim()); } if (!SCUtility.isEmpty(alarmCode)) { alarms = alarms.Where(a => a.ALAM_CODE == alarmCode.Trim()); } alarms = alarms.OrderBy(a => a.RPT_DATE_TIME); return(alarms.ToList()); } catch (Exception ex) { logger.Warn(ex); throw; } }
public virtual void doShareMemoryInit(BCFAppConstants.RUN_LEVEL runLevel) { try { switch (runLevel) { case BCFAppConstants.RUN_LEVEL.ZERO: CarOutSafetyChcek(null, null); CarOutActionType(null, null); CarInSafetyChcek(null, null); MTL_LFTStatus(null, null); //如果該機台為MTS1或者是MTL時,需要將兩台設定為互相doking的機台 if (eqpt is MaintainSpace && SCUtility.isMatche((eqpt as MaintainSpace).EQPT_ID, "MTS")) { (eqpt as MaintainSpace).DokingMaintainDevice = scApp.EquipmentBLL.cache.GetMaintainLift(); } else if (eqpt is MaintainLift && SCUtility.isMatche((eqpt as MaintainLift).EQPT_ID, "MTL")) { (eqpt as MaintainLift).DokingMaintainDevice = scApp.EquipmentBLL.cache.GetDockingMTLOfMaintainSpace(); } break; case BCFAppConstants.RUN_LEVEL.ONE: break; case BCFAppConstants.RUN_LEVEL.TWO: break; case BCFAppConstants.RUN_LEVEL.NINE: break; } } catch (Exception ex) { logger.Error(ex, "Exection:"); } }
public (bool isSuccess, string result) processCarOutScenario(MaintainLift mtx, AVEHICLE preCarOutVh) { string pre_car_out_vh_id = preCarOutVh.VEHICLE_ID; string pre_car_out_vh_ohtc_cmd_id = preCarOutVh.OHTC_CMD; string pre_car_out_vh_cur_adr_id = preCarOutVh.CUR_ADR_ID; bool isSuccess; string result = "OK"; mtx.CancelCarOutRequest = false; mtx.CarOurSuccess = false; mtx.SetCarOutInterlock(true); //isSuccess = VehicleService.doReservationVhToMaintainsBufferAddress(pre_car_out_vh_id, MTL_CAR_OUT_BUFFER_ADDRESS); isSuccess = VehicleService.doReservationVhToMaintainsBufferAddress(pre_car_out_vh_id, mtx.MTL_SYSTEM_OUT_ADDRESS); if (isSuccess && SCUtility.isEmpty(pre_car_out_vh_ohtc_cmd_id)) { //在收到OHT的ID:132-命令結束後或者在變為AutoLocal後此時OHT沒有命令的話則會呼叫此Function來創建一個Transfer command,讓Vh移至移動至System out上 if (SCUtility.isMatche(pre_car_out_vh_cur_adr_id, mtx.MTL_SYSTEM_OUT_ADDRESS)) { VehicleService.doAskVhToMaintainsAddress(pre_car_out_vh_id, mtx.MTL_ADDRESS); } else { VehicleService.doAskVhToSystemOutAddress(pre_car_out_vh_id, mtx.MTL_SYSTEM_OUT_ADDRESS); } } if (isSuccess) { //carOutVhID = pre_car_out_vh_id; mtx.PreCarOutVhID = pre_car_out_vh_id; Task.Run(() => RegularUpdateRealTimeCarInfo(mtx, preCarOutVh)); } else { mtx.SetCarOutInterlock(false); isSuccess = false; result = $"Reservation vh to mtl fail."; } return(isSuccess, result); }
protected virtual Boolean isProcess(SXFY sxfy) { Boolean isProcess = false; string streamFunction = sxfy.StreamFunction; if (line.Host_Control_State == SCAppConstants.LineHostControlState.HostControlState.EQ_Off_line) { if (sxfy is S1F17) { isProcess = true; } else if (sxfy is S2F41) { string rcmd = (sxfy as S2F41).RCMD; } else { isProcess = false; } } else { isProcess = true; } if (!isProcess) { S1F0 sxf0 = new S1F0() { SECSAgentName = scApp.EAPSecsAgentName, StreamFunction = sxfy.getAbortFunctionName(), SystemByte = sxfy.SystemByte }; SCUtility.secsActionRecordMsg(scApp, false, sxf0); TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, sxf0); SCUtility.actionRecordMsg(scApp, sxf0.StreamFunction, line.Real_ID, "Reply Abort To MES.", rtnCode.ToString()); } return(isProcess); }
private void setLineStatus() { try { string subject = BCAppConstants.NATSTopics.NATS_SUBJECT_LINE_INFO; //指定要執行的動作 EventHandler <StanMsgHandlerArgs> msgHandler = (senders, args) => { lock (lineStatLock) { byte[] arrayByte = args.Message.Data; if (arrayByte == null) { return; } //反序列化 saveLineInfo Google.Protobuf.MessageParser <LINE_INFO> parser = new Google.Protobuf.MessageParser <LINE_INFO>(() => new LINE_INFO()); LINE_INFO lineInfo = parser.ParseFrom(arrayByte); if (SCUtility.isEmpty(sLineID)) { sLineID = lineInfo.LineID; //更新Line ID Adapter.Invoke(new SendOrPostCallback((o1) => { lbl_LineID.Text = lineInfo.LineID; }), null); } } }; //訂閱 app.GetNatsManager().Subscriber(subject, msgHandler, false, true, 0, null); //當subject有變化,則進行msgHandler的動作 } catch (Exception ex) { logger.Error(ex, "Exception"); } }