blob: d7079522febb4eb58648a9cd014a95436a1e496a [file] [log] [blame]
Jagpal Singh Gille92aba42025-10-16 00:00:13 -07001#include "device_factory.hpp"
2
3#include "reservoir_pump_unit.hpp"
4
5#include <string>
6#include <vector>
7
8namespace phosphor::modbus::rtu::device
9{
10
11using ReservoirPumpUnitIntf = phosphor::modbus::rtu::device::ReservoirPumpUnit;
12
13auto DeviceFactory::getInterfaces() -> std::vector<std::string>
14{
15 std::vector<std::string> interfaces{};
16
17 auto rpuInterfaces = ReservoirPumpUnitIntf::getInterfaces();
18 interfaces.insert(interfaces.end(), rpuInterfaces.begin(),
19 rpuInterfaces.end());
20
21 return interfaces;
22}
23
24auto DeviceFactory::getConfig(sdbusplus::async::context& ctx,
25 const sdbusplus::message::object_path& objectPath,
26 const std::string& interfaceName)
27 -> sdbusplus::async::task<std::optional<config::DeviceFactoryConfig>>
28{
29 auto rpuInterfaces = ReservoirPumpUnitIntf::getInterfaces();
30 if (rpuInterfaces.find(interfaceName) != rpuInterfaces.end())
31 {
32 co_return co_await ReservoirPumpUnitIntf::getConfig(ctx, objectPath,
33 interfaceName);
34 }
35
36 co_return std::nullopt;
37}
38
39auto DeviceFactory::create(sdbusplus::async::context& ctx,
40 const config::DeviceFactoryConfig& config,
41 PortIntf& serialPort) -> std::unique_ptr<BaseDevice>
42{
43 switch (config.deviceType)
44 {
45 case config::DeviceType::reservoirPumpUnit:
46 return std::make_unique<ReservoirPumpUnit>(ctx, config, serialPort);
47 default:
48 break;
49 }
50
51 return nullptr;
52}
53
54} // namespace phosphor::modbus::rtu::device