Ejemplo n.º 1
0
 void FillCar(Classes.Car car)
 {
     txtChassisLevel.Text     = car.ChassisLevel.ToString();
     txtChassisWear.Text      = car.ChassisWear.ToString();
     txtEngineLevel.Text      = car.EngineLevel.ToString();
     txtEngineWear.Text       = car.EngineWear.ToString();
     txtFWingLevel.Text       = car.FWingLevel.ToString();
     txtFWingWear.Text        = car.FWingWear.ToString();
     txtRWingLevel.Text       = car.RWingLevel.ToString();
     txtRWingWear.Text        = car.RWingWear.ToString();
     txtUnderbodyLevel.Text   = car.UnderbodyLevel.ToString();
     txtUnderbodyWear.Text    = car.UnderbodyWear.ToString();
     txtSidepodsLevel.Text    = car.SidepodsLevel.ToString();
     txtSidepodsWear.Text     = car.SidepodsWear.ToString();
     txtCoolingLevel.Text     = car.CoolingLevel.ToString();
     txtCoolingWear.Text      = car.CoolingWear.ToString();
     txtGearboxLevel.Text     = car.GearboxLevel.ToString();
     txtGearboxWear.Text      = car.GearboxWear.ToString();
     txtBrakesLevel.Text      = car.BrakesLevel.ToString();
     txtBrakesWear.Text       = car.BrakesWear.ToString();
     txtSuspensionLevel.Text  = car.SuspensionLevel.ToString();
     txtSuspensionWear.Text   = car.SuspensionWear.ToString();
     txtElectronicsLevel.Text = car.ElectronicsLevel.ToString();
     txtElectronicsWear.Text  = car.ElectronicsWear.ToString();
 }
Ejemplo n.º 2
0
        public void UpdateCarWear_Test()
        {
            Trace.WriteLine("UpdateCarWear initialized");

            //Assign
            Track  track    = Generator.TestTrack.GetTrack();
            Driver driver   = Generator.Driver.GetAverageDriver();
            int    CTRiskPc = 50;

            GOrganizer.Classes.Car car = Generator.Car.GetAverageCar();
            GOrganizer.Classes.Car expectedCarAfterWear = Generator.Car.GetAverageCar();

            expectedCarAfterWear.BrakesWear      = 57;
            expectedCarAfterWear.ChassisWear     = 25;
            expectedCarAfterWear.CoolingWear     = 21;
            expectedCarAfterWear.ElectronicsWear = 17;
            expectedCarAfterWear.EngineWear      = 43;
            expectedCarAfterWear.FWingWear       = 19;
            expectedCarAfterWear.GearboxWear     = 47;
            expectedCarAfterWear.RWingWear       = 24;
            expectedCarAfterWear.SidepodsWear    = 15;
            expectedCarAfterWear.SuspensionWear  = 38;
            expectedCarAfterWear.UnderbodyWear   = 18;

            //Act
            car.UpdateCarWearAfterRace(track, driver, CTRiskPc);

            //Assert
            //This should be the correct assertion, but doesn't match due to approximations
            //Assert.AreEqual(car, expectedCarAfterWear);
            Assert.AreEqual(car.BrakesWear, expectedCarAfterWear.BrakesWear);
        }
Ejemplo n.º 3
0
        public static GOrganizer.Classes.Car GetAverageCar()
        {
            GOrganizer.Classes.Car car = new GOrganizer.Classes.Car();

            car.BrakesLevel      = 5;
            car.ChassisLevel     = 5;
            car.CoolingLevel     = 5;
            car.ElectronicsLevel = 5;
            car.EngineLevel      = 5;
            car.FWingLevel       = 5;
            car.GearboxLevel     = 5;
            car.RWingLevel       = 5;
            car.SidepodsLevel    = 5;
            car.SuspensionLevel  = 5;
            car.UnderbodyLevel   = 5;

            car.BrakesWear      = 0;
            car.ChassisWear     = 0;
            car.CoolingWear     = 0;
            car.ElectronicsWear = 0;
            car.EngineWear      = 0;
            car.FWingWear       = 0;
            car.GearboxWear     = 0;
            car.RWingWear       = 0;
            car.SidepodsWear    = 0;
            car.SuspensionWear  = 0;
            car.UnderbodyWear   = 0;

            car.CCPoints          = 10;
            car.EngineeringPoints = 10;
            car.RDPoints          = 10;
            car.TestPoints        = 10;

            return(car);
        }
