public int CouplerCompareForNormalCharge(CouplerAddress coupler1, CouplerAddress coupler2) { int result; if (coupler1.Priority == coupler2.Priority && coupler1.DistanceWithTargetAdr == coupler2.DistanceWithTargetAdr) { result = 0; } else { if (coupler1.Priority > coupler2.Priority) { result = 1; } else if (coupler1.Priority < coupler2.Priority) { result = -1; } else if (coupler1.Priority == coupler2.Priority && coupler1.DistanceWithTargetAdr > coupler2.DistanceWithTargetAdr) { result = 1; } else { result = -1; } } return(result); }
//public bool IsCouplerWork(CouplerAddress couplerAddress, UnitBLL unitBLL) //{ // if (SCApplication.getInstance().BC_ID == "NORTH_INNOLUX_Test_Site") return true;//暫時都return ok // AUNIT charger = unitBLL.OperateCatch.getUnit(couplerAddress.ChargerID); // if (charger != null) // { // switch (couplerAddress.CouplerNum) // { // case CouplerNum.NumberOne: // return charger.coupler1Status == SCAppConstants.CouplerStatus.Enable || // charger.coupler1Status == SCAppConstants.CouplerStatus.Charging; // case CouplerNum.NumberTwo: // //return charger.coupler1Status == SCAppConstants.CouplerStatus.Enable || // // charger.coupler1Status == SCAppConstants.CouplerStatus.Charging; // return charger.coupler2Status == SCAppConstants.CouplerStatus.Enable || // charger.coupler2Status == SCAppConstants.CouplerStatus.Charging; // case CouplerNum.NumberThree: // //return charger.coupler1Status == SCAppConstants.CouplerStatus.Enable || // // charger.coupler1Status == SCAppConstants.CouplerStatus.Charging; // return charger.coupler3Status == SCAppConstants.CouplerStatus.Enable || // charger.coupler3Status == SCAppConstants.CouplerStatus.Charging; // } // } // return false; //} public bool IsCouplerWork(CouplerAddress couplerAddress, UnitBLL unitBLL) { string bc_id = SCApplication.getInstance().BC_ID; if (bc_id == "NORTH_INNOLUX_Test_Site") { return(true); //暫時都return ok } AUNIT charger = unitBLL.OperateCatch.getUnit(couplerAddress.ChargerID); if (charger != null) { switch (couplerAddress.CouplerNum) { case CouplerNum.NumberOne: return(charger.GetCoupler1Status(bc_id) == SCAppConstants.CouplerStatus.Enable || charger.GetCoupler1Status(bc_id) == SCAppConstants.CouplerStatus.Charging); case CouplerNum.NumberTwo: return(charger.GetCoupler2Status(bc_id) == SCAppConstants.CouplerStatus.Enable || charger.GetCoupler2Status(bc_id) == SCAppConstants.CouplerStatus.Charging); case CouplerNum.NumberThree: return(charger.GetCoupler3Status(bc_id) == SCAppConstants.CouplerStatus.Enable || charger.GetCoupler3Status(bc_id) == SCAppConstants.CouplerStatus.Charging); } } return(false); }
public CouplerAddress GetCouplerAddress(string chargerID, CouplerNum coupler_num) { List <CouplerAddress> CouplerAddresses = CommObjCacheManager.getCouplerAddresses(); CouplerAddress CouplerAddress = CouplerAddresses.Where(coupler => SCUtility.isMatche(coupler.ChargerID, chargerID) && coupler.CouplerNum == coupler_num).FirstOrDefault(); return(CouplerAddress); }
public void start(SCApplication _app) { scApp = _app; Segments = scApp.MapBLL.loadAllSegments(); Sections = scApp.MapBLL.loadAllSection(); Addresses = scApp.MapBLL.loadAllAddress(); ReserveEnhanceInfosSections = scApp.ReserveEnhanceInfoDao.getReserveEnhanceInfoSections(scApp); TrafficControlInfos = scApp.TrafficControlInfoDao.getTrafficControlInfos(scApp); for (int i = 0; i < Addresses.Count; i++) { AADDRESS address = Addresses[i]; address.initialAddressType(); //address.initialSegmentID(scApp.SectionBLL); bool isReserveEnhanceAddress = GetReserveEnhanceInfo(address.ADR_ID) != null; if (isReserveEnhanceAddress && address.IsCoupler) { AADDRESS couplerAndReserveEnhanceAddress = new CouplerAndReserveEnhanceAddress(); BCFUtility.setValueToPropety(ref address, ref couplerAndReserveEnhanceAddress); setReserveEnhanceAddressInfo(couplerAndReserveEnhanceAddress); setCouplerTypeAddressInfo(couplerAndReserveEnhanceAddress); Addresses[i] = couplerAndReserveEnhanceAddress; } else if (address.IsCoupler) { AADDRESS couplerAddress = new CouplerAddress(); BCFUtility.setValueToPropety(ref address, ref couplerAddress); setCouplerTypeAddressInfo(couplerAddress); Addresses[i] = couplerAddress; } else if (isReserveEnhanceAddress) { AADDRESS couplerAndReserveEnhanceAddress = new ReserveEnhanceAddress(); BCFUtility.setValueToPropety(ref address, ref couplerAndReserveEnhanceAddress); setReserveEnhanceAddressInfo(couplerAndReserveEnhanceAddress); Addresses[i] = couplerAndReserveEnhanceAddress; } } foreach (ASECTION section in Sections) { section.setOnSectionAddress(scApp.AddressesBLL); } foreach (ASEGMENT segment in Segments) { segment.SetSectionList(scApp.SectionBLL); } CommonInfo = new CommonInfo(); initialCommunationInfo(); }
public bool IsCouplerWork(CouplerAddress couplerAddress, UnitBLL unitBLL) { AUNIT charger = unitBLL.OperateCatch.getUnit(couplerAddress.ChargerID); if (charger != null) { switch (couplerAddress.CouplerNum) { case CouplerNum.NumberOne: return(charger.Coupler1Status == SCAppConstants.CouplerStatus.Auto || charger.Coupler1Status == SCAppConstants.CouplerStatus.Charging); case CouplerNum.NumberTwo: return(charger.Coupler1Status == SCAppConstants.CouplerStatus.Auto || charger.Coupler1Status == SCAppConstants.CouplerStatus.Charging); case CouplerNum.NumberThree: return(charger.Coupler1Status == SCAppConstants.CouplerStatus.Auto || charger.Coupler1Status == SCAppConstants.CouplerStatus.Charging); } } return(false); }
private bool couplerSafetyHandler(SCAppConstants.CouplerHPSafety safety, CouplerAddress coupler_address) { bool result = false; if (coupler_address != null) { if (safety == SCAppConstants.CouplerHPSafety.Safety) { scApp.ReserveBLL.RemoveVehicle(unit.UNIT_ID + coupler_address.CouplerNum + "_v_car"); foreach (string seg_id in coupler_address.TrafficControlSegment) { ASEGMENT selectSeg = scApp.SegmentBLL.cache.GetSegment(seg_id); if (selectSeg.STATUS == E_SEG_STATUS.Closed) { var ban_result = scApp.VehicleService.doEnableDisableSegment(selectSeg.SEG_ID.Trim(), E_PORT_STATUS.InService); if (ban_result.isSuccess) { selectSeg.DISABLE_TIME = ban_result.segment.DISABLE_TIME; selectSeg.STATUS = ban_result.segment.STATUS; } } } } else if (coupler_address.hasVh(scApp.VehicleBLL)) { //do nothing } else { string msg = $"The coupler position Address{coupler_address.ADR_ID} is not safe ,begin coupler safe handle process."; LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(SubChargerValueDefMapAction), Device: Service.VehicleService.DEVICE_NAME_AGV, Data: msg); bcf.App.BCFApplication.onErrorMsg(msg); foreach (string seg_id in coupler_address.TrafficControlSegment) { ASEGMENT selectSeg = scApp.SegmentBLL.cache.GetSegment(seg_id); if (selectSeg.STATUS == E_SEG_STATUS.Active && !selectSeg.PRE_DISABLE_FLAG) { var ban_result = scApp.VehicleService.doEnableDisableSegment(selectSeg.SEG_ID.Trim(), E_PORT_STATUS.OutOfService); if (ban_result.isSuccess) { selectSeg.DISABLE_TIME = ban_result.segment.DISABLE_TIME; selectSeg.STATUS = ban_result.segment.STATUS; } } } var update_result = scApp.ReserveBLL.TryAddVehicleOrUpdate(unit.UNIT_ID + coupler_address.CouplerNum + "_v_car", coupler_address.ADR_ID, 90, Mirle.Hlts.Utils.HltDirection.NS); if (!update_result.OK) { string message = $"The coupler position Address{coupler_address.ADR_ID} is not safe, vh:{update_result.VehicleID} need to stop"; LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(SubChargerValueDefMapAction), Device: Service.VehicleService.DEVICE_NAME_AGV, Data: message, Details: update_result.Description, VehicleID: update_result.VehicleID); AVEHICLE will_bumped_vh = scApp.VehicleBLL.cache.getVehicle(update_result.VehicleID); //如果發生碰撞或踩入別人預約的不是虛擬車的話,則就要對兩台車下達EMS if (!update_result.VehicleID.StartsWith(Service.VehicleService.VehicleVirtualSymbol)) { //string cmd_id = will_bumped_vh.OHTC_CMD; //if (!string.IsNullOrWhiteSpace(cmd_id)) //{ // ACMD_OHTC cmd = scApp.CMDBLL.GetCMD_OHTCByID(cmd_id); // string cmdSourceAdr = cmd.SOURCE; // if (!string.IsNullOrWhiteSpace(cmdSourceAdr)) // { // if(SCUtility.isMatche( cmd_id, coupler_address.)) // } //} bcf.App.BCFApplication.onErrorMsg(message); LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(SubChargerValueDefMapAction), Device: Service.VehicleService.DEVICE_NAME_AGV, Data: $"The vehicles bumped coupler will happend. send pause to {update_result.VehicleID}", VehicleID: update_result.VehicleID); scApp.VehicleService.doAbortCommand(will_bumped_vh, will_bumped_vh.OHTC_CMD, ProtocolFormat.OHTMessage.CMDCancelType.CmdEms); //doAbortCommand(assign_vh, ohtc_cmd_id, actType); ; //scApp.VehicleService.PauseRequest(will_bumped_vh.VEHICLE_ID, ProtocolFormat.OHTMessage.PauseEvent.Pause, SCAppConstants.OHxCPauseType.Safty); } } result = true; } } return(result); }
public virtual void ChargerStatusReport(object sender, ValueChangedEventArgs args) { var function = scApp.getFunBaseObj <ChargeToAGVCStatusReport>(unit.UNIT_ID) as ChargeToAGVCStatusReport; try { //1.建立各個Function物件 function.Read(bcfApp, unit.EqptObjectCate, unit.UNIT_ID); //2.read log LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(SubChargerValueDefMapAction), Device: DEVICE_NAME_CHARGER, XID: unit.UNIT_ID, Data: function.ToString()); unit.chargerReserve = function.Reserve; unit.chargerConstantVoltageOutput = function.ConstantVoltageOutput; unit.chargerConstantCurrentOutput = function.ConstantCurrentOutput; unit.chargerHighInputVoltageProtection = function.HighInputVoltageProtection; unit.chargerLowInputVoltageProtection = function.LowInputVoltageProtection; unit.chargerHighOutputVoltageProtection = function.HighOutputVoltageProtection; unit.chargerHighOutputCurrentProtection = function.HighOutputCurrentProtection; unit.chargerOverheatProtection = function.OverheatProtection; unit.chargerRS485Status = function.RS485Status.ToString(); unit.coupler1Status_NORTH_INNOLUX = function.Coupler1Status; unit.coupler2Status_NORTH_INNOLUX = function.Coupler2Status; unit.coupler3Status_NORTH_INNOLUX = function.Coupler3Status; unit.coupler1HPSafety = function.Coupler1Position; unit.coupler2HPSafety = function.Coupler2Position; unit.coupler3HPSafety = function.Coupler3Position; unit.ChargerStatusIndex = function.Index; if (function.Coupler1Position == SCAppConstants.CouplerHPSafety.NonSafety && !unit.coupler1SegmentDisableByAGVC) { CouplerAddress coupler_address = scApp.AddressesBLL.cache.GetCouplerAddress(unit.UNIT_ID, CouplerNum.NumberOne); unit.coupler1SegmentDisableByAGVC = couplerSafetyHandler(SCAppConstants.CouplerHPSafety.NonSafety, coupler_address); } else if (function.Coupler1Position == SCAppConstants.CouplerHPSafety.Safety && unit.coupler1SegmentDisableByAGVC) { CouplerAddress coupler_address = scApp.AddressesBLL.cache.GetCouplerAddress(unit.UNIT_ID, CouplerNum.NumberOne); unit.coupler1SegmentDisableByAGVC = couplerSafetyHandler(SCAppConstants.CouplerHPSafety.Safety, coupler_address); } if (function.Coupler2Position == SCAppConstants.CouplerHPSafety.NonSafety && !unit.coupler2SegmentDisableByAGVC) { CouplerAddress coupler_address = scApp.AddressesBLL.cache.GetCouplerAddress(unit.UNIT_ID, CouplerNum.NumberTwo); unit.coupler2SegmentDisableByAGVC = couplerSafetyHandler(SCAppConstants.CouplerHPSafety.NonSafety, coupler_address); } else if (function.Coupler2Position == SCAppConstants.CouplerHPSafety.Safety && unit.coupler2SegmentDisableByAGVC) { CouplerAddress coupler_address = scApp.AddressesBLL.cache.GetCouplerAddress(unit.UNIT_ID, CouplerNum.NumberTwo); unit.coupler2SegmentDisableByAGVC = couplerSafetyHandler(SCAppConstants.CouplerHPSafety.Safety, coupler_address); } if (function.Coupler3Position == SCAppConstants.CouplerHPSafety.NonSafety && !unit.coupler3SegmentDisableByAGVC) { CouplerAddress coupler_address = scApp.AddressesBLL.cache.GetCouplerAddress(unit.UNIT_ID, CouplerNum.NumberThree); unit.coupler3SegmentDisableByAGVC = couplerSafetyHandler(SCAppConstants.CouplerHPSafety.NonSafety, coupler_address); } else if (function.Coupler3Position == SCAppConstants.CouplerHPSafety.Safety && unit.coupler3SegmentDisableByAGVC) { CouplerAddress coupler_address = scApp.AddressesBLL.cache.GetCouplerAddress(unit.UNIT_ID, CouplerNum.NumberThree); unit.coupler3SegmentDisableByAGVC = couplerSafetyHandler(SCAppConstants.CouplerHPSafety.Safety, coupler_address); } //3.logical (include db save) //eqpt.Inline_Mode = function.InlineMode; } catch (Exception ex) { logger.Error(ex, "Exception"); } finally { scApp.putFunBaseObj <ChargeToAGVCStatusReport>(function); } }