Пример #1
0
        //function for calculating vehicle xyz position
        public double[] LinkToCartesian(LinkID Link, double l)
        {
            double X1, X2, Y1, Y2, Z1, Z2;

            X1 = 0; X2 = 0; Y1 = 0; Y2 = 0; Z1 = 0; Z2 = 0;
            foreach (N_W_Node ThisNode in EN.NodeList)
            {
                if (ThisNode.NodeNum.Equals(Link.StartNode))
                {
                    X1 = ThisNode.X;
                    Y1 = ThisNode.Y;
                    Z1 = ThisNode.Z;
                    break;
                }
            }
            foreach (N_W_Node ThisNode in EN.NodeList)
            {
                if (ThisNode.NodeNum.Equals(Link.EndNode))
                {
                    X2 = ThisNode.X;
                    Y2 = ThisNode.Y;
                    Z2 = ThisNode.Z;
                    break;
                }
            }
            double deltaX = X2 - X1;
            double deltaY = Y2 - Y1;
            double deltaZ = Z2 - Z1;
            double Ratio  = l / Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2) + Math.Pow(deltaZ, 2));

            double[] Location = new double[3] {
                (Ratio * deltaX + X1), (Ratio * deltaY + Y1), (Ratio * deltaZ + Z1)
            };
            return(Location);
        }
Пример #2
0
        //*Constructor
        public EditPaths(string NetPath)
            : base(NetPath)
        {
            FileName = "paths";

            using (StreamReader ReadFile = new StreamReader((NetPath + "\\" + FileName)))// open the paths file
            {
                try
                {
                    string   FileLine;
                    N_W_Path temp = new N_W_Path();
                    LinkID   tLiD = new LinkID();
                    while ((FileLine = ReadFile.ReadLine()) != null)//read the file line by line
                    {
                        if (FileLine.Contains("number "))
                        {
                            temp = new N_W_Path();

                            string[] splitline = FileLine.Split(new Char[] { ' ' });// split the line up into an array of strings
                            //read the data from the file into the class object lists
                            int index = splitline.Length;
                            index--;
                            int num = Convert.ToInt32(splitline[index]);
                            temp.PathIDn = num;
                        }
                        if (FileLine.Contains("name "))
                        {
                            string[] splitline = FileLine.Split(new Char[] { '"' });// split the line up into an array of strings
                            temp.PathName = splitline[1];
                        }
                        if (FileLine.Contains("link "))
                        {
                            string[] splitline       = FileLine.Split(new Char[] { ':' });// split the line up into an array of strings
                            string[] splitsplitline1 = splitline[0].Split(new Char[] { ' ' });
                            string[] splitsplitline2 = splitline[1].Split(new Char[] { ' ' });
                            int      index1          = splitsplitline1.Length;
                            int      index2          = 0;
                            index1--;
                            string num1 = splitsplitline1[index1];
                            string num2 = splitsplitline2[index2];

                            tLiD = new LinkID(num1, num2);
                            temp.PathDescription.Add(tLiD);
                        }
                        if (FileLine.Contains(" end"))
                        {
                            PathList.Add(temp);
                        }
                    }
                }
                catch (Exception e)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("The pathroutes file could not be read:");
                    Console.WriteLine(e.Message);
                }
            }
        }
