1e92aba45SJagpal Singh Gill #pragma once 2e92aba45SJagpal Singh Gill 3e92aba45SJagpal Singh Gill #include "base_config.hpp" 47184805aSJagpal Singh Gill #include "common/events.hpp" 5*cf77ef54SJagpal Singh Gill #include "firmware/device_firmware.hpp" 6e92aba45SJagpal Singh Gill #include "port/base_port.hpp" 7e92aba45SJagpal Singh Gill 8e92aba45SJagpal Singh Gill #include <sdbusplus/async.hpp> 9e92aba45SJagpal Singh Gill #include <xyz/openbmc_project/Sensor/Value/aserver.hpp> 10e92aba45SJagpal Singh Gill 11e92aba45SJagpal Singh Gill namespace phosphor::modbus::rtu::device 12e92aba45SJagpal Singh Gill { 13e92aba45SJagpal Singh Gill 14e92aba45SJagpal Singh Gill class Device; 15e92aba45SJagpal Singh Gill 16e92aba45SJagpal Singh Gill using SensorValueIntf = 17e92aba45SJagpal Singh Gill sdbusplus::aserver::xyz::openbmc_project::sensor::Value<Device>; 18e92aba45SJagpal Singh Gill using PortIntf = phosphor::modbus::rtu::port::BasePort; 197184805aSJagpal Singh Gill namespace EventIntf = phosphor::modbus::events; 20e92aba45SJagpal Singh Gill 21e92aba45SJagpal Singh Gill class BaseDevice 22e92aba45SJagpal Singh Gill { 23e92aba45SJagpal Singh Gill public: 24e92aba45SJagpal Singh Gill BaseDevice() = delete; 25e92aba45SJagpal Singh Gill 26e92aba45SJagpal Singh Gill explicit BaseDevice(sdbusplus::async::context& ctx, 277184805aSJagpal Singh Gill const config::Config& config, PortIntf& serialPort, 287184805aSJagpal Singh Gill EventIntf::Events& events); 29e92aba45SJagpal Singh Gill 30e92aba45SJagpal Singh Gill auto readSensorRegisters() -> sdbusplus::async::task<void>; 31e92aba45SJagpal Singh Gill 32e92aba45SJagpal Singh Gill private: 33e92aba45SJagpal Singh Gill auto createSensors() -> void; 34e92aba45SJagpal Singh Gill 357184805aSJagpal Singh Gill auto readStatusRegisters() -> sdbusplus::async::task<void>; 367184805aSJagpal Singh Gill 377184805aSJagpal Singh Gill auto generateEvent(const config::StatusBit& statusBit, 387184805aSJagpal Singh Gill const sdbusplus::message::object_path& objectPath, 397184805aSJagpal Singh Gill double sensorValue, SensorValueIntf::Unit sensorUnit, 407184805aSJagpal Singh Gill bool statusAsserted) -> sdbusplus::async::task<void>; 417184805aSJagpal Singh Gill 42e92aba45SJagpal Singh Gill using sensors_map_t = 43e92aba45SJagpal Singh Gill std::unordered_map<std::string, std::unique_ptr<SensorValueIntf>>; 44e92aba45SJagpal Singh Gill sdbusplus::async::context& ctx; 45e92aba45SJagpal Singh Gill const config::Config config; 46e92aba45SJagpal Singh Gill PortIntf& serialPort; 477184805aSJagpal Singh Gill EventIntf::Events& events; 48*cf77ef54SJagpal Singh Gill std::unique_ptr<DeviceFirmware> currentFirmware; 49e92aba45SJagpal Singh Gill sensors_map_t sensors; 50e92aba45SJagpal Singh Gill }; 51e92aba45SJagpal Singh Gill 52e92aba45SJagpal Singh Gill } // namespace phosphor::modbus::rtu::device 53