Ejemplo n.º 4
0
        public Classes.Car ReadCarFromForm()
        {
            Classes.Car car = new Classes.Car();

            car.BrakesLevel      = int.Parse(txtBrakesLevel.Text);
            car.BrakesWear       = int.Parse(txtBrakesWear.Text);;
            car.ChassisLevel     = int.Parse(txtChassisLevel.Text);
            car.ChassisWear      = int.Parse(txtChassisWear.Text);
            car.CoolingLevel     = int.Parse(txtCoolingLevel.Text);
            car.CoolingWear      = int.Parse(txtCoolingWear.Text);
            car.ElectronicsLevel = int.Parse(txtElectronicsLevel.Text);
            car.ElectronicsWear  = int.Parse(txtElectronicsWear.Text);
            car.EngineLevel      = int.Parse(txtEngineLevel.Text);
            car.EngineWear       = int.Parse(txtEngineWear.Text);
            car.FWingLevel       = int.Parse(txtFWingLevel.Text);
            car.FWingWear        = int.Parse(txtFWingWear.Text);
            car.GearboxLevel     = int.Parse(txtGearboxLevel.Text);
            car.GearboxWear      = int.Parse(txtGearboxWear.Text);
            car.RWingLevel       = int.Parse(txtRWingLevel.Text);
            car.RWingWear        = int.Parse(txtRWingWear.Text);
            car.SidepodsLevel    = int.Parse(txtSidepodsLevel.Text);
            car.SidepodsWear     = int.Parse(txtSidepodsWear.Text);
            car.SuspensionLevel  = int.Parse(txtSuspensionLevel.Text);
            car.SuspensionWear   = int.Parse(txtSuspensionWear.Text);
            car.UnderbodyLevel   = int.Parse(txtUnderbodyLevel.Text);
            car.UnderbodyWear    = int.Parse(txtUnderbodyWear.Text);

            car.Id = 1;

            return(car);
        }
Ejemplo n.º 5
0
        private void txtRaceLaps_TextChanged(object sender, EventArgs e)
        {
            if (finishedLoading)
            {
                int customLaps;

                if (!int.TryParse(((TextBox)sender).Text, out customLaps))
                {
                    customLaps = 0;
                }

                int fuelConsumption = 0;
                int tyreWear        = 0;

                //Get Track details
                int   distanceKm   = int.Parse(dgvRaceTrack.Rows[0].Cells["DistanceKm"].Value.ToString());
                int   trackLaps    = int.Parse(dgvRaceTrack.Rows[0].Cells["Laps"].Value.ToString());
                float fuelConstant = float.Parse(dgvRaceTrack.Rows[0].Cells["Fuel Constant"].Value.ToString());

                float lapDistance = distanceKm / trackLaps;

                Classes.Driver  driver = ReadDriverFromForm();
                Classes.Car     car    = ReadCarFromForm();
                Classes.RaceTab rt     = ReadRaceTabFromForm();

                //If dry lap, perhaps adding a bool argument for rain in future
                fuelConsumption = (int)Classes.Fuel.ConsumptionDryLap(lapDistance, fuelConstant,
                                                                      (byte)(car.EngineLevel), (byte)car.ElectronicsLevel,
                                                                      (byte)driver.Experience, (byte)driver.TechnicalInsight, (byte)driver.Aggressiveness);

                int   stintDistance = (int)(customLaps * lapDistance);
                float tyreDistance  = TyreDistance(
                    DB.Track.ReadTrackFromDB(rt.SeasonTrackIndex),
                    ReadTyreFromSkillTab(),
                    driver,
                    car,
                    rt);

                tyreWear = (int)(stintDistance / tyreDistance * 100);

                if (((TextBox)sender).Name == "txtRaceLaps1")
                {
                    lblRaceFuel1.Text = (fuelConsumption * customLaps).ToString();
                    lblRaceTyre1.Text = tyreWear.ToString() + "%";
                }
                else
                {
                    lblRaceFuel2.Text = (fuelConsumption * customLaps).ToString();
                    lblRaceTyre2.Text = tyreWear.ToString() + "%";
                }
            }
        }
