2019-09-21 12:33:13 -07:00
|
|
|
/**
|
|
|
|
* @file init_sensorss.cpp
|
|
|
|
*/
|
|
|
|
|
2019-09-21 11:33:38 -07:00
|
|
|
#include "cli_registry.h"
|
|
|
|
#include "init.h"
|
|
|
|
#include "sensor.h"
|
|
|
|
|
2020-03-30 15:29:42 -07:00
|
|
|
static void initSensorCli(Logging* logger);
|
2020-02-08 01:22:23 -08:00
|
|
|
|
|
|
|
// Sensor init/config
|
2020-02-03 22:54:05 -08:00
|
|
|
void initTps();
|
2019-09-21 11:33:38 -07:00
|
|
|
void initOilPressure();
|
|
|
|
|
2020-03-30 15:29:42 -07:00
|
|
|
void initNewSensors(Logging* logger) {
|
2020-02-03 22:54:05 -08:00
|
|
|
initTps();
|
2019-09-21 11:33:38 -07:00
|
|
|
initOilPressure();
|
|
|
|
|
|
|
|
// Init CLI functionality for sensors (mocking)
|
2020-03-30 15:29:42 -07:00
|
|
|
initSensorCli(logger);
|
2019-09-21 11:33:38 -07:00
|
|
|
}
|
|
|
|
|
2020-02-08 01:22:23 -08:00
|
|
|
// Sensor reconfiguration
|
|
|
|
void reconfigureTps();
|
|
|
|
void reconfigureOilPressure();
|
|
|
|
|
|
|
|
void reconfigureSensors() {
|
|
|
|
reconfigureTps();
|
|
|
|
reconfigureOilPressure();
|
|
|
|
}
|
|
|
|
|
2020-03-30 15:29:42 -07:00
|
|
|
static Logging* s_logger;
|
|
|
|
|
2020-02-08 01:22:23 -08:00
|
|
|
// Mocking/testing helpers
|
2020-03-30 15:29:42 -07:00
|
|
|
static void initSensorCli(Logging* logger) {
|
|
|
|
s_logger = logger;
|
|
|
|
|
2019-09-21 11:33:38 -07:00
|
|
|
addConsoleActionIF("set_sensor_mock", Sensor::setMockValue);
|
|
|
|
addConsoleAction("reset_sensor_mocks", Sensor::resetAllMocks);
|
2020-03-30 15:29:42 -07:00
|
|
|
addConsoleAction("show_sensors", []() { Sensor::showAllSensorInfo(s_logger); });
|
|
|
|
addConsoleActionI("show_sensor",
|
|
|
|
[](int idx) {
|
|
|
|
if (auto s = Sensor::getSensorOfType(static_cast<SensorType>(idx))) {
|
|
|
|
s->showAllSensorInfo(s_logger);
|
|
|
|
}
|
|
|
|
});
|
2019-09-21 11:33:38 -07:00
|
|
|
}
|