5#ifndef PARAMETER_PARSER_H
6#define PARAMETER_PARSER_H
16static const char* fileName =
"./simulator/resources/simulation_parameters.txt";
18static const char* batteryVoltageKey =
"batt_V";
19static const char* vbusVoltageKey =
"vbus_V";
20static const char* cpuTemperatureKey =
"cpu_temp";
21static const char* addedAlgoDelayKey =
"algo_del";
26 static bool fileNotDetectedCalled =
false;
28 std::ifstream file(fileName);
31 fileNotDetectedCalled =
false;
36 std::getline(file, line);
39 if (line.empty() or line[0] ==
'#')
41 std::stringstream linestream(line);
47 linestream >> key >> value;
49 if (key == batteryVoltageKey)
51 mock_battery::voltage = value;
53 else if (key == vbusVoltageKey)
55 mock_electrical::inputVbusVoltage = value;
57 else if (key == cpuTemperatureKey)
59 mock_registers::cpuTemperature = value;
61 else if (key == addedAlgoDelayKey)
63 mock_registers::addedAlgoDelay = value;
70 if (!fileNotDetectedCalled)
71 std::cerr <<
"Parameter file " << fileName <<
" not detected" << std::endl;
72 fileNotDetectedCalled =
true;
Handle the physical simulation paremeters of a real lamp.
Simulator dedicated namespace.
Definition: default_simulation.h:8
void read_and_update_parameters()
Read parameters from the parameter file, and update the simulation.
Definition: parameter_parser.h:24