Exemple #1
0
        //Classes.TyresSupplier ReadTyreFromUpdateTab()
        //{
        //    Classes.TyresSupplier tyre = new Classes.TyresSupplier();

        //    tyre.Supplier = (Classes.TyreSuppliers)tyre.GetSupplierCodeFromName(cBoxTyresSuppliers.Text);

        //    return tyre;
        //}
        int GetTyreCodeFromSkillTab()
        {
            Classes.TyresSupplier tyre = ReadTyreFromSkillTab();

            //int tyreCode = tyre.GetSupplierCodeFromName(cBoxTyresSuppliers.Text);
            int tyreCode = tyre.GetSupplierCodeFromName(tyre.Supplier.ToString());

            return(tyreCode);
        }
Exemple #2
0
        Classes.TyresSupplier ReadTyreFromSkillTab()
        {
            Classes.TyresSupplier tyre = new Classes.TyresSupplier();

            string tyreSupplier = cBoxSkillsTyresSupplier.Text;

            tyre = DB.Tyres.ReadTyreFromDB(tyreSupplier);

            return(tyre);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
0
 void FillActiveTyreSupplier(Classes.TyresSupplier tyre)
 {
     //int tyreSupplierId = DB.ActiveTyreSupplier.GetTyreSupplierId();
     cBoxSkillsTyresSupplier.Text = tyre.GetActiveSupplierName();
 }
Exemple #6
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));
 }
Exemple #7
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);
        }