private List <ASECTION> getSectionByOrder(List <ASECTION> sections)
        {
            if (sections.Count == 1)
            {
                return(sections);
            }
            if (SCUtility.isMatche(SEG_ID, "900"))
            {
                return(new List <ASECTION>());
            }
            List <ASECTION> order_sections = new List <ASECTION>();
            string          next_from_adr  = RealFromAddress;

            for (int i = 0; i < sections.Count; i++)
            {
                //ASECTION section = sections.Where(s => s.FROM_ADR_ID.Trim() == next_from_adr.Trim()).SingleOrDefault();
                ASECTION section = sections.Where(s => s.REAL_FROM_ADR_ID.Trim() == next_from_adr.Trim()).SingleOrDefault();
                order_sections.Add(section);
                //next_from_adr = section.TO_ADR_ID;
                if (section == null)
                {
                }
                next_from_adr = section.REAL_TO_ADR_ID;
            }
            return(order_sections);
        }
        public string getNearSegmentAddress(string adrID)
        {
            if (SCUtility.isMatche(FROM_ADR_ID, adrID) || SCUtility.isMatche(TO_ADR_ID, adrID))
            {
                return(adrID);
            }

            ASECTION section_of_to_adr = Sections.Where(sec => sec.TO_ADR_ID.Trim() == adrID.Trim()).Single();
            int      sec_index         = Sections.IndexOf(section_of_to_adr);
            double   with_from_adr_dis = 0;
            double   with_to_adr_dis   = 0;

            for (int i = 0; i < Sections.Count; i++)
            {
                if (i <= sec_index)
                {
                    with_from_adr_dis += Sections[i].SEC_DIS;
                }
                else
                {
                    with_to_adr_dis += Sections[i].SEC_DIS;
                }
            }
            if (with_from_adr_dis >= with_to_adr_dis)
            {
                return(RealToAddress);
            }
            else
            {
                return(RealFromAddress);
            }
        }
 public int GetSectionIndex(ASECTION section)
 {
     return(Sections.IndexOf(section));
 }
Exemplo n.º 4
0
        public void RefreshVhOrder(sc.BLL.VehicleBLL vehicleBLL, sc.BLL.SectionBLL sectionBLL)
        {
            lock (Vehicles)
            {
                Vehicles.Clear();
                List <AVEHICLE> vhs = vehicleBLL.cache.loadVhsBySegmentID(this.SEG_NUM);
                foreach (AVEHICLE vh in vhs)
                {
                    if (!Vehicles.Contains(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 last",
                                          VehicleID: vh.VEHICLE_ID,
                                          CarrierID: vh.CST_ID);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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);
                }
                //}
            }
        }