Пример #1
0
        public void newGraph(Race r)
        {
            race = r;

            drivers.Items.Clear();
            drivers.Items.Add("All");
            drivers.SelectedIndex = 0;
            for (int i = 1; i < 21; i++)
                drivers.Items.Add(r.laps[1].d[i].name);
            lap = race.counter;
        }
Пример #2
0
        public dGraph(Race r)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            newRace(r);
        }
Пример #3
0
        private Boolean LoadXML(String path)
        {
            DebugLog.writeSeparator();
            DebugLog.writeString("Loading xml", path);

            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(path);
            message = "";
            try
            {
                XmlNode root = null;
                foreach (XmlNode n in xDoc.ChildNodes)
                    if (n.Name.ToLower() == "telemetry")
                    {
                        root = n;
                        break;
                    }

                Decimal version = 0;
                String application = "";
                ReadXMLVersion(root, ref version, ref application);
                DebugLog.writeString("Version", version.ToString());
                if (version < 1 || application != "f1-tm")
                    return false;

                XmlNode raceNode = FindXMLChildNode(root, "Race");
                List<XmlNode> laps = FindXMLChildNodes(raceNode, "Lap");
                XmlAttribute lapsCountAtt = FindXMLAttribute(raceNode, "Laps");
                DebugLog.writeString("LapsCount", laps.Count.ToString());
                if (laps.Count != Convert.ToInt32(lapsCountAtt.Value))
                    return false;

                race = new Race(laps.Count + 1);
                maxLap = laps.Count;

                Boolean loadedDriverTeams = false;
                foreach (XmlNode lap in laps)
                {
                    List<XmlNode> rows = FindXMLChildNodes(lap, "Row");
                    if (!loadedDriverTeams)
                    {
                        foreach (XmlNode Row in rows)
                        {
                            String Name = CleanUp(FindXMLChildNode(Row, "Driver").InnerText);
                            String Team = CleanUp(FindXMLChildNode(Row, "Team").InnerText);

                            race.driver_team.AddDriver(Name, Team);
                        }

                        //list1.Items.Clear();
                        //list2.Items.Clear();

                        //list2.Items.AddRange(race.driver_team.getDrivers());
                        //list1.Items.AddRange(race.driver_team.getTeams());

                        loadedDriverTeams = true;
                    }

                    foreach (XmlNode Row in rows)
                    {
                        int lapNo = Convert.ToInt32(FindXMLAttribute(lap, "Number").Value);
                        int Position = Convert.ToInt32(CleanUp(FindXMLChildNode(Row, "Position").InnerText));
                        String Name = CleanUp(FindXMLChildNode(Row, "Driver").InnerText);
                        String Team = CleanUp(FindXMLChildNode(Row, "Team").InnerText);
                        String Time = CleanUp(FindXMLChildNode(Row, "LapTime").InnerText);
                        String Distance = CleanUp(FindXMLChildNode(Row, "Distance").InnerText);
                        String PitTime = CleanUp(FindXMLChildNode(Row, "PitStopTime").InnerText);
                        String Mistake = CleanUp(FindXMLChildNode(Row, "Mistake").InnerText);
                        String Message = CleanUp(FindXMLChildNode(Row, "Message").InnerText);
                        race.assign(lapNo, Position, Name, Team, Time, Distance, PitTime, Mistake, Message);
                    }
                }

                DebugLog.writeString("Laps read");

                XmlNode pitNode = FindXMLChildNode(root, "PitStops");
                if (pitNode != null)
                {
                    List<XmlNode> stops = FindXMLChildNodes(pitNode, "Stop");
                    if (stops.Count > 0)
                        race.pitstops.PitsPresent = true;

                    foreach (XmlNode stop in stops)
                    {
                        String LapNumber = CleanUp(FindXMLChildNode(stop, "LapNumber").InnerText);
                        String Driver = CleanUp(FindXMLChildNode(stop, "Driver").InnerText);
                        String Team = CleanUp(FindXMLChildNode(stop, "Team").InnerText);
                        String Tyres = CleanUp(FindXMLChildNode(stop, "Tyres").InnerText);
                        String Fuel = CleanUp(FindXMLChildNode(stop, "Fuel").InnerText);
                        String Mistake = CleanUp(FindXMLChildNode(stop, "Mistake").InnerText);
                        String Total = CleanUp(FindXMLChildNode(stop, "Total").InnerText);

                        if (race.AddPit(LapNumber, Driver, Team, Tyres, Fuel, Mistake, Total) == false)
                        {
                            message += "Non fatal error in file format in pits stop section. Pit stop information will be unavailable\n";
                            race.pitstops.PitsPresent = false;
                            break;
                        }
                    }
                }

                DebugLog.writeString("Pits read");

                XmlNode wearNode = FindXMLChildNode(root, "CarWear");
                if (wearNode != null)
                {
                    List<XmlNode> cars = FindXMLChildNodes(wearNode, "Car");
                    if (cars.Count > 0)
                        race.WearPresent = true;

                    for (int i = 0; i < cars.Count; i++)
                    {
                        List<XmlNode> parts = FindXMLChildNodes(cars[i], "Part");
                        int carNo = Convert.ToInt32(FindXMLAttribute(cars[i], "DriverNumber").Value);

                        foreach (XmlNode part in parts)
                        {
                            String Name = CleanUp(FindXMLChildNode(part, "Name").InnerText);
                            String Wear = CleanUp(FindXMLChildNode(part, "Wear").InnerText);
                            String Reliability = CleanUp(FindXMLChildNode(part, "Reliability").InnerText);

                            if (race.AddCarWear(carNo, Name, Wear, Reliability) == false)
                            {
                                message += ("Non fatal error in file format in pits stop section. Pit stop information will be unavailable\n");
                                race.WearPresent = false;
                                break;
                            }
                        }
                    }

                    DebugLog.writeString("Wear read");

                    race.Car1Wear.Sort(CompareCarWearNames);
                    race.Car2Wear.Sort(CompareCarWearNames);
                }

                DebugLog.writeString("Done reading");
                DebugLog.writeSeparator();
            }
            catch (Exception ex)
            {
                message += ("Error in file format:\n" + ex.Message);
                DebugLog.writeString("Message Returned", message);
                DebugLog.writeError(ex);
                return false;
            }

            return true;
        }
