diff --git a/Tests/Mieming/host_esp32Wroom/client/lib/ina219/ina219.cpp b/Tests/Mieming/host_esp32Wroom/client/lib/ina219/ina219.cpp index def6a9d73acefe00e1a160a1c3fc2ba64ab2099d..930885f2d99e6ccd1571b778441dfd39668c2108 100644 --- a/Tests/Mieming/host_esp32Wroom/client/lib/ina219/ina219.cpp +++ b/Tests/Mieming/host_esp32Wroom/client/lib/ina219/ina219.cpp @@ -27,7 +27,35 @@ out_data_ina219 ForteINA219 ::readData() std::list<Message> ForteINA219::buildMessages() { - throw "Not yet implemented"; + std::list<Message> messages; + out_data_ina219 data = readData(); + MeasurementData shuntVoltageData{ + data.shuntVoltage_mV, 0, {}, measurementTypeToString.at(MeasurementType::SHUNT_VOLTAGE) + }; + MeasurementData busVoltageData{ + data.busVoltage_V, 0, {}, measurementTypeToString.at(MeasurementType::BUS_VOLTAGE) + }; + MeasurementData currentMilliAmpData{ + data.current_mA, 0, {}, measurementTypeToString.at(MeasurementType::CURRENT_mA) + }; + MeasurementData powerMilliWattData{ + data.power_mW, 0, {}, measurementTypeToString.at(MeasurementType::POWER_mA) + }; + MeasurementData loadVoltageData{ + data.loadVoltage_V, 0, {}, measurementTypeToString.at(MeasurementType::LOAD_VOLTAGE_V) + }; + MeasurementData ina219OverflowData{ + data.ina219_overflow, 0, {}, measurementTypeToString.at(MeasurementType::INA219_OVERFLOW) + }; + + messages.emplace_back(Message(shuntVoltageData, sensorInformation, 0)); + messages.emplace_back(Message(busVoltageData, sensorInformation,0)); + messages.emplace_back(Message(currentMilliAmpData, sensorInformation, 0)); + messages.emplace_back(Message(powerMilliWattData, sensorInformation, 0)); + messages.emplace_back(Message(loadVoltageData, sensorInformation, 0)); + messages.emplace_back(Message(ina219OverflowData, sensorInformation, 0)); + + return messages; } SensorInformation ForteINA219::getSensorInformation() const { diff --git a/Tests/Mieming/host_esp32Wroom/client/lib/ina219/ina219.hpp b/Tests/Mieming/host_esp32Wroom/client/lib/ina219/ina219.hpp index 4a34d9591a325f9232f90ef61b4a74077fe1cf51..1985b996820f696290be13bc776a5f238fcd466a 100644 --- a/Tests/Mieming/host_esp32Wroom/client/lib/ina219/ina219.hpp +++ b/Tests/Mieming/host_esp32Wroom/client/lib/ina219/ina219.hpp @@ -28,6 +28,15 @@ class ForteINA219 : public ForteSensor<out_data_ina219> { INA219_WE ina219; out_data_ina219 data; const SensorInformation sensorInformation{"INA219", Protocol::I2C}; + enum class MeasurementType {SHUNT_VOLTAGE, BUS_VOLTAGE, CURRENT_mA, POWER_mA, LOAD_VOLTAGE_V, INA219_OVERFLOW}; + + std::map<MeasurementType, const char*> measurementTypeToString = { + {MeasurementType::SHUNT_VOLTAGE, "SHUNT_VOLTAGE"}, + {MeasurementType::BUS_VOLTAGE, "BUS_VOLTAGE"}, + {MeasurementType::CURRENT_mA, "CURRENT_mA"}, + {MeasurementType::POWER_mA, "POWER_mA"}, + {MeasurementType::LOAD_VOLTAGE_V, "LOAD_VOLTAGE_V"}, + {MeasurementType::INA219_OVERFLOW, "INA219_OVERFLOW"}}; }; #endif \ No newline at end of file