#include <iop_xdevice.h>

Public Types

typedef std::vector< vDevice * >::const_iterator Iterator
 
- Public Types inherited from faudes::vDevice
enum  DeviceState { Down , StartUp , Up , ShutDown }
 

Public Member Functions

 xDevice (void)
 
virtual ~xDevice (void)
 
Iterator Begin (void) const
 
Iterator End (void) const
 
Idx Size (void) const
 
void Insert (vDevice *device)
 
void Insert (const std::string &rFileName)
 
void Configure (Idx event, const AttributeDeviceEvent &attr)
 
void Configure (const EventSet &rEvents)
 
void Compile (void)
 
void Clear (void)
 
void Reset (void)
 
bool ResetRequest (void)
 
void Start (void)
 
void Stop (void)
 
DeviceState Status (void)
 
void WriteOutput (Idx output)
 
virtual void FlushOutputs (void)
 
Time::Type CurrentTime (void)
 
long int CurrentTimeMs (void)
 
virtual void CurrentTime (Time::Type now)
 
virtual void CurrentTimeMs (long int nowms)
 
- Public Member Functions inherited from faudes::vDevice
 vDevice (void)
 
virtual ~vDevice (void)
 
void Name (const std::string &rName)
 
const std::string & Name (void) const
 
void Tolerance (Time::Type maxgap)
 
Time::Type Tolerance (void)
 
virtual void TimeScale (unsigned int scale)
 
virtual int TimeScale (void)
 
virtual const EventSetOutputs (void) const
 
virtual const EventSetInputs (void) const
 
virtual std::string StatusString (void)
 
virtual Idx ReadInput (void)
 
virtual Idx PeekInput (void)
 
virtual bool InputReady (void)
 
virtual bool WaitInputs (Time::Type duration)
 
virtual bool WaitInputsMs (long int duration)
 
virtual faudes_systime_t FtuToSystemTime (Time::Type duration)
 
void UseCondition (faudes_mutex_t *wmutex, faudes_cond_t *wcond)
 
void UseBuffer (faudes_mutex_t *bmutex, std::deque< Idx > *bbuffer)
 
virtual std::string EStr (Idx ev)
 
SampledDensityFunction Performance (void)
 
void ResetPerformance (void)
 
void WritePerformance (void)
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 
 Type (const Type &rType)
 
virtual ~Type (void)
 
virtual TypeNew (void) const
 
virtual TypeCopy (void) const
 
virtual const TypeCast (const Type *pOther) const
 
virtual TypeAssign (const Type &rSrc)
 
Typeoperator= (const Type &rSrc)
 
virtual bool Equal (const Type &rOther) const
 
bool operator== (const Type &rOther) const
 
bool operator!= (const Type &rOther) const
 
virtual const std::string & TypeName (void) const
 
void Write (const Type *pContext=0) const
 
void Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 
void XWrite (const Type *pContext=0) const
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 
void DWrite (const Type *pContext=0) const
 
void DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
void SWrite (TokenWriter &rTw) const
 
void SWrite (void) const
 
std::string ToSText (void) const
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 

Static Public Member Functions

static xDeviceFromTokenReader (TokenReader &rTr)
 
static xDeviceFromFile (const std::string &rFileName)
 
- Static Public Member Functions inherited from faudes::vDevice
static vDeviceFromTokenReader (TokenReader &rTr)
 
static vDeviceFromFile (const std::string &rFileName)
 
static void StopAll (void)
 

Protected Types

typedef std::vector< vDevice * >::iterator iterator
 

Protected Member Functions

