Detailed Description

Virtual base class to define the interface for event io.

Input and Output event IO

A vDevice provides an virtual interface to execute output events and sense input events, ie ReadInput() and WriteOutput(). The latter is prepared to be organized as a background thread that accumulates events in an internal fifo buffer. Once a input event has been read by the application, the buffer is cleared. A device is configured by passing an event set with device event attributes. The virtual base class formalls takes void attributes, and uses a dynamic cast to the actual attribute type that is provided by any derived class.

Physical Time

The vDevice defines an interface to access the current physical time. The default implementation has msec resolution and is based on the system clock. Time may be queried in ms by CurrentTimeMs() or in faudes time unis (ftu) by CurrentTime(). Faudes time units refer to defining data in eg guards and invariants of timed automata or stochastical execution properties. Conversion to physical time is by the factor mTimeScale given in msecs per ftu. There is also a default implementation WaitInputs() for timed waiting for events based on condition variables. This requires a derived class to send the according signal. Both, physical time and waiting for events, may be overwritten in derived classes.

Operating Status

The device may be in one of four operating states Down, StartUp, Up or ShutDown. Once configured you may Start() the device. The device will assychonously allocate required resources and if successful eventually be in state Up. While the device is Up, you can write outputs and read events. You can request the device to release resources by calling Stop(). While Up, you may also Reset() the device, to set outputs in passive state, to reset physical time to zero and tu flush the input fifo buffer.

File IO

The vDevice provides std faudes token io interface via faudes::Type. In addition, there is a static constructor FromTokenreader() to construct a vDevice object of specific type as indentifiesd by the token section.

Note

The vDevice derived classes implement std faudes type semantics for token IO plus the New() factory function to support type registration required for XML formated files. Assignment and comparison are, however, not implemented.

Definition at line 261 of file iop_vdevice.h.

#include <iop_vdevice.h>

Public Types

enum  DeviceState { Down , StartUp , Up , ShutDown }
 Enum for device stages. More...
 

Public Member Functions

 vDevice (void)
 Default constructor. More...
 
virtual ~vDevice (void)
 Explicit destructor. More...
 
void Name (const std::string &rName)
 Set the device name. More...
 
const std::string & Name (void) const
 Get device name. More...
 
void Tolerance (Time::Type maxgap)
 Set tolerance for time synchonisation. More...
 
Time::Type Tolerance (void)
 Get tolerance. More...
 
virtual void TimeScale (unsigned int scale)
 Set timescale. More...
 
virtual int TimeScale (void)
 Get timescale. More...
 
virtual void Clear (void)
 Clear all configuration. More...
 
virtual void Configure (Idx event, const AttributeDeviceEvent &attr)
 Insert/edit input or output configuration. More...
 
virtual void Configure (const EventSet &rPhysicalEvents)
 Configure by alphabet. More...
 
virtual void Compile (void)
 Compile inner data-structures. More...
 
virtual const EventSetOutputs (void) const
 Get outputs as plain set. More...
 
virtual const EventSetInputs (void) const
 Get inputs as plain set. More...
 
virtual void Reset (void)
 Reset device. More...
 
virtual bool ResetRequest (void)
 A device may ask for a reset by returning true for ResetRequest(). More...
 
virtual void Start (void)
 Activate the device. More...
 
virtual void Stop (void)
 Deactivate the device. More...
 
virtual DeviceState Status (void)
 Get status. More...
 
virtual std::string StatusString (void)
 Get status as infromal string. More...
 
virtual void WriteOutput (Idx output)=0
 Run output command. More...
 
virtual void FlushOutputs (void)
 Flush pending IO Operations. More...
 
virtual Idx ReadInput (void)
 Read sensed input events. More...
 
virtual Idx PeekInput (void)
 Peek for sensed events. More...
 
virtual bool InputReady (void)
 Report whether a input-event is ready. More...
 
virtual bool WaitInputs (Time::Type duration)
 Wait for input trigger. More...
 
virtual bool WaitInputsMs (long int duration)
 Wait for input trigger. More...
 
virtual Time::Type CurrentTime (void)
 Report physical time in ftu. More...
 
