Exemplo n.º 1
0
        public override void ConnectToParamics()
        {
            //Find out the number of agents and junctions
            int AgentNum    = NetworkStruct.GetElementsByTagName("Agent").Count;
            int JunctionNum = NetworkStruct.GetElementsByTagName("Junction").Count;

            //NetDat = new NetworkDataSIT(ParamicsPath, IP, Port, AgentNum, JunctionNum, "Vehicledatasimple", "SITtrue");
            NetDat  = new NetworkDataSIT(ParamicsPath, IP, Port, AgentNum, JunctionNum, "LinkTurningMovements", "SITtrue");
            NetDat2 = new NetworkDataSIT(ParamicsPath, IP, Port, AgentNum, JunctionNum, "VehicledataWobbly", "SITwobbly");
            NetDat.PDB.ClearTableContents();
            NetDat2.PDB.ClearTableContents();
            NetDat2.LTB.ClearTableContents();

            MainZone   = new ZoneAgent(NetDat, Strat);
            WobblyZone = new ZoneAgent(NetDat2, Strat);
            FindAgents(NetDat, ref MainZone);
            FindAgents(NetDat2, ref WobblyZone);

            SitB = new SITbridge(NetDat2);
            FindSITAgents(NetDat2, ref SitB);
            SitB.AreaMash();
            FindSensors(NetDat2, ref SitB);//TODO it is important that this is called after AreaMash() should probably put in acheck for this....

            List <string> NodeNames = new List <string>();

            foreach (JunctionAgent JA in MainZone.Junctions)
            {
                NodeNames.Add(JA.SignalNode);
            }

            SigSet = new SignalsSet(NetDat, NodeNames);
        }
Exemplo n.º 2
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.º 3
0
        //* function to pull specifically the sensor data from the config file...

        private void FindSensors(NetworkData NDin, ref SITbridge SitIn)
        {
            XmlNode SensorData = NetworkStruct.GetElementsByTagName("SensorModel")[0];

            XmlNode CensusData = SensorData.SelectSingleNode("Census");
            XmlNode ProbeData  = SensorData.SelectSingleNode("Probe");

            //get loop data
            XmlNodeList Loops = CensusData.SelectNodes("Loop");

            foreach (XmlNode loop in Loops)
            {
                string Name     = loop.SelectSingleNode("Name").FirstChild.Value;
                string AreaNme  = loop.SelectSingleNode("Area").FirstChild.Value;
                double Position = Convert.ToDouble(loop.SelectSingleNode("Position").FirstChild.Value);
                int    Lanes    = Convert.ToInt32(loop.SelectSingleNode("LanesCovered").FirstChild.Value);
                double CountSD  = Convert.ToDouble(loop.SelectSingleNode("CountSD").FirstChild.Value);
                bool   HasSpeed = Convert.ToBoolean(loop.SelectSingleNode("HasSpeed").FirstChild.Value);
                double SpeedSD  = 0;
                if (HasSpeed)
                {
                    SpeedSD = Convert.ToDouble(loop.SelectSingleNode("SpeedSD").FirstChild.Value);
                }

                SingleInstanceOfTruth.censusSensor TheSensor;

                if (HasSpeed)
                {
                    TheSensor = new SingleInstanceOfTruth.loopPair(Name, Lanes, Position, CountSD, SpeedSD);
                }
                else
                {
                    TheSensor = new SingleInstanceOfTruth.inductiveLoop(Name, CountSD, Lanes, Position);
                }

                SitIn.AddCensus(TheSensor, AreaNme);
            }

            //*get probe data
            XmlNodeList WiFis = ProbeData.SelectNodes("WiFiType");

            foreach (XmlNode wifi in WiFis)
            {
                string Name    = wifi.SelectSingleNode("Name").FirstChild.Value;
                double CountSD = Convert.ToDouble(wifi.SelectSingleNode("CountSD").FirstChild.Value);
                double SpeedSD = Convert.ToDouble(wifi.SelectSingleNode("SpeedSD").FirstChild.Value);
                double PenRate = Convert.ToDouble(wifi.SelectSingleNode("PenetrationRate").FirstChild.Value);
                double PenSD   = Convert.ToDouble(wifi.SelectSingleNode("PenetrationSD").FirstChild.Value);

                SitIn.AddProbe(new SingleInstanceOfTruth.WiFi(Name, CountSD, SpeedSD, PenRate, PenSD));
            }
        }
Exemplo n.º 4
0
        private void writeSITdiffFiles(ZoneAgent ZoneIn, SITbridge SITin, String Path)
        {
            string[] countDiff = new string[SITin.getAreas().Count];
            string[] speedDiff = new string[SITin.getAreas().Count];
            int      Znum      = 0;

            foreach (JunctionAgent JA in ZoneIn.Junctions)
            {
                foreach (StageAgent SA in JA.Stages)
                {
                    foreach (LaneAgent LA in SA.Lanes)
                    {
                        if (!LA.Duplicate)
                        {
                            foreach (SITarea theArea in SITin.getAreas())
                            {
                                if (theArea.Area.name.Equals(LA.Name))
                                {
                                    if (LA.Count == 0)
                                    {
                                        countDiff[Znum] = theArea.Area.name + "," + Math.Round(Math.Abs(theArea.Area.stateNow.getNumberOfVehicles()) * 2).ToString();
                                        speedDiff[Znum] = theArea.Area.name + "," + Math.Round((Math.Abs(13.41 - theArea.Area.stateNow.getAverageSpeedOfVehicles()))).ToString();
                                    }
                                    else
                                    {
                                        countDiff[Znum] = theArea.Area.name + "," + Math.Round((Math.Abs(LA.Count - theArea.Area.stateNow.getNumberOfVehicles())) * 2).ToString();
                                        speedDiff[Znum] = theArea.Area.name + "," + Math.Round((Math.Abs(LA.AvSpeed - theArea.Area.stateNow.getAverageSpeedOfVehicles()))).ToString();
                                    }
                                    break;
                                }
                            }
                            Znum++;
                        }
                    }
                }
            }

            File.WriteAllLines(Path + @"\diffCounts", countDiff);
            File.WriteAllLines(Path + @"\diffSpeeds", speedDiff);
        }