virtual void DoReadConfiguration (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 
virtual void DoWriteConfiguration (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
iterator Begin (void)
 
iterator End (void)
 
- Protected Member Functions inherited from faudes::vDevice
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoWritePreface (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 
virtual void DoReadPreface (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 
virtual long int FtuToMs (Time::Type faudes_time)
 
virtual Time::Type MsToFtu (long int real_time)
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 
bool DoEqual (const Type &rOther) const
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoSWrite (TokenWriter &rTw) const
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

std::vector< vDevice * > mDevices
 
std::vector< std::string > mDeviceNames
 
std::map< Idx, int > mInputToDevice
 
std::map< Idx, int > mOutputToDevice
 
bool lastCommandWasStart
 
- Protected Attributes inherited from faudes::vDevice
std::string mDefaultLabel
 
std::string mName
 
EventSetmpConfiguration
 
EventSet mInputs
 
EventSet mOutputs
 
DeviceState mState
 
faudes_mutex_t mWaitMutex
 
faudes_cond_t mWaitCondition
 
faudes_mutex_t * pWaitMutex
 
faudes_cond_t * pWaitCondition
 
faudes_systime_t mTimeZero
 
int mTimeScale
 
Time::Type mMaxSyncGap
 
std::deque< IdxmInputBuffer
 
std::deque< Idx > * pInputBuffer
 
faudes_mutex_t mBufferMutex
 
faudes_mutex_t * pBufferMutex
 
bool mResetRequest
 
faudes_systime_t * mpPerformanceWaitEnter
 
faudes_systime_t * mpPerformanceWaitExit
 
int mPerformanceEndIterator
 
int mPerformanceBeginIterator
 

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 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.

Member Typedef Documentation

◆ Iterator

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.

◆ iterator

typedef std::vector<vDevice*>::iterator faudes::xDevice::iterator
protected

Definition at line 278 of file iop_xdevice.h.

Constructor & Destructor Documentation

◆ xDevice()

faudes::xDevice::xDevice ( void  )

Default constructor

Definition at line 44 of file iop_xdevice.cpp.

◆ ~xDevice()

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

Explicit destructor.

Definition at line 80 of file iop_xdevice.cpp.

Member Function Documentation

◆ Begin() [1/2]

iterator faudes::xDevice::Begin ( void  )
inlineprotected

Return first Device

Definition at line 314 of file iop_xdevice.h.

◆ Begin() [2/2]

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.

◆ Clear()

void faudes::xDevice::Clear ( void  )
virtual

Clear all configuarations and destroy existing devices

Reimplemented from faudes::vDevice.

Definition at line 197 of file iop_xdevice.cpp.

◆ Compile()

void faudes::xDevice::Compile ( void  )
virtual

Build up internal data structures. I.e. (event-idx,int) - map

Reimplemented from faudes::vDevice.

Definition at line 247 of file iop_xdevice.cpp.

◆ Configure() [1/2]

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 307 of file iop_xdevice.cpp.

◆ Configure() [2/2]

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 296 of file iop_xdevice.cpp.

◆ CurrentTime() [1/2]

void faudes::xDevice::CurrentTime ( Time::Type  now)
virtual

Set physical time in ftu.

Parameters
nownow in faudes time units (ftu).

Reimplemented from faudes::vDevice.

Definition at line 348 of file iop_xdevice.cpp.

◆ CurrentTime() [2/2]

Time::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 319 of file iop_xdevice.cpp.

◆ CurrentTimeMs() [1/2]

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

Set physical time in ms.

Parameters
nowmsnow in msec

Reimplemented from faudes::vDevice.

Definition at line 356 of file iop_xdevice.cpp.

◆ CurrentTimeMs() [2/2]

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 334 of file iop_xdevice.cpp.

◆ DoReadConfiguration()

void faudes::xDevice::DoReadConfiguration ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Actual method to read device configuration from tokenreader.

DoRead basically calls the DoWrite-function of all devices which are part of xDevice

Parameters
rTrTokenReader to read from
rLabelSection to read
pContextRead context to provide contextual information
Exceptions
Exception
  • IO error (id 1)

Reimplemented from faudes::vDevice.

Definition at line 403 of file iop_xdevice.cpp.

◆ DoWriteConfiguration()

void faudes::xDevice::DoWriteConfiguration ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Write the device patrameters to a TokenWriter.

Parameters
rTwReference to TokenWriter
rLabelLabel of section to write
pContextRead context to provide contextual information
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::vDevice.

Definition at line 365 of file iop_xdevice.cpp.

◆ End() [1/2]

iterator faudes::xDevice::End ( void  )
inlineprotected

Return last Device

Definition at line 317 of file iop_xdevice.h.

◆ End() [2/2]

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.

◆ FlushOutputs()

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 461 of file iop_xdevice.cpp.

◆ FromFile()

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
rFileNameFilename
Returns
vDevice pointer
Exceptions
Exception
  • token mismatch (id 552)
  • IO errors (id 1)

Definition at line 101 of file iop_xdevice.cpp.

◆ FromTokenReader()

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
rTrTokenReader to read from
Returns
vDevice pointer
Exceptions
Exception
  • token mismatch (id 552)
  • IO errors (id 1)

Definition at line 90 of file iop_xdevice.cpp.

◆ Insert() [1/2]

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
rFileNameConfiguration-file to build up device

Definition at line 234 of file iop_xdevice.cpp.

◆ Insert() [2/2]

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
devicePointer to vDevice

Definition at line 218 of file iop_xdevice.cpp.

◆ Reset()

void faudes::xDevice::Reset ( void  )
virtual

reset all dynamic state, i.e. call reset on each device

Reimplemented from faudes::vDevice.

Definition at line 183 of file iop_xdevice.cpp.

◆ ResetRequest()

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

Test for reset request

Reimplemented from faudes::vDevice.

Definition at line 393 of file iop_xdevice.cpp.

◆ Size()

Idx faudes::xDevice::Size ( void  ) const
inline

Get number of devices

Definition at line 128 of file iop_xdevice.h.

◆ Start()

void faudes::xDevice::Start ( void  )
virtual

Activate the devices. This function enables output execution and input reading.

Exceptions
Exception
  • Not yet configured (id 551)

Reimplemented from faudes::vDevice.

Definition at line 153 of file iop_xdevice.cpp.

◆ Status()

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 111 of file iop_xdevice.cpp.

◆ Stop()

void faudes::xDevice::Stop ( void  )
virtual

Deactivate the device. This function disables output execution and input reading.

Reimplemented from faudes::vDevice.

Definition at line 168 of file iop_xdevice.cpp.

◆ WriteOutput()

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

Run output command on relevant device.

Exceptions
Exception
  • unknown output event (id 65)

Implements faudes::vDevice.

Definition at line 451 of file iop_xdevice.cpp.

Member Data Documentation

◆ lastCommandWasStart

bool faudes::xDevice::lastCommandWasStart
protected

Current device state: remember last stop/down command

Definition at line 332 of file iop_xdevice.h.

◆ mDeviceNames

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

Vector of member-device-names

Definition at line 323 of file iop_xdevice.h.

◆ mDevices

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

Vector of member-devices

Definition at line 320 of file iop_xdevice.h.

◆ mInputToDevice

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.

◆ mOutputToDevice

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.


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

libFAUDES 2.33b --- 2025.05.07 --- c++ api documentaion by doxygen