FREEDM DGI
IAdapter.hpp
Go to the documentation of this file.
1 
24 #ifndef I_ADAPTER_HPP
25 #define I_ADAPTER_HPP
26 
27 #include <set>
28 #include <cmath>
29 #include <string>
30 #include <utility>
31 
32 #include <boost/asio/io_service.hpp>
33 #include <boost/shared_ptr.hpp>
34 #include <boost/noncopyable.hpp>
35 #include <boost/thread.hpp>
36 
37 namespace freedm {
38 namespace broker {
39 namespace device {
40 
42 typedef float SignalValue;
43 
45 const SignalValue NULL_COMMAND = std::pow(10, 8);
46 
48 typedef std::pair<const std::string, const std::string> DeviceSignal;
49 
67 class IAdapter
68  : private boost::noncopyable
69 {
70 public:
72  typedef boost::shared_ptr<IAdapter> Pointer;
73 
75  virtual void Start() = 0;
76 
78  virtual void Stop() = 0;
79 
81  virtual SignalValue GetState(const std::string device,
82  const std::string signal) const = 0;
83 
85  virtual void SetCommand(const std::string device, const std::string signal,
86  const SignalValue value) = 0;
87 
89  virtual ~IAdapter();
90 
92  void RegisterDevice(const std::string devid);
93 
95  std::set<std::string> GetDevices() const;
96 
97 protected:
99  IAdapter();
100 
102  void RevealDevices();
103 
104 private:
106  std::set<std::string> m_devices;
107 };
108 
109 } // namespace device
110 } // namespace broker
111 } // namespace freedm
112 
113 #endif // I_ADAPTER_HPP
Physical adapter device interface.
Definition: IAdapter.hpp:67
std::pair< const std::string, const std::string > DeviceSignal
Type of the unique identifier for device values.
Definition: IAdapter.hpp:48
IAdapter()
Constructor.
Definition: IAdapter.cpp:47
virtual void Stop()=0
Stops the adapter. Guaranteed to be thread-safe.
std::set< std::string > m_devices
Set of registered device names.
Definition: IAdapter.hpp:106
const SignalValue NULL_COMMAND
Sent by the DGI to indicate it knows nothing about the state of a device.
Definition: IAdapter.hpp:45
virtual SignalValue GetState(const std::string device, const std::string signal) const =0
Retrieves a value from a device.
virtual void Start()=0
Starts the adapter.
virtual void SetCommand(const std::string device, const std::string signal, const SignalValue value)=0
Sets a value on a device.
float SignalValue
Type of the value for device signals.
Definition: IAdapter.hpp:42
General FREEDM Namespace.
Definition: CBroker.cpp:53
virtual ~IAdapter()
Virtual destructor for derived classes.
Definition: IAdapter.cpp:60
boost::shared_ptr< IAdapter > Pointer
Pointer to a physical adapter.
Definition: IAdapter.hpp:72
void RevealDevices()
Reveals devices in the device manager.
Definition: IAdapter.cpp:103
void RegisterDevice(const std::string devid)
Register a device name with the adapter.
Definition: IAdapter.cpp:74
std::set< std::string > GetDevices() const
Get the list of registered device names.
Definition: IAdapter.cpp:89