void _updateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var ets2RawData = SharedMemory.Update <Ets2SdkData>();

            var ets2RawUnmanaged = new Ets2SdkUnmanaged();

            ets2RawUnmanaged.TrailerModel = Encoding.UTF8.GetString(SharedMemory.RawData, ets2RawData.trailerOffset, ets2RawData.trailerLength);
            ets2RawUnmanaged.TruckModel   = Encoding.UTF8.GetString(SharedMemory.RawData, ets2RawData.modelOffset, ets2RawData.modelLength);

            var ets2telemetry = new Ets2Telemetry(ets2RawData, ets2RawUnmanaged);

            if (Data != null)
            {
                Data(ets2telemetry, ets2RawData.time != lastTime);
            }

            lastTime = ets2RawData.time;
        }
示例#2
0
        void _updateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var ets2RawData = SharedMemory.Update <Ets2SdkData>();

            var ets2RawUnmanaged = new Ets2SdkUnmanaged();

            ets2RawUnmanaged.TrailerModel = Encoding.UTF8.GetString(SharedMemory.RawData, ets2RawData.trailerOffset, ets2RawData.trailerLength);
            ets2RawUnmanaged.TruckModel   = Encoding.UTF8.GetString(SharedMemory.RawData, ets2RawData.modelOffset, ets2RawData.modelLength);

            var ets2telemetry = new Ets2Telemetry(ets2RawData, ets2RawUnmanaged);

            if (Data != null)
            {
                Data(ets2telemetry, ets2RawData.time != lastTime);
            }

            // Job close & start events
            if (wasFinishingJob != ets2telemetry.Job.JobFinished)
            {
                wasFinishingJob = ets2telemetry.Job.JobFinished;
                if (ets2telemetry.Job.JobFinished)
                {
                    JobFinished(this, new EventArgs());
                }
            }
            if (wasOnJob != ets2telemetry.Job.OnJob)
            {
                wasOnJob = ets2telemetry.Job.OnJob;
                if (ets2telemetry.Job.OnJob)
                {
                    JobStarted(this, new EventArgs());
                }
            }

            lastTime = ets2RawData.time;
        }
        void _updateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var ets2RawData = SharedMemory.Update<Ets2SdkData>();

            var ets2RawUnmanaged = new Ets2SdkUnmanaged();
            ets2RawUnmanaged.TrailerModel = Encoding.UTF8.GetString(SharedMemory.RawData, ets2RawData.trailerOffset, ets2RawData.trailerLength);
            ets2RawUnmanaged.TruckModel = Encoding.UTF8.GetString(SharedMemory.RawData, ets2RawData.modelOffset, ets2RawData.modelLength);

            var ets2telemetry = new Ets2Telemetry(ets2RawData, ets2RawUnmanaged);

            if (Data != null)
                Data(ets2telemetry, ets2RawData.time != lastTime);

            // Job close & start events
            if (wasFinishingJob != ets2telemetry.Job.JobFinished)
            {
                wasFinishingJob = ets2telemetry.Job.JobFinished;
                if (ets2telemetry.Job.JobFinished)
                    JobFinished(this, new EventArgs());

            }
            if (wasOnJob != ets2telemetry.Job.OnJob)
            {
                wasOnJob = ets2telemetry.Job.OnJob;
                if (ets2telemetry.Job.OnJob)
                    JobStarted(this, new EventArgs());

            }

            lastTime = ets2RawData.time;
        }
