Пример #1
0
        public string TragetSection(BLL.SectionBLL sectionBLL)
        {
            var sections = sectionBLL.cache.GetSectionsByAddress(DESTINATION);

            if (sections == null || sections.Count == 0)
            {
                return("");
            }
            return(sc.Common.SCUtility.Trim(sections.First().SEC_ID, true));
        }
Пример #2
0
        public List <string> getBorderPassAdress(BLL.SectionBLL sectionBLL)
        {
            List <string> border_pass_addrss = new List <string>();

            //如果Section是在同一Zone的話代表就是邊界的入口了
            foreach (string border_section_id in BorderSections)
            {
                var section             = sectionBLL.cache.GetSection(border_section_id);
                var connection_sections = sectionBLL.cache.GetSectionsByAddress(section.REAL_FROM_ADR_ID);
                if (connection_sections.
                    Where(sec => !sc.Common.SCUtility.isMatche(sec.ZONE_ID, this.ZONE_ID)).Count() == 0)
                {
                    border_pass_addrss.Add(section.REAL_FROM_ADR_ID);
                }
                else
                {
                    border_pass_addrss.Add(section.REAL_TO_ADR_ID);
                }
            }
            return(border_pass_addrss);
        }
        public virtual HltDirection DecideReserveDirection(SectionBLL sectionBLL, AVEHICLE reserveVh, string reserveSectionID)
        {
            //先取得目前vh所在的current adr,如果這次要求的Reserve Sec是該Current address連接的其中一點時
            //就不用增加Secsor預約的範圍,預防發生車子預約不到本身路段的問題
            string cur_adr             = reserveVh.CUR_ADR_ID;
            var    related_sections_id = sectionBLL.cache.GetSectionsByAddress(cur_adr).Select(sec => sec.SEC_ID.Trim()).ToList();

            if (related_sections_id.Contains(reserveSectionID))
            {
                return(Mirle.Hlts.Utils.HltDirection.None);
            }
            else
            {
                //在R2000的路段上,預約方向要帶入
                if (IsR2000Section(reserveSectionID))
                {
                    return(Mirle.Hlts.Utils.HltDirection.NS);
                }
                else
                {
                    return(Mirle.Hlts.Utils.HltDirection.NESW);
                }
            }
        }
Пример #4
0
 public virtual HltDirection DecideReserveDirection(SectionBLL sectionBLL, AVEHICLE reserveVh, string reserveSectionID)
 {
     //先取得目前vh所在的current adr,如果這次要求的Reserve Sec是該Current address連接的其中一點時
     //就不用增加Secsor預約的範圍,預防發生車子預約不到本身路段的問題
     return(HltDirection.Forward);
     //string cur_adr = reserveVh.CUR_ADR_ID;
     //var related_sections_id = sectionBLL.cache.GetSectionsByAddress(cur_adr).Select(sec => sec.SEC_ID.Trim()).ToList();
     //if (related_sections_id.Contains(reserveSectionID))
     //{
     //    return HltDirection.None;
     //}
     //else
     //{
     //    //在R2000的路段上,預約方向要帶入
     //    if (IsR2000Section(reserveSectionID))
     //    {
     //        return HltDirection.NorthSouth;
     //    }
     //    else
     //    {
     //        return HltDirection.NESW;
     //    }
     //}
 }
 public Redis(RedisCacheManager _redisCacheManager, SectionBLL _sectionBLL, SCApplication _app)
 {
     scApp             = _app;
     redisCacheManager = _redisCacheManager;
     sectionBLL        = _sectionBLL;
 }
 public override HltDirection DecideReserveDirection(SectionBLL sectionBLL, AVEHICLE reserveVh, string reserveSectionID)
 {
     return(HltDirection.None);
 }
Пример #7
0
 public Redis(RedisCacheManager _redisCacheManager, SectionBLL _sectionBLL)
 {
     redisCacheManager = _redisCacheManager;
     sectionBLL        = _sectionBLL;
 }
Пример #8
0
 public string getCurrentSegment(BLL.SectionBLL sectionBLL)
 {
     return(sectionBLL.cache.GetSection(CUR_SEC_ID)?.SEG_NUM);
 }