virtual long int CurrentTimeMs (void)
 Report physical time in ms. More...
 
virtual void CurrentTime (Time::Type now)
 Set physical time in ftu. More...
 
virtual void CurrentTimeMs (long int nowms)
 Set physical time in ms. More...
 
virtual faudes_systime_t FtuToSystemTime (Time::Type duration)
 Convert faudes time unit duration to system time. More...
 
void UseCondition (faudes_mutex_t *wmutex, faudes_cond_t *wcond)
 Tell the device which condition to use for waiting. More...
 
void UseBuffer (faudes_mutex_t *bmutex, std::deque< Idx > *bbuffer)
 Tell the device which buffer to use for inputs. More...
 
virtual std::string EStr (Idx ev)
 Convenience method. More...
 
SampledDensityFunction Performance (void)
 Get performance (need compiletime option) More...
 
void ResetPerformance (void)
 Clear performance (need compiletime option) More...
 
void WritePerformance (void)
 Convenience method. More...
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor. More...
 
 Type (const Type &rType)
 Copy constructor. More...
 
virtual ~Type (void)
 Destructor. More...
 
virtual TypeNew (void) const
 Construct on heap. More...
 
virtual TypeCopy (void) const
 Construct on heap. More...
 
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type. More...
 
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
virtual Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual const std::string & TypeName (void) const
 Get objects's type name. More...
 
void Write (const Type *pContext=0) const
 Write configuration data to console. More...
 
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
 Write configuration data to a file. More...
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file. More...
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter. More...
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file. More...
 
void XWrite (const Type *pContext=0) const
 Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes. More...
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter. More...
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string. More...
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string. More...
 
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format. More...
 
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
 Write configuration data to a file, debugging format. More...
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter. More...
 
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter. More...
 
void SWrite (void) const
 Write statistics comment to console. More...
 
std::string ToSText (void) const
 Write statistics to a string. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified. More...
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string. More...
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified. More...
 

Static Public Member Functions

static vDeviceFromTokenReader (TokenReader &rTr)
 Construct on heap from token reader. More...
 
static vDeviceFromFile (const std::string &rFileName)
 Construct on heap from file. More...
 
static void StopAll (void)
 Stop all devices. More...
 

Protected Member Functions

virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Token output, see Type::Write for public wrappers. More...
 