Ejemplo n.º 6
0
        float GetFuelPerLap(Classes.Track track, Classes.Car car, Classes.Driver driver, float lapDistance)
        {
            double fuelPerLap = lapDistance / (
                track.FuelConstant +
                car.EngineLevel * 0.028 +
                car.ElectronicsLevel * 0.01 +
                driver.Experience * 0.00025 +
                driver.TechnicalInsight * 0.0005 -
                driver.Aggressiveness * 0.00015
                ); //for dry races

            return((float)fuelPerLap);
        }
Ejemplo n.º 7
0
        public void UpdateCarWearAfterTesting_Test()
        {
            GOrganizer.Classes.Car car = Generator.Car.GetAverageCar();
            GOrganizer.Classes.Car expectedCarAfterTesting = Generator.Car.GetAverageCar();
            expectedCarAfterTesting.BrakesWear      = 10;
            expectedCarAfterTesting.ChassisWear     = 10;
            expectedCarAfterTesting.CoolingWear     = 10;
            expectedCarAfterTesting.ElectronicsWear = 10;
            expectedCarAfterTesting.EngineWear      = 10;
            expectedCarAfterTesting.FWingWear       = 10;
            expectedCarAfterTesting.GearboxWear     = 10;
            expectedCarAfterTesting.RWingWear       = 10;
            expectedCarAfterTesting.SidepodsWear    = 10;
            expectedCarAfterTesting.SuspensionWear  = 10;
            expectedCarAfterTesting.UnderbodyWear   = 10;

            car.Up
        }
Ejemplo n.º 8
0
        void SaveSkills()//testing car
        {
            //Read values from form
            Classes.Car               car     = ReadCarFromForm();
            Classes.Driver            driver  = ReadDriverFromForm();
            Classes.TechnicalDirector td      = ReadTdFromForm();
            Classes.StaffFacilities   sf      = ReadSfFromForm();
            Classes.Weather           weather = ReadWeatherFromForm();
            int activeTyreCode = GetTyreCodeFromSkillTab();

            //Call the Save methods
            DB.Car.UpdateCarToDb(car);
            DB.Driver.UpdateDriverToDb(driver);
            DB.TechnicalDirector.UpdateTdToDb(td);
            DB.StaffFacilities.UpdateStaffFacilitiesToDb(sf);
            DB.Weather.UpdateWeatherToDb(weather);
            DB.Tyres.UpdateTyreToDb(activeTyreCode);
        }
Ejemplo n.º 9
0
        void InitiateSkillsTab()
        {
            Classes.Driver driver = DB.Driver.ReadDriverFromDB();
            FillDriver(driver);
            Classes.Car car = DB.Car.ReadCarFromDB();
            FillCar(car);
            Classes.TechnicalDirector td = DB.TechnicalDirector.ReadTdFromDB();
            FillTd(td);
            Classes.StaffFacilities sf = DB.StaffFacilities.ReadStaffFacilitiesFromDB();
            FillStaffFacilities(sf);
            UpdateStaffAndFacilitiesCost(sf);
            Classes.Weather w = DB.Weather.ReadWeatherFromDB();
            FillWeather(w);
            int activeTyreSupplierId = DB.ActiveTyreSupplier.GetTyreSupplierId();

            Classes.TyresSupplier tyre = DB.Tyres.ReadTyreFromSupplierDB(activeTyreSupplierId);
            FillActiveTyreSupplier(tyre);
        }
Ejemplo n.º 10
0
        float TyreDistance(Classes.Track track, Classes.TyresSupplier tyre, Classes.Driver driver, Classes.Car car,
                           Classes.RaceTab rt)
        {
            double tyreDistance = 1 / (
                0.008f +
                (int)track.TyresWear * 0.0011357f +
                rt.Temp * 0.000117f +
                tyre.Durability * -0.0003848391f +
                rt.Compound * -0.0022681289f +
                driver.Aggressiveness * 1.98713674683317E-06f +
                driver.Experience * -1.98047770495874E-06f +
                car.SuspensionLevel * -0.0001644978f +
                rt.CT * 2.58125503524434E-05f
                );

            return((float)tyreDistance);
        }
