#pragma once #include "base_config.hpp" #include "common/events.hpp" #include "firmware/device_firmware.hpp" #include "port/base_port.hpp" #include #include namespace phosphor::modbus::rtu::device { class Device; using SensorValueIntf = sdbusplus::aserver::xyz::openbmc_project::sensor::Value; using PortIntf = phosphor::modbus::rtu::port::BasePort; namespace EventIntf = phosphor::modbus::events; class BaseDevice { public: BaseDevice() = delete; explicit BaseDevice(sdbusplus::async::context& ctx, const config::Config& config, PortIntf& serialPort, EventIntf::Events& events); auto readSensorRegisters() -> sdbusplus::async::task; private: auto createSensors() -> void; auto readStatusRegisters() -> sdbusplus::async::task; auto generateEvent(const config::StatusBit& statusBit, const sdbusplus::message::object_path& objectPath, double sensorValue, SensorValueIntf::Unit sensorUnit, bool statusAsserted) -> sdbusplus::async::task; using sensors_map_t = std::unordered_map>; sdbusplus::async::context& ctx; const config::Config config; PortIntf& serialPort; EventIntf::Events& events; std::unique_ptr currentFirmware; sensors_map_t sensors; }; } // namespace phosphor::modbus::rtu::device