Пример #3
0
        //function for getting Origin zone from fist Link
        public int GetOriginZone(LinkID Link)
        {
            double[] StartNodeLoc = new double[2] {
                0, 0
            };
            double[] EndNodeLoc = new double[2] {
                0, 0
            };
            int ZoneNum = 511;

            try
            {
                foreach (N_W_Node node in EN.NodeList)
                {
                    if (Link.StartNode.Equals(node.NodeNum))
                    {
                        StartNodeLoc[0] = node.X;
                        StartNodeLoc[1] = node.Y;
                    }
                    else if (Link.EndNode.Equals(node.NodeNum))
                    {
                        EndNodeLoc[0] = node.X;
                        EndNodeLoc[1] = node.Y;
                    }
                }

                foreach (N_W_Zone zone in EZ.ZoneList)
                {
                    if (StartNodeLoc[0] < zone.Max[0] && StartNodeLoc[0] > zone.Min[0])
                    {
                        if (StartNodeLoc[1] < zone.Max[1] && StartNodeLoc[1] > zone.Min[1])
                        {
                            if (EndNodeLoc[0] < zone.Max[0] && EndNodeLoc[0] > zone.Min[0] && EndNodeLoc[1] < zone.Max[1] && EndNodeLoc[1] > zone.Min[1])
                            {
                                ZoneNum = zone.ZoneNum;
                                break;
                            }
                        }
                    }
                }
                if (ZoneNum == 511)
                {
                    throw new Exception("Error: No zone was found that contains both the link nodes");
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
                Console.WriteLine(e.Message);
            }


            return(ZoneNum);
        }
Пример #4
0
 //*class constructor
 public FileData()
 {
     //DEFAULT VALUES
     Tag          = 511;//This may cause a problem because 511 can be an actual tag check it out
     Vtype        = 511;
     Origin       = 511;
     Destination  = 511;
     NextLink     = "NULL";
     NextNextLink = "NULL";
     NextTurn     = "NULL";
     NextNextTurn = "NULL";
     EnterLink    = new LinkID();
     EnterTime    = new DateTime(1979, 2, 14, 0, 0, 0);
 }
 //*Constructor
 public VehicleDataLite()
 {
     //DEFAULT VALUES
     Source       = "default";
     LinkDist     = 511;
     Vspeed       = 511;
     NextLink     = "default";
     NextNextLink = "default";
     NextTurn     = "default";
     NextNextTurn = "default";
     Lane         = 0;
     OnLink       = new LinkID();
     AtTime       = new DateTime(1979, 2, 14, 0, 0, 0);
     BornTime     = new DateTime(1979, 2, 14, 0, 0, 0);
 }
Пример #6
0
        //Function for Finding the First Link on a path
        LinkID FirstLinkinRoute(ReadSnapshotFile.FileData Sn)
        {
            LinkID TempLink = new LinkID();

            foreach (N_W_Path Route in EP.PathList)
            {
                if (Sn.RouteName.Equals(Route.PathName))
                {
                    TempLink = Route.PathDescription[0];
                    break;
                }
            }

            return(TempLink);
        }
Пример #7
0
 //*constructors
 public FileData()
 {
     //DEFAULT VALUES
     Tag          = 511;//This may cause a problem because 511 can be an actual tag check it out
     Vtype        = 511;
     Lane         = 511;
     NextLink     = "NULL";
     NextNextLink = "NULL";
     NextTurn     = "NULL";
     NextNextTurn = "NULL";
     Vspeed       = 511;
     LinkDist     = 511;
     OnLink       = new LinkID();
     AtTime       = new DateTime(1979, 2, 14, 0, 0, 0);
 }
 //*Constructor
 public VehiclePosition()
 {
     //DEFAULT VALUES
     ViD          = "NoID";
     LinkDist     = 511;
     Vspeed       = 511;
     X            = 511;
     Y            = 511;
     Z            = 511;
     NextLink     = "NULL";
     NextNextLink = "NULL";
     NextTurn     = "NULL";
     NextNextTurn = "NULL";
     OnLink       = new LinkID();
     AtTime       = new DateTime(1979, 2, 14, 0, 0, 0);
     Obsolete     = false;
 }
 //*Consructor
 public VehicleIdentity()
 {
     ViD          = "NoID";
     Routename    = "NULL";
     Tag          = 511;
     Vtype        = 511;
     Origin       = 511;
     Destination  = 511;
     NextLink     = "NULL";
     NextNextLink = "NULL";
     NextTurn     = "NULL";
     NextNextTurn = "NULL";
     BornLink     = new LinkID();
     BornAt       = new DateTime(1979, 2, 14, 0, 0, 0);
     Obsolete     = false;
     MagicNumbers = "[511,511]";
 }
Пример #10
0
 //*class constructor
 public FileData()
 {
     //DEFAULT VALUES
     Vtype        = 511;
     Origin       = 511;
     Destination  = 511;
     NextLink     = "NULL";
     NextNextLink = "NULL";
     NextTurn     = "NULL";
     NextNextTurn = "NULL";
     Vspeed       = 511;
     LinkDist     = 511;
     RouteName    = "NULL";
     OnLink       = new LinkID();
     AtTime       = new DateTime(1979, 2, 14, 0, 0, 0);
     BornTime     = new DateTime(1979, 2, 14, 0, 0, 0);
     MagicNumbers = "[511,511]";
 }
Пример #11
0
        //*Constructor
        public EditDetectors(string NetPath)
            : base(NetPath)
        {
            FileName = "detectors";

            using (StreamReader ReadFile = new StreamReader((NetPath + "\\" + FileName)))// open the paths file
            {
                try
                {
                    string   FileLine;
                    Detector temp = new Detector();
                    LinkID   tLiD = new LinkID();
                    while ((FileLine = ReadFile.ReadLine()) != null)//read the file line by line
                    {
                        if (!FileLine.Contains("Detector Count"))
                        {
                            string[] splitline = FileLine.Split(new Char[] { '"' });// split the line up into an array of strings
                            temp.Name = splitline[1];

                            string[] splitline2 = FileLine.Split(new Char[] { ' ' });// split the line up into an array of strings
                            temp.Type     = splitline2[0];
                            temp.LinkDist = Convert.ToDouble(splitline2[5]);
                            tLiD          = new LinkID(splitline2[9]);
                            temp.OnLink   = tLiD;
                            temp.Length   = Convert.ToDouble(splitline2[12]);
                            DetectorList.Add(temp);
                            temp = new Detector();
                        }
                    }
                }
                catch (Exception e)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("The detectors file could not be read:");
                    Console.WriteLine(e.Message);
                }
            }
        }