Пример #9
0
        public (bool isSuccess, string reservedVhID, string reservedSecID) askReserveSuccess(SectionBLL sectionBLL, string vhID, string sectionID, string addressID)
        {
            RepeatedField <ReserveInfo> reserveInfos = new RepeatedField <ReserveInfo>();
            ASECTION      current_section            = sectionBLL.cache.GetSection(sectionID);
            DriveDirction driveDirction = SCUtility.isMatche(current_section.FROM_ADR_ID, addressID) ?
                                          DriveDirction.DriveDirForward : DriveDirction.DriveDirReverse;
            ReserveInfo info = new ReserveInfo()
            {
                //DriveDirction = DriveDirction.DriveDirForward,
                DriveDirction    = driveDirction,
                ReserveSectionID = sectionID
            };

            reserveInfos.Add(info);
            return(IsReserveSuccessNew(vhID, reserveInfos, isAsk: true));
        }
        public void SetSectionList(BLL.SectionBLL sectionBLL)
        {
            var sections_on_segment = sectionBLL.cache.GetSectionBySegmentID(SEG_ID);

            Sections = getSectionByOrder(sections_on_segment);
        }
Пример #11
0
        public void SetSectionList(BLL.SectionBLL sectionBLL)
        {
            var sections_on_segment = sectionBLL.cache.loadSectionsBySegmentID(SEG_NUM);

            Sections = sections_on_segment;
        }
Пример #12
0
        private void RefreshVehicleLocalByRelativePosition(AVEHICLE vh, BLL.SectionBLL sectionBLL)
        {
            ASECTION current_section   = sectionBLL.cache.GetSection(vh.CUR_SEC_ID);
            int      current_sec_index = Sections.IndexOf(current_section);

            if (current_sec_index == -1)
            {
                return;
            }
            if (Vehicles.Count > 0)
            {
                AVEHICLE next_vh = null;
                for (int i = current_sec_index; i < Sections.Count; i++)
                {
                    string   next_sec_id = Sections[i].SEC_ID;
                    AVEHICLE vh_temp     = Vehicles.Where(v => Common.SCUtility.isMatche(v.CUR_SEC_ID, next_sec_id)).
                                           FirstOrDefault();
                    if (vh_temp != null)
                    {
                        if (i == current_sec_index)
                        {
                            if (vh_temp.ACC_SEC_DIST > vh.ACC_SEC_DIST)
                            {
                                next_vh = vh_temp;
                                break;
                            }
                        }
                        else
                        {
                            next_vh = vh_temp;
                            break;
                        }
                    }
                }
                if (next_vh == null)
                {
                    Vehicles.AddFirst(vh);
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                  Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                                  VehicleID: vh.VEHICLE_ID,
                                  CarrierID: vh.CST_ID);
                }
                else
                {
                    var next_vh_node = Vehicles.Find(next_vh);
                    Vehicles.AddAfter(next_vh_node, vh);

                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                  Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,after {next_vh.VEHICLE_ID}",
                                  VehicleID: vh.VEHICLE_ID,
                                  CarrierID: vh.CST_ID);
                }
            }
            else
            {
                Vehicles.AddLast(vh);
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                              Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                              VehicleID: vh.VEHICLE_ID,
                              CarrierID: vh.CST_ID);
            }
        }