virtual void DoWritePreface (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Writes non-event-configuration data from TokenWriter. More...
 
virtual void DoWriteConfiguration (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Writes event-configuration to TokenWriter. More...
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Token input, see Type::DRead for public wrappers. More...
 
virtual void DoReadPreface (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Reads non-event-configuration data from TokenReader. More...
 
virtual void DoReadConfiguration (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Reads event-configuration data from TokenReader. More...
 
virtual long int FtuToMs (Time::Type faudes_time)
 convert duration from fauDES-time units to ms More...
 
virtual Time::Type MsToFtu (long int real_time)
 convert duration in ms to faudes-time units More...
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
bool DoEqual (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter in XML format. More...
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debugging format to TokenWriter. More...
 
virtual void DoSWrite (TokenWriter &rTw) const
 Write statistical data as a comment to TokenWriter. More...
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 Get objects's type definition. More...
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

std::string mDefaultLabel
 Default label for token io. More...
 
std::string mName
 Name. More...
 
EventSetmpConfiguration
 Overall event configuration (uses cast for type) More...
 
EventSet mInputs
 All inputs. More...
 
EventSet mOutputs
 All outputs. More...
 
DeviceState mState
 Status: running, starting etc. More...
 
faudes_mutex_t mWaitMutex
 Default Wait Condition Mutex. More...
 
faudes_cond_t mWaitCondition
 Default Wait Condition. More...
 
faudes_mutex_t * pWaitMutex
 Actual Wait Condition Mutex. More...
 
faudes_cond_t * pWaitCondition
 Actual Wait Condition. More...
 
faudes_systime_t mTimeZero
 physical timepoint zero
More...
 
int mTimeScale
 FauDES-time: scaling factor in ms/ftu. More...
 
Time::Type mMaxSyncGap
 Toleance for time sync. More...
 
std::deque< IdxmInputBuffer
 Default Fifo buffer for input readings. More...
 
std::deque< Idx > * pInputBuffer
 Actual Fifo buffer for input readings. More...
 
faudes_mutex_t mBufferMutex
 Default mutex for input buffer (mutexted) More...
 
faudes_mutex_t * pBufferMutex
 Actual mutex for input buffer (mutexted) More...
 
bool mResetRequest
 Reset request marker (mutexed) More...
 
faudes_systime_t * mpPerformanceWaitEnter
 Structures to store time-samples in. More...
 
faudes_systime_t * mpPerformanceWaitExit
 
int mPerformanceEndIterator
 Global iterator. More...
 
int mPerformanceBeginIterator
 

Static Private Member Functions

static std::set< vDevice * > & AllDevices (void)
 

Friends

class xDevice
 

Member Enumeration Documentation

◆ DeviceState

Enum for device stages.

Enumerator
Down 
StartUp 
Up 
ShutDown 

Definition at line 270 of file iop_vdevice.h.

Constructor & Destructor Documentation

◆ vDevice()

faudes::vDevice::vDevice ( void  )

Default constructor.

Definition at line 149 of file iop_vdevice.cpp.

◆ ~vDevice()

faudes::vDevice::~vDevice ( void  )
virtual

Explicit destructor.

Definition at line 191 of file iop_vdevice.cpp.

Member Function Documentation

◆ AllDevices()

std::set< vDevice * > & faudes::vDevice::AllDevices ( void  )
staticprivate

Definition at line 184 of file iop_vdevice.cpp.

◆ Clear()

void faudes::vDevice::Clear ( void  )
virtual

Clear all configuration.

This implies Stop().

Reimplemented from faudes::Type.

Reimplemented in faudes::xDevice, faudes::nDevice, faudes::sDevice, and faudes::mbDevice.

Definition at line 325 of file iop_vdevice.cpp.

◆ Compile()

void faudes::vDevice::Compile ( void  )
virtual

Compile inner data-structures.

As every derived class may have its own individual inner data-structures to set up, it has to reimplement its own Compile()-function if needed.

In the base class Compile() builds up the input- and output event set.

Reimplemented in faudes::xDevice, faudes::nDevice, faudes::sDevice, and faudes::mbDevice.

Definition at line 647 of file iop_vdevice.cpp.

◆ Configure() [1/2]

void faudes::vDevice::Configure ( const EventSet rPhysicalEvents)
virtual

Configure by alphabet.

For a nontrivial device, a dynamic cast is used to access atributes of the alphabet parameter.

Parameters
rPhysicalEventsEvent set with configuration attributes
Exceptions
Exception
  • Cannot cast argument (id 550)

Reimplemented in faudes::xDevice.

Definition at line 625 of file iop_vdevice.cpp.

◆ Configure() [2/2]

void faudes::vDevice::Configure ( Idx  event,
const AttributeDeviceEvent attr 
)
virtual

Insert/edit input or output configuration.

For a nontrivial device, a dynamic cast is used to access the attribute parameter.

Parameters
eventInput or output event by faudes index
attrConfiguration attribute
Exceptions
Exception
  • unknown event (id 65)
  • Cannot cast attribute (id 550)

Reimplemented in faudes::xDevice.

Definition at line 606 of file iop_vdevice.cpp.

◆ CurrentTime() [1/2]

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

Set physical time in ftu.

Parameters
nowphysical time in faudes time units (ftu).

Reimplemented in faudes::xDevice.

Definition at line 753 of file iop_vdevice.cpp.

◆ CurrentTime() [2/2]

Time::Type faudes::vDevice::CurrentTime ( void  )
virtual

Report physical time in ftu.

The time elapsed since the last reset is retunred in faudes time units (ftu).

Returns
Physical time.

Reimplemented in faudes::xDevice.

Definition at line 739 of file iop_vdevice.cpp.

◆ CurrentTimeMs() [1/2]

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

Set physical time in ms.

Parameters
nowmsphysical time in msec

Reimplemented in faudes::xDevice.

Definition at line 775 of file iop_vdevice.cpp.

◆ CurrentTimeMs() [2/2]

long int faudes::vDevice::CurrentTimeMs ( void  )
virtual

Report physical time in ms.

The time elapsed since the last reset is returned in msecs.

Returns
Physical time.

Reimplemented in faudes::xDevice.

Definition at line 760 of file iop_vdevice.cpp.

◆ DoRead()

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

Token input, see Type::DRead for public wrappers.

The vDevice implkements token input to consist of DoReadPreface (name, time scale etc) and DoReadConfiguration (events attributes), followed by Compile (set up internal data structures). The default label is given by the member variable mDefaultLabel. Derived classes arte meant to set mDefaultLabel in their constructor and to reimplement DoReadPreface to cover additional parameters. The pContext parameter is ignored.

Parameters
rTrReference to TokenReader
rLabelLabel of section to write, defaults to name of set
pContextWrite context to provide contextual information

Reimplemented from faudes::Type.

Definition at line 465 of file iop_vdevice.cpp.

◆ DoReadConfiguration()

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

Reads event-configuration data from TokenReader.

This function is part of the token-input mechanism and reads the device-specific event-configuration. It uses the virtual interface of TBaseSet to figure the actual attribute type. The section defaults to "EventConfiguration".

Parameters
rTrTokenReader to read
rLabelSection to read
pContextProvide contextual information

Reimplemented in faudes::xDevice.

Definition at line 490 of file iop_vdevice.cpp.

◆ DoReadPreface()

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

Reads non-event-configuration data from TokenReader.

This function is part of the non-event-configuration token-input mechanism and located at the top of the class hierarchy. The vDevice will read its name and the time scale, derived classes are meant to first call the base class method and then read add additional configuration parameters.

Note: in order to keep the inputfile-layout as easy as possible no label will be used to separate this data-section. Never the less a default-label ("Device") is specified.

Parameters
rTrTokenReader to write
rLabelSection to read
pContextProvide contextual information

Reimplemented in faudes::nDevice, faudes::sDevice, and faudes::mbDevice.

Definition at line 574 of file iop_vdevice.cpp.

◆ DoWrite()

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

Token output, see Type::Write for public wrappers.

The vDevice inplements token writing to consist of DoWritePreface (device name and time scale). and DoWriteConfiguration (device specific event attributes). The default label is taken from the member variable mDefaultLabel. Derived classes are meant to set mDefaultLabel in their constructor and to reimplement DoWritePreface to add additional data eg cycle time or network address. The parameter pContext is ignored and passed on.

Parameters
rTwReference to TokenWriter
rLabelLabel of section to write, defaults to name of set
pContextWrite context to provide contextual information

Reimplemented from faudes::Type.

Definition at line 373 of file iop_vdevice.cpp.

◆ DoWriteConfiguration()

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

Writes event-configuration to TokenWriter.

This function is part of the event-configuration token-output mechanism. It writes the device-specific event-configuration to provided TokenWriter. It uses the virtual interface of TBaseSet to figure the actual attribute type.

Note: the event-configuration will be labeled by "EventConfiguration"

Parameters
rTwTokenWriter to write to
rLabelSection to write
pContextProvide contextual information

Reimplemented in faudes::xDevice.

Definition at line 408 of file iop_vdevice.cpp.

◆ DoWritePreface()

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

Writes non-event-configuration data from TokenWriter.

This function is part of the non-event-configuration token-output mechanism. The vDevice will write its name and the time scale, derived classes are meant to first call the base class method and then add additional configuration parameter.

Note: in order to keep the inputfile-layout as easy as possible no label will be used to separate this data-section. Never the less a default-label ("Device") is specified.

Parameters
rTwTokenWriter to write to
rLabelSection to read
pContextProvide contextual information

Reimplemented in faudes::nDevice, faudes::sDevice, and faudes::mbDevice.

Definition at line 395 of file iop_vdevice.cpp.

◆ EStr()

virtual std::string faudes::vDevice::EStr ( Idx  ev)
inlinevirtual

Convenience method.

Definition at line 627 of file iop_vdevice.h.

◆ FlushOutputs()

void faudes::vDevice::FlushOutputs ( void  )
virtual

Flush pending IO Operations.

A device may implement buffered output operations, i.e. to assemble a process image befor applying it to the physical plant. By FlushOutputs() you can ask the device to execute all buffered output operations. FlushOutputs() is called by WaitInputs() and WaitInputsMs(), so buffers are automatically flushed when the simulation waits for input events. The default impelmentation of FlushOutputs() does nothing.

Reimplemented in faudes::xDevice.

Definition at line 916 of file iop_vdevice.cpp.

◆ FromFile()

vDevice * faudes::vDevice::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 248 of file iop_vdevice.cpp.

◆ FromTokenReader()

vDevice * faudes::vDevice::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 212 of file iop_vdevice.cpp.

◆ FtuToMs()

long int faudes::vDevice::FtuToMs ( Time::Type  faudes_time)
protectedvirtual

convert duration from fauDES-time units to ms

Definition at line 720 of file iop_vdevice.cpp.

◆ FtuToSystemTime()

faudes_systime_t faudes::vDevice::FtuToSystemTime ( Time::Type  duration)
virtual

Convert faudes time unit duration to system time.

Note: this helper function is not static since it refers to the parameter mTimeScale.

Returns
Absolut system-time form now + duration in the future
Parameters
durationTime in faudes-time

Definition at line 699 of file iop_vdevice.cpp.

◆ InputReady()

bool faudes::vDevice::InputReady ( void  )
virtual

Report whether a input-event is ready.

Definition at line 971 of file iop_vdevice.cpp.

◆ Inputs()

const EventSet & faudes::vDevice::Inputs ( void  ) const
virtual

Get inputs as plain set.

Returns
Set of all configured inputs

Definition at line 694 of file iop_vdevice.cpp.

◆ MsToFtu()

Time::Type faudes::vDevice::MsToFtu ( long int  real_time)
protectedvirtual

convert duration in ms to faudes-time units

Definition at line 731 of file iop_vdevice.cpp.

◆ Name() [1/2]

void faudes::vDevice::Name ( const std::string &  rName)
virtual

Set the device name.

Parameters
rNameGenerator name

Reimplemented from faudes::Type.

Definition at line 340 of file iop_vdevice.cpp.

◆ Name() [2/2]

const std::string & faudes::vDevice::Name ( void  ) const
virtual

Get device name.

Returns
Name of generator

Reimplemented from faudes::Type.

Definition at line 346 of file iop_vdevice.cpp.

◆ Outputs()

const EventSet & faudes::vDevice::Outputs ( void  ) const
virtual

Get outputs as plain set.

Returns
Set of all configured outputs

Definition at line 689 of file iop_vdevice.cpp.

◆ PeekInput()

Idx faudes::vDevice::PeekInput ( void  )
virtual

Peek for sensed events.

Report the oldest input-event from the buffer. However, dont remove the event.

Returns
Input-event index or 0 if no such available.

Definition at line 950 of file iop_vdevice.cpp.

◆ Performance()

SampledDensityFunction faudes::vDevice::Performance ( void  )

Get performance (need compiletime option)

Definition at line 987 of file iop_vdevice.cpp.

◆ ReadInput()

Idx faudes::vDevice::ReadInput ( void  )
virtual

Read sensed input events.

Report the oldest event from the internal input buffer. The event is removed from the buffer. The function returns 0 if the buffer is empty.

Definition at line 930 of file iop_vdevice.cpp.

◆ Reset()

void faudes::vDevice::Reset ( void  )
virtual

Reset device.

Resets any dynamic state such as edge detection. Since the vDevice only provides timing, it only resets the current faudes time to zero. A reset does not stop the device.

Reimplemented in faudes::xDevice, faudes::nDevice, and faudes::sDevice.

Definition at line 311 of file iop_vdevice.cpp.

◆ ResetPerformance()

void faudes::vDevice::ResetPerformance ( void  )

Clear performance (need compiletime option)

Definition at line 1037 of file iop_vdevice.cpp.

◆ ResetRequest()

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

A device may ask for a reset by returning true for ResetRequest().

A well behaved simulator application will perform a Reset() and initialise any faudes::Executors, and stop the simulation. The device is meant to cancel any pending WaitInputs() or WaitInputsMs() when it requests a reset. The default implementation returns false;

Returns
True, if a reset is requested

Reimplemented in faudes::xDevice.

Definition at line 920 of file iop_vdevice.cpp.

◆ Start()

void faudes::vDevice::Start ( void  )
virtual

Activate the device.

This function enables output execution and input reading. It will allocate device specific necessary resources eg start a background thread, initialise operating system device drivers etc.

Exceptions
Exception
  • Not yet configured (id 551)

Reimplemented in faudes::xDevice, faudes::nDevice, faudes::sDevice, and faudes::mbDevice.

Definition at line 281 of file iop_vdevice.cpp.

◆ Status()

virtual DeviceState faudes::vDevice::Status ( void  )
inlinevirtual

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. Stop runs Reset()

Reimplemented in faudes::xDevice.

Definition at line 486 of file iop_vdevice.h.

◆ StatusString()

std::string faudes::vDevice::StatusString ( void  )
virtual

Get status as infromal string.

Definition at line 353 of file iop_vdevice.cpp.

◆ Stop()

void faudes::vDevice::Stop ( void  )
virtual

Deactivate the device.

This function disables output execution and input reading. Stop also runs Reset.

Reimplemented in faudes::xDevice, faudes::nDevice, faudes::sDevice, and faudes::mbDevice.

Definition at line 299 of file iop_vdevice.cpp.

◆ StopAll()

void faudes::vDevice::StopAll ( void  )
static

Stop all devices.

This function is intended to be called on ungraceful termination of a simulater application. It uses a global variable that tracks all device instances.

Definition at line 257 of file iop_vdevice.cpp.

◆ TimeScale() [1/2]

virtual void faudes::vDevice::TimeScale ( unsigned int  scale)
inlinevirtual

Set timescale.

Parameters
scaleConversion factor in msecs/ftu (faudes time units)

Definition at line 364 of file iop_vdevice.h.

◆ TimeScale() [2/2]

virtual int faudes::vDevice::TimeScale ( void  )
inlinevirtual

Get timescale.

Returns
Conversion factor in msecs/ftu (faudes time units)

Definition at line 374 of file iop_vdevice.h.

◆ Tolerance() [1/2]

void faudes::vDevice::Tolerance ( Time::Type  maxgap)
inline

Set tolerance for time synchonisation.

Parameters
maxgapMax acceptable amount of time by which the generator may be behind device time.

Definition at line 344 of file iop_vdevice.h.

◆ Tolerance() [2/2]

Time::Type faudes::vDevice::Tolerance ( void  )
inline

Get tolerance.

Returns
Max acceptable amount of time by which the generator may be behind device time

Definition at line 354 of file iop_vdevice.h.

◆ UseBuffer()

void faudes::vDevice::UseBuffer ( faudes_mutex_t *  bmutex,
std::deque< Idx > *  bbuffer 
)

Tell the device which buffer to use for inputs.

Definition at line 680 of file iop_vdevice.cpp.

◆ UseCondition()

void faudes::vDevice::UseCondition ( faudes_mutex_t *  wmutex,
faudes_cond_t *  wcond 
)

Tell the device which condition to use for waiting.

Definition at line 671 of file iop_vdevice.cpp.

◆ WaitInputs()

bool faudes::vDevice::WaitInputs ( Time::Type  duration)
virtual

Wait for input trigger.

The default implementation assumes that inputs events are notified via the condition signal. The duration to wait is specified in faudes time units (ftu) and is converted to system time by the scaling factor mTimeScale (ms/ftu).

Returns
True, if events are available for read.

Definition at line 800 of file iop_vdevice.cpp.

◆ WaitInputsMs()

bool faudes::vDevice::WaitInputsMs ( long int  duration)
virtual

Wait for input trigger.

Same as WaitInputs, but with the maximum time to wait given in msecs.

Returns
True, if events are available for read.

Definition at line 860 of file iop_vdevice.cpp.

◆ WriteOutput()

virtual void faudes::vDevice::WriteOutput ( Idx  output)
pure virtual

Run output command.

Exceptions
Exception
  • unknown output event (id 65)

Implemented in faudes::xDevice, faudes::nDevice, and faudes::sDevice.

◆ WritePerformance()

void faudes::vDevice::WritePerformance ( void  )

Convenience method.

Definition at line 1026 of file iop_vdevice.cpp.

Friends And Related Function Documentation

◆ xDevice

friend class xDevice ( void  )
friend

Definition at line 264 of file iop_vdevice.h.

Member Data Documentation

◆ mBufferMutex

faudes_mutex_t faudes::vDevice::mBufferMutex
protected

Default mutex for input buffer (mutexted)

Definition at line 800 of file iop_vdevice.h.

◆ mDefaultLabel

std::string faudes::vDevice::mDefaultLabel
protected

Default label for token io.

Definition at line 721 of file iop_vdevice.h.

◆ mInputBuffer

std::deque<Idx> faudes::vDevice::mInputBuffer
protected

Default Fifo buffer for input readings.

Definition at line 794 of file iop_vdevice.h.

◆ mInputs

EventSet faudes::vDevice::mInputs
protected

All inputs.

Definition at line 764 of file iop_vdevice.h.

◆ mMaxSyncGap

Time::Type faudes::vDevice::mMaxSyncGap
protected

Toleance for time sync.

Definition at line 791 of file iop_vdevice.h.

◆ mName

std::string faudes::vDevice::mName
protected

Name.

Definition at line 758 of file iop_vdevice.h.

◆ mOutputs

EventSet faudes::vDevice::mOutputs
protected

All outputs.

Definition at line 767 of file iop_vdevice.h.

◆ mpConfiguration

EventSet* faudes::vDevice::mpConfiguration
protected

Overall event configuration (uses cast for type)

Definition at line 761 of file iop_vdevice.h.

◆ mPerformanceBeginIterator

int faudes::vDevice::mPerformanceBeginIterator
protected

Definition at line 832 of file iop_vdevice.h.

◆ mPerformanceEndIterator

int faudes::vDevice::mPerformanceEndIterator
protected

Global iterator.

Definition at line 831 of file iop_vdevice.h.

◆ mpPerformanceWaitEnter

faudes_systime_t* faudes::vDevice::mpPerformanceWaitEnter
protected

Structures to store time-samples in.

Definition at line 827 of file iop_vdevice.h.

◆ mpPerformanceWaitExit

faudes_systime_t* faudes::vDevice::mpPerformanceWaitExit
protected

Definition at line 828 of file iop_vdevice.h.

◆ mResetRequest

bool faudes::vDevice::mResetRequest
protected

Reset request marker (mutexed)

Definition at line 806 of file iop_vdevice.h.

◆ mState

DeviceState faudes::vDevice::mState
protected

Status: running, starting etc.

Definition at line 770 of file iop_vdevice.h.

◆ mTimeScale

int faudes::vDevice::mTimeScale
protected

FauDES-time: scaling factor in ms/ftu.

Definition at line 788 of file iop_vdevice.h.

◆ mTimeZero

faudes_systime_t faudes::vDevice::mTimeZero
protected

physical timepoint zero

Definition at line 785 of file iop_vdevice.h.

◆ mWaitCondition

faudes_cond_t faudes::vDevice::mWaitCondition
protected

Default Wait Condition.

Definition at line 776 of file iop_vdevice.h.

◆ mWaitMutex

faudes_mutex_t faudes::vDevice::mWaitMutex
protected

Default Wait Condition Mutex.

Definition at line 773 of file iop_vdevice.h.

◆ pBufferMutex

faudes_mutex_t* faudes::vDevice::pBufferMutex
protected

Actual mutex for input buffer (mutexted)

Definition at line 803 of file iop_vdevice.h.

◆ pInputBuffer

std::deque<Idx>* faudes::vDevice::pInputBuffer
protected

Actual Fifo buffer for input readings.

Definition at line 797 of file iop_vdevice.h.

◆ pWaitCondition

faudes_cond_t* faudes::vDevice::pWaitCondition
protected

Actual Wait Condition.

Definition at line 782 of file iop_vdevice.h.

◆ pWaitMutex

faudes_mutex_t* faudes::vDevice::pWaitMutex
protected

Actual Wait Condition Mutex.

Definition at line 779 of file iop_vdevice.h.


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

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen