#include <sp_dplpexecutor.h>

Public Member Functions

Constructors & Destructor
 DeviceExecutor ()
 
 DeviceExecutor (const DeviceExecutor &)
 
 ~DeviceExecutor ()
 
DeviceExecutorNew (void)
 
Re-implemenented from ParallelExecutor
virtual void Reset (long int seed=0)
 
virtual void Clear (void)
 
bool ExecuteEvent (Idx event)
 
- Public Member Functions inherited from faudes::ProposingExecutor
 ProposingExecutor ()
 
 ProposingExecutor (const ProposingExecutor &)
 
const SimEventAttributeEventAttribute (Idx index) const
 
void EventAttribute (Idx index, const SimEventAttribute &rAttr)
 
void Alphabet (const sEventSet &rAlphabet)
 
const sEventSetAlphabet (void) const
 
TimedEvent ExecuteNextTransition ()
 
const TimedEventProposeNextTransition ()
 
std::string EventStatesToString (void) const
 
virtual void Reset (void)
 
bool ExecuteTime (Time::Type duration)
 
bool ExecuteEvent (Idx event)
 
bool ExecuteTransition (const TimedEvent &tevent)
 
bool RevertToStep (Idx step)
 
- Public Member Functions inherited from faudes::LoggingExecutor
 LoggingExecutor (void)
 
 LoggingExecutor (const LoggingExecutor &rOther)
 
 LoggingExecutor (const std::string &rFileName)
 
virtual ~LoggingExecutor (void)
 
virtual bool Valid (void) const
 
Time::Type CurrentTime (void) const
 
void CurrentTime (Time::Type time)
 
int CurrentStep (void) const
 
void CurrentStep (int step)
 
bool CurrentParallelTimedState (const ParallelTimedState &ptstate)
 
const ParallelTimedStateCurrentParallelTimedState (void) const
 
void LogOpen (TokenWriter &rTw, int mode)
 
void LogOpen (const std::string &rFileName, int logmode, std::ios::openmode openmode=std::ios::out|std::ios::trunc)
 
void LogClose (void)
 
const SimConditionSetConditions (void) const
 
void Conditions (const SimConditionSet &)
 
const AttributeSimConditionCondition (const std::string &rName) const
 
const AttributeSimConditionCondition (Idx cond) const
 
Idx SetCondition (const std::string &rName, const AttributeSimCondition &rCondition)
 
void SetCondition (Idx cond, const AttributeSimCondition &rCondition)
 
void ClrCondition (const std::string &rName)
 
void ClrCondition (Idx cond)
 
void ConditionsWrite (TokenWriter &rTw, const std::string &rLabel="SimConditions") const
 
void ConditionsRead (TokenReader &rTr, const std::string &rLabel="SimConditions")
 
ConditionIterator ConditionsBegin (void) const
 
ConditionIterator ConditionsEnd (void) const
 
bool BreakCondition (void) const
 
void TraceClear (int length=-2)
 
int TraceLength (void) const
 
TraceIterator TraceBegin (void) const
 
TraceIterator TraceEnd (void) const
 
const TraceSampleTraceAtTime (Time::Type time) const
 
const TraceSampleTraceAtStep (int step) const
 
const TraceSampleTraceFirst (void) const
 
const TraceSampleTraceRecent (void) const
 
const TraceSampleTraceCurrent (void) const
 
void TraceWrite (TokenWriter &rTw, const TraceSample &sample) const
 
void TraceWrite (const TraceSample &sample) const
 
std::string TraceToString (const TraceSample &sample) const
 
void TraceWrite (void) const
 
- Public Member Functions inherited from faudes::ParallelExecutor
 ParallelExecutor (void)
 
 ParallelExecutor (const ParallelExecutor &rOther)
 
 ParallelExecutor (const std::string &rFileName)
 
virtual ~ParallelExecutor (void)
 
Idx Size (void) const
 
void Insert (const std::string &rFileName)
 
void Insert (const TimedGenerator &rGen)
 
const EventSetAlphabet (void) const
 
Iterator Begin (void) const
 
Iterator End (void) const
 
const ExecutorAt (int i) const
 
Idx EventIndex (const std::string &rName) const
 
std::string EventName (Idx index) const
 
Time::Type CurrentTime (void) const
 
int CurrentStep (void) const
 
bool IsDeadlocked () const
 
const ParallelTimedStateCurrentParallelTimedState (void) const
 
