blob: 58debeea72967fc65b0fa0eb23f20378fee05389 [file] [log] [blame]
Jagpal Singh Gille92aba42025-10-16 00:00:13 -07001#include "reservoir_pump_unit.hpp"
2
3#include "device_factory.hpp"
4
5#include <phosphor-logging/lg2.hpp>
6
7namespace phosphor::modbus::rtu::device
8{
9
10PHOSPHOR_LOG2_USING;
11
12static constexpr auto ModbusRDF040DSS5193E0ReservoirPumpUnitInterface =
13 "xyz.openbmc_project.Configuration.ModbusRDF040DSS5193E0ReservoirPumpUnit";
14
15static const std::unordered_map<std::string_view, config::DeviceModel>
16 validDevices = {{ModbusRDF040DSS5193E0ReservoirPumpUnitInterface,
17 config::DeviceModel::RDF040DSS5193E0}};
18
19ReservoirPumpUnit::ReservoirPumpUnit(sdbusplus::async::context& ctx,
20 const config::Config& config,
21 PortIntf& serialPort) :
22 BaseDevice(ctx, config, serialPort)
23{
24 info("Reservoir pump unit {NAME} created successfully", "NAME",
25 config.name);
26}
27
28auto ReservoirPumpUnit::getInterfaces() -> std::unordered_set<std::string>
29{
30 return {ModbusRDF040DSS5193E0ReservoirPumpUnitInterface};
31}
32
33auto ReservoirPumpUnit::getConfig(
34 sdbusplus::async::context& ctx,
35 const sdbusplus::message::object_path& objectPath,
36 const std::string& interfaceName)
37 -> sdbusplus::async::task<std::optional<config::DeviceFactoryConfig>>
38{
39 config::DeviceFactoryConfig config{};
40
41 auto res = co_await config::updateBaseConfig(ctx, objectPath, interfaceName,
42 config);
43 if (!res)
44 {
45 co_return std::nullopt;
46 }
47
48 for (const auto& [deviceInterface, deviceModel] : validDevices)
49 {
50 if (interfaceName == deviceInterface)
51 {
52 config.deviceModel = deviceModel;
53 }
54 }
55
56 if (config.deviceModel == config::DeviceModel::unknown)
57 {
58 error("Invalid device model {MODEL} for {NAME}", "MODEL", interfaceName,
59 "NAME", config.name);
60 co_return std::nullopt;
61 }
62
63 config.deviceType = config::DeviceType::reservoirPumpUnit;
64
65 co_return config;
66}
67
68} // namespace phosphor::modbus::rtu::device