Get() public method

public Get ( double throttle, double ratio ) : double
throttle double
ratio double
return double
Esempio n. 1
0
        private void Fire_LS(object o)
        {
            try
            {
                ICar car = Telemetry.m.Sim.Garage.SearchCar(Telemetry.m.Sim.Drivers.Player.CarClass,
                                                            Telemetry.m.Sim.Drivers.Player.CarModel);
                car.Scan();
                car.ScanGeneral();
                car.ScanEngine();

                GameData_LS package = new GameData_LS();

                /** TYRE TEMPERATURES **/
                try
                {
                    if (Telemetry.m.Sim.Player.Tyre_Temperature_LF_Middle > 0)
                    {
                        package.TyreTemperature_LF = Convert.ToByte(Limits(Telemetry.m.Sim.Player.Tyre_Temperature_LF_Middle - 273.16, 0, 150));
                        package.TyreTemperature_RF = Convert.ToByte(Limits(Telemetry.m.Sim.Player.Tyre_Temperature_RF_Middle - 273.16, 0, 150));
                        package.TyreTemperature_LR = Convert.ToByte(Limits(Telemetry.m.Sim.Player.Tyre_Temperature_LR_Middle - 273.16, 0, 150));
                        package.TyreTemperature_RR = Convert.ToByte(Limits(Telemetry.m.Sim.Player.Tyre_Temperature_RR_Middle - 273.16, 0, 150));
                    }
                }
                catch (Exception ex)
                { }
                /** TYRE & BRAKE WEAR **/
                // package.TyreWear_F = Convert.ToByte(200 * Limits(Telemetry.m.Sim.Drivers.Player.Wheel_LeftFront.Wear + Telemetry.m.Sim.Drivers.Player.Wheel_RightFront.Wear, 0, 2) / 2.0);
                //package.TyreWear_R = Convert.ToByte(200 * Limits(Telemetry.m.Sim.Drivers.Player.Wheel_LeftRear.Wear + Telemetry.m.Sim.Drivers.Player.Wheel_RightRear.Wear, 0, 2) / 2.0);
                package.BrakeWear_F = 0;
                package.BrakeWear_R = 0;

                /** CURRENT FUEL INFO **/
                package.Fuel_Litre = Convert.ToUInt16(Limits(Telemetry.m.Sim.Player.Fuel, 0, 150) * 10);
                package.Fuel_Laps  = 0;

                /** DRIVING TIMES **/
                package.Laptime_Last = Convert.ToSingle(Limits(Telemetry.m.Sim.Drivers.Player.LapTime_Last, 0, 1200));
                package.Laptime_Best = Convert.ToSingle(Limits(Telemetry.m.Sim.Drivers.Player.LapTime_Best, 0, 1200));
                switch (Telemetry.m.Sim.Drivers.Player.SectorsDriven % 3)
                {
                case 0:
                    package.Split_Sector = Telemetry.m.Sim.Drivers.Player.Sector_3_Last - Telemetry.m.Sim.Drivers.Player.Sector_3_Best;
                    break;

                case 1:
                    package.Split_Sector = Telemetry.m.Sim.Drivers.Player.Sector_1_Last - Telemetry.m.Sim.Drivers.Player.Sector_1_Best;
                    break;

                case 2:
                    package.Split_Sector = Telemetry.m.Sim.Drivers.Player.Sector_2_Last - Telemetry.m.Sim.Drivers.Player.Sector_2_Best;
                    break;
                }
                package.Split_Sector = Convert.ToSingle(Limits(package.Split_Sector, -2, 2));
                package.Split_Lap    = Telemetry.m.Sim.Drivers.Player.LapTime_Best - Telemetry.m.Sim.Drivers.Player.LapTime_Last;
                package.Split_Lap    = Convert.ToSingle(Limits(package.Split_Lap, -2, 2));

                package.RaceTime   = (float)Limits(Telemetry.m.Sim.Session.Time - 30, 0, 3600);
                package.RaceLength = 3600;

                SendPackage(DashboardPackages.PACK_GAMEDATA_LS, ByteMethods.ToBytes(package));

                /*** Temporarely do cardata here as well ***/
                CarData cardata = new CarData();

                cardata.RPM_Max  = Convert.ToUInt16(Limits(Telemetry.m.Sim.Player.Engine_RPM_Max_Live, 200, 25000) - 200);
                cardata.RPM_Idle = Convert.ToUInt16(Limits(car.Engine.IdleRPM * rads_to_rpm, 0, 7000));
                cardata.RPM_Idle = 1000;

                //cardata.HP_Max = Convert.ToUInt16(EngineCurve.GetMaxHP());
                cardata.Gears = (byte)Limits(car.Gearbox.Gears, 0, 10);
                //cardata.Fuel_Max = (byte)Limits(car.General.Fueltank,0,100);
                cardata.Fuel_Max   = 100;
                cardata.GearRatio0 = Convert.ToSingle(Limits(GetGearRatio_Pure(0), 0, 20));
                cardata.GearRatio1 = Convert.ToSingle(Limits(GetGearRatio_Pure(1), 0, 20));
                cardata.GearRatio2 = Convert.ToSingle(Limits(GetGearRatio_Pure(2), 0, 20));
                cardata.GearRatio3 = Convert.ToSingle(Limits(GetGearRatio_Pure(3), 0, 20));
                cardata.GearRatio4 = Convert.ToSingle(Limits(GetGearRatio_Pure(4), 0, 20));
                cardata.GearRatio5 = Convert.ToSingle(Limits(GetGearRatio_Pure(5), 0, 20));
                cardata.GearRatio6 = Convert.ToSingle(Limits(GetGearRatio_Pure(6), 0, 20));
                cardata.GearRatio7 = Convert.ToSingle(Limits(GetGearRatio_Pure(7), 0, 20));


                //if (Telemetry.m.Sim.Name == "GTR2") // messy bugfix

                /*
                 * {
                 *  cardata.GearRatio0 = 12.0f;
                 *  cardata.GearRatio1 = cardata.GearRatio0 * 0.85f;
                 *  cardata.GearRatio2 = cardata.GearRatio1 * 0.85f;
                 *  cardata.GearRatio3 = cardata.GearRatio2 * 0.85f;
                 *  cardata.GearRatio4 = cardata.GearRatio3 * 0.85f;
                 *  cardata.GearRatio5 = cardata.GearRatio4 * 0.85f;
                 *  cardata.GearRatio6 = cardata.GearRatio5 * 0.85f;
                 * }*/
                ShiftRpm r = new ShiftRpm();
                cardata.RPM_Shift0 = cardata.RPM_Max;
                cardata.RPM_Shift1 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(1)));
                cardata.RPM_Shift2 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(2)));
                cardata.RPM_Shift3 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(3)));
                cardata.RPM_Shift4 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(4)));
                cardata.RPM_Shift5 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(5)));
                cardata.RPM_Shift6 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(6)));

                /*ShiftRpm r = new ShiftRpm();
                 * cardata.RPM_Shift0 = cardata.RPM_Max;
                 * cardata.RPM_Shift1 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
                 * cardata.RPM_Shift2 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
                 * cardata.RPM_Shift3 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
                 * cardata.RPM_Shift4 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
                 * cardata.RPM_Shift5 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
                 * cardata.RPM_Shift6 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
                 * cardata.RPM_Shift7 = (ushort)Limits(cardata.RPM_Max, 0, 25000);*/

                SendPackage(DashboardPackages.PACK_CARDATA, ByteMethods.ToBytes(cardata));

                // Send leds config..
                //return;
                string[] leds = System.IO.File.ReadAllLines("LEDs.csv");
                byte[]   bf   = new byte[leds.Length * 9 + 1];
                bf[0] = 0;
                int i = 1;
                int k = 0;
                foreach (string led in leds)
                {
                    string[] data = led.Split(",".ToCharArray());

                    bf[i]     = (byte)(Convert.ToByte(data[4]));
                    bf[i + 1] = (byte)(Convert.ToByte(data[1]));
                    bf[i + 2] = (byte)(Convert.ToByte(data[2]));
                    bf[i + 3] = (byte)(Convert.ToByte(data[3]));
                    byte[] bf_tmp = BitConverter.GetBytes(0);
                    bf[i + 4] = bf_tmp[0];
                    bf[i + 5] = bf_tmp[1];
                    bf[i + 6] = 64;
                    bf[i + 7] = Convert.ToByte(k * 50 / 16);
                    bf[i + 8] = 255;

                    i += 9;
                    k++;
                }
                string t = BitConverter.ToString(bf);
                SendPackage(DashboardPackages.PACK_PREFS_SHIFTBAR, bf);

                /*
                 * bf = new byte[leds.Length * 9 + 1];
                 * bf[0] = 1;
                 * i = 1;
                 * k = 0;
                 * foreach (string led in leds)
                 * {
                 * string[] data = led.Split(",".ToCharArray());
                 *
                 * bf[i] = 0;
                 * bf[i + 1] = 5;
                 * bf[i + 2] = 0;
                 * bf[i + 3] = 5;
                 * byte[] bf_tmp = BitConverter.GetBytes(600);
                 * bf[i + 4] = bf_tmp[0];
                 * bf[i + 5] = bf_tmp[1];
                 * bf[i + 6] = 50;
                 * bf[i + 7] = Convert.ToByte(((k % 2 == 0) ? 50 : 0));
                 * bf[i + 8] = 200;
                 *
                 * i += 9;
                 * k++;
                 * }
                 * SendPackage(DashboardPackages.PACK_PREFS_SHIFTBAR, bf);
                 */
            }
            catch (Exception ex)
            { }
            return;
        }
Esempio n. 2
0
        private void Fire_LS(object o)
        {
            try
            {
                ICar car = Telemetry.m.Sim.Garage.SearchCar(Telemetry.m.Sim.Drivers.Player.CarClass,
                                                 Telemetry.m.Sim.Drivers.Player.CarModel);
                car.Scan();
                car.ScanGeneral();
                car.ScanEngine();

            GameData_LS package = new GameData_LS();

            /** TYRE TEMPERATURES **/
            try
            {
                if (Telemetry.m.Sim.Player.Tyre_Temperature_LF_Middle > 0)
                {
                    package.TyreTemperature_LF = Convert.ToByte(Limits(Telemetry.m.Sim.Player.Tyre_Temperature_LF_Middle - 273.16, 0, 150));
                    package.TyreTemperature_RF = Convert.ToByte(Limits(Telemetry.m.Sim.Player.Tyre_Temperature_RF_Middle - 273.16, 0, 150));
                    package.TyreTemperature_LR = Convert.ToByte(Limits(Telemetry.m.Sim.Player.Tyre_Temperature_LR_Middle - 273.16, 0, 150));
                    package.TyreTemperature_RR = Convert.ToByte(Limits(Telemetry.m.Sim.Player.Tyre_Temperature_RR_Middle - 273.16, 0, 150));
                }
            }
            catch (Exception ex)
            { }
            /** TYRE & BRAKE WEAR **/
            // package.TyreWear_F = Convert.ToByte(200 * Limits(Telemetry.m.Sim.Drivers.Player.Wheel_LeftFront.Wear + Telemetry.m.Sim.Drivers.Player.Wheel_RightFront.Wear, 0, 2) / 2.0);
            //package.TyreWear_R = Convert.ToByte(200 * Limits(Telemetry.m.Sim.Drivers.Player.Wheel_LeftRear.Wear + Telemetry.m.Sim.Drivers.Player.Wheel_RightRear.Wear, 0, 2) / 2.0);
            package.BrakeWear_F = 0;
            package.BrakeWear_R = 0;

            /** CURRENT FUEL INFO **/
            package.Fuel_Litre = Convert.ToUInt16(Limits(Telemetry.m.Sim.Player.Fuel, 0, 150) * 10);
            package.Fuel_Laps = 0;

            /** DRIVING TIMES **/
            package.Laptime_Last = Convert.ToSingle(Limits(Telemetry.m.Sim.Drivers.Player.LapTime_Last,0,1200));
            package.Laptime_Best = Convert.ToSingle(Limits(Telemetry.m.Sim.Drivers.Player.LapTime_Best,0,1200));
            switch (Telemetry.m.Sim.Drivers.Player.SectorsDriven % 3)
            {
                case 0:
                    package.Split_Sector = Telemetry.m.Sim.Drivers.Player.Sector_3_Last - Telemetry.m.Sim.Drivers.Player.Sector_3_Best;
                    break;
                case 1:
                    package.Split_Sector = Telemetry.m.Sim.Drivers.Player.Sector_1_Last - Telemetry.m.Sim.Drivers.Player.Sector_1_Best;
                    break;
                case 2:
                    package.Split_Sector = Telemetry.m.Sim.Drivers.Player.Sector_2_Last - Telemetry.m.Sim.Drivers.Player.Sector_2_Best;
                    break;

            }
            package.Split_Sector = Convert.ToSingle(Limits(package.Split_Sector, -2, 2));
            package.Split_Lap = Telemetry.m.Sim.Drivers.Player.LapTime_Best - Telemetry.m.Sim.Drivers.Player.LapTime_Last;
            package.Split_Lap = Convert.ToSingle(Limits(package.Split_Lap, -2, 2));

            package.RaceTime = (float)Limits(Telemetry.m.Sim.Session.Time - 30, 0, 3600);
            package.RaceLength = 3600;

            SendPackage(DashboardPackages.PACK_GAMEDATA_LS, ByteMethods.ToBytes(package));

            /*** Temporarely do cardata here as well ***/
            CarData cardata = new CarData();

            cardata.RPM_Max = Convert.ToUInt16(Limits(Telemetry.m.Sim.Player.Engine_RPM_Max_Live ,200,25000)-200);
            cardata.RPM_Idle = Convert.ToUInt16(Limits(car.Engine.IdleRPM * rads_to_rpm, 0, 7000));
                cardata.RPM_Idle = 1000;

            //cardata.HP_Max = Convert.ToUInt16(EngineCurve.GetMaxHP());
            cardata.Gears = (byte)Limits(car.Gearbox.Gears,0, 10);
            //cardata.Fuel_Max = (byte)Limits(car.General.Fueltank,0,100);
                cardata.Fuel_Max = 100;
            cardata.GearRatio0 = Convert.ToSingle(Limits(GetGearRatio_Pure(0),0,20));
            cardata.GearRatio1 = Convert.ToSingle(Limits(GetGearRatio_Pure(1),0,20));
            cardata.GearRatio2 = Convert.ToSingle(Limits(GetGearRatio_Pure(2),0,20));
            cardata.GearRatio3 = Convert.ToSingle(Limits(GetGearRatio_Pure(3),0,20));
            cardata.GearRatio4 = Convert.ToSingle(Limits(GetGearRatio_Pure(4),0,20));
            cardata.GearRatio5 = Convert.ToSingle(Limits(GetGearRatio_Pure(5),0,20));
            cardata.GearRatio6 = Convert.ToSingle(Limits(GetGearRatio_Pure(6),0,20));
            cardata.GearRatio7 = Convert.ToSingle(Limits(GetGearRatio_Pure(7),0,20));

            //if (Telemetry.m.Sim.Name == "GTR2") // messy bugfix
            /*
            {
                cardata.GearRatio0 = 12.0f;
                cardata.GearRatio1 = cardata.GearRatio0 * 0.85f;
                cardata.GearRatio2 = cardata.GearRatio1 * 0.85f;
                cardata.GearRatio3 = cardata.GearRatio2 * 0.85f;
                cardata.GearRatio4 = cardata.GearRatio3 * 0.85f;
                cardata.GearRatio5 = cardata.GearRatio4 * 0.85f;
                cardata.GearRatio6 = cardata.GearRatio5 * 0.85f;
            }*/
            ShiftRpm r = new ShiftRpm();
            cardata.RPM_Shift0 = cardata.RPM_Max;
            cardata.RPM_Shift1 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(1)));
            cardata.RPM_Shift2 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(2)));
            cardata.RPM_Shift3 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(3)));
            cardata.RPM_Shift4 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(4)));
            cardata.RPM_Shift5 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(5)));
            cardata.RPM_Shift6 = Convert.ToUInt16(r.Get(1, r.GetRatioBetween(6)));
            /*ShiftRpm r = new ShiftRpm();
            cardata.RPM_Shift0 = cardata.RPM_Max;
            cardata.RPM_Shift1 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
            cardata.RPM_Shift2 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
            cardata.RPM_Shift3 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
            cardata.RPM_Shift4 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
            cardata.RPM_Shift5 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
            cardata.RPM_Shift6 = (ushort)Limits(cardata.RPM_Max, 0, 25000);
            cardata.RPM_Shift7 = (ushort)Limits(cardata.RPM_Max, 0, 25000);*/

            SendPackage(DashboardPackages.PACK_CARDATA, ByteMethods.ToBytes(cardata));

            // Send leds config..
            //return;
            string[] leds = System.IO.File.ReadAllLines("LEDs.csv");
            byte[] bf = new byte[leds.Length * 9 + 1];
            bf[0] = 0;
            int i = 1;
            int k = 0;
            foreach (string led in leds)
            {
                string[] data = led.Split(",".ToCharArray());

                bf[i] = (byte)(Convert.ToByte(data[4]));
                bf[i + 1] = (byte)(Convert.ToByte(data[1]));
                bf[i + 2] = (byte)(Convert.ToByte(data[2]));
                bf[i + 3] = (byte)(Convert.ToByte(data[3]));
                byte[] bf_tmp = BitConverter.GetBytes(0);
                bf[i + 4] = bf_tmp[0];
                bf[i + 5] = bf_tmp[1];
                bf[i + 6] = 64;
                bf[i + 7] = Convert.ToByte(k * 50 / 16);
                bf[i + 8] = 255;

                i += 9;
                k++;
            }
                string t = BitConverter.ToString(bf);
            SendPackage(DashboardPackages.PACK_PREFS_SHIFTBAR, bf);
                /*
            bf = new byte[leds.Length * 9 + 1];
            bf[0] = 1;
            i = 1;
            k = 0;
            foreach (string led in leds)
            {
                string[] data = led.Split(",".ToCharArray());

                bf[i] = 0;
                bf[i + 1] = 5;
                bf[i + 2] = 0;
                bf[i + 3] = 5;
                byte[] bf_tmp = BitConverter.GetBytes(600);
                bf[i + 4] = bf_tmp[0];
                bf[i + 5] = bf_tmp[1];
                bf[i + 6] = 50;
                bf[i + 7] = Convert.ToByte(((k % 2 == 0) ? 50 : 0));
                bf[i + 8] = 200;

                i += 9;
                k++;
            }
            SendPackage(DashboardPackages.PACK_PREFS_SHIFTBAR, bf);
                */

            }
            catch (Exception ex)
            { }
            return;
        }