const ParallelStateCurrentParallelState (void) const
 
const TimeIntervalEnabledTime () const
 
const EventSetEnabledEvents () const
 
const EventSetDisabledEvents () const
 
const TimeIntervalEnabledInterval () const
 
TimeInterval EnabledEventTime (Idx event) const
 
TimeInterval EnabledGuardTime (Idx event) const
 
EventSet ActiveEventSet (const ParallelState &stateVec) const
 
bool Active (Idx ev, const ParallelState &stateVec) const
 
bool Active (Idx ev) const
 
std::string PTSStr (const ParallelTimedState &ptstate) const
 
std::string PSStr (const ParallelState &pstate) const
 
std::string TEStr (const TimedEvent &tevent) const
 
std::string CStr (Idx clock) const
 
std::string EStr (Idx event) const
 
std::string CurrentParallelTimedStateStr (void) const
 
std::string CurrentParallelStateStr (void) const
 
void ComputeEnabled (void) const
 
void ComputeEnabledNonConst (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 void Name (const std::string &rName)
 
virtual const std::string & Name (void) 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)
 

Protected Member Functions

void DoAssign (const DeviceExecutor &rSrc)
 
- Protected Member Functions inherited from faudes::ProposingExecutor
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
void DoAssign (const ProposingExecutor &rSrc)
 
- Protected Member Functions inherited from faudes::LoggingExecutor
virtual void Compile ()
 
void DoAssign (const LoggingExecutor &rSrc)
 
- Protected Member Functions inherited from faudes::ParallelExecutor
virtual void DoReadGenerators (TokenReader &rTr)
 
virtual void DoWriteGenerators (TokenWriter &rTw) const
 
void DoAssign (const ParallelExecutor &rSrc)
 
- 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

bool mSyncError
 
Time::Type mMaxSyncGap
 
int mSyncMode
 
vDevicepDevice
 
- Protected Attributes inherited from faudes::ParallelExecutor
Idx mRecentEvent
 

Application Interface

enum  SyncMode { SyncStrictTime =0x01 , SyncStrictEvents =0x02 }
 
void ToleranceTime (Time::Type maxgap)
 
void ToleranceMode (int flag)
 
bool SyncTime (void)
 
Idx SyncEvents ()
 
bool SyncWait (Time::Type duration=Time::Max())
 
bool SyncWaitMs (int durationms)
 
Idx SyncStep (Time::Type duration=Time::Max())
 
bool SyncRun (Time::Type duration=Time::Max())
 
bool IsSynchronous (void) const
 
void Devicep (vDevice *dev)
 
vDeviceDevicep ()
 
void DeviceReset (void)
 
void DeviceStart (void)
 
void DeviceStop (void)
 
virtual bool DeviceResetRequest (void)
 

Additional Inherited Members

- Public Types inherited from faudes::LoggingExecutor
enum  LogMode { LogStatistics =0x01 , LogStates =0x02 , LogEvents =0x04 , LogTime =0x08 }
 
typedef SimConditionSet::Iterator ConditionIterator
 
typedef std::deque< TraceSample >::const_iterator TraceIterator
 
- Public Types inherited from faudes::ParallelExecutor
typedef std::vector< IdxParallelState
 
typedef std::vector< std::map< Idx, Time::Type > > ParallelClock
 
typedef Executor::TimedState TimedState
 
typedef std::vector< Executor >::const_iterator Iterator
 

Detailed Description

Executer with IO device to handle external/physical events

External/Physical Events and Time

This executor class is derived from the ProposingExecutor and uses a vDevice from the IO Device Plugin to handle input and output events and physical time. Technically, the class provides the routine SyncStep() that has to be called periodically to synchronize executor clock time with physical time and to perform input readings and output writings. There is also a convenience routine SyncRun() which runs a loop with SyncStep().

The SyncStep() procedure implements the below stages. It returns true, if indeed a transition was executed. It returns false on synchronistion errors or when the specified duration expired.

  • get a proposal from ProposingEcexutor
  • if physical time is ahead of the genartors current clock time, sync time by ExecuteTime; in the case that this is not consistent with the proposal, an error is reported;
  • if the generators current clock time is ahead of physical time, an error is reported
  • if a input event has been reported that can be executed at generators current time, execute it
  • if the proposal schedules an event for the generators current time, execute it
  • if a input event has been reported, execute it now; if this event is not accepted by the generator, report an error
  • if the proposals time is not yet executed, wait for that amount of time to pass or a input event to be delivered.

