Example #1
0
 public void setDistanceWithTargetAdr(GuideBLL guideBLL, string targetAdr)
 {
     if (!guideBLL.IsRoadWalkable(this.ADR_ID, targetAdr))
     {
         DistanceWithTargetAdr = int.MaxValue;
     }
     else
     {
         DistanceWithTargetAdr = guideBLL.getGuideInfo(this.ADR_ID, targetAdr).totalCost;
     }
 }
Example #2
0
        private string findBestCoupler(string vh_current_address, bool isNeedToLongCharge)
        {
            string best_coupler_adr = string.Empty;
            //List<CouplerAddress> coupler_addresses = addressesBLL.cache.GetCouplerAddresses().ToList();
            List <CouplerAddress> coupler_addresses = addressesBLL.cache.GetEnableCouplerAddresses(unitBLL).ToList();

            //1.先計算過一次各個Address與Target Adr的距離後,再進行權重與距離的排序
            try
            {
                coupler_addresses.ForEach(coupler_address => coupler_address.setDistanceWithTargetAdr(guideBLL, vh_current_address));
                //coupler_addresses.Sort();
                if (isNeedToLongCharge)
                {
                    coupler_addresses.Sort(CouplerCompareForLongCharge);
                }
                else
                {
                    coupler_addresses.Sort(CouplerCompareForNormalCharge);
                }
            }
            catch { }
            List <KeyValuePair <string, int> > all_coupler_adr_and_distance = new List <KeyValuePair <string, int> >();

            foreach (CouplerAddress adr in coupler_addresses)
            {
                string coupler_adr = adr.ADR_ID;
                //1.確定路段是可以通的
                if (!guideBLL.IsRoadWalkable(vh_current_address, coupler_adr))
                {
                    continue;
                }
                //2.確認沒有車子在上面
                //if (!adr.hasVh(vehicleBLL) &&
                if (!adr.hasChargingVh(vehicleBLL) &&
                    !adr.hasVhGoing(vehicleBLL))
                {
                    best_coupler_adr = adr.ADR_ID;
                    break;
                }
            }
            return(best_coupler_adr);
        }
        private void Charger_CouplerHPSafetyChaged(object sender, SCAppConstants.CouplerHPSafety e)
        {
            try
            {
                if (DebugParameter.isPassCouplerHPSafetySignal)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"pass coupler hp safey signal,flag:{DebugParameter.isPassCouplerHPSafetySignal}");
                    return;
                }
                AUNIT charger = sender as AUNIT;
                if (charger == null)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"charger is null");
                    return;
                }
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                              Data: $"Coupler hp safyte has changed,charger id:{charger.UNIT_ID} hp safety:{e}");
                var couplers = addressesBLL.cache.LoadCouplerAddresses(charger.UNIT_ID);
                var vhs      = vehicleBLL.cache.loadAllVh();
                switch (e)
                {
                case SCAppConstants.CouplerHPSafety.NonSafety:
                    lineService.ProcessAlarmReport(charger.UNIT_ID, AlarmBLL.AGVC_CHARGER_HP_NOT_SAFETY, ErrorStatus.ErrSet, $"Coupler position not safety.");
                    break;

                case SCAppConstants.CouplerHPSafety.Safyte:
                    lineService.ProcessAlarmReport(charger.UNIT_ID, AlarmBLL.AGVC_CHARGER_HP_NOT_SAFETY, ErrorStatus.ErrReset, $"Coupler position not safety.");
                    break;
                }
                foreach (var coupler in couplers)
                {
                    string coupler_adr_id = coupler.ADR_ID;
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"Coupler hp safyte has changed,coupler adr id:{coupler_adr_id}, start check has vh can pass...");
                    foreach (var vh in vhs)
                    {
                        if (vh.isTcpIpConnect &&
                            (vh.MODE_STATUS == VHModeStatus.AutoRemote ||
                             vh.MODE_STATUS == VHModeStatus.AutoCharging ||
                             vh.MODE_STATUS == VHModeStatus.AutoCharging)
                            )
                        {
                            string vh_cur_adr_id = vh.CUR_ADR_ID;
                            bool   is_walkable   = guideBLL.IsRoadWalkable(coupler_adr_id, vh_cur_adr_id);
                            if (is_walkable)
                            {
                                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                              Data: $"Coupler hp safyte has changed,coupler adr id:{coupler_adr_id} vh current adr:{vh_cur_adr_id}, is walkable start pause/continue action");
                                string     vh_id      = vh.VEHICLE_ID;
                                PauseType  pauseType  = PauseType.Normal;
                                PauseEvent pauseEvent = PauseEvent.Pause;
                                if (e == SCAppConstants.CouplerHPSafety.Safyte)
                                {
                                    pauseEvent = PauseEvent.Continue;
                                }
                                else
                                {
                                    pauseEvent = PauseEvent.Pause;
                                }
                                //Task.Run(() =>
                                //{
                                //    try
                                //    {
                                //        vehicleService.Send.Pause(vh_id, pauseEvent, pauseType);
                                //    }
                                //    catch (Exception ex)
                                //    {
                                //        logger.Error(ex, "Exception:");
                                //    }
                                //});
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception:");
            }
        }