Пример #12
0
        //Function for adding data
        public void AddStep(int StageNumber, int ScenarioNumber)
        {
            try
            {
                foreach (ReadEventsFile.FileData VehiclesBorn in REF.Fdata)
                {
                    VehicleIdentity TempID = new VehicleIdentity();
                    ViDincriment();
                    TempID.ViD          = IDno.ToString("00000");
                    TempID.Tag          = VehiclesBorn.Tag;
                    TempID.Vtype        = VehiclesBorn.Vtype;
                    TempID.BornAt       = VehiclesBorn.AtTime;
                    TempID.BornLink     = VehiclesBorn.OnLink;
                    TempID.BornStage    = StageNumber;
                    TempID.BornScenario = ScenarioNumber;
                    //Destination data are not available, to be added later
                    //Origin data only available in OD

                    if (RouteMethod.Equals("OD"))
                    {
                        TempID.Origin = GetOriginZone(VehiclesBorn.OnLink);
                    }

                    PDB.ViDAddLine(TempID.MakeDBLine());
                }



                foreach (ReadSnapshotFile.FileData SnapShot in RSF.Fdata)
                {
                    string DBcondition = "ABC";

                    if (RouteMethod.Equals("OD"))
                    {
                        //DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND Origin = " + SnapShot.Origin + " AND VehicleType = " + SnapShot.Vtype);//+ " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                        DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND Origin = " + SnapShot.Origin + " AND VehicleType = " + SnapShot.Vtype + " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                    }
                    else if (RouteMethod.Equals("Paths"))
                    {
                        LinkID FirstLink = FirstLinkinRoute(SnapShot);
                        DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND BornLink = '" + FirstLink.MakeString() + "' AND VehicleType = " + SnapShot.Vtype + " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                    }

                    List <VehicleIdentity> TempIDL = new List <VehicleIdentity>();
                    TempIDL = PDB.VidGrabLine(DBcondition);
                    VehicleIdentity TempID = new VehicleIdentity();

                    if (TempIDL.Count == 1)
                    {
                        TempID = TempIDL[0];
                    }
                    else if (TempIDL.Count > 1)
                    {
                        try
                        {
                            if (RouteMethod.Equals("OD"))
                            {
                                //DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND Origin = " + SnapShot.Origin + " AND VehicleType = " + SnapShot.Vtype);//+ " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                                DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND Origin = " + SnapShot.Origin + " AND VehicleType = " + SnapShot.Vtype + " AND MagicNumbers = '" + SnapShot.MagicNumbers + "'" + " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                            }
                            else if (RouteMethod.Equals("Paths"))
                            {
                                LinkID FirstLink = FirstLinkinRoute(SnapShot);
                                DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND BornLink = '" + FirstLink.MakeString() + "' AND VehicleType = " + SnapShot.Vtype + " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                            }
                            List <VehicleIdentity> TempIDL2 = PDB.VidGrabLine(DBcondition);
                            if (TempIDL2.Count == 0)
                            {
                                throw new Exception();
                            }
                            else if (TempIDL2.Count == 1)
                            {
                                TempID = TempIDL2[0];
                            }
                            else
                            {
                                Console.WriteLine("Something weird is going on");
                            }
                        }
                        catch (Exception e)
                        {
                            if (RouteMethod.Equals("OD"))
                            {
                                //DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND Origin = " + SnapShot.Origin + " AND VehicleType = " + SnapShot.Vtype);//+ " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                                DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND Origin = " + SnapShot.Origin + " AND VehicleType = " + SnapShot.Vtype + " AND ISNULL(MagicNumbers)" + " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                            }
                            else if (RouteMethod.Equals("Paths"))
                            {
                                LinkID FirstLink = FirstLinkinRoute(SnapShot);
                                DBcondition = ("BornTime = '" + SnapShot.BornTime.TimeOfDay.ToString() + "' AND BornLink = '" + FirstLink.MakeString() + "' AND VehicleType = " + SnapShot.Vtype + " AND Obsolete = '0' AND (BornStage < " + StageNumber + " OR BornScenario = " + ScenarioNumber + ")");
                            }
                            List <VehicleIdentity> TempIDL3 = PDB.VidGrabLine(DBcondition);

                            if (TempIDL3.Count == 0)
                            {
                                Console.WriteLine("Something weird is going on again");
                            }

                            TempID = TempIDL3[(TempIDL3.Count - 1)];
                            TempID.MagicNumbers = SnapShot.MagicNumbers;
                            PDB.ViDAddLine(TempID.MakeDBLine());
                        }
                    }
                    else if (TempIDL.Count == 0)
                    {
                        Console.WriteLine("What is happenning here?");
                    }


                    if (TempID.ViD.Equals("NoID"))
                    {
                        //throw new Exception("Error: Unique vehicle ID was not assigned to vehicle from snapshot");
                        Console.WriteLine("Vehicle id is unassigned");
                    }

                    if (RouteMethod.Equals("OD"))
                    {
                        if (TempID.Destination == 511)
                        {
                            TempID.Destination = SnapShot.Destination;
                            PDB.ViDAddLine(TempID.MakeDBLine());
                        }
                    }
                    else if (RouteMethod.Equals("Paths"))
                    {
                        if (TempID.Routename.Equals("NULL"))
                        {
                            TempID.Routename = SnapShot.RouteName;
                            PDB.ViDAddLine(TempID.MakeDBLine());
                        }
                    }
                    VehiclePosition TempDat = new VehiclePosition();
                    TempDat.ViD      = TempID.ViD;
                    TempDat.OnLink   = SnapShot.OnLink;
                    TempDat.AtTime   = SnapShot.AtTime;
                    TempDat.LinkDist = SnapShot.LinkDist;
                    TempDat.Vspeed   = SnapShot.Vspeed;
                    double[] Position = LinkToCartesian(SnapShot.OnLink, SnapShot.LinkDist);
                    TempDat.X          = Position[0];
                    TempDat.Y          = Position[1];
                    TempDat.Z          = Position[2];
                    TempDat.InStage    = StageNumber;
                    TempDat.InScenario = ScenarioNumber;

                    PDB.VposAddLine(TempDat.MakeDBLine());
                    //CollatedData.Add(TempDat);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #13
0
        //constructor function
        private void ConstructorFunction()
        {
            try
            {
                DirectoryInfo        LogDirI                  = new DirectoryInfo(LogDir);
                FileInfo[]           snaplist                 = LogDirI.GetFiles("snap*");
                DateTime             TimeNow                  = new DateTime();
                DateTime             ZeroHour                 = DateTime.Parse("00:00:00");
                LinkID               LinkNow                  = new LinkID();
                ReadTurningIntention RTI                      = new ReadTurningIntention();
                string               TempVariableNextLink     = "";
                string               TempVariableNextNextLink = "";
                string               TempVariableNextTurn     = "";
                string               TempVariableNextNextTurn = "";


                FileInfo snapfile = snaplist[snaplist.Length - 1];
                using (StreamReader ReadFile = new StreamReader(snapfile.FullName))
                {
                    string FileLine;
                    while ((FileLine = ReadFile.ReadLine()) != null)
                    {
                        if (FileLine.Contains("snapshot at time"))
                        {
                            string[] splitline = FileLine.Split(new char[] { ' ' });
                            double   TimeSecs  = Convert.ToDouble(splitline[3]);
                            TimeNow = ZeroHour.AddSeconds(TimeSecs);
                        }
                        else if (FileLine.Contains("on link"))
                        {
                            string[] splitline = FileLine.Split(new char[] { ' ', ':' });
                            LinkNow = new LinkID(splitline[2], splitline[3]);
                            //ApproachNode = splitline[2];
                            //JunctionNode = splitline[3];
                        }
                        else if (FileLine.Contains("type "))
                        {
                            FileData TempDat = new FileData();

                            if (FileLine.Contains("path"))
                            {
                                string[] splitline = FileLine.Split(new char[] { ' ', '"' });
                                TempDat.Vtype       = Convert.ToInt32(splitline[1]) + 1;
                                TempDat.Origin      = Convert.ToInt32(splitline[15]) + 1;
                                TempDat.Destination = Convert.ToInt32(splitline[16]) + 1;
                                TempDat.Vspeed      = Convert.ToDouble(splitline[13]);
                                TempDat.LinkDist    = Convert.ToDouble(splitline[8]);
                                TempDat.RouteName   = splitline[6];
                                TempDat.OnLink      = LinkNow;
                                TempDat.AtTime      = TimeNow;
                                double bornsecs = Convert.ToDouble(splitline[17]);
                                TempDat.BornTime      = ZeroHour.AddSeconds(bornsecs);
                                TempDat.MagicNumbers  = ("[" + splitline[10]);
                                TempDat.MagicNumbers += ("," + splitline[20] + "]");    //This needs to be checked

                                Fdata.Add(TempDat);
                            }
                            else
                            {
                                string[] splitline = FileLine.Split(new char[] { ' ' });
                                TempDat.Vtype       = (Convert.ToInt32(splitline[1])) + 1;
                                TempDat.Origin      = (Convert.ToInt32(splitline[10])) + 1;
                                TempDat.Destination = (Convert.ToInt32(splitline[11])) + 1;
                                TempDat.Lane        = (Convert.ToInt32(splitline[7]));

                                TempDat.Vspeed   = Convert.ToDouble(splitline[8]);
                                TempDat.LinkDist = Convert.ToDouble(splitline[3]);
                                TempDat.OnLink   = LinkNow;
                                TempDat.AtTime   = TimeNow;
                                double bornsecs = Convert.ToDouble(splitline[12]);
                                TempDat.BornTime      = ZeroHour.AddSeconds(bornsecs);
                                TempDat.MagicNumbers  = ("[" + splitline[5]);
                                TempDat.MagicNumbers += ("," + splitline[15] + "]");
                                TempVariableNextLink  = RTI.NextLinkNumber(LinkNow.StartNode, LinkNow.EndNode, splitline[13]);
                                if (TempVariableNextLink == "null")
                                {
                                    TempDat.NextLink     = "99999";           //TODO 99999 could be a next link number!
                                    TempDat.NextNextLink = "99999";
                                }
                                else
                                {
                                    TempDat.NextLink = TempVariableNextLink;
                                }
                                TempVariableNextNextLink = RTI.NextLinkNumber(LinkNow.EndNode, TempVariableNextLink, splitline[14]);
                                if (TempVariableNextNextLink == "null")
                                {
                                    TempDat.NextNextLink = "99999";
                                }
                                else
                                {
                                    TempDat.NextNextLink = TempVariableNextNextLink;
                                }
                                TempVariableNextTurn = RTI.NextTurnDirection(LinkNow.StartNode, LinkNow.EndNode, splitline[13]);
                                if (TempVariableNextTurn == "null")
                                {
                                    TempDat.NextTurn     = "None";           //99999 shows an error
                                    TempDat.NextNextTurn = "None";
                                }
                                else
                                {
                                    TempDat.NextTurn = TempVariableNextTurn;
                                }
                                TempVariableNextNextTurn = RTI.NextTurnDirection(LinkNow.EndNode, TempVariableNextLink, splitline[14]);
                                if (TempVariableNextNextTurn == "null")
                                {
                                    TempDat.NextNextTurn = "None";          //99999 shows an error
                                }
                                else
                                {
                                    TempDat.NextNextTurn = TempVariableNextNextTurn;
                                }
                                //TempDat.NextTurn = "Null10";
                                //TempDat.NextNextTurn = "Null10";
                                Fdata.Add(TempDat);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
                Console.WriteLine("Error reading snapfiles:");
                Console.WriteLine(e.Message);
            }
        }
Пример #14
0
        //constructor function
        private void ConstructorFunction()
        {
            try
            {
                DirectoryInfo LogDirI  = new DirectoryInfo(LogDir);
                FileInfo[]    snaplist = LogDirI.GetFiles("snap*");
                DateTime      TimeNow  = new DateTime();
                DateTime      ZeroHour = DateTime.Parse("00:00:00");
                LinkID        LinkNow  = new LinkID();
                foreach (FileInfo snapfile in snaplist)
                {
                    using (StreamReader ReadFile = new StreamReader(snapfile.FullName))
                    {
                        string FileLine;
                        while ((FileLine = ReadFile.ReadLine()) != null)
                        {
                            if (FileLine.Contains("snapshot at time"))
                            {
                                string[] splitline = FileLine.Split(new char[] { ' ' });
                                double   TimeSecs  = Convert.ToDouble(splitline[3]);
                                TimeNow = ZeroHour.AddSeconds(TimeSecs);
                            }
                            else if (FileLine.Contains("on link"))
                            {
                                string[] splitline = FileLine.Split(new char[] { ' ', ':' });
                                LinkNow = new LinkID(splitline[2], splitline[3]);
                            }
                            else if (FileLine.Contains("type "))
                            {
                                FileData TempDat = new FileData();

                                if (FileLine.Contains("path"))
                                {
                                    string[] splitline = FileLine.Split(new char[] { ' ', '"' });
                                    TempDat.Vtype       = Convert.ToInt32(splitline[1]) + 1;
                                    TempDat.Origin      = Convert.ToInt32(splitline[15]) + 1;
                                    TempDat.Destination = Convert.ToInt32(splitline[16]) + 1;
                                    TempDat.Vspeed      = Convert.ToDouble(splitline[13]);
                                    TempDat.LinkDist    = Convert.ToDouble(splitline[8]);
                                    TempDat.RouteName   = splitline[6];
                                    TempDat.OnLink      = LinkNow;
                                    TempDat.AtTime      = TimeNow;
                                    double bornsecs = Convert.ToDouble(splitline[17]);
                                    TempDat.BornTime      = ZeroHour.AddSeconds(bornsecs);
                                    TempDat.MagicNumbers  = ("[" + splitline[10]);
                                    TempDat.MagicNumbers += ("," + splitline[20] + "]");//This needs to be checked


                                    Fdata.Add(TempDat);
                                }
                                else
                                {
                                    string[] splitline = FileLine.Split(new char[] { ' ' });
                                    TempDat.Vtype        = (Convert.ToInt32(splitline[1])) + 1;
                                    TempDat.Origin       = (Convert.ToInt32(splitline[10])) + 1;
                                    TempDat.Destination  = (Convert.ToInt32(splitline[11])) + 1;
                                    TempDat.Vspeed       = Convert.ToDouble(splitline[8]);
                                    TempDat.LinkDist     = Convert.ToDouble(splitline[3]);
                                    TempDat.NextLink     = splitline[13];
                                    TempDat.NextNextLink = splitline[14];
                                    TempDat.NextTurn     = "NULL3";
                                    TempDat.NextNextTurn = "NULL3";

                                    TempDat.OnLink = LinkNow;
                                    TempDat.AtTime = TimeNow;
                                    double bornsecs = Convert.ToDouble(splitline[12]);
                                    TempDat.BornTime      = ZeroHour.AddSeconds(bornsecs);
                                    TempDat.MagicNumbers  = ("[" + splitline[5]);
                                    TempDat.MagicNumbers += ("," + splitline[15] + "]");


                                    Fdata.Add(TempDat);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
                Console.WriteLine("Error reading snapfiles:");
                Console.WriteLine(e.Message);
            }
        }