faudes::Executor Class Reference
[Simulator Plugin]

#include <sp_executor.h>

Inheritance diagram for faudes::Executor:

faudes::TtGenerator< GlobalAttr, StateAttr, EventAttr, TransAttr > List of all members.

Detailed Description

An Executor is a timed generator that maintains a current state.

The Executor is the lowest level building block for the libFAUDES simulator plugin. It maintains a current state that consists of the discrete state and a value map that assigns values to clock variables. It can be retrieved by the method Executor::CurrentState(void), and it is updated whenever time or transitions are executed via Executor::ExecuteTime(tpTime::Type) or Executor::ExecuteEvent(Idx). If you plan to execute multiple generators with synchronized shared events, you will find the class ParallelExecutor with a very similar interface more appropriate.

The Executor provides Methods that indicate which transitions currently are enabled, referring to the current state, the current clock values and the guard and invariant data from the tGenerator. In contrast to enabled events, there is also the notion of active events, which refers to the discrete state only, ignoring guards and invariants.

Technically, the Executor class is derived from the tGenerator, however inheritence is private. The common way to initialise an Executor object is to construct it from a const ref to a tGenerator, which sets up additional internal data structures. Read-only access to the underlying generator is given by the faudes::Executor::Generator() method.

Note: a prequisit of the current implementation is that the underlying generator is deterministic ie the current discrete state is uniquely determind by the external sequence of discrete events.

Definition at line 86 of file sp_executor.h.

Public Member Functions

 Executor (void)
 Creates an emtpy Executer.
 Executor (const tGenerator &rGen)
 Construct from tgenerator.
 Executor (const std::string &rFileName)
 Construct from tGenerator file.
void Read (const std::string &rFileName)
 Read tGenerator file.
void Read (TokenReader &rTr)
 Read form tokenreader.
void Write (TokenWriter &rTw) const
 Write to tokenwriter.
void Write (const std::string &rFileName, std::ios::openmode openmode=std::ios::out|std::ios::trunc)
 Write to file.
void Generator (const tGenerator &rGen)
 Initialise from tGenerator.
const tGeneratorGenerator (void) const
 Reference to the internal generator for inspection.
std::string Name (void) const
 Generator name (for convenience).
std::string StateName (Idx idx) const
 State name (for convenience).
std::string EventName (Idx idx) const
 Event name (for convenience).
void Clear (void)
 Clear all data incl tGenerator.
void Reset ()
 Reset all clocks and assign initial state.
const TimeIntervalEnabledTime () const
 Get maximal interval of time that can pass without executing an event.
const EventSetEnabledEvents () const
 Get set of events that are enabled at current (timed) state.
const EventSetDisabledEvents () const
 Get set of events that are disabled at current (timed) state.
const TimeIntervalEnabledInterval () const
 Get maximal interval on which set of enabled events is constant.
TimeInterval EnabledEventTime (Idx event) const
 Get interval on which an active event is enabled.
TimeInterval EnabledGuardTime (Idx event) const
 Get interval on which an active event satisfies its guard.
const EventSetActiveEventSet (void) const
 Get set of events that are active at current (untimed) state.
const TransSetActiveTransSet (void) const
 Get set of transitions that are active at current (untimed) state.
bool ExecuteTime (tpTime::Type time)
 Let time pass.
bool ExecuteEvent (Idx event)
 Execute transition.
bool CurrentTimedState (const TimedState &tstate)
 Set timed state.
const TimedStateCurrentTimedState (void) const
 Get timed state.
bool CurrentState (Idx index)
 Set discrete state.
Idx CurrentState (void) const
 Get discrete state.
bool CurrentClockValue (Idx clock, tpTime::Type time)
 Set value of clock variable.
tpTime::Type CurrentClockValue (Idx clock) const
 Get value of clock.
void CurrentTime (tpTime::Type time)
 Set current time.
tpTime::Type CurrentTime (void) const
 Get current time.
void CurrentStep (int step)
 Set logic time (# of steps).
int CurrentStep (void) const
 Get logic time ie numer of transitions so far.
bool IsDeadlocked () const
 Returns true if timed generator is in a deadlocked state.
virtual bool Valid (void) const
 Check if Executor is valid.
std::string CurrentTimedStateStr (void) const
 Pretty printable string of current state.
std::string TSStr (const TimedState &tstate) const
 Pretty printable string of timed state.
std::string TEStr (const TimedEvent &tevent) const
 Pretty printable string of timed event.
std::string CStr (Idx idx) const
 Pretty printable string of clock name.
std::string EStr (Idx idx) const
 Pretty printable string of event.
std::string SStr (Idx idx) const
 Pretty printable string of state.

Private Member Functions

void Compile (void)
 Prepare internal data structurs from generator.
void ComputeEnabled (void) const
 Compute enabled events and enabled interval (fake const).
void ComputeEnabledNonConst (void)
 Compute enabled core routine (non const).

Private Attributes

TimedState mCurrentTimedState
 Current state incl clock values.
tpTime::Type mCurrentTime
 Current physical time.
int mCurrentStep
 Current logic time.
TimeInterval mETime
 Record enabled time.
EventSet mEEvents
 Record enabled events.
TimeInterval mEInterval
 Record rime on shich mEEvents is constant.
std::map< Idx, TimeIntervalmEGuardInterval
 Record interval in which each guard is enabled.
EventSet mDEvents
 Record disabled events.
EventSet mAEvents
 Record active events (ie regardles time).
TransSet mATrans
 Record active transitions (regardles time).
bool mEValid
 Validity flag for the above data.
std::map< Transition, std::map<
Idx, TimeInterval > > 
mTransClockIntervalMap
 Compiled generator data: map transition to clock to interval constraint.
std::map< Idx, std::map< Idx,
TimeInterval > > 
mStateClockIntervalMap
 Compiled generator data: map state to clock to interval constraint.

Classes

struct  TimedState
 Typedef for timed state. More...


Constructor & Destructor Documentation

faudes::Executor::Executor void   ) 
 

Creates an emtpy Executer.

Definition at line 19 of file sp_executor.cpp.

faudes::Executor::Executor const tGenerator rGen  ) 
 

Construct from tgenerator.

Construction from a tGenerator will copy all given tGenerator data and complie it to some additional Executor specific data. Thus, if the original tGenerator changes the Executor will not reflect these changes.

Parameters:
rGen Input generator
Exceptions:
Exception 
  • Nondetrministic input generator (id 501)

Definition at line 26 of file sp_executor.cpp.

faudes::Executor::Executor const std::string &  rFileName  ) 
 

Construct from tGenerator file.

Parameters:
rFileName File to read
Exceptions:
Exception 
  • IO errors (id 1)
  • token mismatch (id 50, 51, 52, 80, 85)
  • nondetrministic generator (id 501)

Definition at line 32 of file sp_executor.cpp.


Member Function Documentation

const EventSet & faudes::Executor::ActiveEventSet void   )  const
 

Get set of events that are active at current (untimed) state.

Returns:
Set of active events

Definition at line 263 of file sp_executor.cpp.

const TransSet & faudes::Executor::ActiveTransSet void   )  const
 

Get set of transitions that are active at current (untimed) state.

Returns:
Set of active trans

Definition at line 269 of file sp_executor.cpp.

void faudes::Executor::Clear void   )  [virtual]
 

Clear all data incl tGenerator.

Reimplemented from faudes::TaGenerator< GlobalAttr, StateAttr, EventAttr, TransAttr >.

Definition at line 105 of file sp_executor.cpp.

void faudes::Executor::Compile void   )  [private]
 

Prepare internal data structurs from generator.

Definition at line 67 of file sp_executor.cpp.

void faudes::Executor::ComputeEnabled void   )  const [private]
 

Compute enabled events and enabled interval (fake const).

Definition at line 129 of file sp_executor.cpp.

void faudes::Executor::ComputeEnabledNonConst void   )  [private]
 

Compute enabled core routine (non const).

Definition at line 135 of file sp_executor.cpp.

std::string faudes::Executor::CStr Idx  idx  )  const
 

Pretty printable string of clock name.

Reimplemented from faudes::TtGenerator< GlobalAttr, StateAttr, EventAttr, TransAttr >.

Definition at line 486 of file sp_executor.cpp.

tpTime::Type faudes::Executor::CurrentClockValue Idx  clock  )  const
 

Get value of clock.

Parameters:
clock Index of clock variable
Returns:
time Value of clock variable

Definition at line 412 of file sp_executor.cpp.

bool faudes::Executor::CurrentClockValue Idx  clock,
tpTime::Type  time
 

Set value of clock variable.

Returns false if clock not in clockset.

Parameters:
clock Index of clock variable to set
time Time to set
Returns:
True/false -- success

Definition at line 404 of file sp_executor.cpp.

Idx faudes::Executor::CurrentState void   )  const
 

Get discrete state.

Returns:
Discret state by index

Definition at line 399 of file sp_executor.cpp.

bool faudes::Executor::CurrentState Idx  index  ) 
 

Set discrete state.

Returns false if state is not in state set.

Parameters:
index State index
Returns:
True/false -- success

Definition at line 391 of file sp_executor.cpp.

int faudes::Executor::CurrentStep void   )  const
 

Get logic time ie numer of transitions so far.

Definition at line 437 of file sp_executor.cpp.

void faudes::Executor::CurrentStep int  step  ) 
 

Set logic time (# of steps).

Parameters:
step New logic time

Definition at line 431 of file sp_executor.cpp.

tpTime::Type faudes::Executor::CurrentTime void   )  const
 

Get current time.

Returns:
time Current time

Definition at line 426 of file sp_executor.cpp.

void faudes::Executor::CurrentTime tpTime::Type  time  ) 
 

Set current time.

Parameters:
time New current time

Definition at line 420 of file sp_executor.cpp.

const Executor::TimedState & faudes::Executor::CurrentTimedState void   )  const
 

Get timed state.

Returns:
Current discrete state and clock values.

Definition at line 386 of file sp_executor.cpp.

bool faudes::Executor::CurrentTimedState const TimedState tstate  ) 
 

Set timed state.

Returns false if state or clock values are invalid.

Parameters:
tstate State to set.
Returns:
True/false -- success

Definition at line 372 of file sp_executor.cpp.

std::string faudes::Executor::CurrentTimedStateStr void   )  const
 

Pretty printable string of current state.

Definition at line 469 of file sp_executor.cpp.

const EventSet & faudes::Executor::DisabledEvents  )  const
 

Get set of events that are disabled at current (timed) state.

Returns:
Set of disabled events

Definition at line 251 of file sp_executor.cpp.

const EventSet & faudes::Executor::EnabledEvents  )  const
 

Get set of events that are enabled at current (timed) state.

Returns:
Set of enabled events

Definition at line 245 of file sp_executor.cpp.

TimeInterval faudes::Executor::EnabledEventTime Idx  event  )  const
 

Get interval on which an active event is enabled.

Parameters:
event Active event
Returns:
TimeInterval (empty if event not active or active with guard violated)

Definition at line 275 of file sp_executor.cpp.

TimeInterval faudes::Executor::EnabledGuardTime Idx  event  )  const
 

Get interval on which an active event satisfies its guard.

Parameters:
event Active event
Returns:
TimeInterval (empty if event not active or active with guard violated)

Definition at line 294 of file sp_executor.cpp.

const TimeInterval & faudes::Executor::EnabledInterval  )  const
 

Get maximal interval on which set of enabled events is constant.

Returns:
TimeInterval

Definition at line 257 of file sp_executor.cpp.

const TimeInterval & faudes::Executor::EnabledTime  )  const
 

Get maximal interval of time that can pass without executing an event.

This corresponds to the inveriant of the current timed state.

Returns:
TimeInterval

Definition at line 239 of file sp_executor.cpp.

std::string faudes::Executor::EStr Idx  idx  )  const
 

Pretty printable string of event.

Reimplemented from faudes::vGenerator.

Definition at line 481 of file sp_executor.cpp.

std::string faudes::Executor::EventName Idx  idx  )  const [inline]
 

Event name (for convenience).

Reimplemented from faudes::vGenerator.

Definition at line 215 of file sp_executor.h.

bool faudes::Executor::ExecuteEvent Idx  event  ) 
 

Execute transition.

Returns false if the transition is not enabled and hence cannot be executed at the current time

Parameters:
event Indicate transition to execute
Returns:
True/false -- success

Definition at line 344 of file sp_executor.cpp.

bool faudes::Executor::ExecuteTime tpTime::Type  time  ) 
 

Let time pass.

Returns false if the specified amount of time cannot elapse without an event being executed

Parameters:
time Amount of time that shall elapse.
Returns:
True/false -- success

Definition at line 307 of file sp_executor.cpp.

const tGenerator & faudes::Executor::Generator void   )  const
 

Reference to the internal generator for inspection.

Returns:
const reference of mTGen

Definition at line 54 of file sp_executor.cpp.

void faudes::Executor::Generator const tGenerator rGen  ) 
 

Initialise from tGenerator.

Parameters:
rGen Input generator

Definition at line 59 of file sp_executor.cpp.

bool faudes::Executor::IsDeadlocked  )  const
 

Returns true if timed generator is in a deadlocked state.

Returns:
true/false

Definition at line 442 of file sp_executor.cpp.

std::string faudes::Executor::Name void   )  const [inline]
 

Generator name (for convenience).

Reimplemented from faudes::vGenerator.

