FREEDM DGI
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
freedm::broker::device::CFakeAdapter Class Reference

Physical adapter device interface that stores settings in itself. More...

#include <CFakeAdapter.hpp>

Inheritance diagram for freedm::broker::device::CFakeAdapter:
freedm::broker::device::IAdapter

Public Types

typedef boost::shared_ptr< CFakeAdapterPointer
 Type of a fake adapter pointer. More...
 

Public Member Functions

std::set< std::string > GetDevices () const
 Get the list of registered device names. More...
 
SignalValue GetState (const std::string device, const std::string key) const
 Retrieves a value from a device. More...
 
void RegisterDevice (const std::string devid)
 Register a device name with the adapter. More...
 
void SetCommand (const std::string device, const std::string key, const SignalValue value)
 Sets a value on a device. More...
 
void Start ()
 Start the fake adapter. More...
 
void Stop ()
 Stop the fake adapter. More...
 

Static Public Member Functions

static Pointer Create ()
 Creates a new fake adapter. More...
 

Protected Member Functions

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

Private Types

typedef std::map< std::string, KeyMapDeviceMap
 Map of devices of KeyMaps. More...
 
typedef std::map< std::string, SignalValueKeyMap
 Map of device setting keys to values. More...
 

Private Member Functions

 CFakeAdapter ()
 Constructor. More...
 

Private Attributes

DeviceMap m_registry
 Registry of device keys and values. More...
 
boost::mutex m_stopMutex
 Protects m_stopped. More...
 
bool m_stopped
 Is the adapter stopped? More...
 

Detailed Description

Physical adapter device interface that stores device settings in itself and updates them immediately when receiving commands. This class is used when no "real" adapter is desired.

Limitations:
Cannot be used for realistic power simulations, since commands take effect immediately.

Member Typedef Documentation

typedef std::map<std::string, KeyMap> freedm::broker::device::CFakeAdapter::DeviceMap
private
typedef std::map<std::string, SignalValue> freedm::broker::device::CFakeAdapter::KeyMap
private

Constructor & Destructor Documentation

freedm::broker::device::CFakeAdapter::CFakeAdapter ( )
private

Member Function Documentation

CFakeAdapter::Pointer freedm::broker::device::CFakeAdapter::Create ( )
static

Creates a new fake device adapter adapter.

Returns
a smart pointer to the new device adapter.
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::CFakeAdapter::GetState ( const std::string  device,
const std::string  key 
) const
virtual

Sets the value of a device's setting. If the device is not currently registered with the adapter, it is added. If the setting does not currently exist, it is added with a default value of 0.0

Parameters
devicethe unique identifier of the target device.
keythe desired setting on the target device.
Returns
the value of the requested setting.

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

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::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::CFakeAdapter::SetCommand ( const std::string  device,
const std::string  key,
const SignalValue  value 
)
virtual

Sets the value of a device's setting. The set occurs immediately. If the adapter has been stopped, nothing happens.

Parameters
devicethe unique identifier of the target device.
keythe desired setting on the target device.
valuethe new value for the setting to take.

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

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

Starts the fake adapter. Reveals the adapter's devices to the device manager.

Precondition:
adapter is stopped
Postcondition:
adapter is started

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

void freedm::broker::device::CFakeAdapter::Stop ( )
virtual

Stops the fake adapter. (Makes sets fail.) Thread-safe.

Precondition:
adapter is started
Postcondition:
adapter is stopped

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

Member Data Documentation

DeviceMap freedm::broker::device::CFakeAdapter::m_registry
mutableprivate
boost::mutex freedm::broker::device::CFakeAdapter::m_stopMutex
private
bool freedm::broker::device::CFakeAdapter::m_stopped
private

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