Exemplo n.º 1
0
        public ReserveCheckResult TryAddReservedSectionNew(string vhID, string sectionID, HltDirection sensorDir = HltDirection.None, HltDirection forkDir = HltDirection.None, bool isAsk = false)
        {
            //int sec_id = 0;
            //int.TryParse(sectionID, out sec_id);
            string sec_id = SCUtility.Trim(sectionID);

            ReserveCheckResult result = mapAPI.TryAddReservedSection(vhID, sec_id, sensorDir, forkDir, isAsk).ToReserveCheckResult();

            onReserveStatusChange();

            return(result);
        }
Exemplo n.º 2
0
        public override (bool isSuccess, string reservedVhID, string reservedFailSection, RepeatedField <ReserveInfo> reserveSuccessInfos) IsMultiReserveSuccess
            (SCApplication scApp, 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, 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    = "";
                ReserveCheckResult result = default(ReserveCheckResult);
                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.NS;
                    //Mirle.Hlts.Utils.HltDirection hltDirection = decideReserveDirection(vh, reserve_section_id);
                    //AVEHICLE vh = scApp.VehicleBLL.cache.getVehicle(vhID);
                    //Mirle.Hlts.Utils.HltDirection hltDirection = scApp.ReserveBLL.DecideReserveDirection(scApp.SectionBLL, vh, reserve_section_id);
                    //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 = TryAddReservedSectionNew(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);
            }
        }