xref: /openbmc/phosphor-modbus/rtu/device/device_factory.hpp (revision 7184805ae4ede906935133e3e0f8ee2468bc781b)
1e92aba45SJagpal Singh Gill #pragma once
2e92aba45SJagpal Singh Gill 
3e92aba45SJagpal Singh Gill #include "base_device.hpp"
4e92aba45SJagpal Singh Gill 
5e92aba45SJagpal Singh Gill namespace phosphor::modbus::rtu::device
6e92aba45SJagpal Singh Gill {
7e92aba45SJagpal Singh Gill 
8e92aba45SJagpal Singh Gill namespace config
9e92aba45SJagpal Singh Gill {
10e92aba45SJagpal Singh Gill 
11e92aba45SJagpal Singh Gill enum class DeviceType
12e92aba45SJagpal Singh Gill {
13e92aba45SJagpal Singh Gill     reservoirPumpUnit,
14e92aba45SJagpal Singh Gill     heatExchanger,
15e92aba45SJagpal Singh Gill     flowMeter,
16e92aba45SJagpal Singh Gill     unknown
17e92aba45SJagpal Singh Gill };
18e92aba45SJagpal Singh Gill 
19e92aba45SJagpal Singh Gill enum class DeviceModel
20e92aba45SJagpal Singh Gill {
21e92aba45SJagpal Singh Gill     RDF040DSS5193E0,
22e92aba45SJagpal Singh Gill     unknown
23e92aba45SJagpal Singh Gill };
24e92aba45SJagpal Singh Gill 
25e92aba45SJagpal Singh Gill struct DeviceFactoryConfig : public Config
26e92aba45SJagpal Singh Gill {
27e92aba45SJagpal Singh Gill     DeviceType deviceType = DeviceType::unknown;
28e92aba45SJagpal Singh Gill     DeviceModel deviceModel = DeviceModel::unknown;
29e92aba45SJagpal Singh Gill };
30e92aba45SJagpal Singh Gill 
31e92aba45SJagpal Singh Gill } // namespace config
32e92aba45SJagpal Singh Gill 
33e92aba45SJagpal Singh Gill class DeviceFactory
34e92aba45SJagpal Singh Gill {
35e92aba45SJagpal Singh Gill   public:
36e92aba45SJagpal Singh Gill     DeviceFactory() = delete;
37e92aba45SJagpal Singh Gill 
38e92aba45SJagpal Singh Gill     static auto getInterfaces() -> std::vector<std::string>;
39e92aba45SJagpal Singh Gill 
40e92aba45SJagpal Singh Gill     static auto getConfig(sdbusplus::async::context& ctx,
41e92aba45SJagpal Singh Gill                           const sdbusplus::message::object_path& objectPath,
42e92aba45SJagpal Singh Gill                           const std::string& interfaceName)
43e92aba45SJagpal Singh Gill         -> sdbusplus::async::task<std::optional<config::DeviceFactoryConfig>>;
44e92aba45SJagpal Singh Gill 
45e92aba45SJagpal Singh Gill     static auto create(sdbusplus::async::context& ctx,
46e92aba45SJagpal Singh Gill                        const config::DeviceFactoryConfig& config,
47*7184805aSJagpal Singh Gill                        PortIntf& serialPort, EventIntf::Events& events)
48*7184805aSJagpal Singh Gill         -> std::unique_ptr<BaseDevice>;
49e92aba45SJagpal Singh Gill };
50e92aba45SJagpal Singh Gill 
51e92aba45SJagpal Singh Gill } // namespace phosphor::modbus::rtu::device
52