Definition at line 202 of file sp_executor.h.

void faudes::Executor::Read TokenReader rTr  ) 
 

Read form tokenreader.

Parameters:
rTr tokenreader
Exceptions:
Exception 
  • IO errors (id 1)
  • token mismatch (id 50, 51, 52, 80, 85)
  • nondetrministic generator (id 501)

Definition at line 46 of file sp_executor.cpp.

void faudes::Executor::Read const std::string &  rFileName  ) 
 

Read tGenerator file.

Parameters:
rFileName File to read
Exceptions:
Exception 
  • IO errors (id 1)
  • token mismatch (id 50, 51, 52, 80, 85)
  • nondetrministic generator (id 501)

Definition at line 38 of file sp_executor.cpp.

void faudes::Executor::Reset  ) 
 

Reset all clocks and assign initial state.

Definition at line 116 of file sp_executor.cpp.

std::string faudes::Executor::SStr Idx  idx  )  const
 

Pretty printable string of state.

Reimplemented from faudes::vGenerator.

Definition at line 491 of file sp_executor.cpp.

std::string faudes::Executor::StateName Idx  idx  )  const [inline]
 

State name (for convenience).

Reimplemented from faudes::vGenerator.

Definition at line 208 of file sp_executor.h.

std::string faudes::Executor::TEStr const TimedEvent tevent  )  const
 

Pretty printable string of timed event.

Definition at line 474 of file sp_executor.cpp.

std::string faudes::Executor::TSStr const TimedState tstate  )  const
 

Pretty printable string of timed state.

Definition at line 450 of file sp_executor.cpp.

virtual bool faudes::Executor::Valid void   )  const [inline, virtual]
 

Check if Executor is valid.

Not implemented, should check for determinism and consitency of current state and clock values.

Returns:
Success

Definition at line 436 of file sp_executor.h.

void faudes::Executor::Write const std::string &  rFileName,
std::ios::openmode  openmode = std::ios::out|std::ios::trunc
[inline]
 

Write to file.

Parameters:
rFileName File to write
openmode ios::openmode
Exceptions:
Exception 
  • IO errors (id 2)

Definition at line 178 of file sp_executor.h.

void faudes::Executor::Write TokenWriter rTw  )  const [inline]
 

Write to tokenwriter.

Parameters:
rTw WokenWriter
Exceptions:
Exception 
  • IO errors (id 2)

Definition at line 165 of file sp_executor.h.


Member Data Documentation

EventSet faudes::Executor::mAEvents [private]
 

Record active events (ie regardles time).

Definition at line 506 of file sp_executor.h.

TransSet faudes::Executor::mATrans [private]
 

Record active transitions (regardles time).

Definition at line 509 of file sp_executor.h.

int faudes::Executor::mCurrentStep [private]
 

Current logic time.

Definition at line 479 of file sp_executor.h.

tpTime::Type faudes::Executor::mCurrentTime [private]
 

Current physical time.

Definition at line 476 of file sp_executor.h.

TimedState faudes::Executor::mCurrentTimedState [private]
 

Current state incl clock values.

Definition at line 473 of file sp_executor.h.

EventSet faudes::Executor::mDEvents [private]
 

Record disabled events.

Definition at line 503 of file sp_executor.h.

EventSet faudes::Executor::mEEvents [private]
 

Record enabled events.

Definition at line 494 of file sp_executor.h.

std::map<Idx,TimeInterval> faudes::Executor::mEGuardInterval [private]
 

Record interval in which each guard is enabled.

Definition at line 500 of file sp_executor.h.

TimeInterval faudes::Executor::mEInterval [private]
 

Record rime on shich mEEvents is constant.

Definition at line 497 of file sp_executor.h.

TimeInterval faudes::Executor::mETime [private]
 

Record enabled time.

Definition at line 491 of file sp_executor.h.

bool faudes::Executor::mEValid [private]
 

Validity flag for the above data.

Definition at line 512 of file sp_executor.h.

std::map<Idx, std::map<Idx,TimeInterval> > faudes::Executor::mStateClockIntervalMap [private]
 

Compiled generator data: map state to clock to interval constraint.

Definition at line 518 of file sp_executor.h.

std::map<Transition, std::map<Idx,TimeInterval> > faudes::Executor::mTransClockIntervalMap [private]
 

Compiled generator data: map transition to clock to interval constraint.

Definition at line 515 of file sp_executor.h.


The documentation for this class was generated from the following files:
Generated on Mon Nov 10 08:13:18 2008 for libFAUDES 2.11v by  doxygen 1.4.4