Example #1
0
        Classes.Weather ReadWeatherFromForm()
        {
            Classes.Weather weather = new Classes.Weather();

            weather.Q1[(int)Classes.WeatherEnum2.Temp] = int.Parse(txtWeatherQ1Temp.Text);
            weather.Q1[(int)Classes.WeatherEnum2.Hum]  = int.Parse(txtWeatherQ1Hum.Text);
            weather.Q1[(int)Classes.WeatherEnum2.Rain] = int.Parse(txtWeatherQ1Rain.Text);
            weather.Q2[(int)Classes.WeatherEnum2.Temp] = int.Parse(txtWeatherQ2Temp.Text);
            weather.Q2[(int)Classes.WeatherEnum2.Hum]  = int.Parse(txtWeatherQ2Hum.Text);
            weather.Q2[(int)Classes.WeatherEnum2.Rain] = int.Parse(txtWeatherQ2Rain.Text);
            weather.R1[(int)Classes.WeatherEnum2.Temp] = int.Parse(txtWeatherR1Temp.Text);
            weather.R1[(int)Classes.WeatherEnum2.Hum]  = int.Parse(txtWeatherR1Hum.Text);
            weather.R1[(int)Classes.WeatherEnum2.Rain] = int.Parse(txtWeatherR1Rain.Text);
            weather.R2[(int)Classes.WeatherEnum2.Temp] = int.Parse(txtWeatherR2Temp.Text);
            weather.R2[(int)Classes.WeatherEnum2.Hum]  = int.Parse(txtWeatherR2Hum.Text);
            weather.R2[(int)Classes.WeatherEnum2.Rain] = int.Parse(txtWeatherR2Rain.Text);
            weather.R3[(int)Classes.WeatherEnum2.Temp] = int.Parse(txtWeatherR3Temp.Text);
            weather.R3[(int)Classes.WeatherEnum2.Hum]  = int.Parse(txtWeatherR3Hum.Text);
            weather.R3[(int)Classes.WeatherEnum2.Rain] = int.Parse(txtWeatherR3Rain.Text);
            weather.R4[(int)Classes.WeatherEnum2.Temp] = int.Parse(txtWeatherR4Temp.Text);
            weather.R4[(int)Classes.WeatherEnum2.Hum]  = int.Parse(txtWeatherR4Hum.Text);
            weather.R4[(int)Classes.WeatherEnum2.Rain] = int.Parse(txtWeatherR4Rain.Text);

            weather.Id = 1;

            return(weather);
        }
Example #2
0
        private void UpdateRaceSetup(short[] q1Setup)
        {
            Classes.Weather weather   = ReadWeatherFromForm();
            short           wingSplit = ReadWS();

            short[] raceSetup = GetRaceSetup(q1Setup, weather);

            lblRaceFWing.Text      = (raceSetup[0] + wingSplit).ToString();
            lblRaceRWing.Text      = (raceSetup[1] - wingSplit).ToString();
            lblRaceEngine.Text     = raceSetup[2].ToString();
            lblRaceBreaks.Text     = raceSetup[3].ToString();
            lblRaceGear.Text       = raceSetup[4].ToString();
            lblRaceSuspension.Text = raceSetup[5].ToString();
        }
Example #3
0
        void UpdateRaceTabWeather(Classes.Weather weather)
        {
            int raceTemp = (int)((weather.R1[(int)Classes.WeatherEnum2.Temp] +
                                  weather.R2[(int)Classes.WeatherEnum2.Temp] +
                                  weather.R3[(int)Classes.WeatherEnum2.Temp] +
                                  weather.R4[(int)Classes.WeatherEnum2.Temp]) / 4);
            int raceHum = (int)((weather.R1[(int)Classes.WeatherEnum2.Hum] +
                                 weather.R2[(int)Classes.WeatherEnum2.Hum] +
                                 weather.R3[(int)Classes.WeatherEnum2.Hum] +
                                 weather.R4[(int)Classes.WeatherEnum2.Hum]) / 4);

            txtRaceTemp.Text = raceTemp.ToString();
            txtRaceHum.Text  = raceHum.ToString();
        }
Example #4
0
        private void UpdateQ2Setup(short[] q1Setup)
        {
            Classes.Weather weather = ReadWeatherFromForm();

            short wingSplit = ReadWS();

            short[] q2Setup = GetQ2Setup(q1Setup, weather);

            lblQ2FWing.Text      = (q2Setup[0] + wingSplit).ToString();
            lblQ2RWing.Text      = (q2Setup[1] - wingSplit).ToString();
            lblQ2Engine.Text     = q2Setup[2].ToString();
            lblQ2Breaks.Text     = q2Setup[3].ToString();
            lblQ2Gear.Text       = q2Setup[4].ToString();
            lblQ2Suspension.Text = q2Setup[5].ToString();
        }
Example #5
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);
        }
Example #6
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);
        }
Example #7
0
        short[] GetQ2Setup(short[] q1Setup, Classes.Weather weather)
        {
            short[] q2Setup = new short[6];

            int temp1 = weather.Q1[(int)Classes.WeatherEnum2.Temp];
            int temp2 = weather.Q2[(int)Classes.WeatherEnum2.Temp];
            int rain  = weather.Q2[(int)Classes.WeatherEnum2.Rain] -
                        weather.Q1[(int)Classes.WeatherEnum2.Rain];

            q2Setup[0] = (short)(q1Setup[0] + (272 - 4.05 * temp1) * rain + 3.6 * (temp2 - temp1) * (1 - rain));
            q2Setup[1] = (short)(q1Setup[1] + (254 - 5.95 * temp1) * rain + 4.36 * (temp2 - temp1) * (1 - rain));
            q2Setup[2] = (short)(q1Setup[2] + (-190 + 3.7 * temp1) * rain - 4.26 * (temp2 - temp1) * (1 - rain));
            q2Setup[3] = (short)(q1Setup[3] + (105 - 2 * temp1) * rain + 6 * (temp2 - temp1) * (1 - rain));
            q2Setup[4] = (short)(q1Setup[4] + (-4 - 4 * temp1) * rain - 4 * (temp2 - temp1) * (1 - rain));
            q2Setup[5] = (short)(q1Setup[5] + (-257 + 5 * temp1) * rain - 6 * (temp2 - temp1) * (1 - rain));

            return(q2Setup);
        }
