|
libFAUDES
Sections
Index
|
faudes::LoggingExecutor Class Reference
|
Classes | |
struct | TraceSample |
Buffer data entry. More... | |
Public Member Functions | |
Constructors & Destructor | |
LoggingExecutor (void) | |
Construct an emtpy LoggingExecuter. | |
LoggingExecutor (const std::string &rFileName) | |
Construct from file. | |
virtual | ~LoggingExecutor (void) |
Explicit destructor. | |
Re-implemenented from ParallelExecutor | |
virtual void | Clear (void) |
Clear all data. | |
virtual void | Reset (void) |
Goto initial state. | |
virtual bool | Valid (void) const |
Check validity of executors. | |
virtual bool | ExecuteTime (tpTime::Type duration) |
Let time pass without executing a transition. | |
virtual bool | ExecuteEvent (Idx event) |
Execute transition. | |
tpTime::Type | CurrentTime (void) const |
Get clock time. | |
void | CurrentTime (tpTime::Type time) |
Set clock time. | |
int | CurrentStep (void) const |
Get logical time, ie number of transitions so far,. | |
void | CurrentStep (int step) |
Set logical time (# of steps). | |
bool | CurrentParallelTimedState (const ParallelTimedState &ptstate) |
Set current state of the ParallelExecutor. | |
const ParallelTimedState & | CurrentParallelTimedState (void) const |
Get current state of the ParallelExecutor. | |
Protected Member Functions | |
virtual void | Compile () |
Compile internal data (all). | |
Private Member Functions | |
void | CompileConditions (void) |
Compile condition internal data. | |
void | ConditionsReset (void) |
Reset condition simulation state. | |
void | ConditionsProcess (void) |
Process condition hook. | |
void | LogWriteStatistics (void) |
Logging hook: dump statistics. | |
void | LogWriteState (void) |
Logging hook: dump current state. | |
void | LogWriteEvent (void) |
Logging hook: dump recent event. | |
void | LogWriteTime (void) |
Logging hook: dump current time. | |
void | LogWritePause (void) |
Logging hook: halt simulation. | |
void | LogWriteResume (void) |
Logging hook: continue simulation. | |
void | TraceAddSample (void) |
Trace: helper, append one void sample. | |
void | TraceUpdateTime (void) |
Trace: append sample (if necessary) and update to current time. | |
void | TraceUpdateTransition (Idx event) |
Trace: append sample (if necessary) and update to current state via given event. | |
virtual void | DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0) |
Reads logging executor from TokenReader, see also public wrappers in faudes::Type. | |
virtual void | DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
Write to TokenWriter, see also public wrappers in faudes::Type. | |
Private Attributes | |
SimConditionSet | mConditions |
Simulation conditions. | |
std::vector < AttributeSimCondition * > | mEnabledConditions |
Enabled simulation conditions. | |
bool | mBreakCondition |
Indicate break. | |
TokenWriter * | pLogTokenWriter |
Logging: tokenwriter ref. | |
std::string | mLogFile |
Logging: file name. | |
int | mLogMode |
Logging: mode. | |
int | mTraceMax |
Trace data: max fifo length. | |
int | mTraceFirstStep |
Trace data: step no of first sample. | |
std::deque< TraceSample > | mTraceBuffer |
Trace data: fifo buffer. | |
std::map< tpTime::Type, int > | mTraceTimeToStep |
Trace data: time to step mapping (first step). | |
Logging to Token I/O | |
| |
enum | LogMode { Statistics = 0x01, States = 0x02, Events = 0x04, Time = 0x08 } |
Logging mode flags, to specify what data to log. More... | |
void | LogOpen (TokenWriter &rTw, int mode) |
Start logging to TokenWriter. | |
void | LogOpen (const std::string &rFileName, int logmode, std::ios::openmode openmode=std::ios::out|std::ios::trunc) |
Start logging to file. | |
void | LogClose (void) |
Stop logging. | |
Simulation Conditions | |
| |
typedef SimConditionSet::Iterator | ConditionIterator |
Condition iterator: typedef. | |
const SimConditionSet & | Conditions (void) const |
Read-only access to simulation conditions. | |
void | Conditions (const SimConditionSet &) |
Set all simulation conditions. | |
const AttributeSimCondition & | Condition (const std::string &rName) const |
Read-only access to a simulation condition by name. | |
const AttributeSimCondition & | Condition (Idx cond) const |
Read-only access to a simulation condition by index. | |
Idx | SetCondition (const std::string &rName, const AttributeSimCondition &rCondition) |
Set (or add) a condition by name. | |
void | SetCondition (Idx cond, const AttributeSimCondition &rCondition) |
Set a condition by index. | |
void | ClrCondition (const std::string &rName) |
Remove a condition by name. | |
void | ClrCondition (Idx cond) |
Remove a condition by index. | |
void | ConditionsWrite (TokenWriter &rTw, const std::string &rLabel="SimConditions") const |
Write conditions so labled section. | |
void | ConditionsRead (TokenReader &rTr, const std::string &rLabel="SimConditions") |
Read conditions from labled section. | |
ConditionIterator | ConditionsBegin (void) const |
Condition iterator: begin. | |
ConditionIterator | ConditionsEnd (void) const |
Condition iterator: end. | |
bool | BreakCondition (void) const |
Simulation state: true if some break condition is currently satisfied. | |
Trace to FIFO buffer | |
| |
typedef std::deque < TraceSample > ::const_iterator | TraceIterator |
Access buffer: iterator. | |
void | TraceClear (int length=-2) |
Clear buffer and set max buffer. | |
int | TraceLength (void) const |
Access buffer: current length. | |
TraceIterator | TraceBegin (void) const |
Condition iterator: begin. | |
TraceIterator | TraceEnd (void) const |
Condition iterator: end. | |
const TraceSample * | TraceAtTime (tpTime::Type time) const |
Access buffer: sample by faudes time (returns first sample). | |
const TraceSample * | TraceAtStep (int step) const |
Access buffer: sample by step. | |
const TraceSample * | TraceFirst (void) const |
Access buffer: first sample. | |
const TraceSample * | TraceRecent (void) const |
Access buffer: recent sample. | |
const TraceSample * | TraceCurrent (void) const |
Access buffer: current sample. | |
void | TraceWrite (TokenWriter &rTw, const TraceSample &sample) const |
Access buffer: tokenwriter output. | |
void | TraceWrite (const TraceSample &sample) const |
Access buffer: console output. | |
std::string | TraceToString (const TraceSample &sample) const |
Access buffer: convert to string. | |
void | TraceWrite (void) const |
Access buffer: console output (list all). | |
virtual bool | RevertToStep (Idx step) |
Revert executors state to past step from buffer. |
Executor with logging facilities.
Logging destination in general is a TokenWriter, which may be initialised to a file or console output. Logging can be configured to include
The state- and event-sequence can be logged to a internal FIFO Buffer. Methods to revert to a previous state are provided. This feature is meant to facilitate user interaction in simulator applications.
Technical detail: since the trace buffer only covers the dynamic state of the parallel executor, the RevertToStep method cannot recover the condition status. Including stochastic states with the trace buffer is considered to expensive.
For token IO, the LoggingExecutor reads and writes a section with default label "Executor". It contains a ParallelExecutor section to define a vector of generators and a SimConditionSet section to define the relevant conditions. Example:
<Executor> <Generators> "./some_generator.gen" "./other_generator.gen" </Generators> <Conditions> "IdleCond" <EventCondition> <StartEvents> "beta" "mue" </StartEvents> <StopEvents> "alpha" </StopEvents> </EventCondition> "DownCond" <StateCondition> <StateSet> "down" </StateSet> % refers to first generator <StateSet> "down" "repair" </StateSet> % refers to second generator </StateCondition> </Conditions> </Executor>
Definition at line 85 of file sp_lpexecutor.h.
Condition iterator: typedef.
Definition at line 284 of file sp_lpexecutor.h.
typedef std::deque<TraceSample>::const_iterator faudes::LoggingExecutor::TraceIterator |
Access buffer: iterator.
Definition at line 348 of file sp_lpexecutor.h.
Logging mode flags, to specify what data to log.
doxygen group
Definition at line 306 of file sp_lpexecutor.h.
faudes::LoggingExecutor::LoggingExecutor | ( | void | ) |
faudes::LoggingExecutor::LoggingExecutor | ( | const std::string & | rFileName | ) |
Construct from file.
See ParallelExecutor::Insert(const std::string& rFileName) for details.
rFileName | Filename |
Exception |
|
Definition at line 27 of file sp_lpexecutor.cpp.
faudes::LoggingExecutor::~LoggingExecutor | ( | void | ) | [virtual] |
Explicit destructor.
Definition at line 35 of file sp_lpexecutor.cpp.
bool faudes::LoggingExecutor::BreakCondition | ( | void | ) | const [inline] |
Simulation state: true if some break condition is currently satisfied.
Definition at line 293 of file sp_lpexecutor.h.
void faudes::LoggingExecutor::Clear | ( | void | ) | [virtual] |
Clear all data.
doxygen group Removes all generators/executors, all conditions, and resets the current state to a void value.
Reimplemented from faudes::ParallelExecutor.
Reimplemented in faudes::DeviceExecutor, and faudes::ProposingExecutor.
Definition at line 67 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::ClrCondition | ( | Idx | cond | ) |
Remove a condition by index.
Definition at line 244 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::ClrCondition | ( | const std::string & | rName | ) |
Remove a condition by name.
Definition at line 238 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::Compile | ( | void | ) | [protected, virtual] |
Compile internal data (all).
Reimplemented from faudes::ParallelExecutor.
Definition at line 41 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::CompileConditions | ( | void | ) | [private] |
Compile condition internal data.
Definition at line 272 of file sp_lpexecutor.cpp.
const AttributeSimCondition & faudes::LoggingExecutor::Condition | ( | Idx | cond | ) | const |
Read-only access to a simulation condition by index.
Definition at line 206 of file sp_lpexecutor.cpp.
const AttributeSimCondition & faudes::LoggingExecutor::Condition | ( | const std::string & | rName | ) | const |
Read-only access to a simulation condition by name.
Definition at line 201 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::Conditions | ( | const SimConditionSet & | rConditions | ) |
Set all simulation conditions.
Definition at line 192 of file sp_lpexecutor.cpp.
const SimConditionSet & faudes::LoggingExecutor::Conditions | ( | void | ) | const |
Read-only access to simulation conditions.
doxygen group
Definition at line 187 of file sp_lpexecutor.cpp.
LoggingExecutor::ConditionIterator faudes::LoggingExecutor::ConditionsBegin | ( | void | ) | const |
Condition iterator: begin.
Definition at line 262 of file sp_lpexecutor.cpp.
LoggingExecutor::ConditionIterator faudes::LoggingExecutor::ConditionsEnd | ( | void | ) | const |
Condition iterator: end.
Definition at line 267 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::ConditionsProcess | ( | void | ) | [private] |
Process condition hook.
Definition at line 305 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::ConditionsRead | ( | TokenReader & | rTr, | |
const std::string & | rLabel = "SimConditions" | |||
) |
Read conditions from labled section.
Definition at line 255 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::ConditionsReset | ( | void | ) | [private] |
Reset condition simulation state.
Definition at line 298 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::ConditionsWrite | ( | TokenWriter & | rTw, | |
const std::string & | rLabel = "SimConditions" | |||
) | const |
Write conditions so labled section.
Definition at line 250 of file sp_lpexecutor.cpp.
const ParallelTimedState& faudes::LoggingExecutor::CurrentParallelTimedState | ( | void | ) | const [inline] |
Get current state of the ParallelExecutor.
Reimplemented from faudes::ParallelExecutor.
Definition at line 240 of file sp_lpexecutor.h.
bool faudes::LoggingExecutor::CurrentParallelTimedState | ( | const ParallelTimedState & | ptstate | ) | [virtual] |
Set current state of the ParallelExecutor.
This resets the parallel executor to the given state, incl clock values. The trace buffer is cleared. You should pause/resume logging befor/after interfering with the executors state.
Reimplemented from faudes::ParallelExecutor.
Definition at line 174 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::CurrentStep | ( | int | step | ) | [virtual] |
Set logical time (# of steps).
This does not affect clocks and, hence, is purely cosmetic. Note that, in contrast to clock time, the individual generators do not agree in logical time. The trace buffer is cleared. You should pause/resume logging befor/after interfering with the executors state.
step | New logical time |
Reimplemented from faudes::ParallelExecutor.
Definition at line 154 of file sp_lpexecutor.cpp.
int faudes::LoggingExecutor::CurrentStep | ( | void | ) | const [inline] |
Get logical time, ie number of transitions so far,.
Reimplemented from faudes::ParallelExecutor.
Definition at line 205 of file sp_lpexecutor.h.
void faudes::LoggingExecutor::CurrentTime | ( | tpTime::Type | time | ) | [virtual] |
Set clock time.
This does not affect clocks and, hence, is purely cosmetic. The trace buffer is cleared. You should pause/resume logging befor/after interfering with the executors state.
time | New clock time |
Reimplemented from faudes::ParallelExecutor.
Definition at line 164 of file sp_lpexecutor.cpp.
tpTime::Type faudes::LoggingExecutor::CurrentTime | ( | void | ) | const [inline] |
Get clock time.
Reimplemented from faudes::ParallelExecutor.
Definition at line 188 of file sp_lpexecutor.h.
void faudes::LoggingExecutor::DoRead | ( | TokenReader & | rTr, | |
const std::string & | rLabel = "" , |
|||
const Type * | pContext = 0 | |||
) | [private, virtual] |
Reads logging executor from TokenReader, see also public wrappers in faudes::Type.
rTr | TokenReader to read from | |
rLabel | Section to read, defaults to "Executor" | |
pContext | Read context to provide contextual information (ignored) |
Exception |
|
Reimplemented from faudes::ParallelExecutor.
Reimplemented in faudes::ProposingExecutor.
Definition at line 90 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::DoWrite | ( | TokenWriter & | rTw, | |
const std::string & | rLabel = "" , |
|||
const Type * | pContext = 0 | |||
) | const [private, virtual] |
Write to TokenWriter, see also public wrappers in faudes::Type.
rTw | Reference to TokenWriter | |
rLabel | Label of section to write, defaults to "Executor" | |
pContext | Write context to provide contextual information (ignored) |
Exception |
|
Reimplemented from faudes::ParallelExecutor.
Reimplemented in faudes::ProposingExecutor.
Definition at line 79 of file sp_lpexecutor.cpp.
bool faudes::LoggingExecutor::ExecuteEvent | ( | Idx | event | ) | [virtual] |
Execute transition.
Returns false if the transition cannot be executed at the current time.
event | Indicate transition to execute |
Reimplemented from faudes::ParallelExecutor.
Reimplemented in faudes::DeviceExecutor, and faudes::ProposingExecutor.
Definition at line 136 of file sp_lpexecutor.cpp.
bool faudes::LoggingExecutor::ExecuteTime | ( | tpTime::Type | duration | ) | [virtual] |
Let time pass without executing a transition.
Return false if the specified duration cannot elapse without an event being executed.
duration | Amount of time that shall elapse. |
Reimplemented from faudes::ParallelExecutor.
Reimplemented in faudes::ProposingExecutor.
Definition at line 124 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogClose | ( | void | ) |
Stop logging.
Definition at line 395 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogOpen | ( | const std::string & | rFileName, | |
int | logmode, | |||
std::ios::openmode | openmode = std::ios::out|std::ios::trunc | |||
) |
Start logging to file.
Definition at line 386 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogOpen | ( | TokenWriter & | rTw, | |
int | mode | |||
) |
Start logging to TokenWriter.
Definition at line 369 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogWriteEvent | ( | void | ) | [private] |
Logging hook: dump recent event.
Definition at line 445 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogWritePause | ( | void | ) | [private] |
Logging hook: halt simulation.
Definition at line 471 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogWriteResume | ( | void | ) | [private] |
Logging hook: continue simulation.
Definition at line 483 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogWriteState | ( | void | ) | [private] |
Logging hook: dump current state.
Definition at line 435 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogWriteStatistics | ( | void | ) | [private] |
Logging hook: dump statistics.
Definition at line 414 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::LogWriteTime | ( | void | ) | [private] |
Logging hook: dump current time.
Definition at line 458 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::Reset | ( | void | ) | [virtual] |
Goto initial state.
Reset all clock values to zero, assign initial states to each executor, reset condition states to not-satisfied, invalidate timing samples.
Reimplemented from faudes::ParallelExecutor.
Definition at line 51 of file sp_lpexecutor.cpp.
bool faudes::LoggingExecutor::RevertToStep | ( | Idx | step | ) | [virtual] |
Revert executors state to past step from buffer.
Reimplemented in faudes::ProposingExecutor.
Definition at line 634 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::SetCondition | ( | Idx | cond, | |
const AttributeSimCondition & | rCondition | |||
) |
Set a condition by index.
Definition at line 232 of file sp_lpexecutor.cpp.
Idx faudes::LoggingExecutor::SetCondition | ( | const std::string & | rName, | |
const AttributeSimCondition & | rCondition | |||
) |
Set (or add) a condition by name.
Definition at line 225 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::TraceAddSample | ( | void | ) | [private] |
Trace: helper, append one void sample.
Definition at line 557 of file sp_lpexecutor.cpp.
const LoggingExecutor::TraceSample * faudes::LoggingExecutor::TraceAtStep | ( | int | step | ) | const |
Access buffer: sample by step.
Definition at line 517 of file sp_lpexecutor.cpp.
const LoggingExecutor::TraceSample * faudes::LoggingExecutor::TraceAtTime | ( | tpTime::Type | time | ) | const |
Access buffer: sample by faudes time (returns first sample).
Definition at line 525 of file sp_lpexecutor.cpp.
LoggingExecutor::TraceIterator faudes::LoggingExecutor::TraceBegin | ( | void | ) | const |
Condition iterator: begin.
Definition at line 507 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::TraceClear | ( | int | length = -2 |
) |
Clear buffer and set max buffer.
doxygen group
length | Max length of buffer, or: -2 <> keep length, -1<>infinite, 0<> no buffer |
Definition at line 491 of file sp_lpexecutor.cpp.
const LoggingExecutor::TraceSample * faudes::LoggingExecutor::TraceCurrent | ( | void | ) | const |
Access buffer: current sample.
Definition at line 534 of file sp_lpexecutor.cpp.
LoggingExecutor::TraceIterator faudes::LoggingExecutor::TraceEnd | ( | void | ) | const |
Condition iterator: end.
Definition at line 512 of file sp_lpexecutor.cpp.
const LoggingExecutor::TraceSample * faudes::LoggingExecutor::TraceFirst | ( | void | ) | const |
Access buffer: first sample.
Definition at line 546 of file sp_lpexecutor.cpp.
int faudes::LoggingExecutor::TraceLength | ( | void | ) | const |
Access buffer: current length.
Definition at line 552 of file sp_lpexecutor.cpp.
const LoggingExecutor::TraceSample * faudes::LoggingExecutor::TraceRecent | ( | void | ) | const |
Access buffer: recent sample.
Definition at line 540 of file sp_lpexecutor.cpp.
std::string faudes::LoggingExecutor::TraceToString | ( | const TraceSample & | sample | ) | const |
Access buffer: convert to string.
Definition at line 627 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::TraceUpdateTime | ( | void | ) | [private] |
Trace: append sample (if necessary) and update to current time.
Definition at line 590 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::TraceUpdateTransition | ( | Idx | event | ) | [private] |
Trace: append sample (if necessary) and update to current state via given event.
Definition at line 578 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::TraceWrite | ( | void | ) | const |
Access buffer: console output (list all).
Definition at line 620 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::TraceWrite | ( | const TraceSample & | sample | ) | const |
Access buffer: console output.
Definition at line 614 of file sp_lpexecutor.cpp.
void faudes::LoggingExecutor::TraceWrite | ( | TokenWriter & | rTw, | |
const TraceSample & | sample | |||
) | const |
Access buffer: tokenwriter output.
Definition at line 601 of file sp_lpexecutor.cpp.
virtual bool faudes::LoggingExecutor::Valid | ( | void | ) | const [inline, virtual] |
Check validity of executors.
This is currently not implemented. It should include tests on the state based conditions.
Reimplemented from faudes::ParallelExecutor.
Definition at line 156 of file sp_lpexecutor.h.
bool faudes::LoggingExecutor::mBreakCondition [private] |
Indicate break.
Definition at line 404 of file sp_lpexecutor.h.
Simulation conditions.
Definition at line 398 of file sp_lpexecutor.h.
std::vector<AttributeSimCondition*> faudes::LoggingExecutor::mEnabledConditions [private] |
Enabled simulation conditions.
Definition at line 401 of file sp_lpexecutor.h.
std::string faudes::LoggingExecutor::mLogFile [private] |
Logging: file name.
Definition at line 419 of file sp_lpexecutor.h.
int faudes::LoggingExecutor::mLogMode [private] |
Logging: mode.
Definition at line 422 of file sp_lpexecutor.h.
std::deque<TraceSample> faudes::LoggingExecutor::mTraceBuffer [private] |
Trace data: fifo buffer.
Definition at line 449 of file sp_lpexecutor.h.
int faudes::LoggingExecutor::mTraceFirstStep [private] |
Trace data: step no of first sample.
Definition at line 446 of file sp_lpexecutor.h.
int faudes::LoggingExecutor::mTraceMax [private] |
Trace data: max fifo length.
Definition at line 443 of file sp_lpexecutor.h.
std::map<tpTime::Type,int> faudes::LoggingExecutor::mTraceTimeToStep [private] |
Trace data: time to step mapping (first step).
Definition at line 452 of file sp_lpexecutor.h.
Logging: tokenwriter ref.
Definition at line 416 of file sp_lpexecutor.h.
libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3