FREEDM DGI
IBufferAdapter.hpp
Go to the documentation of this file.
1 
24 #ifndef I_BUFFER_ADAPTER_HPP
25 #define I_BUFFER_ADAPTER_HPP
26 
27 #include "IAdapter.hpp"
28 
29 #include <map>
30 #include <string>
31 #include <vector>
32 
33 #include <boost/shared_ptr.hpp>
34 #include <boost/thread/shared_mutex.hpp>
35 
36 namespace freedm {
37 namespace broker {
38 namespace device {
39 
48  : public virtual IAdapter
49 {
50 public:
52  typedef boost::shared_ptr<IBufferAdapter> Pointer;
53 
55  void SetCommand(const std::string device, const std::string signal,
56  const SignalValue value);
57 
59  SignalValue GetState(const std::string device, const std::string signal) const;
60 
62  void RegisterStateInfo(const std::string device, const std::string signal,
63  const std::size_t index);
64 
66  void RegisterCommandInfo(const std::string device, const std::string signal,
67  const std::size_t index);
68 
70  void Start();
71 
73  virtual ~IBufferAdapter();
74 protected:
77 
79  std::map<const DeviceSignal, const std::size_t> m_stateInfo;
80 
82  std::map<const DeviceSignal, const std::size_t> m_commandInfo;
83 
85  std::vector<SignalValue> m_rxBuffer;
86 
88  std::vector<SignalValue> m_txBuffer;
89 
91  mutable boost::shared_mutex m_rxMutex;
92 
94  mutable boost::shared_mutex m_txMutex;
95 
98 };
99 
100 } // namespace device
101 } // namespace broker
102 } // namespace freedm
103 
104 #endif // I_BUFFER_ADAPTER_HPP
Physical adapter device interface.
Definition: IAdapter.hpp:67
void RegisterCommandInfo(const std::string device, const std::string signal, const std::size_t index)
Registers a new device signal with the physical adapter.
Definition: IBufferAdapter.cpp:269
void SetCommand(const std::string device, const std::string signal, const SignalValue value)
Set data in txBuffer.
Definition: IBufferAdapter.cpp:148
std::map< const DeviceSignal, const std::size_t > m_stateInfo
Translates a device signal into its rxBuffer (state) index.
Definition: IBufferAdapter.hpp:79
std::vector< SignalValue > m_rxBuffer
The "state table" buffer received from the external host.
Definition: IBufferAdapter.hpp:85
bool m_buffer_initialized
Flag that indicates whether the buffer is NaN.
Definition: IBufferAdapter.hpp:97
virtual ~IBufferAdapter()
Virtual destructor for derived classes.
Definition: IBufferAdapter.cpp:314
Buffer adapter device interface.
Definition: IBufferAdapter.hpp:47
std::map< const DeviceSignal, const std::size_t > m_commandInfo
Translates a device signal into its txBuffer (command) index.
Definition: IBufferAdapter.hpp:82
SignalValue GetState(const std::string device, const std::string signal) const
Retrieve data from rxBuffer.
Definition: IBufferAdapter.cpp:181
void Start()
Starts the adapter.
Definition: IBufferAdapter.cpp:70
float SignalValue
Type of the value for device signals.
Definition: IAdapter.hpp:42
void RegisterStateInfo(const std::string device, const std::string signal, const std::size_t index)
Registers a new device signal with the physical adapter.
Definition: IBufferAdapter.cpp:217
std::vector< SignalValue > m_txBuffer
The "command table" buffer sent to the external host.
Definition: IBufferAdapter.hpp:88
boost::shared_mutex m_txMutex
Provides synchronization for m_txBuffer.
Definition: IBufferAdapter.hpp:94
General FREEDM Namespace.
Definition: CBroker.cpp:53
boost::shared_ptr< IBufferAdapter > Pointer
Pointer to a physical adapter.
Definition: IBufferAdapter.hpp:52
boost::shared_mutex m_rxMutex
Provides synchronization for m_rxBuffer.
Definition: IBufferAdapter.hpp:91
IBufferAdapter()
Constructor.
Definition: IBufferAdapter.cpp:54