| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /* | |||
| 2 | * @file init_aux_speed_sensor.cpp | |||
| 3 | * | |||
| 4 | */ | |||
| 5 | ||||
| 6 | #include "pch.h" | |||
| 7 | #include "init.h" | |||
| 8 | #include "frequency_sensor.h" | |||
| 9 | ||||
| 10 | static FrequencySensor auxSpeed1(SensorType::AuxSpeed1, MS2NT(500)); | |||
| 11 | static FrequencySensor auxSpeed2(SensorType::AuxSpeed2, MS2NT(500)); | |||
| 12 | ||||
| 13 | static class : public SensorConverter { | |||
| 14 | public: | |||
| 15 | ✗ | SensorResult convert(float frequency) const override { | ||
| 16 | ✗ | return frequency; | ||
| 17 | } | |||
| 18 | } converter; | |||
| 19 | ||||
| 20 | class WheelSlipBasedOnAuxSpeedSensor : public Sensor { | |||
| 21 | public: | |||
| 22 | 1 | WheelSlipBasedOnAuxSpeedSensor() : Sensor(SensorType::WheelSlipRatio) { } | ||
| 23 | ||||
| 24 | ✗ | SensorResult get() const final override { | ||
| 25 | ✗ | auto value1 = auxSpeed1.get(); | ||
| 26 | ✗ | auto value2 = engineConfiguration->useVssAsSecondWheelSpeed ? Sensor::get(SensorType::VehicleSpeed) : auxSpeed2.get(); | ||
| 27 | ✗ | if (!value1.Valid || !value2.Valid) { | ||
| 28 | ✗ | return UnexpectedCode::Unknown; | ||
| 29 | } | |||
| 30 | // todo: remove handling of zero in July of 2024 | |||
| 31 | ✗ | float correctedAuxSpeed1Multiplier = engineConfiguration->auxSpeed1Multiplier == 0 ? 1 : engineConfiguration->auxSpeed1Multiplier; | ||
| 32 | ✗ | float result = value1.Value * correctedAuxSpeed1Multiplier / value2.Value; | ||
| 33 | ✗ | return result; | ||
| 34 | } | |||
| 35 | ||||
| 36 | ✗ | void showInfo(const char*) const override { } | ||
| 37 | }; | |||
| 38 | ||||
| 39 | static WheelSlipBasedOnAuxSpeedSensor wheelSlipSensor; | |||
| 40 | ||||
| 41 | 2 | void initAuxSpeedSensors() { | ||
| 42 | 2 | auxSpeed1.useBiQuad = engineConfiguration->useBiQuadOnAuxSpeedSensors; | ||
| 43 | 2 | auxSpeed1.initIfValid(engineConfiguration->auxSpeedSensorInputPin[0], converter, engineConfiguration->auxFrequencyFilter); | ||
| 44 | 2 | auxSpeed2.initIfValid(engineConfiguration->auxSpeedSensorInputPin[1], converter, 0.05f); | ||
| 45 | ||||
| 46 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 2 times.
|
2 | if (engineConfiguration->useAuxSpeedForSlipRatio) { |
| 47 | ✗ | wheelSlipSensor.Register(); | ||
| 48 | } | |||
| 49 | 2 | } | ||
| 50 | ||||
| 51 | ✗ | void deinitAuxSpeedSensors() { | ||
| 52 | ✗ | auxSpeed1.deInit(); | ||
| 53 | ✗ | auxSpeed2.deInit(); | ||
| 54 | ✗ | wheelSlipSensor.unregister(); | ||
| 55 | ✗ | } | ||
| 56 |