Example #8
0
        short[] GetRaceSetup(short[] q1Setup, Classes.Weather weather)
        {
            short[] raceSetup = new short[6];
            //Not yet implemented
            float tuneRaceSetup = 0.5f; //Best setup on: 0-beginning of the race; 1-end of the race

            int   temp1    = weather.Q1[(int)Classes.WeatherEnum2.Temp];
            int   tempRace = weather.GetRaceAvgTemp();
            float rain     = (weather.Q1[(int)Classes.WeatherEnum2.Rain] - weather.GetRaceAvgRain()) / 100;

            raceSetup[0] = (short)(q1Setup[0] + (272 - 4.05 * temp1) * rain + 3.6 * (tempRace - temp1) * (1 - rain));
            raceSetup[1] = (short)(q1Setup[1] + (254 - 5.95 * temp1) * rain + 4.36 * (tempRace - temp1) * (1 - rain));
            raceSetup[2] = (short)(q1Setup[2] + (-190 + 3.7 * temp1) * rain - 4.26 * (tempRace - temp1) * (1 - rain));
            raceSetup[3] = (short)(q1Setup[3] + (105 - 2 * temp1) * rain + 6 * (tempRace - temp1) * (1 - rain));
            raceSetup[4] = (short)(q1Setup[4] + (-4 - 4 * temp1) * rain - 4 * (tempRace - temp1) * (1 - rain));
            raceSetup[5] = (short)(q1Setup[5] + (-257 + 5 * temp1) * rain - 6 * (tempRace - temp1) * (1 - rain));

            return(raceSetup);
        }
Example #9
0
        private void txtRace_TextChanged(object sender, EventArgs e)
        {
            if (finishedLoading)
            {
                CreateDtRacingTimes();
                if (tabControl1.SelectedTab != tabControl1.TabPages[1]) //not in race tab
                {
                    Classes.Weather weather = ReadWeatherFromForm();
                    UpdateRaceTabWeather(weather);
                }

                //Update TDC
                float tdcConstant = float.Parse(dgvRaceTrack.Rows[0].Cells[16].Value.ToString());
                float raceTemp    = 0;
                float.TryParse(txtRaceTemp.Text, out raceTemp);
                float suppliersTdcConstant = ReadTyreFromSkillTab().TdcVariable;
                float tdc = (50f - raceTemp) * tdcConstant + suppliersTdcConstant;
                lblRaceTDC.Text = string.Format("{0:0.000} s", tdc); //tdc.ToString() + " s";

                txtRaceLaps_TextChanged(txtRaceLaps1, null);
                txtRaceLaps_TextChanged(txtRaceLaps2, null);
            }
        }
Example #10
0
        void FillWeather(Classes.Weather weather)
        {
            txtWeatherQ1Temp.Text = weather.Q1[(int)Classes.WeatherEnum2.Temp].ToString();
            txtWeatherQ1Hum.Text  = weather.Q1[(int)Classes.WeatherEnum2.Hum].ToString();
            txtWeatherQ1Rain.Text = weather.Q1[(int)Classes.WeatherEnum2.Rain].ToString();
            txtWeatherQ2Temp.Text = weather.Q2[(int)Classes.WeatherEnum2.Temp].ToString();
            txtWeatherQ2Hum.Text  = weather.Q2[(int)Classes.WeatherEnum2.Hum].ToString();
            txtWeatherQ2Rain.Text = weather.Q2[(int)Classes.WeatherEnum2.Rain].ToString();

            txtWeatherR1Temp.Text = weather.R1[(int)Classes.WeatherEnum2.Temp].ToString();
            txtWeatherR1Hum.Text  = weather.R1[(int)Classes.WeatherEnum2.Hum].ToString();
            txtWeatherR1Rain.Text = weather.R1[(int)Classes.WeatherEnum2.Rain].ToString();
            txtWeatherR2Temp.Text = weather.R2[(int)Classes.WeatherEnum2.Temp].ToString();
            txtWeatherR2Hum.Text  = weather.R2[(int)Classes.WeatherEnum2.Hum].ToString();
            txtWeatherR2Rain.Text = weather.R2[(int)Classes.WeatherEnum2.Rain].ToString();
            txtWeatherR3Temp.Text = weather.R3[(int)Classes.WeatherEnum2.Temp].ToString();
            txtWeatherR3Hum.Text  = weather.R3[(int)Classes.WeatherEnum2.Hum].ToString();
            txtWeatherR3Rain.Text = weather.R3[(int)Classes.WeatherEnum2.Rain].ToString();
            txtWeatherR4Temp.Text = weather.R4[(int)Classes.WeatherEnum2.Temp].ToString();
            txtWeatherR4Hum.Text  = weather.R4[(int)Classes.WeatherEnum2.Hum].ToString();
            txtWeatherR4Rain.Text = weather.R4[(int)Classes.WeatherEnum2.Rain].ToString();

            UpdateRaceTabWeather(weather);
        }