示例#1
0
    public override void OnInspectorGUI()
    {
        rNet = target as RouteNet;
        base.OnInspectorGUI();

        EditorGUI.BeginChangeCheck();

        if (GUILayout.Button("BuildAllRoute"))
        {
            Undo.RecordObject(target, "BuildAllRoute");

            ERRoadNetwork net = new ERRoadNetwork();
            foreach (var r in rNet.allRoutes)
            {
                Debug.Log("Road Name : " + r.__roadName + " Points Count " + r.positions.Count);
                markers = net.GetRoadByName(r.__roadName);
                if (markers == null)
                {
                    Debug.LogError("NO SUCH ROAD.....CANCELED......");
                    continue;
                }

                r.resolution = 50;
                Vector3[] arr = markers.GetSplinePointsCenter();
                r.positions = new List <Vector3>(arr);
                for (int i = 0; i < r.positions.Count; i++)
                {
                    //Debug.Log(r.positions[i]);
                }
            }
            EditorUtility.SetDirty(target);
        }
    }
        protected override void DoCommandAction()
        {
            if (this.StartLocations.Count != this.SinkLocations.Count)
            {
                throw new ArgumentException("Number of sinks and source must match");
            }
            List<Location> sources = this.GetLocations(this.StartLocations);
            List<Location> sinks = this.GetLocations(this.SinkLocations);

            // result
            List<List<Location>> paths = new List<List<Location>>();

            Dictionary<Location, PathUsage> pipUsage = new Dictionary<Location, PathUsage>();

            for (int i = 0; i < sources.Count; i++)
            {
                Location source = sources[i];
                Location sink = sinks[i];
                PathSearchOnFPGA.CheckLocationsForExistence(source, sink);

                RouteNet routeCmd = new RouteNet();
                foreach (List<Location> path in routeCmd.Route("BFS", true, Enumerable.Repeat(source, 1), sink, 100, this.MaxDepth, true))
                {
                    if (!PathSearchOnFPGA.PathAlreadyFound(path, paths))
                    {
                        paths.Add(path);

                        // attach
                        PathUsage usage = new PathUsage(source, sink);

                        foreach (Location l in path)
                        {
                            if(
                        }
                    }
                }

            }
        }
        protected override void DoCommandAction()
        {
            // read input
            Queue <Tuple <Location, Location> > fromToTuples = null;

            ReadSearchInput(out fromToTuples);

            // result
            List <List <Location> > paths = new List <List <Location> >();
            List <XDLNet>           nets  = new List <XDLNet>();

            RouteNet routeCmd = new RouteNet();

            routeCmd.Watch = Watch;

            int size  = fromToTuples.Count;
            int count = 0;

            UsageManager usageManager = new UsageManager();

            // upon sink chnmage, block the last nets
            Location lastSink = null;

            while (fromToTuples.Count > 0)
            {
                ProgressInfo.Progress = ProgressStart + (int)((double)count++ / (double)size * ProgressShare);

                Tuple <Location, Location> tuple = fromToTuples.Dequeue();
                Location source = tuple.Item1;
                Location sink   = tuple.Item2;

                bool pathFound = false;

                bool sinkChange = lastSink == null ? false : !lastSink.Equals(sink);
                lastSink = sink;
                if (sinkChange)
                {
                    BlockPips(nets);
                }
                Usage usage = new Usage(source, sink);

                //if (source.Tile.Location.Equals("CLEXL_X22Y16") && source.Pip.Name.Equals("XX_AQ") && sink.Tile.Location.Equals("CLEXM_X23Y18") && sink.Pip.Name.Equals("X_AX"))
                if (source.Tile.Location.Equals("CLEXL_X22Y16") && source.Pip.Name.Equals("XX_AQ") && sink.Tile.Location.Equals("CLEXM_X23Y16") && sink.Pip.Name.Equals("X_AX"))
                {
                }

                List <Location> initialSearchFront = new List <Location>();
                foreach (Location location in usageManager.GetLocationsWithExclusiveUsage(usage).OrderBy(l => Distance(l, sink)))
                {
                    initialSearchFront.Add(location);
                }
                // add default source after the others
                initialSearchFront.Add(source);

                // truncate on first run
                TextWriter tw = new StreamWriter(OutputFile, count > 1);
                tw.Write(PathSearchOnFPGA.GetBanner(source, sink));



                //Console.WriteLine("Running path " + count + " " + usage + (initialSearchFront.Count > 1 ? " with shortcut" : ""));

                if (initialSearchFront.Count > 1)
                {
                }

                Watch.Start("search");
                foreach (List <Location> path in routeCmd.Route("BFS", true, initialSearchFront, sink, 100, MaxDepth, false))
                {
                    if (!PathSearchOnFPGA.PathAlreadyFound(path, paths))
                    {
                        paths.Add(path);

                        XDLNet n = PathToNet(source, sink, path);
                        nets.Add(n);
                        usage.Net = n;

                        tw.Write(PathSearchOnFPGA.PathToString(source, sink, Enumerable.Repeat(path, 1)));
                        pathFound = true;

                        // no blocking on CLEX LOGIC
                        foreach (XDLPip pip in GetPipsToBlock(n))
                        {
                            Location l = new Location(FPGA.FPGA.Instance.GetTile(pip.Location), new Port(pip.From));
                            //Location r = new Location(FPGA.FPGA.Instance.GetTile(pip.Location), new Port(pip.To));
                            usageManager.Add(l, usage, n);
                            //usageManager.Add(r, usage);
                        }
                        break;
                    }
                }
                Watch.Stop("search");

                if (!pathFound)
                {
                    tw.WriteLine("No path found");
                    string trigger = ("if (source.Tile.Location.Equals(\"" + source.Tile.Location + "\") && source.Pip.Name.Equals(\"" + source.Pip.Name + "\") && sink.Tile.Location.Equals(\"" + sink.Tile.Location + "\") && sink.Pip.Name.Equals(\"" + sink.Pip.Name + "\"))");
                    Console.WriteLine(trigger);
                }

                tw.Close();

                if (nets.Count % 20 == 0)
                {
                    //    Console.WriteLine(this.Watch.GetResults());
                }
            }
        }