Ejemplo n.º 1
0
        public (bool isSuccess, string reservedVhID, string reservedSecID) IsReserveSuccessNew(string vhID, RepeatedField <ReserveInfo> reserveInfos, bool isAsk = false)
        {
            try
            {
                if (DebugParameter.isForcedPassReserve)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ReserveBLL), Device: "AGV",
                                  Data: "test flag: Force pass reserve is open, will driect reply to vh pass",
                                  VehicleID: vhID);
                    return(true, string.Empty, string.Empty);
                }

                //強制拒絕Reserve的要求
                if (DebugParameter.isForcedRejectReserve)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ReserveBLL), Device: "AGV",
                                  Data: "test flag: Force reject reserve is open, will driect reply to vh can't pass",
                                  VehicleID: vhID);
                    return(false, string.Empty, string.Empty);
                }

                if (reserveInfos == null || reserveInfos.Count == 0)
                {
                    return(false, string.Empty, string.Empty);
                }
                string reserve_section_id = reserveInfos[0].ReserveSectionID;

                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(ReserveBLL), Device: "AGV",
                              Data: $"vh:{vhID} Try add reserve section:{reserve_section_id}...",
                              VehicleID: vhID);
                Mirle.Hlts.Utils.HltDirection hltDirection = HltDirection.None;
                var result = TryAddReservedSection(vhID, reserve_section_id,
                                                   sensorDir: hltDirection,
                                                   forkDir: hltDirection,
                                                   isAsk: isAsk);

                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(ReserveBLL), Device: "AGV",
                              Data: $"vh:{vhID} Try add reserve section:{reserve_section_id},result:{result.ToString()}",
                              VehicleID: vhID);
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(ReserveBLL), Device: "AGV",
                              Data: $"current reserve section:{GetCurrentReserveSectionString()}",
                              VehicleID: vhID);
                return(result.OK, result.VehicleID, reserve_section_id);
            }
            catch (Exception ex)
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(ReserveBLL), Device: "AGV",
                              Data: ex,
                              Details: $"process function:{nameof(IsReserveSuccessNew)} Exception");
                return(false, string.Empty, string.Empty);
            }
        }
 public override HltResult TryAddVehicleOrUpdate(string vhID, string adrID, float angle = 0, Mirle.Hlts.Utils.HltDirection direction = HltDirection.NESW)
 {
     return(new HltResult(true, "By Pass Reserve"));
 }
        public virtual HltResult TryAddVehicleOrUpdate(string vhID, string adrID, float angle = 0, Mirle.Hlts.Utils.HltDirection direction = HltDirection.NESW)
        {
            var adr_obj = mapAPI.GetAddressObjectByID(adrID);
            var hlt_vh  = new HltVehicle(vhID, adr_obj.X, adr_obj.Y, angle, sensorDirection: direction);
            //HltResult result = mapAPI.TryAddVehicleOrUpdate(vhID, adr_obj.X, adr_obj.Y, 0, vehicleSensorDirection: Mirle.Hlts.Utils.HltDirection.NESW);
            HltResult result = mapAPI.TryAddOrUpdateVehicle(hlt_vh);

            onReserveStatusChange();

            return(result);
        }
Ejemplo n.º 4
0
        public (bool isSuccess, string reservedVhID, string reservedFailSection, RepeatedField <ReserveInfo> reserveSuccessInfos) IsMultiReserveSuccess
            (SCApplication scApp, string vhID, RepeatedField <ReserveInfo> reserveInfos, bool isAsk = false)
        {
            try
            {
                if (SCUtility.isMatche(vhID, "AGV06") || SCUtility.isMatche(vhID, "AGV11"))
                {
                    if (DebugParameter.isForcedPassReserve_AGV0609)
                    {
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ReserveBLL), Device: "AGV",
                                      Data: "test flag(AGV06,11): Force pass reserve is open, will driect reply to vh pass",
                                      VehicleID: vhID);
                        return(true, string.Empty, string.Empty, reserveInfos);
                    }
                }
                else
                {
                    if (DebugParameter.isForcedPassReserve)
                    {
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ReserveBLL), Device: "AGV",
                                      Data: "test flag: Force pass reserve is open, will driect reply to vh pass",
                                      VehicleID: vhID);
                        return(true, string.Empty, string.Empty, reserveInfos);
                    }
                }

                //強制拒絕Reserve的要求
                if (DebugParameter.isForcedRejectReserve)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ReserveBLL), Device: "AGV",
                                  Data: "test flag: Force reject reserve is open, will driect reply to vh can't pass",
                                  VehicleID: vhID);
                    return(false, string.Empty, string.Empty, null);
                }

                if (reserveInfos == null || reserveInfos.Count == 0)
                {
                    return(false, string.Empty, string.Empty, null);
                }

                var    reserve_success_section    = new RepeatedField <ReserveInfo>();
                bool   has_success                = false;
                string final_blocked_vh_id        = string.Empty;
                string reserve_fail_section       = "";
                Mirle.Hlts.Utils.HltResult result = default(Mirle.Hlts.Utils.HltResult);
                foreach (var reserve_info in reserveInfos)
                {
                    string reserve_section_id = reserve_info.ReserveSectionID;

                    var reserve_enhance_check_result = IsReserveBlockSuccess(scApp, vhID, reserve_section_id);
                    //var reserve_enhance_check_result = IsReserveBlockSuccessNew(vh, reserve_section_id, drive_dirction);
                    if (!reserve_enhance_check_result.isSuccess)
                    {
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(ReserveBLL), Device: "AGV",
                                      Data: $"vh:{vhID} Try add reserve enhance section:{reserve_section_id} fail. reserved vh id:{reserve_enhance_check_result.reservedVhID}",
                                      VehicleID: vhID);
                        has_success         |= false;
                        final_blocked_vh_id  = reserve_enhance_check_result.reservedVhID;
                        reserve_fail_section = reserve_section_id;

                        break;
                    }

                    Mirle.Hlts.Utils.HltDirection hltDirection = Mirle.Hlts.Utils.HltDirection.None;
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(ReserveBLL), Device: "AGV",
                                  Data: $"vh:{vhID} Try add(Only ask) reserve section:{reserve_section_id} ,hlt dir:{hltDirection}...",
                                  VehicleID: vhID);
                    result = TryAddReservedSection(vhID, reserve_section_id,
                                                   sensorDir: hltDirection,
                                                   isAsk: isAsk);
                    if (result.OK)
                    {
                        reserve_success_section.Add(reserve_info);
                        has_success |= true;
                    }
                    else
                    {
                        has_success         |= false;
                        final_blocked_vh_id  = result.VehicleID;
                        reserve_fail_section = reserve_section_id;
                        break;
                    }
                }

                return(has_success, final_blocked_vh_id, reserve_fail_section, reserve_success_section);
            }
            catch (Exception ex)
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(ReserveBLL), Device: "AGV",
                              Data: ex,
                              Details: $"process function:{nameof(IsMultiReserveSuccess)} Exception");
                return(false, string.Empty, string.Empty, null);
            }
        }