Пример #13
0
        //public void Entry(AVEHICLE vh, BLL.SectionBLL sectionBLL, bool is_need_recalculate)
        //{
        //    if (vh == null) return;
        //    lock (Vehicles)
        //    {
        //        if (!Vehicles.Contains(vh))
        //        {
        //            if (is_need_recalculate)
        //            {
        //                ASECTION current_section = sectionBLL.cache.GetSection(vh.CUR_SEC_ID);
        //                int current_sec_index = Sections.IndexOf(current_section);
        //                if (current_sec_index == -1) return;
        //                if (Vehicles.Count > 0)
        //                {
        //                    AVEHICLE next_vh = null;
        //                    for (int i = current_sec_index; i < Sections.Count; i++)
        //                    {
        //                        string next_sec_id = Sections[i].SEC_ID;
        //                        AVEHICLE vh_temp = Vehicles.Where(v => Common.SCUtility.isMatche(v.CUR_SEC_ID, next_sec_id)).
        //                                                    FirstOrDefault();
        //                        if (vh_temp != null)
        //                        {
        //                            if (i == current_sec_index)
        //                            {
        //                                if (vh_temp.ACC_SEC_DIST > vh.ACC_SEC_DIST)
        //                                {
        //                                    next_vh = vh_temp;
        //                                    break;
        //                                }
        //                            }
        //                            else
        //                            {
        //                                next_vh = vh_temp;
        //                                break;
        //                            }
        //                        }
        //                    }
        //                    if (next_vh == null)
        //                    {
        //                        Vehicles.AddFirst(vh);
        //                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
        //                           Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
        //                           VehicleID: vh.VEHICLE_ID,
        //                           CarrierID: vh.CST_ID);

        //                    }
        //                    else
        //                    {
        //                        var next_vh_node = Vehicles.Find(next_vh);
        //                        Vehicles.AddAfter(next_vh_node, vh);

        //                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
        //                           Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,after {next_vh.VEHICLE_ID}",
        //                           VehicleID: vh.VEHICLE_ID,
        //                           CarrierID: vh.CST_ID);
        //                    }
        //                }
        //                else
        //                {
        //                    Vehicles.AddLast(vh);
        //                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
        //                       Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
        //                       VehicleID: vh.VEHICLE_ID,
        //                       CarrierID: vh.CST_ID);
        //                }
        //            }
        //            else
        //            {
        //                Vehicles.AddLast(vh);
        //                LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
        //                   Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is last",
        //                   VehicleID: vh.VEHICLE_ID,
        //                   CarrierID: vh.CST_ID);
        //            }
        //            onEntry(vh);
        //        }
        //    }
        //}
        public void Entry(AVEHICLE vh, BLL.SectionBLL sectionBLL, bool is_need_recalculate)
        {
            if (vh == null)
            {
                return;
            }
            lock (Vehicles)
            {
                bool is_contains = Vehicles.Contains(vh);
                //if (!Vehicles.Contains(vh))
                //{
                if (is_need_recalculate)
                {
                    if (is_contains)
                    {
                        Vehicles.Remove(vh);
                    }
                    ASECTION current_section   = sectionBLL.cache.GetSection(vh.CUR_SEC_ID);
                    int      current_sec_index = Sections.IndexOf(current_section);
                    if (current_sec_index == -1)
                    {
                        return;
                    }
                    if (Vehicles.Count > 0)
                    {
                        AVEHICLE next_vh = null;
                        for (int i = current_sec_index; i < Sections.Count; i++)
                        {
                            string   next_sec_id = Sections[i].SEC_ID;
                            AVEHICLE vh_temp     = Vehicles.Where(v => Common.SCUtility.isMatche(v.CUR_SEC_ID, next_sec_id)).
                                                   FirstOrDefault();
                            if (vh_temp != null)
                            {
                                if (i == current_sec_index)
                                {
                                    if (vh_temp.ACC_SEC_DIST > vh.ACC_SEC_DIST)
                                    {
                                        next_vh = vh_temp;
                                        break;
                                    }
                                }
                                else
                                {
                                    next_vh = vh_temp;
                                    break;
                                }
                            }
                        }
                        if (next_vh == null)
                        {
                            Vehicles.AddFirst(vh);
                            LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                          Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                                          VehicleID: vh.VEHICLE_ID,
                                          CarrierID: vh.CST_ID);
                        }
                        else
                        {
                            var next_vh_node = Vehicles.Find(next_vh);
                            Vehicles.AddAfter(next_vh_node, vh);

                            LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                          Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,after {next_vh.VEHICLE_ID}",
                                          VehicleID: vh.VEHICLE_ID,
                                          CarrierID: vh.CST_ID);
                        }
                    }
                    else
                    {
                        Vehicles.AddLast(vh);
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                      Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                                      VehicleID: vh.VEHICLE_ID,
                                      CarrierID: vh.CST_ID);
                    }
                }
                else
                {
                    if (!is_contains)
                    {
                        Vehicles.AddLast(vh);
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                      Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is last",
                                      VehicleID: vh.VEHICLE_ID,
                                      CarrierID: vh.CST_ID);
                    }
                }
                if (!is_contains)
                {
                    onEntry(vh);
                }
                //}
            }
        }