Beispiel #1
0
        private void RoadControl(string vh_id, string cur_adr_id, bool isEnable)
        {
            ICpuplerType couplerAddress = addressesBLL.cache.GetAddress(cur_adr_id) as ICpuplerType;

            if (couplerAddress == null)
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                              Data: $"CouplerAddress not exist.current adr id {cur_adr_id}",
                              VehicleID: vh_id);
                return;
            }
            LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                          Data: $"Excute cpupler address:{cur_adr_id} of road contol," +
                          $"segment ids:{string.Join(",", couplerAddress.TrafficControlSegment)},is ban:{isEnable} ",
                          VehicleID: vh_id);

            foreach (string segment in couplerAddress.TrafficControlSegment)
            {
                if (isEnable)
                {
                    vehicleService.doEnableDisableSegment(segment, E_PORT_STATUS.InService);
                }
                else
                {
                    vehicleService.doEnableDisableSegment(segment, E_PORT_STATUS.OutOfService);
                }
            }
        }
        private (bool isSuccess, string msg) askVhToCharging(AVEHICLE vh)
        {
            string   vh_current_address = vh.CUR_ADR_ID;
            AADDRESS current_adr        = addressesBLL.cache.GetAddress(vh.CUR_ADR_ID);

            if (current_adr != null &&
                current_adr is CouplerAddress && (current_adr as CouplerAddress).IsWork(unitBLL))
            {
                ICpuplerType cpupler = (current_adr as CouplerAddress);
                string       meg     = $"ask vh:{vh.VEHICLE_ID} to charging. but it is already in charger:{cpupler.ChargerID} ,cpupler num:{cpupler.CouplerNum}";
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                              Data: meg,
                              VehicleID: vh.VEHICLE_ID);
                return(false, meg);
            }
            bool   is_need_to_long_charge = vh.IsNeedToLongCharge();
            string best_coupler_adr       = findBestCoupler(vh_current_address, is_need_to_long_charge);

            LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                          Data: $"ask vh:{vh.VEHICLE_ID} to charging. coupler adr:{best_coupler_adr} ",
                          VehicleID: vh.VEHICLE_ID);
            if (!SCUtility.isEmpty(best_coupler_adr))
            {
                bool is_success = vehicleService.Command.MoveToCharge(vh.VEHICLE_ID, best_coupler_adr);
                return(is_success, "");
            }
            else
            {
                lineService.ProcessAlarmReport(vh, AlarmBLL.VEHICLE_CAN_NOT_FIND_THE_COUPLER_TO_CHARGING, ErrorStatus.ErrSet, $"vehicle:{vh.VEHICLE_ID} can't find coupler to charging");
                return(false, $"vehicle:{vh.VEHICLE_ID} can't find coupler to charging");
            }
        }