async _initializeData()

in source/simulator/lib/device/generators/vehicle/dynamics/dynamics-model.js [45:92]


    async _initializeData(params) {
        this.pollerDelay = 500;
        this.snapshot = params.snapshot;
        this.routeParams = await this.getRoute(this.snapshot);
        this.calculations = [];
        this.calculations.push(new SpeedCalc(this.snapshot));
        this.calculations.push(new AccelerationCalc(this.snapshot));
        this.calculations.push(new GearCalc(this.snapshot));
        this.calculations.push(new GearIntCalc(this.snapshot));
        this.calculations.push(new TorqueCalc(this.snapshot));
        this.calculations.push(new EngineSpeedCalc(this.snapshot));
        this.calculations.push(new FuelConsumedCalc(this.snapshot));
        this.calculations.push(new OdometerCalc(this.snapshot));
        this.calculations.push(new FuelLevelCalc(this.snapshot));
        this.calculations.push(new OilTempCalc(this.snapshot));
        this.calculations.push(new RouteCalc(this.routeParams, this.snapshot));
        //add initial calulationdata to snapshot
        for (let calculation of this.calculations) {
            //Add back data from previous lambda if available
            if (this.snapshot[calculation.name]) {
                calculation.put(this.snapshot[calculation.name]);
            } else {
                this.snapshot[calculation.name] = calculation.get();
            }
        }
        this.accelerator = this.snapshot.acceleratorPedalPosition || 0.0;
        this.brake = this.snapshot.brake || 0.0;
        this.steeringWheelAngle = this.snapshot.steeringWheelAngle || 0.0;
        this.parkingBrakeStatus = !!this.snapshot.parkingBrakeStatus;
        this.engineRunning = this.snapshot.engineRunning || true;
        this.ignitionData = this.snapshot.ignitionStatus || 'run';
        this.gearLever = this.snapshot.gearLeverPosition || 'drive';
        this.manualTransStatus = !!this.snapshot.manualTrans;
        this.triggers = {};

        this.snapshot.acceleratorPedalPosition = this.accelerator;
        this.snapshot.brake = this.brake;
        this.snapshot.steeringWheelAngle = this.steeringWheelAngle;
        this.snapshot.parkingBrakeStatus = this.parkingBrakeStatus;
        this.snapshot.engineRunning = this.engineRunning;
        this.snapshot.ignitionStatus = this.ignitionData;
        this.snapshot.brakePedalStatus = this.brakePedalStatus;
        this.snapshot.gearLeverPosition = this.gearLever;
        this.snapshot.manualTrans = this.manualTransStatus;
        this.snapshot.triggers = this.triggers;
        //start calculating vehicle data
        this.startPhysicsLoop();
    }