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); }
//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)); } } } } }
//* 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)); } }