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); //除了第一段的from address以外其他要屬於該Segment的Address string[] segment_of_section_from_address = device_segment.Sections. Where(sec => sec != device_segment.Sections.First()). Select(section => section.FROM_ADR_ID.Trim()).ToArray(); //除了最後一段的to address以外其他要屬於該Segment的Address string[] segment_of_section_to_address = device_segment.Sections. Where(sec => sec != device_segment.Sections.Last()). 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); }
public (bool isSuccess, string reason) RecoverCVEnable(string segmentID) { bool is_success = true; string reason = ""; try { ASEGMENT seg_vo = SegmentBLL.cache.GetSegment(segmentID); List <sc.Data.VO.OHCV> ohcvs = app.EquipmentBLL.cache.loadOHCVDevicesBySegmentLocation(segmentID); if (ohcvs == null || ohcvs.Count == 0) { reason = $"Segment ID:{segmentID} not is cv of segemnt."; is_success = false;; return(is_success, reason); } if (!seg_vo.DISABLE_FLAG_SAFETY) { reason = $"Segment ID:{segmentID} of safty flag already off."; is_success = false;; return(is_success, reason); } foreach (sc.Data.VO.OHCV ohcv in ohcvs) { if (!ohcv.DoorClosed) { reason = $"ohcv ID:{ohcv.EQPT_ID} of door closed:{ohcv.DoorClosed} ,can't enable segment."; is_success = false; return(is_success, reason); } if (!ohcv.Is_Eq_Alive) { reason = $"ohcv ID:{ohcv.EQPT_ID} of alive:{ohcv.Is_Eq_Alive} ,can't enable segment."; is_success = false; return(is_success, reason); } } //取得CV所在的Node,By Segment ID string seg_id = SCUtility.Trim(segmentID, true); ANODE node = NodeBLL.OperateCatch.getNodeBySegment(seg_id); doEnableDisableSegment(seg_id, E_PORT_STATUS.InService, ASEGMENT.DisableType.Safety, sc.Data.SECS.CSOT.SECSConst.LANECUTTYPE_LaneCutOnHMI); foreach (var ohcv in node.getSubEqptList()) { LineService.ProcessAlarmReport( ohcv.NODE_ID, ohcv.EQPT_ID, ohcv.Real_ID, "", SCAppConstants.SystemAlarmCode.OHCV_Issue.CVALLAlarmReset, ProtocolFormat.OHTMessage.ErrorStatus.ErrReset); } return(is_success, reason); } catch (Exception ex) { logger.Error(ex, "Exception:"); reason = $"{ex}-Exception"; is_success = false; return(is_success, reason); } }
public virtual void RemoveManyReservedSectionsByVIDSID(string vhID, string sectionID) { string sec_id = SCUtility.Trim(sectionID); mapAPI.RemoveManyReservedSectionsByVIDSID(vhID, sec_id); onReserveStatusChange(); }
//public HltResult TryAddReservedSection(string vhID, string sectionID, HltDirection sensorDir = HltDirection.Forward, HltDirection forkDir = HltDirection.None, bool isAsk = false) //{ // //int sec_id = 0; // //int.TryParse(sectionID, out sec_id); // string sec_id = SCUtility.Trim(sectionID); // HltResult result = mapAPI.TryAddReservedSection(vhID, sec_id, sensorDir, forkDir, isAsk); // onReserveStatusChange(); // return result; //} public HltResult TryAddReservedSection(string vhID, string sectionID, HltDirection sensorDir = HltDirection.Forward, HltDirection forkDir = HltDirection.None, bool isAsk = false) { HltResult result = null; string sec_id = SCUtility.Trim(sectionID); //如果詢問的Section是Reserve Enhance的section時, //則要判斷該區塊且之後的Section是否要得到 var reserve_enhance_info_check_result = IsReserveEnhanceSection(sectionID); if (reserve_enhance_info_check_result.isEnhanceInfo) { List <string> enhance_control_sections = reserve_enhance_info_check_result.info.EnhanceControlSections; int section_index = enhance_control_sections.IndexOf(sectionID); for (int i = section_index; i < enhance_control_sections.Count; i++) { result = mapAPI.TryAddReservedSection(vhID, enhance_control_sections[i], sensorDir, forkDir, true); if (!result.OK) { result.Description += $",section:{sectionID} is reserve enhance group:{reserve_enhance_info_check_result.info.GroupID}," + $"current has vh:{result.VehicleID}"; return(result); } } } result = mapAPI.TryAddReservedSection(vhID, sec_id, sensorDir, forkDir, isAsk); onReserveStatusChange(); return(result); }
private void Sec_obj_VehicleLeave(object sender, string vhID) { App.SCApplication app = App.SCApplication.getInstance(); ASECTION section = sender as ASECTION; AVEHICLE leave_vh = app.VehicleBLL.cache.getVehicle(vhID); if (!ControlSections.Contains(SCUtility.Trim(leave_vh.CUR_SEC_ID, true))) { string Vh_id = string.Empty; if (CurrentVhs.TryRemove(vhID, out Vh_id)) { } } //判斷是否所有車子都已經不再該管制道路中了。 var vhs = app.VehicleBLL.cache.loadAllVh(); foreach (AVEHICLE vh in vhs) { string vh_current_section = Common.SCUtility.Trim(vh.CUR_SEC_ID, true); if (ControlSections.Contains(vh_current_section)) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(TrafficControlInfo), Device: "OHx", Data: $"vh:{vhID} is leave sec:{section.SEC_ID},but vh:{vh.VEHICLE_ID} in traffic contorl:{ID} of control section:{vh_current_section}," + $"can't notify section clear event.", VehicleID: vhID); return; } } TrafficControlSectionIsClear?.Invoke(this, vhID); }
public static void LogBCRReadInfo(string VehicleID, string portID, string mcsCmdID, string ohtcCmdID, string carrierID, string readCarrierID, ProtocolFormat.OHTMessage.BCRReadResult bCRReadResult, bool IsEnableIDReadFailScenario, [CallerMemberName] string Method = "") { try { dynamic logEntry = new Newtonsoft.Json.Linq.JObject(); logEntry.dateTime = DateTime.Now; logEntry.Method = Method; logEntry.VH_ID = VehicleID; logEntry.PortID = SCUtility.Trim(portID); logEntry.CarrierID = SCUtility.Trim(carrierID); logEntry.ReadCarrierID = SCUtility.Trim(readCarrierID); logEntry.MCS_CMD_ID = SCUtility.Trim(mcsCmdID); logEntry.OHTC_CMD_ID = SCUtility.Trim(ohtcCmdID); logEntry.BCRReadResult = bCRReadResult.ToString(); logEntry.IsEnableIDReadFailScenario = IsEnableIDReadFailScenario; logEntry.Index = "BCRReadInfo"; var json = logEntry.ToString(Newtonsoft.Json.Formatting.None); json = json.Replace("dateTime", "@timestamp"); LogManager.GetLogger("BCRReadInfo").Info(json); } catch (Exception e) { LogHelper.logger.Error($"{e}, Exception"); } }
public bool checkIsNeedWaitForLoad(IAGVStationType agvStation, int waitTimeOut) { string result = ""; string url = ""; try { //TransferManagement/TransferCheck/Swap/AGVStation/{agvStationName} string agv_url = agvStation.RemoveURI; url = SCUtility.Trim(agv_url, true); string agv_station_id = agvStation.getAGVStationID(); string[] action_targets = new string[] { "TransferManagement", "IsAnyAdditionalCstToBeTransfer", "Swap", "AGVStation" }; string[] param = new string[] { agv_station_id }; LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(TransferBLL), Device: "AGVC", Data: $"Try to pre open agv station cover,uri:{agv_url} station id:{agv_station_id} "); result = webClientManager.GetInfoFromServer(agv_url, action_targets, param, waitTimeOut); LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(TransferBLL), Device: "AGVC", Data: $"Try to pre open agv station cover,uri:{agv_url} station id:{agv_station_id} ,result:{result}"); result = result.ToUpper(); } catch (Exception ex) { logger.Error(ex, $"Exception:{url}"); } return(result.Contains(CHECK_IS_WAIT_RESULT_TRUE)); }
private void _SetRailToolTip() { this.ToolTip.SetToolTip(this.pic_VhStatus, "Current Adr : " + SCUtility.Trim(vh.CUR_ADR_ID) + "\r\n" + "Current SEC : " + SCUtility.Trim(vh.CUR_SEC_ID) + "\r\n" + "Action : " + vh.ACT_STATUS.ToString()); }
public void preOpenAGVStationCover(IAGVStationType agvStation, string portID) { 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", "PreOpenAGVStationCover", "AGVStationPorts" }; string[] param = new string[] { portID }; LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(TransferBLL), Device: "AGVC", Data: $"Try to pre open agv station cover,uri:{agv_url} station id:{agv_station_id} port id:{portID}..."); result = webClientManager.GetInfoFromServer(agv_url, action_targets, param); LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(TransferBLL), Device: "AGVC", Data: $"Try to pre open agv station cover,uri:{agv_url} station id:{agv_station_id} port id:{portID} ,result:{result}"); result = result.ToUpper(); } catch (Exception ex) { logger.Error(ex, $"Exception:{url}"); } }
public bool RecoverCVEnable(string segmentID) { try { //取得CV所在的Node,By Segment ID string seg_id = SCUtility.Trim(segmentID, true); ANODE node = NodeBLL.OperateCatch.getNodeBySegment(seg_id); doEnableDisableSegment(seg_id, E_PORT_STATUS.InService, ASEGMENT.DisableType.Safety, sc.Data.SECS.CSOT.SECSConst.LANECUTTYPE_LaneCutOnHMI); foreach (var ohcv in node.getSubEqptList()) { LineService.ProcessAlarmReport( ohcv.NODE_ID, ohcv.EQPT_ID, ohcv.Real_ID, "", SCAppConstants.SystemAlarmCode.OHCV_Issue.CVALLAlarmReset, ProtocolFormat.OHTMessage.ErrorStatus.ErrReset); } return(true); } catch (Exception ex) { logger.Error(ex, "Exception:"); return(false); } }
public static string tryGetVirturePortID(BLL.PortStationBLL portStationBLL, BLL.EqptBLL eqptBLL, string dest) { APORTSTATION port_station = portStationBLL.OperateCatch.getPortStation(dest); if (port_station == null) { return(dest); } var eqpt = port_station.GetEqpt(eqptBLL); if (eqpt is AGVStation) { var agv_station = eqpt as AGVStation; var virtrue_port = agv_station.getAGVVirtruePort(); if (agv_station.IsVirtrueUse) { return(SCUtility.Trim(virtrue_port.PORT_ID, true)); } else { return(dest); } } else { return(dest); } }
private ShelfDef FindRandomEmptyShelf(List <CassetteData> cassetteDatas)//A0.01 { //找出在儲位中的Cassette cassetteDatas = cassetteDatas.Where(cst => cst.Carrier_LOC.StartsWith("10") || cst.Carrier_LOC.StartsWith("11") || cst.Carrier_LOC.StartsWith("21") || cst.Carrier_LOC.StartsWith("20")). ToList(); List <string> current_cst_at_shelf_id = cassetteDatas. Select(cst => SCUtility.Trim(cst.Carrier_LOC, true)). ToList(); //刪除目前有cst所在的儲位,讓他排除在Cycle Run的列表中 foreach (var shelf in shelfDefs.ToList()) { if (current_cst_at_shelf_id.Contains(SCUtility.Trim(shelf.ShelfID))) { shelfDefs.Remove(shelf); } } //隨機找出一個要放置的shelf int task_RandomIndex = rnd_Index.Next(shelfDefs.Count - 1); return(shelfDefs[task_RandomIndex]); }
private void initialComBox() { List <AADDRESS> allAddress_obj = scApp.MapBLL.loadAllAddress(); allAdr_ID = allAddress_obj.Select(adr => adr.ADR_ID).ToArray(); //string[] adr_port1_ID = allAddress_obj. // Where(adr => adr.PORT1_ID != null && adr.PORT1_ID != string.Empty). // Select(adr => adr.PORT1_ID).ToArray(); //string[] adr_port2_ID = allAddress_obj. // Where(adr => adr.PORT2_ID != null && adr.PORT2_ID != string.Empty). // Select(adr => adr.PORT2_ID).ToArray(); //List<string> portIDTemp = new List<string>(); //portIDTemp.AddRange(adr_port1_ID); //portIDTemp.AddRange(adr_port2_ID); //portIDTemp.OrderBy(id => id); //allPortID = scApp.MapBLL.loadAllPort().Select(s => s.PORT_ID).ToArray(); allPortID = scApp.PortStationBLL.OperateCatch.loadAllPortStation(). Where(s => !s.PORT_ID.Contains("_ST0")). Select(s => SCUtility.Trim(s.PORT_ID, true)).ToArray(); //allPortID = allAddress_obj.Where(adr=>adr. BCUtility.setComboboxDataSource(cmb_toAddress, allAdr_ID); BCUtility.setComboboxDataSource(cmb_fromAddress, allAdr_ID.ToArray()); //cmb_fromAddress.DataSource = allAdr_ID.ToArray(); //cmb_fromAddress.AutoCompleteCustomSource.AddRange(allAdr_ID); //cmb_fromAddress.AutoCompleteMode = AutoCompleteMode.Suggest; //cmb_fromAddress.AutoCompleteSource = AutoCompleteSource.ListItems; string[] allSec = scApp.MapBLL.loadAllSectionID().ToArray(); cmb_fromSection.DataSource = allSec; cmb_fromSection.AutoCompleteCustomSource.AddRange(allSec); cmb_fromSection.AutoCompleteMode = AutoCompleteMode.Suggest; cmb_fromSection.AutoCompleteSource = AutoCompleteSource.ListItems; List <string> lstVh = new List <string>(); lstVh.Add(string.Empty); lstVh.AddRange(scApp.VehicleBLL.cache.loadAllVh().Select(vh => vh.VEHICLE_ID).ToList()); string[] allVh = lstVh.ToArray(); cmb_Vehicle.DataSource = allVh; cmb_Vehicle.AutoCompleteCustomSource.AddRange(allVh); cmb_Vehicle.AutoCompleteMode = AutoCompleteMode.Suggest; cmb_Vehicle.AutoCompleteSource = AutoCompleteSource.ListItems; cbm_Action_admin.DataSource = Enum.GetValues(typeof(E_CMD_TYPE)).Cast <E_CMD_TYPE>() .Where(e => e != E_CMD_TYPE.Move_Park && e != E_CMD_TYPE.Teaching && e != E_CMD_TYPE.Continue && e != E_CMD_TYPE.Round && e != E_CMD_TYPE.Override && e != E_CMD_TYPE.MTLHome && e != E_CMD_TYPE.Move_Teaching ).ToList(); cbm_Action_op.DataSource = Enum.GetValues(typeof(E_CMD_TYPE)).Cast <E_CMD_TYPE>() .Where(e => e == E_CMD_TYPE.Move).ToList(); }
public bool setTrafficControlKey(string trafficControlID, string vhID, string adrID) { string traffic_control_key = string.Format(SCAppConstants.REDIS_KEY_TRAFFIC_CONTROL_INFO_0, trafficControlID.Trim()); string traffic_control_value = $"{vhID}#{SCUtility.Trim(adrID, true)}"; //redisCacheManager.stringSetAsync(adr_reserve_key, vhID); return(redisCacheManager.stringSet(traffic_control_key, traffic_control_value)); }
//public void setVehicleInReserveList(string vhID, string adrID) public bool setVehicleInReserveList(string vhID, string adrID, string sectionID) { string adr_reserve_key = string.Format(SCAppConstants.REDIS_KEY_ADDRESS_RESERVE_INFO_0, adrID.Trim()); string adr_reserve_value = $"{vhID}#{SCUtility.Trim(sectionID, true)}"; //redisCacheManager.stringSetAsync(adr_reserve_key, vhID); return(redisCacheManager.stringSet(adr_reserve_key, adr_reserve_value)); }
public virtual HltResult RemoveAllReservedSectionsBySectionID(string sectionID) { string sec_id = SCUtility.Trim(sectionID); HltResult result = mapAPI.RemoveAllReservedSectionsBySectionID(sec_id); onReserveStatusChange(); return(result); }
public void RemoveManyReservedSectionsByVIDSID(string vhID, string sectionID) { //int sec_id = 0; //int.TryParse(sectionID, out sec_id); string sec_id = SCUtility.Trim(sectionID); mapAPI.RemoveManyReservedSectionsByVIDSID(vhID, sec_id); onReserveStatusChange(); }
public List <ASECTION> GetSectionsByAddresses(List <string> adrIDs) { List <ASECTION> result_sections = CommObjCacheManager.getSections(). Where(sec => adrIDs.Contains(SCUtility.Trim(sec.FROM_ADR_ID)) || adrIDs.Contains(SCUtility.Trim(sec.TO_ADR_ID))). ToList(); return(result_sections); }
public string getSourcePortEQID(BLL.PortStationBLL portStationBLL) { var port_station = portStationBLL.OperateCatch.getPortStation(this.HOSTSOURCE); if (port_station == null) { return(""); } return(SCUtility.Trim(port_station.EQPT_ID, true)); }
public string getTragetPortAdrID(BLL.PortStationBLL portStationBLL) { var port_station = portStationBLL.OperateCatch.getPortStation(this.HOSTDESTINATION); if (port_station == null) { return(""); } return(SCUtility.Trim(port_station.ADR_ID, true)); }
private void _SetRailToolTip() { //AVEHICLE vh = bcApp.SCApplication.VehicleBLL.getVehicleByID(eqpt.VEHICLE_ID); AVEHICLE vh = bcApp.SCApplication.getEQObjCacheManager().getVehicletByVHID(eqpt.VEHICLE_ID); this.ToolTip.SetToolTip(this.lblPresence, "Current Adr : " + SCUtility.Trim(vh.CUR_ADR_ID) + "\r\n" + "Current SEC : " + SCUtility.Trim(vh.CUR_SEC_ID) + "\r\n" + "Action : " + vh.ACT_STATUS.ToString()); }
public HltResult RemoveAllReservedSectionsBySectionID(string sectionID) { //int sec_id = 0; //int.TryParse(sectionID, out sec_id); string sec_id = SCUtility.Trim(sectionID); HltResult result = mapAPI.RemoveAllReservedSectionsBySectionID(sec_id); onReserveStatusChange(); return(result); }
public void set(AVEHICLE vh, int seqNum, ID_136_TRANS_EVENT_REP gpbMessage) { SEQ_NUM = seqNum.ToString(); EVENT_TYPE = gpbMessage.EventType.ToString(); if (gpbMessage.ReserveInfos.Count > 0) { RESERVE_SEC_ID = gpbMessage.ReserveInfos[0].ReserveSectionID; } CMD_ID = SCUtility.Trim(gpbMessage.CmdID, true); }
public string getSourcePortGroupID(BLL.PortStationBLL portStationBLL) { var port_station = portStationBLL.OperateCatch.getPortStation(ID); if (port_station == null) { return(""); } return(SCUtility.Trim(port_station.GROUP_ID, true)); }
public bool ReportAlarmCleared(string vhID, string transferID, ErrorStatus alarm_status, string error_code, string desc, List <AMCSREPORTQUEUE> reportqueues) { string alcd = SCAppConstants.AlarmStatus.convert2MCS(alarm_status); string alid = error_code; string altx = $"[{SCUtility.Trim(vhID, true) }]{desc}"; iBSEMDriver.S6F11SendUnitAlarmCleared(vhID, transferID, alid, altx); iBSEMDriver.S5F1SendAlarmReport(alcd, alid, altx); return(true); }
private async void excuteScanCommand() { //string fromAdr = string.Empty; string vehicleId = string.Empty; string hostsource_portid = cmb_fromAddress.Text; string hostdest_portid = cmb_toAddress.Text; string from_adr = string.Empty; string to_adr = string.Empty; string cmd_id = string.Empty; string cst_id = txt_cstID.Text; string box_id = "box_id"; string lot_id = "lot_id"; E_VH_TYPE vh_type = E_VH_TYPE.None; vehicleId = SCUtility.Trim(cmb_Vehicle.Text, true); scApp.PortDefBLL.getAddressID(hostsource_portid, out from_adr, out vh_type); cmd_id = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual); if (BCFUtility.isEmpty(vehicleId)) { MessageBox.Show("No find vehile."); return; } if (BCFUtility.isEmpty(cst_id)) { MessageBox.Show("cst id can't empty."); return; } AVEHICLE vh = scApp.getEQObjCacheManager().getVehicletByVHID(vehicleId); sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null; await Task.Run(() => { //if (SCUtility.isMatche(vh.CUR_ADR_ID, fromAdr)) //{ // scApp.VehicleService.TransferRequset(vehicleId, cmd_id, ActiveType.Scan, "CST02", new string[0], new string[0], fromAdr, ""); //} //else { //scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, "CST06", scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id, E_CMD_TYPE.Scan, hostsource_portid, "", 0, 0, box_id, lot_id, from_adr); 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); } }
public List <string> getAGVStationPortAdrIDs() { if (portStationList == null) { return(new List <string>()); } return(portStationList. Where(port_station => !port_station.PORT_ID.Contains("_ST0")). Select(port_station => SCUtility.Trim(port_station.ADR_ID, true)). ToList()); }
public bool setReleaseAddressInfo(string vhID, string adrID) { string adr_vh_release_key = string.Format(SCAppConstants.REDIS_KEY_ADDRESS_RELEASE_INFO_0_1, SCUtility.Trim(adrID, true), SCUtility.Trim(vhID, true)); string adr_vh_release_value = $"{SCUtility.Trim(adrID, true)}#{SCUtility.Trim(vhID, true)}"; bool is_success = redisCacheManager.stringSet(adr_vh_release_key, adr_vh_release_value, timeOut_4sec); LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(AddressesBLL), Device: "AGVC", Details: $"Excute add address id:{adrID} release time out info by vh id:{vhID},result:{is_success}"); return(is_success); }
private string tryGetCurrentTransferCommand(AVEHICLE vh) { if (!SCUtility.isEmpty(vh.TRANSFER_ID_1)) { return(SCUtility.Trim(vh.TRANSFER_ID_1)); } else if (!SCUtility.isEmpty(vh.TRANSFER_ID_2)) { return(SCUtility.Trim(vh.TRANSFER_ID_2)); } return(""); }
public virtual HltResult TryAddReservedSection(string vhID, string sectionID, HltDirection sensorDir = HltDirection.NESW, HltDirection forkDir = HltDirection.None, bool isAsk = false) { //int sec_id = 0; //int.TryParse(sectionID, out sec_id); string sec_id = SCUtility.Trim(sectionID); HltResult result = mapAPI.TryAddReservedSection(vhID, sec_id, sensorDir, forkDir, isAsk); onReserveStatusChange(); return(result); }