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) |
An xDevice does not provide event based configuration. | |
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, i.e. | |
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 | WriteOutput (Idx output) |
Run output command on relevant device. | |
virtual void | FlushOutputs (void) |
Flush any pending IO Operations. | |
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 | DoReadConfiguration (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0) |
Actual method to read device configuration from tokenreader. | |
virtual void | DoWriteConfiguration (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
Write the device patrameters 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 > | mInputToDevice |
Compiled data: Input map to map input idx to device no. | |
std::map< Idx, int > | mOutputToDevice |
Compiled data: Output Map to map input idx to device no. | |
bool | lastCommandWasStart |
Current device state: remember last stop/down command. |
Container of devices.
The xDevices is a container of vDevices. Input readings are combined in a union fashion over all participating devices, output 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 configured to have individual outputs or inputs, but to hold particular vDevices.
Technical detail: the xDevice uses the vDevice interface to register a common event fifo buffer and a common condition variable. 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 278 of file iop_xdevice.h.
typedef std::vector<vDevice*>::const_iterator faudes::xDevice::Iterator |
Iterator for const access to individual devices.
Definition at line 58 of file iop_xdevice.h.
faudes::xDevice::xDevice | ( | void | ) |
Default constructor.
Definition at line 45 of file iop_xdevice.cpp.
faudes::xDevice::~xDevice | ( | void | ) | [virtual] |
Explicit destructor.
Definition at line 81 of file iop_xdevice.cpp.
iterator faudes::xDevice::Begin | ( | void | ) | [inline, protected] |
Return first Device.
Definition at line 314 of file iop_xdevice.h.
Iterator faudes::xDevice::Begin | ( | void | ) | const [inline] |
Set Iterator to first device.
Definition at line 114 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 198 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 248 of file iop_xdevice.cpp.
void faudes::xDevice::Configure | ( | const EventSet & | rEvents | ) | [virtual] |
An xDevice does not provide event based configuration.
Use Insert instead. This function will throw an execption
Reimplemented from faudes::vDevice.
Definition at line 308 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 297 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 349 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 320 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 357 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 335 of file iop_xdevice.cpp.
void faudes::xDevice::DoReadConfiguration | ( | 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 404 of file iop_xdevice.cpp.
void faudes::xDevice::DoWriteConfiguration | ( | TokenWriter & | rTw, | |
const std::string & | rLabel = "" , |
|||
const Type * | pContext = 0 | |||
) | const [protected, virtual] |
Write the device patrameters to a TokenWriter.
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 366 of file iop_xdevice.cpp.
iterator faudes::xDevice::End | ( | void | ) | [inline, protected] |
Return last Device.
Definition at line 317 of file iop_xdevice.h.
Iterator faudes::xDevice::End | ( | void | ) | const [inline] |
Set Iterator to last device.
Definition at line 122 of file iop_xdevice.h.
void faudes::xDevice::FlushOutputs | ( | void | ) | [virtual] |
Flush any pending IO Operations.
Pass on flush output buffers to participating devices.
Reimplemented from faudes::vDevice.
Definition at line 462 of file iop_xdevice.cpp.
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 102 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 91 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 output/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 235 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 output/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 219 of file iop_xdevice.cpp.
void faudes::xDevice::Reset | ( | void | ) | [virtual] |
reset all dynamic state, i.e.
call reset on each device
Reimplemented from faudes::vDevice.
Definition at line 184 of file iop_xdevice.cpp.
bool faudes::xDevice::ResetRequest | ( | void | ) | [virtual] |
Test for reset request.
Reimplemented from faudes::vDevice.
Definition at line 394 of file iop_xdevice.cpp.
Idx faudes::xDevice::Size | ( | void | ) | const [inline] |
Get number of devices.
Definition at line 128 of file iop_xdevice.h.
void faudes::xDevice::Start | ( | void | ) | [virtual] |
Activate the devices.
This function enables output execution and input reading.
Exception |
|
Reimplemented from faudes::vDevice.
Definition at line 154 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 input 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 112 of file iop_xdevice.cpp.
void faudes::xDevice::Stop | ( | void | ) | [virtual] |
Deactivate the device.
This function disables output execution and input reading.
Reimplemented from faudes::vDevice.
Definition at line 169 of file iop_xdevice.cpp.
void faudes::xDevice::WriteOutput | ( | Idx | output | ) | [virtual] |
Run output command on relevant device.
Exception |
|
Implements faudes::vDevice.
Definition at line 452 of file iop_xdevice.cpp.
bool faudes::xDevice::lastCommandWasStart [protected] |
Current device state: remember last stop/down command.
Definition at line 332 of file iop_xdevice.h.
std::vector<std::string> faudes::xDevice::mDeviceNames [protected] |
Vector of member-device-names.
Definition at line 323 of file iop_xdevice.h.
std::vector<vDevice*> faudes::xDevice::mDevices [protected] |
Vector of member-devices.
Definition at line 317 of file iop_xdevice.h.
std::map<Idx,int> faudes::xDevice::mInputToDevice [protected] |
Compiled data: Input map to map input idx to device no.
Definition at line 326 of file iop_xdevice.h.
std::map<Idx,int> faudes::xDevice::mOutputToDevice [protected] |
Compiled data: Output Map to map input idx to device no.
Definition at line 329 of file iop_xdevice.h.
libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen