FREEDM DGI
|
Defines the interface used to access physical hardware. More...
#include <CDevice.hpp>
Public Types | |
typedef boost::shared_ptr< CDevice > | Pointer |
Pointer to physical device interface. More... | |
Public Member Functions | |
CDevice (std::string id, DeviceInfo info, IAdapter::Pointer adapter) | |
Constructs a device with a specific structure and adapter. More... | |
std::set< std::string > | GetCommandSet () const |
Gets the set of command signals recognized by the device. More... | |
std::string | GetID () const |
Gets the unique identifier for this device. More... | |
SignalValue | GetState (std::string signal) const |
Gets the current state of some signal from the adapter. More... | |
std::set< std::string > | GetStateSet () const |
Gets the set of state signals recognized by the device. More... | |
bool | HasCommand (std::string signal) const |
Checks if the device recognizes a command signal. More... | |
bool | HasState (std::string signal) const |
Checks if the device recognizes a state signal. More... | |
bool | HasType (std::string type) const |
Checks if the device recognizes a type. More... | |
void | SetCommand (std::string signal, SignalValue value) |
Sets the next command for some signal in the adapter. More... | |
Private Attributes | |
IAdapter::Pointer | m_adapter |
Adapter that handles the storage for this device. More... | |
std::string | m_devid |
Unique identifier for this device. More... | |
DeviceInfo | m_devinfo |
Internal structure of this device. More... | |
The CDevice class provides the universal interface for how modules in the DGI interact with physical hardware. Each device object has an internal DeviceInfo structure that specifies which types, states, and commands the device object recognizes. If the device object tries to access a state or command not defined by its structure, it will throw a runtime exception. The device structure must be defined when a device object is created and cannot be changed after construction.
The storage for devices is handled by a separate IAdapter member variable. A device object queries its associated adapter each time it needs to read a state variable or update a command value. An adapter must be defined at device construction and cannot be changed later.
typedef boost::shared_ptr<CDevice> freedm::broker::device::CDevice::Pointer |
freedm::broker::device::CDevice::CDevice | ( | std::string | id, |
DeviceInfo | info, | ||
IAdapter::Pointer | adapter | ||
) |
Constructor for device objects.
id | The unique identifier for this device object. |
info | The structure that defines the type of this device object. |
adapter | The adapter that handles storage for this device object. |
std::set< std::string > freedm::broker::device::CDevice::GetCommandSet | ( | ) | const |
Accessor for the set of recognized command signals.
std::string freedm::broker::device::CDevice::GetID | ( | ) | const |
Accessor for the unique device identifier.
SignalValue freedm::broker::device::CDevice::GetState | ( | std::string | signal | ) | const |
Gets the value of a device state from the adapter.
signal | The string identifier for the state signal to retrieve. |
std::set< std::string > freedm::broker::device::CDevice::GetStateSet | ( | ) | const |
Accessor for the set of recognized state signals.
bool freedm::broker::device::CDevice::HasCommand | ( | std::string | signal | ) | const |
Checks if the device has some specified command.
signal | The string identifier of some command signal. |
bool freedm::broker::device::CDevice::HasState | ( | std::string | signal | ) | const |
Checks if the device has some specified state.
signal | The string identifier of some state signal. |
bool freedm::broker::device::CDevice::HasType | ( | std::string | type | ) | const |
Checks if the device can be used as a specific type.
type | The string identifier of some device type. |
void freedm::broker::device::CDevice::SetCommand | ( | std::string | signal, |
SignalValue | value | ||
) |
Sets the value of a device command in the adapter.
signal | The string identifier for the command signal to set. |
value | The value to set for the command signal. |
|
private |
|
private |
|
private |