About
User Reference
C++ API
luafaudes
Developer
Links
libFAUDES online
libFAUDES

Sections

Index

faudes::xDevice Class Reference
[IO Device PlugIn]

Container of devices. More...

#include <iop_xdevice.h>

List of all members.

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, 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 WriteOutput (Idx output)
 Run output 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 xDeviceFromTokenReader (TokenReader &rTr)
 Construct on heap from token reader.
static xDeviceFromFile (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.

Detailed Description

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 configureb 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 pthread condition. Thus, the xDevice only works with devices that support this configuration feature.

Definition at line 49 of file iop_xdevice.h.


Member Typedef Documentation

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 58 of file iop_xdevice.h.


Constructor & Destructor Documentation

faudes::xDevice::xDevice ( void   ) 

Default constructor.

Definition at line 40 of file iop_xdevice.cpp.

faudes::xDevice::~xDevice ( void   )  [virtual]

Explicit destructor.

Definition at line 64 of file iop_xdevice.cpp.


Member Function Documentation

iterator faudes::xDevice::Begin ( void   )  [inline, protected]

Return first Device.

Definition at line 305 of file iop_xdevice.h.

Iterator faudes::xDevice::Begin ( void   )  const [inline]

Set Iterator to first device.

Returns:
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 181 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 232 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 292 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 281 of file iop_xdevice.cpp.

void faudes::xDevice::CurrentTime ( tpTime::Type  now  )  [virtual]

Set physical time in ftu.

Parameters:
now now in faudes time units (ftu).

Reimplemented from faudes::vDevice.

Definition at line 333 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.

Returns:
fauDES-time

Reimplemented from faudes::vDevice.

Definition at line 304 of file iop_xdevice.cpp.

void faudes::xDevice::CurrentTimeMs ( long int  nowms  )  [virtual]

Set physical time in ms.

Parameters:
nowms now in msec

Reimplemented from faudes::vDevice.

Definition at line 341 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.

Returns:
fauDES-time

Reimplemented from faudes::vDevice.

Definition at line 319 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

Parameters:
rTr TokenReader to read from
rLabel Section to read
pContext Read context to provide contextual information
Exceptions:
Exception 
  • IO error (id 1)

Reimplemented from faudes::vDevice.

Definition at line 388 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.

Parameters:
rTw Reference to TokenWriter
rLabel Label of section to write
pContext Read context to provide contextual information
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::vDevice.

Definition at line 350 of file iop_xdevice.cpp.

iterator faudes::xDevice::End ( void   )  [inline, protected]

Return last Device.

Definition at line 308 of file iop_xdevice.h.

Iterator faudes::xDevice::End ( void   )  const [inline]

Set Iterator to last device.

Returns:
Iterator to last device

Definition at line 122 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.

Parameters:
rFileName Filename
Returns:
vDevice pointer
Exceptions:
Exception 
  • token mismatch (id 552)
  • IO errors (id 1)

Reimplemented from faudes::vDevice.

Definition at line 85 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.

Parameters:
rTr TokenReader to read from
Returns:
vDevice pointer
Exceptions:
Exception 
  • token mismatch (id 552)
  • IO errors (id 1)

Reimplemented from faudes::vDevice.

Definition at line 74 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

Parameters:
rFileName Configuration-file to build up device

Definition at line 218 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.

Parameters:
device Pointer to vDevice

Definition at line 202 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 167 of file iop_xdevice.cpp.

bool faudes::xDevice::ResetRequest ( void   )  [virtual]

Test for reset request.

Reimplemented from faudes::vDevice.

Definition at line 378 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.

xxx This function enables output execution and input reading.

Exceptions:
Exception 
  • Not yet configured (id 551)

Reimplemented from faudes::vDevice.

Definition at line 137 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 95 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 152 of file iop_xdevice.cpp.

void faudes::xDevice::WriteOutput ( Idx  output  )  [virtual]

Run output command.

Exceptions:
Exception 
  • unknown output event (id 65)

Implements faudes::vDevice.

Definition at line 442 of file iop_xdevice.cpp.


Member Data Documentation

Current device state: remember last stop/down command.

Definition at line 323 of file iop_xdevice.h.

std::vector<std::string> faudes::xDevice::mDeviceNames [protected]

Vector of member-device-names.

Definition at line 314 of file iop_xdevice.h.

std::vector<vDevice*> faudes::xDevice::mDevices [protected]

Vector of member-devices.

Definition at line 308 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 317 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 320 of file iop_xdevice.h.


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

libFAUDES 2.20d --- 2011.04.26 --- c++ source docu by doxygen