public bool isSectionAtFireDoorArea(string section_id) { ASECTION section = scApp.SectionBLL.cache.GetSection(section_id); string segment_id = section.SEG_NUM; return(scApp.FireDoorDao.isSegmentIDatFireDoorArea(scApp, segment_id)); }
private bool BidingGroupRailsAndAddress() { bool bRet = false; List <string> secIDs = mainForm.BCApp.SCApplication.MapBLL.loadAllSectionID(); uctlAddress addressTemp = null; foreach (string sec_id in secIDs) { ASECTION section = mainForm.BCApp.SCApplication.MapBLL.getSectiontByID(sec_id); if (section == null) { continue; } addressTemp = m_objItemAddr.Where(a => a.p_Address.Trim() == section.FROM_ADR_ID.Trim()).FirstOrDefault(); if (addressTemp != null) { m_DicSectionGroupRails[section.SEC_ID.Trim()].p_Points[0].BindingAddress(addressTemp, false); } addressTemp = m_objItemAddr.Where(a => a.p_Address.Trim() == section.TO_ADR_ID.Trim()).FirstOrDefault(); if (addressTemp != null) { m_DicSectionGroupRails[section.SEC_ID.Trim()].p_Points[1].BindingAddress(addressTemp, true); } } return(bRet); }
//public string[] loadNextSectionIDBySectionID(DBConnection_EF con, String section_id) //{ // if (string.IsNullOrWhiteSpace(section_id)) // return null; // string[] nextSection_ids = null; // ASECTION sec = null; // sec = getByID(con, section_id); // if (sec != null) // { // List<ASECTION> nextSections = loadByFromAdr(con, sec.TO_ADR_ID); // if (nextSections != null) // nextSection_ids = nextSections.Select(s => s.SEC_ID).ToArray(); // } // return nextSection_ids; //} public string[] loadNextSectionIDBySectionID(DBConnection_EF con, String section_id) { if (string.IsNullOrWhiteSpace(section_id)) { return(null); } string[] nextSection_ids = null; ASECTION sec = null; sec = getByID(con, section_id); if (sec != null) { List <ASECTION> nextSections = loadByFromAdr(con, sec.TO_ADR_ID); if (nextSections != null) { foreach (ASECTION next_sec in nextSections.ToList()) { if ((sec.SEG_NUM.Trim() == next_sec.SEG_NUM.Trim()) || sec.CHG_SEG_NUM_1.Trim() == next_sec.SEG_NUM.Trim() || sec.CHG_SEG_NUM_2.Trim() == next_sec.SEG_NUM.Trim()) { continue; } nextSections.Remove(next_sec); } nextSection_ids = nextSections.Select(s => s.SEC_ID).ToArray(); } } return(nextSection_ids); }
public bool IsPortInSpecifiedSegment(BLL.SectionBLL sectionBLL, string portID, string segmentID) { APORTSTATION aPORTSTATION = getPortStation(portID); ASECTION aSECTION = sectionBLL.cache.GetSectionsByAddress(aPORTSTATION.ADR_ID.Trim()).First(); return(SCUtility.isMatche(aSECTION.SEG_NUM, segmentID)); }
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 ASECTION getSectiontByID(string section_id) { ASECTION section = objCacheManager.GetSections(). Where(value => value.SEC_ID?.Trim() == section_id?.Trim()). SingleOrDefault(); return(section); }
public bool CheckSegmentInActiveByPortID(string port_id) { bool SegmentInActive = true; APORTSTATION aPORTSTATION = scApp.MapBLL.getPortByPortID(port_id); ASECTION aSECTION = scApp.SectionDao.loadByFromOrToAdr(commObjCacheManager, aPORTSTATION.ADR_ID.Trim()).First(); SegmentInActive = scApp.MapBLL.IsSegmentActive(aSECTION.SEG_NUM); return(SegmentInActive); }
public void sectionUnreserveAtFireDoorArea(string section_id) { ASECTION section = scApp.SectionBLL.cache.GetSection(section_id); string segment_id = section.SEG_NUM; string firedoor_id = scApp.FireDoorDao.getFireDoorIDBySegmentID(scApp, segment_id); AUNIT fireDoor = scApp.getEQObjCacheManager().getUnitByUnitID(firedoor_id); fireDoor.section_unreserved(section_id); }
public bool CheckSegmentInActiveByPortID(BLL.SegmentBLL segmentBLL, BLL.SectionBLL sectionBLL, string port_id) { bool SegmentInActive = true; APORTSTATION aPORTSTATION = getPortStation(port_id); ASECTION aSECTION = sectionBLL.cache.GetSectionsByAddress(aPORTSTATION.ADR_ID.Trim()).First(); SegmentInActive = segmentBLL.cache.IsSegmentActive(aSECTION.SEG_NUM); return(SegmentInActive); }
public void update(DBConnection_EF con, ASECTION section) { try { con.SaveChanges(); } catch (Exception ex) { throw; } }
public Boolean isFirstSectionInSegment(DBConnection_EF con, ASECTION section) { List <ASECTION> lstSec = loadBySegmentNum(con, section.SEG_NUM); if (lstSec == null || lstSec.Count() <= 0) { return(false); } ASECTION FirstSection = lstSec.First(); return(FirstSection.SEC_ID == section.SEC_ID); }
public ASECTION getSectiontByID(string section_id) { ASECTION section = null; //using (DBConnection_EF con = new DBConnection_EF()) //{ // section = sectionDAO.getByID(con, section_id); //} section = sectionDAO.getByID(commObjCacheManager, section_id); return(section); }
private async void excuteLoadUnloadCommand() { string fromSection = cmb_fromSection.Text; ASECTION asection = scApp.MapBLL.getSectiontByID(fromSection); string hostsource = cmb_fromAddress.Text; string hostdest = cmb_toAddress.Text; string from_adr = string.Empty; string to_adr = string.Empty; string cst_id = txt_cst_id.Text; E_VH_TYPE vh_type = E_VH_TYPE.None; scApp.MapBLL.getAddressID(hostsource, out from_adr, out vh_type); scApp.MapBLL.getAddressID(hostdest, out to_adr); string vehicleId = string.Empty; if (BCFUtility.isEmpty(cmb_Vehicle.Text)) { //AVEHICLE firstVh = scApp.VehicleBLL.findBestSuitableVhByFromAdr(fromadr); AVEHICLE firstVh = scApp.VehicleBLL.findBestSuitableVhStepByStepFromAdr_New(from_adr, vh_type); if (firstVh != null) { vehicleId = firstVh.VEHICLE_ID.Trim(); } } else { vehicleId = cmb_Vehicle.Text; } if (BCFUtility.isEmpty(vehicleId)) { MessageBox.Show("No find idle vehile."); return; } sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null; await Task.Run(() => { scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id, E_CMD_TYPE.LoadUnload, from_adr, to_adr, 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 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); List <string> segments = new List <string>(); string pre_segment_id = null; foreach (string section_id in PredictPath) { ASECTION section = scApp.SectionBLL.cache.GetSection(section_id); if (!SCUtility.isMatche(pre_segment_id, section.SEG_NUM)) { segments.Add(section.SEG_NUM.Trim()); pre_segment_id = section.SEG_NUM; } } scApp.CMDBLL.setVhExcuteCmdToShow(aCMD_OHTC, this.eqpt, segments, PredictPath, null, new List <string>(), new List <string>()); } } //先讓車子一開始都當作是"VehicleInstall"的狀態 //之後要從DB得知上次的狀態,是否為Remove 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 bool BidingRailPointAndGroupForRail() { bool bRet = false; List <AGROUPRAILS> listGroup = mainForm.BCApp.SCApplication.MapBLL.loadAllGroupRail(); for (int i = 0; i < listGroup.Count - 1; i++) { if (!BCFUtility.isMatche(listGroup[i].SECTION_ID, listGroup[i + 1].SECTION_ID)) { continue; } findMatchRailPoint(listGroup[i].RAIL_ID, listGroup[i + 1].RAIL_ID); } foreach (AGROUPRAILS group_rail in listGroup) { uctlRail railTemp = null; string section_id = group_rail.SECTION_ID.Trim(); railTemp = m_objItemRail.Where(r => r.p_ID.Trim() == group_rail.RAIL_ID.Trim()).FirstOrDefault(); if (railTemp == null) { continue; } if (!m_DicSectionGroupRails.ContainsKey(section_id)) { ASECTION ASEC_ObJ = mainForm.BCApp.SCApplication.MapBLL.getSectiontByID(section_id); ASEGMENT ASEG_ObJ = mainForm.BCApp.SCApplication.MapBLL.getSegmentByID(ASEC_ObJ.SEG_NUM); m_DicSectionGroupRails.Add(group_rail.SECTION_ID.Trim(), new GroupRails(group_rail.SECTION_ID, ASEC_ObJ.SEC_DIS, group_rail.DIR , ASEG_ObJ.SEG_NUM, ASEG_ObJ.DIR)); } m_DicSectionGroupRails[section_id].uctlRails.Add(new KeyValuePair <uctlRail, E_RAIL_DIR>(railTemp, group_rail.DIR)); } foreach (GroupRails group in m_DicSectionGroupRails.Values) { group.RefreshDistance(); group.DecisionFirstAndLastPoint(true); } List <ASEGMENT> listSegment = mainForm.BCApp.SCApplication.MapBLL.loadAllSegments(); foreach (ASEGMENT seg in listSegment) { List <GroupRails> segSections = m_DicSectionGroupRails.Values .Where(group => group.Segment_Num.Trim() == seg.SEG_NUM.Trim()).ToList(); m_DicSegmentGroupRails.Add(seg.SEG_NUM.Trim(), segSections); } return(bRet); }
public void registeredControlSectionLeaveEvent(BLL.SectionBLL sectionBLL) { foreach (string section_id in ControlSections) { ASECTION sec_obj = sectionBLL.cache.GetSection(section_id); sec_obj.VehicleLeave += Sec_obj_VehicleLeave; sec_obj.VehicleEntry += Sec_obj_VehicleEntry; } //再多註冊Entry Section的Entry event,這樣可以提早發現有人準備跑進被管制的區域了 foreach (var entry_section_info in EntrySectionInfos) { ASECTION sec_obj = sectionBLL.cache.GetSection(entry_section_info.ReserveSectionID); sec_obj.VehicleEntry += Sec_obj_VehicleEntry; } }
private async void excuteLoadUnloadCommand() { string fromSection = cmb_fromSection.Text; ASECTION asection = scApp.MapBLL.getSectiontByID(fromSection); string hostsource_portid = cmb_fromAddress.Text; string hostdest_portid = cmb_toAddress.Text; string from_adr = string.Empty; string to_adr = string.Empty; E_VH_TYPE vh_type = E_VH_TYPE.None; scApp.PortDefBLL.getAddressID(hostsource_portid, out from_adr, out vh_type); scApp.PortDefBLL.getAddressID(hostdest_portid, out to_adr); string vehicleId = string.Empty; vehicleId = SCUtility.Trim(cmb_Vehicle.Text, true); if (BCFUtility.isEmpty(vehicleId)) { MessageBox.Show("No find idle vehile."); return; } string cst_id = txt_cstID.Text; string box_id = txt_boxID.Text; string lot_id = "lot_id"; if (BCFUtility.isEmpty(box_id)) { MessageBox.Show(" 'BOX ID' must not be empty."); return; } sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null; await Task.Run(() => { scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id, E_CMD_TYPE.LoadUnload, hostsource_portid, hostdest_portid, 0, 0, box_id, lot_id, from_adr, to_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 (bool isSuccess, string reservedVhID, string reservedSecID) askReserveSuccess(SectionBLL sectionBLL, string vhID, string sectionID, string addressID) { RepeatedField <ReserveInfo> reserveInfos = new RepeatedField <ReserveInfo>(); ASECTION current_section = sectionBLL.cache.GetSection(sectionID); DriveDirction driveDirction = SCUtility.isMatche(current_section.FROM_ADR_ID, addressID) ? DriveDirction.DriveDirForward : DriveDirction.DriveDirReverse; ReserveInfo info = new ReserveInfo() { //DriveDirction = DriveDirction.DriveDirForward, DriveDirction = driveDirction, ReserveSectionID = sectionID }; reserveInfos.Add(info); return(IsReserveSuccessNew(vhID, reserveInfos, isAsk: true)); }
public ASEGMENT getSegmentBySectionID(string id) { ASEGMENT segment = null; using (DBConnection_EF con = new DBConnection_EF()) { //ASECTION section = sectionDAO.getByID(con, id); ASECTION section = sectionDAO.getByID(commObjCacheManager, id); if (section != null) { segment = segmentDAO.getByID(con, section.SEG_NUM); } } return(segment); }
public List <ASECTION> loadNextSectionBySectionID(DBConnection_EF con, String section_id) { if (string.IsNullOrWhiteSpace(section_id)) { return(null); } List <ASECTION> nextSections = null; ASECTION sec = null; sec = getByID(con, section_id); if (sec != null) { nextSections = loadByFromAdr(con, sec.TO_ADR_ID); } return(nextSections); }
public bool updateSecDistance(string from_id, string to_id, double distance, out ASECTION section) { try { using (DBConnection_EF con = DBConnection_EF.GetUContext()) { section = sectionDAO.getByFromToAdr(con, from_id, to_id); section.SEC_DIS = distance; section.LAST_TECH_TIME = DateTime.Now; sectionDAO.update(con, section); } return(true); } catch (Exception ex) { logger.Error(ex, "Exception"); section = null; return(false); } }
private void To_adr_of_section_VehicleLeave(object sender, string e) { try { string vh_id = e; ASECTION leave_section = sender as ASECTION; string leave_section_of_to_adr_id = leave_section.TO_ADR_ID; LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(BlockControlService), Device: VehicleService.DEVICE_NAME_OHx, Data: $"Start try force release block by leave section:{leave_section.SEC_ID} of to adr id:{leave_section_of_to_adr_id}", VehicleID: vh_id); forceReleaseBlock(vh_id, leave_section_of_to_adr_id); } catch (Exception ex) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(BlockControlService), Device: VehicleService.DEVICE_NAME_OHx, Data: ex, VehicleID: e); } }
private void From_adr_of_section_VehicleEntry(object sender, string e) { try { string vh_id = e; ASECTION entry_section = sender as ASECTION; string entry_section_of_from_adr_id = entry_section.FROM_ADR_ID; LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(BlockControlService), Device: VehicleService.DEVICE_NAME_OHx, Data: $"Start try force release block by entry section:{entry_section.SEC_ID} of from adr id:{entry_section_of_from_adr_id}", VehicleID: vh_id); forceReleaseBlock(vh_id, entry_section_of_from_adr_id); } catch (Exception ex) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(BlockControlService), Device: VehicleService.DEVICE_NAME_OHx, Data: ex, VehicleID: e); } }
public bool updateSectionData(ASECTION sec, ASECTION_CONTROL_100 sec_100) { try { using (System.Transactions.TransactionScope tx = sc.Common.SCUtility.getTransactionScope()) { using (sc.Data.DBConnection_EF con = sc.Data.DBConnection_EF.GetUContext()) { updateSection(sec); updateSection(sec_100); tx.Complete(); } } } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex, "Exception:"); return(false); } return(true); }
public bool updateSecDistance(string id, double distance) { ASECTION section = null; try { using (DBConnection_EF con = DBConnection_EF.GetUContext()) { section = sectionDAO.getByID(con, id); section.SEC_DIS = distance; //bool isDetached = con.Entry(section).State == EntityState.Modified; //if (isDetached) sectionDAO.update(con, section); } return(true); } catch (Exception ex) { logger.Error(ex, "Exception"); return(false); } }
public bool resetSecTechingTime(string id) { ASECTION section = null; try { using (DBConnection_EF con = DBConnection_EF.GetUContext()) { section = sectionDAO.getByID(con, id); section.LAST_TECH_TIME = null; //bool isDetached = con.Entry(section).State == EntityState.Modified; //if (isDetached) sectionDAO.update(con, section); } return(true); } catch (Exception ex) { logger.Error(ex, "Exception"); return(false); } }
public List <String> loadNextSegmentNumBySegmentNum(DBConnection_EF con, String segment_num) { if (string.IsNullOrWhiteSpace(segment_num)) { return(null); } List <String> nextSegment_Nums = new List <string>(); ASECTION lastsec = null; lastsec = loadBySegmentNum(con, segment_num).LastOrDefault(); if (lastsec != null) { List <ASECTION> nextSections = loadByFromAdr(con, lastsec.TO_ADR_ID); List <ASECTION> branchSections = loadByFromAdr(con, lastsec.FROM_ADR_ID); //1.移除掉自己的Section branchSections.Remove(lastsec); //2.過濾掉並非為該Segment 第1條的Section List <ASECTION> branchSectionsTemp = branchSections.ToList(); foreach (ASECTION sec in branchSectionsTemp) { if (!isFirstSectionInSegment(con, sec)) { branchSections.Remove(sec); } } if (nextSections != null && nextSections.Count > 0) { nextSegment_Nums.AddRange(nextSections.Select(s => s.SEG_NUM).ToList()); } if (branchSections != null && branchSections.Count > 0) { nextSegment_Nums.AddRange(branchSections.Select(s => s.SEG_NUM).ToList()); } } return(nextSegment_Nums); }
private void updateSection(ASECTION sec) { ASECTION secTemp = new ASECTION(); using (sc.Data.DBConnection_EF con = sc.Data.DBConnection_EF.GetUContext()) { secTemp.SEC_ID = sec.SEC_ID; secTemp.SUB_VER = ""; con.ASECTION.Attach(secTemp); secTemp.DIRC_DRIV = sec.DIRC_DRIV; secTemp.DIRC_GUID = sec.DIRC_GUID; secTemp.CDOG_1 = sec.CDOG_1; secTemp.CDOG_2 = sec.CDOG_2; secTemp.CHG_SEG_NUM_1 = sec.CHG_SEG_NUM_1; secTemp.CHG_SEG_NUM_2 = sec.CHG_SEG_NUM_2; secTemp.SEC_DIS = sec.SEC_DIS; secTemp.SEC_SPD = sec.SEC_SPD; secTemp.PRE_BLO_REQ = sec.PRE_BLO_REQ; secTemp.AREA_SECSOR = sec.AREA_SECSOR; //secTemp.PRE_DIV = sec.PRE_DIV; con.Entry(secTemp).Property(p => p.DIRC_DRIV).IsModified = true; con.Entry(secTemp).Property(p => p.DIRC_GUID).IsModified = true; con.Entry(secTemp).Property(p => p.CDOG_1).IsModified = true; con.Entry(secTemp).Property(p => p.CDOG_2).IsModified = true; con.Entry(secTemp).Property(p => p.CHG_SEG_NUM_1).IsModified = true; con.Entry(secTemp).Property(p => p.CHG_SEG_NUM_2).IsModified = true; con.Entry(secTemp).Property(p => p.SEC_DIS).IsModified = true; con.Entry(secTemp).Property(p => p.SEC_SPD).IsModified = true; con.Entry(secTemp).Property(p => p.PRE_BLO_REQ).IsModified = true; con.Entry(secTemp).Property(p => p.AREA_SECSOR).IsModified = true; //con.Entry(secTemp).Property(p => p.PRE_DIV).IsModified = true; SectionDao.update(con, secTemp); con.Entry(secTemp).State = System.Data.Entity.EntityState.Detached; } }
private void excuteMoveCommandAllVh() { //string toAdr = string.Empty; List <AVEHICLE> lstVh = scApp.VehicleBLL.cache.loadVhs(); foreach (AVEHICLE vh in lstVh) { if (SCUtility.isEmpty(vh.CUR_ADR_ID) || SCUtility.isEmpty(vh.CUR_SEC_ID)) { continue; } ASECTION sec = scApp.MapBLL.getSectiontByID(vh.CUR_SEC_ID); string vehicleId = vh.VEHICLE_ID.Trim(); string toAdr = sec.TO_ADR_ID; string[] nextSections = scApp.MapBLL.loadNextSectionIDBySectionID(vh.CUR_SEC_ID); ASECTION nextSection = null; if (nextSections != null && nextSections.Count() > 0) { nextSection = scApp.MapBLL.getSectiontByID(nextSections[0]); } if (BCFUtility.isEmpty(vehicleId)) { MessageBox.Show("No find vehile."); return; } Task.Run(() => scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, string.Empty, E_CMD_TYPE.Move, string.Empty, nextSection.TO_ADR_ID, 0, 0)); SpinWait.SpinUntil(() => false, 1000); } }
private void SectionVehicleLeave(object sender, string vhID) { ASECTION sec = sender as ASECTION; sec.ReleaseSectionReservation(vhID); }