|
libFAUDES
Sections
Index
|
faudes::xDevice Class Reference
|
Public Types | |
typedef std::vector< vDevice * > ::const_iterator | Iterator |
Iterator for const access to individual devices. | |
Public Member Functions | |
xDevice (void) | |
Default constructor. | |
virtual | ~xDevice (void) |
Explicit destructor. | |
Iterator | Begin (void) const |
Set Iterator to first device. | |
Iterator | End (void) const |
Set Iterator to last device. | |
Idx | Size (void) const |
Get number of devices. | |
void | Insert (vDevice *device) |
Insert a new device. | |
void | Insert (const std::string &rFileName) |
Insert a new device by Filename. | |
void | Configure (Idx event, const AttributeDeviceEvent &attr) |
Dummy. | |
void | Configure (const EventSet &rEvents) |
Dummy. | |
void | Compile (void) |
Build up internal data structures. | |
void | Clear (void) |
Clear all configuarations and destroy existing devices. | |
void | Reset (void) |
reset all dynamic state, iw call reset on each device | |
bool | ResetRequest (void) |
Test for reset request. | |
void | Start (void) |
Activate the devices. | |
void | Stop (void) |
Deactivate the device. | |
DeviceState | Status (void) |
Get status. | |
void | WriteActuator (Idx actuator) |
Run actuator command. | |
tpTime::Type | CurrentTime (void) |
Report global fauDES-time Note: per convention we take the time of the first device inserted in xDevice as global time. | |
long int | CurrentTimeMs (void) |
Report global fauDES-time Note: per convention we take the time of the first device inserted in xDevice as global time. | |
virtual void | CurrentTime (tpTime::Type now) |
Set physical time in ftu. | |
virtual void | CurrentTimeMs (long int nowms) |
Set physical time in ms. | |
Static Public Member Functions | |
static xDevice * | FromTokenReader (TokenReader &rTr) |
Construct on heap from token reader. | |
static xDevice * | FromFile (const std::string &rFileName) |
Construct on heap from file. | |
Protected Types | |
typedef std::vector< vDevice * > ::iterator | iterator |
Protected Member Functions | |
virtual void | DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0) |
Actual method to read device configuration from tokenreader. | |
virtual void | DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
Actual method to write the device configuration to a TokenWriter. | |
iterator | Begin (void) |
Return first Device. | |
iterator | End (void) |
Return last Device. | |
Protected Attributes | |
std::vector< vDevice * > | mDevices |
Vector of member-devices. | |
std::vector< std::string > | mDeviceNames |
Vector of member-device-names. | |
std::map< Idx, int > | mSensorToDevice |
Compiled data: Sensor map to map sensor idx to device no. | |
std::map< Idx, int > | mActuatorToDevice |
Compiled data: Actuator Map to map sensor idx to device no. | |
bool | lastCommandWasStart |
Current device state: remember last stop/down command. |
Container of devices.
The xDevices is a container of vDevices. Sensor readings are combined in a union fashion over all participating devices, actuator writings are dispatched to the relevant device. Formally, the xDevice class is derived from the vDevice class to provide the same interaface to a simulator. Ie, the application does not need to know whether is acts on a single vDevice or an xDevice. This is also true for configuration from file, but of cause not for programatical configuration. An xDevice may not be configureb to have individual actuators or sensors, but to hold particular vDevices.
Technical detail: the xDevice uses the vDevice interface to register a common event fifo buffer and a pthread condition. Thus, the xDevice only works with devices that support this configuration feature.
Definition at line 49 of file iop_xdevice.h.
typedef std::vector<vDevice*>::iterator faudes::xDevice::iterator [protected] |
Definition at line 269 of file iop_xdevice.h.
typedef std::vector<vDevice*>::const_iterator faudes::xDevice::Iterator |
Iterator for const access to individual devices.
Definition at line 55 of file iop_xdevice.h.
faudes::xDevice::xDevice | ( | void | ) |
Default constructor.
Definition at line 33 of file iop_xdevice.cpp.
faudes::xDevice::~xDevice | ( | void | ) | [virtual] |
Explicit destructor.
Definition at line 41 of file iop_xdevice.cpp.
iterator faudes::xDevice::Begin | ( | void | ) | [inline, protected] |
Return first Device.
Definition at line 306 of file iop_xdevice.h.
Iterator faudes::xDevice::Begin | ( | void | ) | const [inline] |
Set Iterator to first device.
Definition at line 111 of file iop_xdevice.h.
void faudes::xDevice::Clear | ( | void | ) | [virtual] |
Clear all configuarations and destroy existing devices.
Reimplemented from faudes::vDevice.
Definition at line 158 of file iop_xdevice.cpp.
void faudes::xDevice::Compile | ( | void | ) | [virtual] |
Build up internal data structures.
I.e. (event-idx,int) - map
Reimplemented from faudes::vDevice.
Definition at line 209 of file iop_xdevice.cpp.
void faudes::xDevice::Configure | ( | const EventSet & | rEvents | ) | [virtual] |
Dummy.
An xDevice does not provide event based configuration. Use Insert instead. This function will throw an execption
Reimplemented from faudes::vDevice.
Definition at line 269 of file iop_xdevice.cpp.
void faudes::xDevice::Configure | ( | Idx | event, | |
const AttributeDeviceEvent & | attr | |||
) | [virtual] |
Dummy.
An xDevice does not provide event based configuration. Use Insert instead. This function will throw an execption
Reimplemented from faudes::vDevice.
Definition at line 258 of file iop_xdevice.cpp.
void faudes::xDevice::CurrentTime | ( | tpTime::Type | now | ) | [virtual] |
Set physical time in ftu.
now | now in faudes time units (ftu). |
Reimplemented from faudes::vDevice.
Definition at line 310 of file iop_xdevice.cpp.
tpTime::Type faudes::xDevice::CurrentTime | ( | void | ) | [virtual] |
Report global fauDES-time Note: per convention we take the time of the first device inserted in xDevice as global time.
Reimplemented from faudes::vDevice.
Definition at line 281 of file iop_xdevice.cpp.
void faudes::xDevice::CurrentTimeMs | ( | long int | nowms | ) | [virtual] |
Set physical time in ms.
nowms | now in msec |
Reimplemented from faudes::vDevice.
Definition at line 318 of file iop_xdevice.cpp.
long int faudes::xDevice::CurrentTimeMs | ( | void | ) | [virtual] |
Report global fauDES-time Note: per convention we take the time of the first device inserted in xDevice as global time.
Reimplemented from faudes::vDevice.
Definition at line 296 of file iop_xdevice.cpp.
void faudes::xDevice::DoRead | ( | TokenReader & | rTr, | |
const std::string & | rLabel = "" , |
|||
const Type * | pContext = 0 | |||
) | [protected, virtual] |
Actual method to read device configuration from tokenreader.
DoRead basically calls the DoWrite-function of all devices which are part of xDevice
rTr | TokenReader to read from | |
rLabel | Section to read | |
pContext | Read context to provide contextual information |
Exception |
|
Reimplemented from faudes::vDevice.
Definition at line 368 of file iop_xdevice.cpp.
void faudes::xDevice::DoWrite | ( | TokenWriter & | rTw, | |
const std::string & | rLabel = "" , |
|||
const Type * | pContext = 0 | |||
) | const [protected, virtual] |
Actual method to write the device configuration to a TokenWriter.
DoWrite basically calls the DoWrite-function of all devices which are part of xDevice
rTw | Reference to TokenWriter | |
rLabel | Label of section to write | |
pContext | Read context to provide contextual information |
Exception |
|
Reimplemented from faudes::vDevice.
Definition at line 327 of file iop_xdevice.cpp.
iterator faudes::xDevice::End | ( | void | ) | [inline, protected] |
Return last Device.
Definition at line 309 of file iop_xdevice.h.
Iterator faudes::xDevice::End | ( | void | ) | const [inline] |
Set Iterator to last device.
Definition at line 119 of file iop_xdevice.h.
xDevice * faudes::xDevice::FromFile | ( | const std::string & | rFileName | ) | [static] |
Construct on heap from file.
This constructor examines the file, determines the coressponding class and constructs the device on the heap.
rFileName | Filename |
Exception |
|
Reimplemented from faudes::vDevice.
Definition at line 62 of file iop_xdevice.cpp.
xDevice * faudes::xDevice::FromTokenReader | ( | TokenReader & | rTr | ) | [static] |
Construct on heap from token reader.
This constructor examines the token strean, determines the coressponding class and constructs the device on the heap. Todo: the implementation of this function is a hack, there must be proper solution to this issue.
rTr | TokenReader to read from |
Exception |
|
Reimplemented from faudes::vDevice.
Definition at line 51 of file iop_xdevice.cpp.
void faudes::xDevice::Insert | ( | const std::string & | rFileName | ) |
Insert a new device by Filename.
An xDevice is configured by inserting vDevices. An xDevice cannot be configured by individual actuator/sensro events.
Note: by inserting a device into an xdevice its ownership will be assumed by the xdevice and therewith the right to destoy
For information on how to write such a file see the "iodevice" - tutorial
rFileName | Configuration-file to build up device |
Definition at line 195 of file iop_xdevice.cpp.
void faudes::xDevice::Insert | ( | vDevice * | device | ) |
Insert a new device.
An xDevice is configured by inserting vDevices. An xDevice cannot be configured by individual actuator/sensro events.
Note: by inserting a device into an xdevice its ownership will be assumed by the xdevice and therewith the right to destoy it.
device | Pointer to vDevice |
Definition at line 179 of file iop_xdevice.cpp.
void faudes::xDevice::Reset | ( | void | ) | [virtual] |
reset all dynamic state, iw call reset on each device
Reimplemented from faudes::vDevice.
Definition at line 144 of file iop_xdevice.cpp.
bool faudes::xDevice::ResetRequest | ( | void | ) | [virtual] |
Test for reset request.
Reimplemented from faudes::vDevice.
Definition at line 358 of file iop_xdevice.cpp.
Idx faudes::xDevice::Size | ( | void | ) | const [inline] |
Get number of devices.
Definition at line 125 of file iop_xdevice.h.
void faudes::xDevice::Start | ( | void | ) | [virtual] |
Activate the devices.
xxx This function enables actuator execution and sensor reading.
Exception |
|
Reimplemented from faudes::vDevice.
Definition at line 114 of file iop_xdevice.cpp.
xDevice::DeviceState faudes::xDevice::Status | ( | void | ) | [virtual] |
Get status.
This function returns the current status of the device. In derived classes that use background threads for sensor reading etc, a device may change its status without notice. Dont forget to reimplement this method with an appropriate mutex.
Reimplemented from faudes::vDevice.
Definition at line 72 of file iop_xdevice.cpp.
void faudes::xDevice::Stop | ( | void | ) | [virtual] |
Deactivate the device.
This function disables actuator execution and sensor reading.
Reimplemented from faudes::vDevice.
Definition at line 129 of file iop_xdevice.cpp.
void faudes::xDevice::WriteActuator | ( | Idx | actuator | ) | [virtual] |
Run actuator command.
Exception |
|
Implements faudes::vDevice.
Definition at line 423 of file iop_xdevice.cpp.
bool faudes::xDevice::lastCommandWasStart [protected] |
Current device state: remember last stop/down command.
Definition at line 324 of file iop_xdevice.h.
std::map<Idx,int> faudes::xDevice::mActuatorToDevice [protected] |
Compiled data: Actuator Map to map sensor idx to device no.
Definition at line 321 of file iop_xdevice.h.
std::vector<std::string> faudes::xDevice::mDeviceNames [protected] |
Vector of member-device-names.
Definition at line 315 of file iop_xdevice.h.
std::vector<vDevice*> faudes::xDevice::mDevices [protected] |
Vector of member-devices.
Definition at line 309 of file iop_xdevice.h.
std::map<Idx,int> faudes::xDevice::mSensorToDevice [protected] |
Compiled data: Sensor map to map sensor idx to device no.
Definition at line 318 of file iop_xdevice.h.
libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3