Exemplo n.º 1
0
        //Function like FindAgents above but specifically for pulling out the area data for SIT calculation and the sensor data...

        public void FindSITAgents(NetworkData NDin, ref SITbridge SITin)
        {
            XmlNodeList JunctionsData = NetworkStruct.GetElementsByTagName("Junction");

            foreach (XmlNode Jcn in JunctionsData)
            {
                string SignalNode = Jcn.SelectSingleNode("SignalNode").FirstChild.Value;
                int    NumStages  = Convert.ToInt32(Jcn.SelectSingleNode("Stages").FirstChild.Value);

                //JunctionAgent TempJA = new JunctionAgent(NDin, Strat, SignalNode, NumStages);

                XmlNodeList StageData = Jcn.SelectNodes("Stage");
                foreach (XmlNode Stg in StageData)
                {
                    //StageAgent TempSA = new StageAgent(NDin, Strat);

                    XmlNodeList AgentData = Stg.SelectNodes("Agent");
                    foreach (XmlNode Agt in AgentData)
                    {
                        LaneAgent TempLA = new LaneAgent(NDin, Strat);
                        TempLA.Duplicate = Convert.ToBoolean(Agt.SelectSingleNode("Duplicate").FirstChild.Value);
                        if (!TempLA.Duplicate)
                        {
                            TempLA.Name = Agt.SelectSingleNode("name").FirstChild.Value;
                            if (Agt.SelectSingleNode("UpstreamAgents").HasChildNodes)
                            {
                                TempLA.UpstreamAgents = Agt.SelectSingleNode("UpstreamAgents").FirstChild.Value;
                            }
                            if (Agt.SelectSingleNode("FeedPercentage").HasChildNodes)
                            {
                                TempLA.feedPercentages = Agt.SelectSingleNode("FeedPercentage").FirstChild.Value;
                            }
                            XmlNodeList RoadData = Agt.SelectNodes("RoadSec");
                            foreach (XmlNode Rsec in RoadData)
                            {
                                string Snode, Enode;
                                int    Lane, OLanes;
                                double Oset, Tlen;

                                Snode  = Rsec.SelectSingleNode("StartNode").FirstChild.Value;
                                Enode  = Rsec.SelectSingleNode("EndNode").FirstChild.Value;
                                Lane   = Convert.ToInt32(Rsec.SelectSingleNode("Lane").FirstChild.Value);
                                OLanes = Convert.ToInt32(Rsec.SelectSingleNode("OfLanes").FirstChild.Value);
                                Oset   = Convert.ToDouble(Rsec.SelectSingleNode("Offset").FirstChild.Value);
                                Tlen   = Convert.ToDouble(Rsec.SelectSingleNode("TotalLength").FirstChild.Value);

                                LaneAgent.BitOfRoad br = new LaneAgent.BitOfRoad(Snode, Enode, Lane, OLanes, Oset);
                                br.TotalLength = Tlen;
                                TempLA.RoadSegments.Add(br);
                            }
                            SITin.AddArea(new SITarea(TempLA));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Function to read get the agent data from the XML file
        protected void FindAgents(NetworkData NDin, ref ZoneAgent ZAin)
        {
            XmlNodeList JunctionsData = NetworkStruct.GetElementsByTagName("Junction");

            foreach (XmlNode Jcn in JunctionsData)
            {
                string SignalNode = Jcn.SelectSingleNode("SignalNode").FirstChild.Value;
                int    NumStages  = Convert.ToInt32(Jcn.SelectSingleNode("Stages").FirstChild.Value);

                JunctionAgent TempJA = new JunctionAgent(NDin, Strat, SignalNode, NumStages);

                XmlNodeList StageData = Jcn.SelectNodes("Stage");
                foreach (XmlNode Stg in StageData)
                {
                    StageAgent TempSA = new StageAgent(NDin, Strat);

                    XmlNodeList AgentData = Stg.SelectNodes("Agent");
                    foreach (XmlNode Agt in AgentData)
                    {
                        LaneAgent TempLA = new LaneAgent(NDin, Strat);
                        TempLA.Duplicate = Convert.ToBoolean(Agt.SelectSingleNode("Duplicate").FirstChild.Value);
                        TempLA.Name      = Agt.SelectSingleNode("name").FirstChild.Value;
                        //TempLA.UpstreamAgents = Agt.SelectSingleNode("UpstreamAgents").FirstChild.Value;
                        XmlNodeList RoadData = Agt.SelectNodes("RoadSec");
                        foreach (XmlNode Rsec in RoadData)
                        {
                            string Snode, Enode;
                            int    Lane, OLanes;
                            double Oset;

                            Snode  = Rsec.SelectSingleNode("StartNode").FirstChild.Value;
                            Enode  = Rsec.SelectSingleNode("EndNode").FirstChild.Value;
                            Lane   = Convert.ToInt32(Rsec.SelectSingleNode("Lane").FirstChild.Value);
                            OLanes = Convert.ToInt32(Rsec.SelectSingleNode("OfLanes").FirstChild.Value);
                            Oset   = Convert.ToDouble(Rsec.SelectSingleNode("Offset").FirstChild.Value);

                            TempLA.RoadSegments.Add(new LaneAgent.BitOfRoad(Snode, Enode, Lane, OLanes, Oset));
                        }
                        TempSA.Lanes.Add(TempLA);
                    }
                    TempSA.NeutralWeight();
                    TempJA.Stages.Add(TempSA);
                }
                ZAin.Junctions.Add(TempJA);
            }
        }