Ejemplo n.º 11
0
 float TyreDistance(Classes.Track track, Classes.TyresSupplier tyre, Classes.Driver driver, Classes.Car car,
                    Classes.RaceTab rt, int compoundCode)
 {
     rt.Compound = compoundCode;
     return(TyreDistance(track, tyre, driver, car, rt));
 }
Ejemplo n.º 12
0
        void FillDgvRacingTimes()
        {
            //For Styling
            int[,] tyreWearArray = new int[5, 5]; //row, col

            Classes.RaceTab rt      = ReadRaceTabFromForm();
            int             trackId = DB.SeasonTrack.GetTrackId(rt.SeasonTrackIndex + 1);

            Classes.Track track = DB.Track.ReadTrackFromDB(trackId);

            int supplierId = DB.ActiveTyreSupplier.GetTyreSupplierId();

            Classes.TyresSupplier tyre = DB.Tyres.ReadTyreFromSupplierDB(supplierId);

            Classes.Car car = finishedLoading ?
                              ReadCarFromForm() :
                              DB.Car.ReadCarFromDB();
            Classes.Driver driver = finishedLoading ?
                                    ReadDriverFromForm() :
                                    DB.Driver.ReadDriverFromDB();

            float lapDistance = (float)track.DistanceKm / track.Laps;
            float totalFuel   = GetFuelPerLap(track, car, driver, lapDistance) * track.Laps;

            float pitStopDriveTime = track.PitStopTime;
            float baseTime         = track.baseTime;
            float tdc = track.TDCConstant * rt.Temp + tyre.TdcVariable;

            string[] o = new string[6];
            for (int line = 0; line < 7; line++)
            {
                switch (line)
                {
                case 0:
                    o[0] = "XSoft";
                    break;

                case 1:
                    o[0] = "Soft";
                    break;

                case 2:
                    o[0] = "Medium";
                    break;

                case 3:
                    o[0] = "Hard";
                    break;

                case 4:
                    o[0] = "Rain";
                    break;

                case 5:
                    o[0] = "Fuel";
                    break;

                case 6:
                    o[0] = "Laps/stop";
                    break;

                default:
                    o[0] = "Error";
                    break;
                }

                for (int nStops = 0; nStops < 5; nStops++)
                {
                    float stintDistance = (float)track.DistanceKm / (nStops + 1);
                    if (line < 4) //Race Time
                    {
                        string raceTime     = "";
                        float  tyreDistance = TyreDistance(track, tyre, driver, car, rt, line);
                        float  tyreWear     = stintDistance / tyreDistance * 100;
                        if (tyreDistance > stintDistance)
                        {
                            int fuelPerStint = (int)(totalFuel / (1 + nStops));
                            raceTime = CalculateTotalRaceTime(nStops, fuelPerStint, track, tdc, tyre.WarmUpDistance,
                                                              line, rt.Rain, rt.CT).ToString("0");
                        }
                        tyreWearArray[line, nStops] = (int)tyreWear;
                        o[nStops + 1] = raceTime;
                    }
                    else if (line == 5) //Fuel
                    {
                        int    fuelPerStint = (int)(totalFuel / (1 + nStops));
                        string fuel         = string.Format("{0:###.#}", fuelPerStint);
                        o[nStops + 1] = fuel;
                    }
                    else if (line == 6) // Laps / Stint
                    {
                        string laps = string.Format("{0:##.#}", track.Laps / (nStops + 1));
                        o[nStops + 1] = laps;
                    }
                }
                dtRacingTimes.Rows.Add(o);
            }


            dgvRacingTimes.DataSource = dtRacingTimes;

            foreach (DataGridViewColumn col in dgvRacingTimes.Columns)
            {
                col.Width = 45;
            }

            PaintDgvRacingTimesCells(tyreWearArray);
        }