示例#4
0
        public Ets2Telemetry(Ets2SdkData raw, Ets2SdkUnmanaged rawUnmanaged)
        {
            Time = raw.time;
            Paused = (raw.paused > 0);

            TruckId = rawUnmanaged.TruckModel;
            Truck = Encoding.UTF8.GetString(raw.truckModel).Replace('\0', ' ').Trim();
            Manufacturer = Encoding.UTF8.GetString(raw.truckMake).Replace('\0', ' ').Trim();
            ManufacturerId= Encoding.UTF8.GetString(raw.truckMakeId).Replace('\0', ' ').Trim();

            Version = new _Version();
            Controls = new _Controls();
            Physics = new _Physics();
            Drivetrain = new _Drivetrain();
            Job = new _Job();
            Axilliary = new _Axilliary();
            Damage = new _Damage();
            Lights = new _Lights();

            // Version
            Version.Ets2Major = raw.ets2_version_major;
            Version.Ets2Minor = raw.ets2_version_minor;
            Version.SdkPlugin = raw.ets2_telemetry_plugin_revision;
            
            // Controls
            Controls.GameBrake = raw.gameBrake;
            Controls.GameClutch = raw.gameClutch;
            Controls.GameSteer = raw.gameSteer;
            Controls.GameThrottle = raw.gameThrottle;

            Controls.UserBrake = raw.userBrake;
            Controls.UserClutch = raw.userClutch;
            Controls.UserSteer = raw.userSteer;
            Controls.UserThrottle = raw.userThrottle;

            // Physics
            Physics.AccelerationX = raw.accelerationX;
            Physics.AccelerationY = raw.accelerationY;
            Physics.AccelerationZ = raw.accelerationZ;

            Physics.CoordinateX = raw.coordinateX;
            Physics.CoordinateY = raw.coordinateY;
            Physics.CoordinateZ = raw.coordinateZ;

            Physics.RotationX = raw.rotationX;
            Physics.RotationY = raw.rotationY;
            Physics.RotationZ = raw.rotationZ;

            Physics.Speed = raw.speed;
            Physics.SpeedKmh = raw.speed*3.6f;
            Physics.SpeedMph = Physics.SpeedKmh/1.6f;

            // Drivetrain
            Drivetrain.Adblue = raw.adblue;
            Drivetrain.AdblueConsumption = raw.adblueConsumption;
            Drivetrain.AirPressure = raw.airPressure;
            Drivetrain.BrakeTemperature = raw.brakeTemperature;
            Drivetrain.CruiseControl = raw.GetBool(Ets2SdkBoolean.CruiseControl);
            Drivetrain.CruiseControlSpeed = raw.cruiseControlSpeed;
            Drivetrain.CruiseControlSpeedKmh = raw.cruiseControlSpeed * 3.6f;
            Drivetrain.CruiseControlSpeedMph = Drivetrain.CruiseControlSpeedKmh/ 1.6f;
            Drivetrain.ElectricEnabled = raw.GetBool(Ets2SdkBoolean.ElectricEnabled);
            Drivetrain.EngineEnabled = raw.GetBool(Ets2SdkBoolean.EngineEnabled);
            Drivetrain.EngineRpm = raw.engineRpm;
            Drivetrain.EngineRpmMax = raw.engineRpmMax;

            Drivetrain.Speed = raw.speed;
            Drivetrain.SpeedKmh = raw.speed * 3.6f;
            Drivetrain.SpeedMph = Physics.SpeedKmh / 1.6f;

            Drivetrain.Fuel = raw.fuel;
            Drivetrain.FuelAvgConsumption = raw.fuelAvgConsumption;
            Drivetrain.FuelMax = raw.fuelCapacity;
            Drivetrain.FuelRate = raw.fuelRate;
            Drivetrain.FuelWarning = raw.fuelWarning; 

            Drivetrain.Gear = raw.gear;
            Drivetrain.GearRange = raw.gearRangeActive;
            Drivetrain.GearRanges = raw.gearRanges;
            Drivetrain.GearsForward = raw.gears;
            Drivetrain.GearsReverse = raw.gearsReverse;

            Drivetrain.MotorBrake = raw.GetBool(Ets2SdkBoolean.MotorBrake);
            Drivetrain.OilPressure = raw.oilPressure;
            Drivetrain.OilTemperature = raw.oilTemperature;
            Drivetrain.ParkingBrake = raw.GetBool(Ets2SdkBoolean.ParkBrake);
            Drivetrain.Retarder = raw.retarderBrake;
            Drivetrain.ShifterSlot = raw.shifterSlot;
            Drivetrain.ShifterToggle = raw.shifterToggle;
            Drivetrain.TruckOdometer = raw.truckOdometer;
            Drivetrain.WaterTemperature = raw.waterTemperature;

            // Job info:
            Job.CityDestination = Encoding.UTF8.GetString(raw.jobCityDestination).Replace('\0',' ').Trim();
            Job.CitySource = Encoding.UTF8.GetString(raw.jobCitySource).Replace('\0', ' ').Trim();
            Job.CompanyDestination = Encoding.UTF8.GetString(raw.jobCompanyDestination).Replace('\0', ' ').Trim();
            Job.CompanySource = Encoding.UTF8.GetString(raw.jobCompanySource).Replace('\0', ' ').Trim();
            Job.Deadline = raw.jobDeadline;
            Job.Income = raw.jobIncome;
            Job.Mass = raw.trailerMass;
            Job.TrailerAttached = raw.GetBool(Ets2SdkBoolean.TrailerAttached);//TODO
            Job.TrailerId = Encoding.UTF8.GetString(raw.trailerId).Replace('\0', ' ').Trim();
            Job.TrailerName = Encoding.UTF8.GetString(raw.trailerName).Replace('\0', ' ').Trim();
            Job.Cargo = rawUnmanaged.TrailerModel.Replace('\0', ' ').Trim();

            // Axilliary flags
            Axilliary.AdblueWarning = raw.GetBool(Ets2SdkBoolean.AdblueWarning);
            Axilliary.AirPressureEmergency = raw.GetBool(Ets2SdkBoolean.AirPressureEmergency);
            Axilliary.AirPressureWarning = raw.GetBool(Ets2SdkBoolean.AirPressureWarning);
            Axilliary.BatteryVoltageWarning = raw.GetBool(Ets2SdkBoolean.BatteryVoltageWarning);
            Axilliary.OilPressureWarning = raw.GetBool(Ets2SdkBoolean.OilPressureWarning);
            Axilliary.WaterTemperatureWarning = raw.GetBool(Ets2SdkBoolean.WaterTemperatureWarning);
            Axilliary.Wipers = raw.GetBool(Ets2SdkBoolean.Wipers);

            // Damage
            Damage.WearCabin = raw.wearCabin;
            Damage.WearChassis = raw.wearChassis;
            Damage.WearEnigne = raw.wearEngine;
            Damage.WearTrailer = raw.wearTrailer;
            Damage.WearTransmission = raw.wearTransmission;
            Damage.WearWheels = raw.wearWheels;

            // Lights
            Lights.Beacon = raw.GetBool(Ets2SdkBoolean.LightsBeacon);
            Lights.BlinkerLeftActive = raw.GetBool(Ets2SdkBoolean.BlinkerLeftActive);// TODO
            Lights.BlinkerLeftOn = raw.GetBool(Ets2SdkBoolean.BlinkerLeftOn);// TODO
            Lights.BlinkerRightActive = raw.GetBool(Ets2SdkBoolean.BlinkerRightActive);// TODO
            Lights.BlinkerRightOn = raw.GetBool(Ets2SdkBoolean.BlinkerRightOn);// TODO
            Lights.BrakeLight = raw.GetBool(Ets2SdkBoolean.LightsBrake);// TODO
            Lights.FrontAux = raw.GetBool(Ets2SdkBoolean.LightsAuxFront);// TODO
            Lights.HighBeams = raw.GetBool(Ets2SdkBoolean.LightsBeamHigh);// TODO
            Lights.LightsDashboard = raw.lightsDashboard;
            Lights.LowBeams = raw.GetBool(Ets2SdkBoolean.LightsBeamLow);// TODO
            Lights.ParkingLights = raw.GetBool(Ets2SdkBoolean.LightsParking);// TODO
            Lights.ReverseLight = raw.GetBool(Ets2SdkBoolean.LightsReverse);// TODO
            Lights.RoofAux = raw.GetBool(Ets2SdkBoolean.LightsAuxRoof);// TODO
        }
        void _updateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var ets2RawData = SharedMemory.Update<Ets2SdkData>();

            var ets2RawUnmanaged = new Ets2SdkUnmanaged();
            ets2RawUnmanaged.TrailerModel = Encoding.UTF8.GetString(SharedMemory.RawData, ets2RawData.trailerOffset, ets2RawData.trailerLength);
            ets2RawUnmanaged.TruckModel = Encoding.UTF8.GetString(SharedMemory.RawData, ets2RawData.modelOffset, ets2RawData.modelLength);

            var ets2telemetry = new Ets2Telemetry(ets2RawData, ets2RawUnmanaged);

            if (Data != null)
                Data(ets2telemetry, ets2RawData.time != lastTime);

            lastTime = ets2RawData.time;
        }
        public Ets2Telemetry(Ets2SdkData raw, Ets2SdkUnmanaged rawUnmanaged)
        {
            Time = raw.time;
            Paused = (raw.paused > 0);

            TruckId = rawUnmanaged.TruckModel;
            Truck = Encoding.UTF8.GetString(raw.truckModel).Replace('\0', ' ').Trim();
            Manufacturer = Encoding.UTF8.GetString(raw.truckMake).Replace('\0', ' ').Trim();
            ManufacturerId= Encoding.UTF8.GetString(raw.truckMakeId).Replace('\0', ' ').Trim();

            Version = new _Version();
            Controls = new _Controls();
            Physics = new _Physics();
            Drivetrain = new _Drivetrain();
            Job = new _Job();
            Axilliary = new _Axilliary();
            Damage = new _Damage();
            Lights = new _Lights();

            // Version
            Version.Ets2Major = raw.ets2_version_major;
            Version.Ets2Minor = raw.ets2_version_minor;
            Version.SdkPlugin = raw.ets2_telemetry_plugin_revision;

            // Controls
            Controls.GameBrake = raw.gameBrake;
            Controls.GameClutch = raw.gameClutch;
            Controls.GameSteer = raw.gameSteer;
            Controls.GameThrottle = raw.gameThrottle;

            Controls.UserBrake = raw.userBrake;
            Controls.UserClutch = raw.userClutch;
            Controls.UserSteer = raw.userSteer;
            Controls.UserThrottle = raw.userThrottle;

            // Physics
            Physics.AccelerationX = raw.accelerationX;
            Physics.AccelerationY = raw.accelerationY;
            Physics.AccelerationZ = raw.accelerationZ;

            Physics.CoordinateX = raw.coordinateX;
            Physics.CoordinateY = raw.coordinateY;
            Physics.CoordinateZ = raw.coordinateZ;

            Physics.RotationX = raw.rotationX;
            Physics.RotationY = raw.rotationY;
            Physics.RotationZ = raw.rotationZ;

            Physics.Speed = raw.speed;
            Physics.SpeedKmh = raw.speed*3.6f;
            Physics.SpeedMph = Physics.SpeedKmh/1.6f;

            // Drivetrain
            Drivetrain.Adblue = raw.adblue;
            Drivetrain.AdblueConsumption = raw.adblueConsumption;
            Drivetrain.AirPressure = raw.airPressure;
            Drivetrain.BrakeTemperature = raw.brakeTemperature;
            Drivetrain.CruiseControl = raw.GetBool(Ets2SdkBoolean.CruiseControl);
            Drivetrain.CruiseControlSpeed = raw.cruiseControlSpeed;
            Drivetrain.CruiseControlSpeedKmh = raw.cruiseControlSpeed * 3.6f;
            Drivetrain.CruiseControlSpeedMph = Drivetrain.CruiseControlSpeedKmh/ 1.6f;
            Drivetrain.ElectricEnabled = raw.GetBool(Ets2SdkBoolean.ElectricEnabled);
            Drivetrain.EngineEnabled = raw.GetBool(Ets2SdkBoolean.EngineEnabled);
            Drivetrain.EngineRpm = raw.engineRpm;
            Drivetrain.EngineRpmMax = raw.engineRpmMax;

            Drivetrain.Speed = raw.speed;
            Drivetrain.SpeedKmh = raw.speed * 3.6f;
            Drivetrain.SpeedMph = Physics.SpeedKmh / 1.6f;

            Drivetrain.Fuel = raw.fuel;
            Drivetrain.FuelRange = raw.fuelRange;
            Drivetrain.FuelAvgConsumption = raw.fuelAvgConsumption;
            Drivetrain.FuelMax = raw.fuelCapacity;
            Drivetrain.FuelRate = raw.fuelRate;
            Drivetrain.FuelWarningLight = raw.fuelWarning == 0 ? false : true;

            Drivetrain.Gear = raw.gear;
            Drivetrain.GearRange = raw.gearRangeActive;
            Drivetrain.GearRanges = raw.gearRanges;
            Drivetrain.GearsForward = raw.gears;
            Drivetrain.GearsReverse = raw.gearsReverse;

            // Note all gears
            var gearFw = raw.gearRatioForward;
            var gearRw = raw.gearRatioReverse;

            Array.Resize<float>(ref gearFw, Drivetrain.GearsForward);
            Array.Resize<float>(ref gearRw, Drivetrain.GearsReverse);

            Drivetrain.GearRatiosForward = gearFw;
            Drivetrain.GearRatiosReverse = gearRw;
            Drivetrain.GearRatioDifferential = raw.gearRatioDifferential;

            Drivetrain.GearDashboard =raw.gearDashboard;

            Drivetrain.MotorBrake = raw.GetBool(Ets2SdkBoolean.MotorBrake);
            Drivetrain.OilPressure = raw.oilPressure;
            Drivetrain.OilTemperature = raw.oilTemperature;
            Drivetrain.ParkingBrake = raw.GetBool(Ets2SdkBoolean.ParkBrake);
            Drivetrain.Retarder = raw.retarderBrake;
            Drivetrain.ShifterSlot = raw.shifterSlot;
            Drivetrain.ShifterToggle = raw.shifterToggle;
            Drivetrain.TruckOdometer = raw.truckOdometer;
            Drivetrain.WaterTemperature = raw.waterTemperature;

            // Job info:
            Job.CityDestination = Encoding.UTF8.GetString(raw.jobCityDestination).Replace('\0',' ').Trim();
            Job.CitySource = Encoding.UTF8.GetString(raw.jobCitySource).Replace('\0', ' ').Trim();
            Job.CompanyDestination = Encoding.UTF8.GetString(raw.jobCompanyDestination).Replace('\0', ' ').Trim();
            Job.CompanySource = Encoding.UTF8.GetString(raw.jobCompanySource).Replace('\0', ' ').Trim();
            Job.Deadline = raw.jobDeadline;
            Job.Income = raw.jobIncome;
            Job.Mass = raw.trailerMass;
            Job.TrailerAttached = raw.GetBool(Ets2SdkBoolean.TrailerAttached);//TODO
            Job.TrailerId = Encoding.UTF8.GetString(raw.trailerId).Replace('\0', ' ').Trim();
            Job.TrailerName = Encoding.UTF8.GetString(raw.trailerName).Replace('\0', ' ').Trim();
            Job.Cargo = Job.TrailerName; // trailerModel is actually deprecated

            Job.NavigationDistanceLeft = raw.routeDistance;
            Job.NavigationTimeLeft = raw.routeTime;
            Job.SpeedLimit = raw.speedLimit;

            Job.OnJob = raw.onJob != 0;
            Job.JobFinished = raw.jobFinished != 0;

            // Axilliary flags
            Axilliary.AdblueWarning = raw.GetBool(Ets2SdkBoolean.AdblueWarning);
            Axilliary.AirPressureEmergency = raw.GetBool(Ets2SdkBoolean.AirPressureEmergency);
            Axilliary.AirPressureWarning = raw.GetBool(Ets2SdkBoolean.AirPressureWarning);
            Axilliary.BatteryVoltageWarning = raw.GetBool(Ets2SdkBoolean.BatteryVoltageWarning);
            Axilliary.OilPressureWarning = raw.GetBool(Ets2SdkBoolean.OilPressureWarning);
            Axilliary.WaterTemperatureWarning = raw.GetBool(Ets2SdkBoolean.WaterTemperatureWarning);
            Axilliary.Wipers = raw.GetBool(Ets2SdkBoolean.Wipers);

            // Damage
            Damage.WearCabin = raw.wearCabin;
            Damage.WearChassis = raw.wearChassis;
            Damage.WearEnigne = raw.wearEngine;
            Damage.WearTrailer = raw.wearTrailer;
            Damage.WearTransmission = raw.wearTransmission;
            Damage.WearWheels = raw.wearWheels;

            // Lights
            Lights.Beacon = raw.GetBool(Ets2SdkBoolean.LightsBeacon);
            Lights.BlinkerLeftActive = raw.GetBool(Ets2SdkBoolean.BlinkerLeftActive);// TODO
            Lights.BlinkerLeftOn = raw.GetBool(Ets2SdkBoolean.BlinkerLeftOn);// TODO
            Lights.BlinkerRightActive = raw.GetBool(Ets2SdkBoolean.BlinkerRightActive);// TODO
            Lights.BlinkerRightOn = raw.GetBool(Ets2SdkBoolean.BlinkerRightOn);// TODO
            Lights.BrakeLight = raw.GetBool(Ets2SdkBoolean.LightsBrake);// TODO
            Lights.FrontAux = raw.GetBool(Ets2SdkBoolean.LightsAuxFront);// TODO
            Lights.HighBeams = raw.GetBool(Ets2SdkBoolean.LightsBeamHigh);// TODO
            Lights.LightsDashboard = raw.lightsDashboard;
            Lights.LowBeams = raw.GetBool(Ets2SdkBoolean.LightsBeamLow);// TODO
            Lights.ParkingLights = raw.GetBool(Ets2SdkBoolean.LightsParking);// TODO
            Lights.ReverseLight = raw.GetBool(Ets2SdkBoolean.LightsReverse);// TODO
            Lights.RoofAux = raw.GetBool(Ets2SdkBoolean.LightsAuxRoof);// TODO
        }