Naturally, the DeviceExecutor requires the IO Device plugin in order to be functional. In the absence of the plugin, the DeviceExecutor will behave like a ProposingExecutor.

File IO

The DeviceExecutor inherits file IO from the ProposingExecutor. The device itself is initialized by vDevice methods (eg configured from File) and then passed to the DeviceExecutor by the method Devicep(). Thus, the DeviceExecutor does not need to implement additional token io facilities.

Definition at line 75 of file sp_dplpexecutor.h.

Member Enumeration Documentation

◆ SyncMode

Modes of synchronisation

Enumerator
SyncStrictTime 
SyncStrictEvents 

Definition at line 177 of file sp_dplpexecutor.h.

Constructor & Destructor Documentation

◆ DeviceExecutor() [1/2]

faudes::DeviceExecutor::DeviceExecutor ( void  )

doxygen group Creates an emtpy DeviceExecutor

Definition at line 24 of file sp_dplpexecutor.cpp.

◆ DeviceExecutor() [2/2]

faudes::DeviceExecutor::DeviceExecutor ( const DeviceExecutor rOther)

Copy constructor

Definition at line 30 of file sp_dplpexecutor.cpp.

◆ ~DeviceExecutor()

faudes::DeviceExecutor::~DeviceExecutor ( void  )

Explicit destructor

Definition at line 37 of file sp_dplpexecutor.cpp.

Member Function Documentation

◆ Clear()

void faudes::DeviceExecutor::Clear ( void  )
virtual

Clear all data (generators, simulation attributes etc)

This includes the "HardwareReset" event.

Reimplemented from faudes::ProposingExecutor.

Definition at line 86 of file sp_dplpexecutor.cpp.

◆ Devicep() [1/2]

vDevice* faudes::DeviceExecutor::Devicep ( )
inline

Get device.

Retturn a refernce to the device for inspection. Note: you must not interfear with the device during synchronuous execution.

Returns
dev IO Device to use

Definition at line 309 of file sp_dplpexecutor.h.

◆ Devicep() [2/2]

void faudes::DeviceExecutor::Devicep ( vDevice dev)

Set device.

The device must be configured. You must start the device befor the first call to SyncRun. Ownership of the device stays with the caller.

Parameters
devIO Device to use

Definition at line 52 of file sp_dplpexecutor.cpp.

◆ DeviceReset()

void faudes::DeviceExecutor::DeviceReset ( void  )

Convenience: Reset the device.

Definition at line 62 of file sp_dplpexecutor.cpp.

◆ DeviceResetRequest()

bool faudes::DeviceExecutor::DeviceResetRequest ( void  )
virtual

Query the device whther it has received an external reset request. This method will reset the request.

Returns
True, if there is such a reset request

Definition at line 117 of file sp_dplpexecutor.cpp.

◆ DeviceStart()

void faudes::DeviceExecutor::DeviceStart ( void  )

Convenience: Start the device.

Definition at line 70 of file sp_dplpexecutor.cpp.

◆ DeviceStop()

void faudes::DeviceExecutor::DeviceStop ( void  )

Convenience: Stop the device.

Definition at line 78 of file sp_dplpexecutor.cpp.

◆ DoAssign()

void faudes::DeviceExecutor::DoAssign ( const DeviceExecutor rSrc)
protected

Assignment method

Parameters
rSrcSource to assign from

Definition at line 43 of file sp_dplpexecutor.cpp.

◆ ExecuteEvent()

bool faudes::DeviceExecutor::ExecuteEvent ( Idx  event)
virtual

Execute event.

Programmatically override any internal schedules and execute the specified event. This routine will neither synchronize generator time nor events.

Parameters
eventEvent by index
Returns
True on success

Reimplemented from faudes::LoggingExecutor.

Definition at line 129 of file sp_dplpexecutor.cpp.

◆ IsSynchronous()

bool faudes::DeviceExecutor::IsSynchronous ( void  ) const
inline

Test Syncronisation

Returns
True, if device time and events are in sync with generator time and events.

Definition at line 284 of file sp_dplpexecutor.h.

◆ New()

DeviceExecutor* faudes::DeviceExecutor::New ( void  )
inline

Dummy factory method.

Note: the executor classes currently do not implement faudes Type RTI related function. This factory method is only to prevent registry error messages.

Definition at line 112 of file sp_dplpexecutor.h.

