FREEDM DGI
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
freedm::broker::device::IBufferAdapter Class Referenceabstract

Buffer adapter device interface. More...

#include <IBufferAdapter.hpp>

Inheritance diagram for freedm::broker::device::IBufferAdapter:
freedm::broker::device::IAdapter freedm::broker::device::COpenDssAdapter freedm::broker::device::CPnpAdapter freedm::broker::device::CRtdsAdapter

Public Types

typedef boost::shared_ptr< IBufferAdapterPointer
 Pointer to a physical adapter. More...
 

Public Member Functions

virtual ~IBufferAdapter ()
 Virtual destructor for derived classes. More...
 
std::set< std::string > GetDevices () const
 Get the list of registered device names. More...
 
SignalValue GetState (const std::string device, const std::string signal) const
 Retrieve data from rxBuffer. More...
 
void RegisterCommandInfo (const std::string device, const std::string signal, const std::size_t index)
 Registers a new device signal with the physical adapter. More...
 
void RegisterDevice (const std::string devid)
 Register a device name with the adapter. More...
 
void RegisterStateInfo (const std::string device, const std::string signal, const std::size_t index)
 Registers a new device signal with the physical adapter. More...
 
void SetCommand (const std::string device, const std::string signal, const SignalValue value)
 Set data in txBuffer. More...
 
void Start ()
 Starts the adapter. More...
 
virtual void Stop ()=0
 Stops the adapter. Guaranteed to be thread-safe. More...
 

Protected Member Functions

 IBufferAdapter ()
 Constructor. More...
 
void RevealDevices ()
 Reveals devices in the device manager. More...
 

Protected Attributes

bool m_buffer_initialized
 Flag that indicates whether the buffer is NaN. More...
 
std::map< const DeviceSignal, const std::size_t > m_commandInfo
 Translates a device signal into its txBuffer (command) index. More...
 
std::vector< SignalValuem_rxBuffer
 The "state table" buffer received from the external host. More...
 
boost::shared_mutex m_rxMutex
 Provides synchronization for m_rxBuffer. More...
 
std::map< const DeviceSignal, const std::size_t > m_stateInfo
 Translates a device signal into its rxBuffer (state) index. More...
 
std::vector< SignalValuem_txBuffer
 The "command table" buffer sent to the external host. More...
 
boost::shared_mutex m_txMutex
 Provides synchronization for m_txBuffer. More...
 

Detailed Description

Defines the interface used by adapters that need send and receive buffers to communicate with an external host.

Limitations:
None.

Member Typedef Documentation

Constructor & Destructor Documentation

freedm::broker::device::IBufferAdapter::~IBufferAdapter ( )
virtual

Virtual destructor made available for derived classes.

Precondition:
None.
Postcondition:
Destructs the object.
Limitations:
None.
freedm::broker::device::IBufferAdapter::IBufferAdapter ( )
protected

Member Function Documentation

std::set< std::string > freedm::broker::device::IAdapter::GetDevices ( ) const
inherited

Accessor function for the registered device set.

Precondition:
None.
Postcondition:
Returns m_devices.
Returns
A set of device identifiers.
Limitations:
None.
SignalValue freedm::broker::device::IBufferAdapter::GetState ( const std::string  device,
const std::string  signal 
) const
virtual

Read the specified value from the rxBuffer.

Error Handling:
Throws std::exception if the value cannot be found.
Precondition:
The passed signal must be recognized by the adapter.
Postcondition:
Returns the value of the signal stored in m_rxBuffer.
Parameters
deviceThe unique identifier of a physical device.
signalA power electronic reading related to the device.
Returns
SignalValue from the rxBuffer.
Limitations:
None.

Implements freedm::broker::device::IAdapter.

void freedm::broker::device::IBufferAdapter::RegisterCommandInfo ( const std::string  device,
const std::string  signal,
const std::size_t  index 
)

Registers a new device signal as command information with the adapter.

Error Handling:
Throws a std::runtime_error if the device signal is invalid or already registered with the adapter.
Precondition:
The parameters must not be empty.
Precondition:
The device signal must not already be registered.
Precondition:
The index must not be registered with another signal.
Postcondition:
m_commandInfo is updated to store the new device signal.
Parameters
deviceThe unique identifier of the device to register.
signalThe signal of the device that will be registered.
indexThe numeric index associated with the device signal.
Limitations:
None.
void freedm::broker::device::IAdapter::RegisterDevice ( const std::string  devid)
inherited

Adds a device name to the registered device set.

Precondition:
None.
Postcondition:
Inserts the device name into m_devices.
Parameters
devidThe name of the device to register.
Limitations:
None.
void freedm::broker::device::IBufferAdapter::RegisterStateInfo ( const std::string  device,
const std::string  signal,
const std::size_t  index 
)

Registers a new device signal as state information with the adapter.

Error Handling:
Throws a std::runtime_error if the device signal is invalid or already registered with the adapter.
Precondition:
The parameters must not be empty.
Precondition:
The device signal must not already be registered.
Precondition:
The index must not be registered with another signal.
Postcondition:
m_stateInfo is updated to store the new device signal.
Parameters
deviceThe unique identifier of the device to register.
signalThe signal of the device that will be registered.
indexThe numeric index associated with the device signal.
Limitations:
None.
void freedm::broker::device::IAdapter::RevealDevices ( )
protectedinherited

Reveals the associated devices in the device manager.

Precondition:
No prior call has been made to this function.
Postcondition:
Calls CDeviceManger::RevealDevice for each known device.
Limitations:
This function can be called at most once.
void freedm::broker::device::IBufferAdapter::SetCommand ( const std::string  device,
const std::string  signal,
const SignalValue  value 
)
virtual

Update the specified value in the txBuffer.

Error Handling:
Throws std::exception if the value cannot be found.
Precondition:
The passed signal must be recognized by the adapter.
Postcondition:
Updates the value of the signal in m_txBuffer.
Parameters
deviceThe unique identifier of a physical device.
signalA power electronic reading related to the device.
valueThe desired new value for the device signal.
Limitations:
None.

Implements freedm::broker::device::IAdapter.

void freedm::broker::device::IBufferAdapter::Start ( )
virtual

Called when "starting" the adapter, after all devices have been added. Allocates send and receive buffers and performs error-checking on the device specification.

Precondition:
The adapter has not yet been started, and buffers have no size.
Postcondition:
The adapter has now been started, and buffers have been allocated.
Error Handling:
Throws std::runtime_error if the entry indices of the adapter's devices are malformed.
Limitations:
All devices must be added to the adapter before Start is invoked.

Implements freedm::broker::device::IAdapter.

virtual void freedm::broker::device::IAdapter::Stop ( )
pure virtualinherited

Member Data Documentation

bool freedm::broker::device::IBufferAdapter::m_buffer_initialized
protected
std::map<const DeviceSignal, const std::size_t> freedm::broker::device::IBufferAdapter::m_commandInfo
protected
std::vector<SignalValue> freedm::broker::device::IBufferAdapter::m_rxBuffer
protected
boost::shared_mutex freedm::broker::device::IBufferAdapter::m_rxMutex
mutableprotected
std::map<const DeviceSignal, const std::size_t> freedm::broker::device::IBufferAdapter::m_stateInfo
protected
std::vector<SignalValue> freedm::broker::device::IBufferAdapter::m_txBuffer
protected
boost::shared_mutex freedm::broker::device::IBufferAdapter::m_txMutex
mutableprotected

The documentation for this class was generated from the following files: