faudes::DeviceExecutor Class Reference
[Simulator PlugIn]

Executer with IO device to handle external/physical events. More...

#include <sp_dplpexecutor.h>

List of all members.

Public Member Functions

Constructors & Destructor

 DeviceExecutor ()
 Creates an emtpy DeviceExecutor.
 DeviceExecutor (const DeviceExecutor &)
 Copy constructor.
 ~DeviceExecutor ()
 Explicit destructor.
DeviceExecutorNew (void)
 Dummy factory method.
Re-implemenented from ParallelExecutor

virtual void Reset (long int seed=0)
 Reset the DeviceExecutor.
virtual void Clear (void)
 Clear all data (generators, simulation attributes etc).
bool ExecuteEvent (Idx event)
 Execute event.

Protected Member Functions

virtual void DoAssign (const DeviceExecutor &rSrc)
 Assignment method.

Protected Attributes

bool mSyncError
 Sync error flag.
tpTime::Type mMaxSyncGap
 Max gap between physical and generator clock time.
int mSyncMode
 Mode flags for synchronisation.
vDevicepDevice
 Device reference.

Application Interface



enum  SyncMode { SyncStrictTime = 0x01, SyncStrictEvents = 0x02 }
 

Modes of synchronisation.

More...
void ToleranceTime (tpTime::Type maxgap)
 Set tolerance for time synchonisation.
void ToleranceMode (int flag)
 Set synchronisation flags.
bool SyncTime (void)
 Execute generator clock time to sync with device time.
Idx SyncEvents ()
 Execute scheduled or input events now.
bool SyncWait (tpTime::Type duration=tpTime::Max)
 Wait for input events.
bool SyncWaitMs (int durationms)
 Wait for input events.
Idx SyncStep (tpTime::Type duration=tpTime::Max)
 Execute one transition with synchronous physical signals.
bool SyncRun (tpTime::Type duration=tpTime::Max)
 Run execution with synchronous physical signals.
bool IsSynchronous (void) const
 Test Syncronisation.
void Devicep (vDevice *dev)
 Set device.
vDeviceDevicep ()
 Get device.
void DeviceReset (void)
 Convenience: Reset the device.
void DeviceStart (void)
 Convenience: Start the device.
void DeviceStop (void)
 Convenience: Stop the device.
virtual bool DeviceResetRequest (void)
 Query the device whther it has received an external reset request.

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 77 of file sp_dplpexecutor.h.


Member Enumeration Documentation

Modes of synchronisation.

Enumerator:
SyncStrictTime 
SyncStrictEvents 

Definition at line 179 of file sp_dplpexecutor.h.


Constructor & Destructor Documentation

faudes::DeviceExecutor::DeviceExecutor ( void   ) 

Creates an emtpy DeviceExecutor.

doxygen group

Definition at line 22 of file sp_dplpexecutor.cpp.

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

Copy constructor.

Definition at line 28 of file sp_dplpexecutor.cpp.

faudes::DeviceExecutor::~DeviceExecutor ( void   ) 

Explicit destructor.

Definition at line 35 of file sp_dplpexecutor.cpp.


Member Function Documentation

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 84 of file sp_dplpexecutor.cpp.

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 311 of file sp_dplpexecutor.h.

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:
dev IO Device to use

Definition at line 50 of file sp_dplpexecutor.cpp.

void faudes::DeviceExecutor::DeviceReset ( void   ) 

Convenience: Reset the device.

Definition at line 60 of file sp_dplpexecutor.cpp.

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 115 of file sp_dplpexecutor.cpp.

void faudes::DeviceExecutor::DeviceStart ( void   ) 

Convenience: Start the device.

Definition at line 68 of file sp_dplpexecutor.cpp.

void faudes::DeviceExecutor::DeviceStop ( void   ) 

Convenience: Stop the device.

Definition at line 76 of file sp_dplpexecutor.cpp.

void faudes::DeviceExecutor::DoAssign ( const DeviceExecutor rSrc  )  [protected, virtual]

Assignment method.

Parameters:
rSrc Source to assign from

Definition at line 41 of file sp_dplpexecutor.cpp.

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:
event Event by index
Returns:
True on success

Reimplemented from faudes::ProposingExecutor.

Definition at line 127 of file sp_dplpexecutor.cpp.

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 286 of file sp_dplpexecutor.h.

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 114 of file sp_dplpexecutor.h.

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

Reset the DeviceExecutor.

doxygen group

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

Parameters:
seed Seed for PropossingExecutor random generator, 0<>system time

Reimplemented from faudes::ProposingExecutor.

Definition at line 90 of file sp_dplpexecutor.cpp.

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 228 of file sp_dplpexecutor.cpp.

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

Run execution with synchronous physical signals.

Loops SyncStep until the specified amount on time expired.

Parameters:
duration Duration of execution wrt generator time, tpTime::Max for infinite
Returns:
True, for no error

Definition at line 385 of file sp_dplpexecutor.cpp.

Idx faudes::DeviceExecutor::SyncStep ( tpTime::Type  duration = tpTime::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:
duration Max duration of execution wrt generator time, tpTime::Max for unlimited
Returns:
Idx of executed event or 0 for time out or error

Definition at line 357 of file sp_dplpexecutor.cpp.

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 149 of file sp_dplpexecutor.cpp.

bool faudes::DeviceExecutor::SyncWait ( tpTime::Type  duration = tpTime::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:
duration Max duration to wait for
Returns:
True, if input events are available

Definition at line 289 of file sp_dplpexecutor.cpp.

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:
durationms Max duration in msecs to wait for
Returns:
True, if input events are available

Definition at line 321 of file sp_dplpexecutor.cpp.

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

Set synchronisation flags.

Semantics are defined via the enum typedef SyncMode.

Parameters:
flag Flag word to set mode

Definition at line 193 of file sp_dplpexecutor.h.

void faudes::DeviceExecutor::ToleranceTime ( tpTime::Type  maxgap  )  [inline]

Set tolerance for time synchonisation.

doxygen group

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

Definition at line 174 of file sp_dplpexecutor.h.


Member Data Documentation

Max gap between physical and generator clock time.

Definition at line 349 of file sp_dplpexecutor.h.

Sync error flag.

Definition at line 346 of file sp_dplpexecutor.h.

Mode flags for synchronisation.

Definition at line 352 of file sp_dplpexecutor.h.

Device reference.

Definition at line 355 of file sp_dplpexecutor.h.


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

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen