_getSnapshotData()

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


    _getSnapshotData() {
        let newSnapshot = {};
        //For each calculation, calculate new data, then update snapshot
        for (let calculation of this.calculations) {
            //calculate new data
            calculation.iterate(this.snapshot);
            newSnapshot[calculation.name] = calculation.get();
            //aggregate necessary route info into single object
            if (calculation.name === 'routeInfo') {
                newSnapshot.latitude = calculation.latitude;
                newSnapshot.longitude = calculation.longitude;
                newSnapshot.acceleratorPedalPosition = calculation.throttlePosition;
                newSnapshot.brake = calculation.brakePosition;
                this.brakePedalStatus = calculation.brakePosition > 0;
                //check if route has ended
                if (calculation.routeEnded) {
                    newSnapshot.routeDuration = calculation.routeDuration;
                    newSnapshot.routeEnded = true;
                }
                //check if random triggers were triggered
                if (calculation.updateTriggers) {
                    this.triggers = calculation.triggers;
                }
            }
        }
        newSnapshot.steeringWheelAngle = this.steeringWheelAngle;
        newSnapshot.parkingBrakeStatus = this.parkingBrakeStatus;
        newSnapshot.engineRunning = this.engineRunning;
        newSnapshot.ignitionStatus = this.ignitionData;
        newSnapshot.brakePedalStatus = this.brakePedalStatus;
        newSnapshot.gearLeverPosition = this.gearLever;
        newSnapshot.manualTrans = this.manualTransStatus;
        newSnapshot.triggers = this.triggers;
        //if route ended, clear timer for calculating vehicle data
        if (newSnapshot.routeEnded) {
            this.stopPhysicsLoop();
        }
        //update the snapshot
        this.snapshot = newSnapshot;
    }