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