Example #1
0
        /// <summary>
        /// bt爆搜寻路(可搜折返),单向寻路,以进路为单位搜索
        /// </summary>
        /// <param name="Now"></param>
        /// <param name="res"></param>
        /// <param name="tempRoutes"></param>
        /// <param name="src"></param>
        /// <param name="tar"></param>
        /// <param name="k"></param>
        /// <param name="used"></param>
        void SearchSinglePath(ATSRoute Now, List <OptionalRoutes> res, OptionalRoutes tempRoutes, string tar, int k, HashSet <ATSRoute> routeUsed, RouteDirection routedir, int maxY, int minY)
        {
            if (k > deepth || res.Count > MaxResNum)
            {
                return;
            }
            foreach (var de in Now.InSections)
            {
                if (de.Name == tar)
                {
                    tempRoutes.UpdateDistance();
                    res.Add(new OptionalRoutes(tempRoutes));
                    return;
                }
            }

            foreach (var possibleRoute in Now.OptionalRoutes)
            {
                ATS.Signal signal = possibleRoute.StartSignal as ATS.Signal;
                double     y      = Canvas.GetTop(signal);
                if (possibleRoute.Dir == routedir && y >= minY && y <= maxY && !routeUsed.Contains(possibleRoute))
                //if (possibleRoute.Dir == routedir)
                {
                    tempRoutes.Routes.Add(possibleRoute);
                    routeUsed.Add(possibleRoute);
                    SearchSinglePath(tempRoutes.Routes.Last(), res, tempRoutes, tar, k + 1, routeUsed, routedir, maxY, minY);
                    tempRoutes.Routes.Remove(tempRoutes.Routes.Last());
                    routeUsed.Remove(possibleRoute);
                }
            }
        }
Example #2
0
 public void AddOpenedRoute(ATSRoute route)
 {
     if (!_RouteOpened.Contains(route))
     {
         this._RouteOpened.Add(route);
     }
 }
Example #3
0
        public GraphicElement UPdateTrainPosByOffset(int type, int id, byte dir, double offset)
        {
            Dir = dir;
            this.Dispatcher.Invoke(() =>
            {
                nowid   = id;
                nowtype = type;
                GraphicElement nowSection = Elements.Find((线路绘图工具.GraphicElement item) =>
                {
                    if (type == (byte)DeviceType.区段 && item is Section)
                    {
                        Section sc = item as Section;
                        return(sc.ID == id);
                    }
                    else if (type == (byte)DeviceType.道岔 && item is RailSwitch)
                    {
                        RailSwitch rs = item as RailSwitch;
                        return(rs.ID == id);
                    }
                    else
                    {
                        return(false);
                    }
                });

                UpdatePos(nowSection, dir, offset);
                if (Res != null && Res.Count != 0)
                {
                    ATSRoute OpenRoute     = null;
                    List <ATSRoute> routes = Res[0].Routes;
                    OpenRoute = routes.Find((ATSRoute r) =>
                    {
                        foreach (Device item in r.IncomingSections)
                        {
                            if (item == nowSection)
                            {
                                return(true);
                            }
                        }
                        return(false);
                    });
                    this.OpenRoute = OpenRoute;
                }
                NowSection = nowSection;
                return(NowSection);
            });
            return(null);
        }