◆ Reset()

void faudes::DeviceExecutor::Reset ( long int  seed = 0)
virtual

doxygen group Reset the DeviceExecutor.

Reset the executor to its initial state and reset the device, ie clear queued input event set outputs to a passive state

Parameters
seedSeed for PropossingExecutor random generator, 0<>system time

Reimplemented from faudes::ProposingExecutor.

Definition at line 92 of file sp_dplpexecutor.cpp.

◆ SyncEvents()

Idx faudes::DeviceExecutor::SyncEvents ( void  )

Execute scheduled or input events now

If an event is scheduled for now, execute it. Otherwise, execute a input event if such is ready. Otherwise execute do nothing.

Returns
Idx of event executed, 0 for no execution or error

Definition at line 230 of file sp_dplpexecutor.cpp.

◆ SyncRun()

bool faudes::DeviceExecutor::SyncRun ( Time::Type  duration = Time::Max())

Run execution with synchronous physical signals.

Loops SyncStep until the specified amount on time expired.

Parameters
durationDuration of execution wrt generator time, Time::Max for infinite
Returns
True, for no error

Definition at line 387 of file sp_dplpexecutor.cpp.

◆ SyncStep()

Idx faudes::DeviceExecutor::SyncStep ( Time::Type  duration = Time::Max())

Execute one transition with synchronous physical signals.

Calls SyncTime, SyncEvents and SyncWait to execute one transition. It will, however, not pass more than the specified duration.

Parameters
durationMax duration of execution wrt generator time, Time::Max for unlimited
Returns
Idx of executed event or 0 for time out or error

Definition at line 359 of file sp_dplpexecutor.cpp.

◆ SyncTime()

bool faudes::DeviceExecutor::SyncTime ( void  )

Execute generator clock time to sync with device time.

If possible, execute the amount of clock time required for an exact match. Otherwise, accept the specified tolerance. As a last resort, issue a sync error.

Returns
True, on success ie synchron within tolerance.

Definition at line 151 of file sp_dplpexecutor.cpp.

◆ SyncWait()

bool faudes::DeviceExecutor::SyncWait ( Time::Type  duration = Time::Max())

Wait for input events

Wait the specified amount of time, for the proposed time to elaps, or a input event to occur - whatever comes first. This function will not synchronise with generator time. You may call SyncTime afterwards.

Parameters
durationMax duration to wait for
Returns
True, if input events are available

Definition at line 291 of file sp_dplpexecutor.cpp.

◆ SyncWaitMs()

bool faudes::DeviceExecutor::SyncWaitMs ( int  durationms)

Wait for input events

Wait the specified amount of time, for the proposed time to elaps, or a input event to occur - whatever comes first. This function will not synchronise with generator time. You may call SyncTime afterwards.

Note that the executor does not know about msecs, and thus the core interface referc to faudes-time units only. This function is an exception of this rule and is for convenience only.

Parameters
durationmsMax duration in msecs to wait for
Returns
True, if input events are available

Definition at line 323 of file sp_dplpexecutor.cpp.

◆ ToleranceMode()

void faudes::DeviceExecutor::ToleranceMode ( int  flag)
inline

Set synchronisation flags.

Semantics are defined via the enum typedef SyncMode.

Parameters
flagFlag word to set mode

Definition at line 191 of file sp_dplpexecutor.h.

◆ ToleranceTime()

void faudes::DeviceExecutor::ToleranceTime ( Time::Type  maxgap)
inline

doxygen group Set tolerance for time synchonisation.

Parameters
maxgapMax acceptable amount of faudes-time units by which the generators global clock may be behind physical time

Definition at line 172 of file sp_dplpexecutor.h.

Member Data Documentation

◆ mMaxSyncGap

Time::Type faudes::DeviceExecutor::mMaxSyncGap
protected

Max gap between physical and generator clock time

Definition at line 347 of file sp_dplpexecutor.h.

◆ mSyncError

bool faudes::DeviceExecutor::mSyncError
protected

Sync error flag

Definition at line 344 of file sp_dplpexecutor.h.

◆ mSyncMode

int faudes::DeviceExecutor::mSyncMode
protected

Mode flags for synchronisation

Definition at line 350 of file sp_dplpexecutor.h.

◆ pDevice

vDevice* faudes::DeviceExecutor::pDevice
protected

Device reference

Definition at line 353 of file sp_dplpexecutor.h.


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

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