5#ifndef PARAMETER_PARSER_H
6#define PARAMETER_PARSER_H
16#ifndef LMBD_SIMULATOR_RESOURCES_DIR
17#error "LMBD_SIMULATOR_RESOURCES_DIR must be defined by CMake"
20static const char* fileName = LMBD_SIMULATOR_RESOURCES_DIR
"/simulation_parameters.txt";
22static const char* batteryVoltageKey =
"batt_V";
23static const char* vbusVoltageKey =
"vbus_V";
24static const char* vbusCurrentKey =
"vbus_A";
25static const char* cpuTemperatureKey =
"cpu_temp";
26static const char* addedAlgoDelayKey =
"algo_del";
31 static bool fileNotDetectedCalled =
false;
33 std::ifstream file(fileName);
36 fileNotDetectedCalled =
false;
41 std::getline(file, line);
44 if (line.empty() or line[0] ==
'#')
46 std::stringstream linestream(line);
52 linestream >> key >> value;
54 if (key == batteryVoltageKey)
56 mock_battery::voltage = value;
58 else if (key == vbusVoltageKey)
60 mock_electrical::inputVbusVoltage = value;
62 else if (key == vbusCurrentKey)
64 mock_electrical::inputVbusCurrent = value;
66 else if (key == cpuTemperatureKey)
68 mock_registers::cpuTemperature = value;
70 else if (key == addedAlgoDelayKey)
72 mock_registers::addedAlgoDelay = value;
78 if (!fileNotDetectedCalled)
79 std::cerr <<
"Parameter file " << fileName <<
" not detected" << std::endl;
80 fileNotDetectedCalled =
true;
Handle the physical simulation paremeters of a real lamp.
Simulator dedicated namespace.
Definition: BQ25713_mock.h:23
void read_and_update_parameters()
Read parameters from the parameter file, and update the simulation.
Definition: parameter_parser.h:29