Пример #4
0
 public void newPitstop(Race r)
 {
     race = r;
     driversList.Items.Clear();
     driversList.Items.AddRange(race.driver_team.getDrivers());
 }
Пример #5
0
 public pitStops(Race r)
 {
     InitializeComponent();
     newPitstop(r);
 }
Пример #6
0
        public void newRace(Race r)
        {
            race = r;

            drivers.Items.Clear();
            for (int i = 1; i < 21; i++)
                drivers.Items.Add(r.laps[1].d[i].name);
            drivers.SelectedIndex = 0;

            lap = race.counter;

            float[] t;
            string name = race.laps[1].d[1].name;
            string team = race.laps[1].d[1].team;
            best = new string[21];
            bestLaps = new int[21];
            worst = new string[21];
            worstLaps = new int[21];
            int max = 1, min = 1;
            int[] maxs = new int[21];
            int[] mins = new int[21];
            for (int d = 1; d < 21; d++)
            {
                t = new float[lap];
                for (int c = 1; c < lap; c++)
                {
                    t[c] = new float();
                    name = race.laps[1].d[d].name;
                    team = race.laps[1].d[d].team;
                    float time = race.laps[c].getConvertedTime(name, team);
                    t[c] = time;
                    if (t[max] < t[c])
                        max = c;
                    if ((t[min] > t[c] || c == 1) && time != -1)
                        min = c;
                }
                //best[d] = new string();
                bestLaps[d] = new int();
                bestLaps[d] = min;
                best[d] = race.laps[min].getLapTime(name, team);
                float t1 = Lap.ConvertTime(best[d]);
                if (Lap.ConvertTime(best[rmin]) > t1 && Lap.ConvertTime(best[d]) != -1)
                    rmin = d;
                //worst[d] = new string();
                worstLaps[d] = new int();
                worstLaps[d] = max;
                worst[d] = race.laps[max].getLapTime(name, team);
                float t2 = Lap.ConvertTime(worst[d]);
                if (Lap.ConvertTime(worst[rmax]) < t2)
                    rmax = d;
            }
            lb1.Text = "Race Quickest Lap Time: " + best[rmin];
            lb2.Text = "Race Slowest Lap Time: " + worst[rmax];
        }
Пример #7
0
 public void newPitstop(Race r)
 {
     race = r;
     driversList.Items.Clear();
     driversList.Items.AddRange(race.driver_team.getDrivers());
 }
Пример #8
0
 public pitStops(Race r)
 {
     InitializeComponent();
     newPitstop(r);
 }