sp_lpexecutor.cpp
Go to the documentation of this file.
1 /** @file sp_lpexecutor.cpp Executor with logging facilities */
2 
3 /*
4  FAU Discrete Event Systems Library (libfaudes)
5 
6  Copyright (C) 2007, 2008 Thomas Moor
7  Copyright (C) 2007 Ruediger Berndt
8  Exclusive copyright is granted to Klaus Schmidt
9 
10 */
11 
12 
13 #include "sp_lpexecutor.h"
14 
15 namespace faudes {
16 
17 
18 // std faudes type
19 FAUDES_TYPE_IMPLEMENTATION(LoggingExecutor,LoggingExecutor,ParallelExecutor)
20 
21 // LoggingExecutor(void)
23  : ParallelExecutor(), pLogTokenWriter(0), mLogFile(""), mLogMode(0)
24 {
25  FD_DX("LoggingExecutor(" << this << ")::LoggingExecutor()");
26  TraceClear(0);
27 }
28 
29 // LoggingExecutor(void)
31  : ParallelExecutor(), pLogTokenWriter(0), mLogFile(""), mLogMode(0)
32 {
33  FD_DX("LoggingExecutor(" << this << ")::LoggingExecutor()");
34  TraceClear(0);
35  DoAssign(rOther);
36 }
37 
38 // LoggingExecutor(rFileName)
39 LoggingExecutor::LoggingExecutor(const std::string& rFileName)
40  : ParallelExecutor(), pLogTokenWriter(0), mLogFile(""), mLogMode(0)
41 {
42  FD_DX("LoggingExecutor(" << this << ")::LoggingExecutor(" << rFileName << ")");
43  TraceClear(0);
44  Read(rFileName);
45 }
46 
47 // LoggingExecutor
49  FD_DX("LoggingExecutor(" << this << ")::~LoggingExecutor()");
50  LogClose();
51 }
52 
53 // DoAssign(other)
55  FD_DX("LoggingExecutor(" << this << ")::DoAssign(other)");
56  // my members
58  // base
60 }
61 
62 // Compile()
64  FD_DX("LoggingExecutor(" << this << ")::Compile(): #" << Size());
65  // call base
67  // care about my members
69  FD_DX("LoggingExecutor(" << this << ")::Compile(): done");
70 }
71 
72 // Reset()
74  FD_DX("LoggingExecutor(" << this << ")::Reset()");
75  // log trace
76  LogWritePause();
77  // call base (incl compile)
79  // log trace
81  // clear and initialise trace (base was called first)
82  TraceClear();
83  // figure initial state
85 }
86 
87 
88 // Clear()
90  FD_DX("LoggingExecutor(" << this << ")::Clear()");
91  // clear my members
92  LogClose();
94  mBreakCondition=false;
95  TraceClear();
96  // call base
98 }
99 
100 //DoWrite(rTr,rLabel)
101 void LoggingExecutor::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
102  (void) pContext;
103  std::string label=rLabel;
104  if(label=="") label = "Executor";
105  rTw.WriteBegin(label);
106  ParallelExecutor::DoWrite(rTw,"Generators");
107  mConditions.Write(rTw,"Conditions",this);
108  rTw.WriteEnd(label);
109 }
110 
111 //DoRead(rTr,rLabel)
112 void LoggingExecutor::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
113  (void) pContext;
114  FD_DC("LoggingExecutor::DoRead(rTr, " << rLabel<<")");
115  std::string label=rLabel;
116  if(label=="") label = "Executor";
117  rTr.ReadBegin(label);
118  while(!rTr.Eos(label)) {
119  // peek token
120  Token token;
121  rTr.Peek(token);
122  // case 1: generators
123  if(token.Type()==Token::Begin)
124  if(token.StringValue()=="Generators") {
126  continue;
127  }
128  // case 2: conditions
129  if(token.Type()==Token::Begin)
130  if(token.StringValue()=="Conditions") {
131  mConditions.Read(rTr,"Conditions",this);
132  continue;
133  }
134  // else report error
135  std::stringstream errstr;
136  errstr << "Invalid token, generators or conditions section expected, " << rTr.FileLine();
137  throw Exception("LoggingExecutor::DoRead", errstr.str(), 502);
138  }
139  rTr.ReadEnd(label);
140  Reset();
141 }
142 
143 
144 
145 // ExecuteTime(time)
147  // call base
148  bool res=ParallelExecutor::ExecuteTime(time);
149  // bail out
150  if(!res) return false;
151  // update trace (after base)
152  TraceUpdateTime();
153  // done
154  return res;
155 }
156 
157 // ExecuteEvent(event)
159  // call base
160  bool res=ParallelExecutor::ExecuteEvent(event);
161  // bail out
162  if(!res) return false;
163  // process conditions
165  // record log
166  LogWriteTime();
167  LogWriteEvent();
168  LogWriteState();
169  // record trace
170  TraceUpdateTransition(event);
171  return true;
172 }
173 
174 
175 // set logic time
177  FD_DX("LoggingExecutor(" << this << ")::CurrentStep(step)");
178  // call base
180  // clear trace
181  TraceClear();
182  mConditions.Reset();
183 }
184 
185 // set physical time
187  FD_DX("LoggingExecutor(" << this << ")::CurrentTime(time)");
188  // call base
190  // clear trace
191  TraceClear();
192  mConditions.Reset();
193 }
194 
195 // set current state (clear trace)
197  FD_DX("LoggingExecutor(" << this << ")::CurrentParallelTimedState(ptstate)");
198  // call base
200  // clear trace
201  TraceClear();
202  ConditionsReset();
203  return res;
204 }
205 
206 
207 
208 // get conditions
210  return mConditions;
211 }
212 
213 // set conditions
215  FD_DC("ProposingExecutor::DoRead(rTr,): loop X");
216  mConditions=rConditions;
217  FD_DC("ProposingExecutor::DoRead(rTr, ): loop Y");
219  FD_DC("ProposingExecutor::DoRead(rTr, loop Z");
220 }
221 
222 // get condition
223 const AttributeSimCondition& LoggingExecutor::Condition(const std::string& rName) const {
224  return mConditions.Attribute(mConditions.Index(rName));
225 }
226 
227 // get condition
229  return mConditions.Attribute(cond);
230 }
231 
232 /*
233 // get condition pointer
234 AttributeSimCondition* LoggingExecutor::Conditionp(const std::string& rName) {
235  return mConditions.Attributep(mConditions.Index(rName));
236 }
237 */
238 
239 /*
240 // get condition pointer
241 AttributeSimCondition* LoggingExecutor::Conditionp(Idx cond) {
242  return mConditions.Attributep(cond);
243 }
244 */
245 
246 // add/edit one condition
247 Idx LoggingExecutor::SetCondition(const std::string& rName, const AttributeSimCondition& rCondition) {
248  Idx cond=mConditions.Insert(rName,rCondition);
250  return cond;
251 }
252 
253 // edit one condition
255  mConditions.Insert(cond,rCondition);
257 }
258 
259 // remove condition
260 void LoggingExecutor::ClrCondition(const std::string& rName) {
261  mConditions.Erase(rName);
263 }
264 
265 // remove condition
267  mConditions.Erase(cond);
269 }
270 
271 // token io
272 void LoggingExecutor::ConditionsWrite(TokenWriter& rTw, const std::string& rLabel) const {
273  mConditions.Write(rTw,rLabel);
274 }
275 
276 // token io
277 void LoggingExecutor::ConditionsRead(TokenReader& rTr, const std::string& rLabel) {
278  mConditions.Read(rTr,rLabel);
280 }
281 
282 
283 // iterators
285  return mConditions.Begin();
286 }
287 
288 // iterators
290  return mConditions.End();
291 }
292 
293 // set up internal datastructure
295  FD_DX("LoggingExecutor::CompileConditions()");
296  // need a lock to prevent realocation of attributes
297  mConditions.Lock();
298  // have a minmal copy to avoid pointless iterations
299  mEnabledConditions.clear();
301  for(; cit != mConditions.End(); ++cit) {
302  FD_DX("LoggingExecutor::CompileConditions(): compile " << mConditions.Str(*cit));
305  // reject if not enabled
306  if(!pattr->Enabled()) continue;
307  // reject incompatible dims
308  if(pattr->IsStateCondition())
309  if(pattr->StateCondition().mStateSets.size()!=Size()) continue;
310  // have it
311  mEnabledConditions.push_back(pattr);
312  }
313  // reset all states (incl disabled)
314  mConditions.Reset();
315  mBreakCondition=false;
316  FD_DX("LoggingExecutor(" << this << ")::CompileConditions(): #" << mEnabledConditions.size());
317 }
318 
319 // logging: reset
321  FD_DX("LoggingExecutor(" << this << ")::ConditionsReset()");
324 }
325 
326 // logging: test
328  FD_DX("LoggingExecutor(" << this << ")::ConditionsProcess()");
329  mBreakCondition=false;
330  std::vector<AttributeSimCondition*>::iterator ait=mEnabledConditions.begin();
331  // loop over all enabled conditions
332  for(; ait != mEnabledConditions.end(); ++ait) {
333  AttributeSimCondition* pattr= *ait;
334  // case 1: event condition
335  if(pattr->IsEventCondition()) {
336  // positive edge
337  if(!pattr->Satisfied())
338  if(pattr->EventCondition().mStart.Exists(mRecentEvent)) {
339  pattr->Satisfied(true,CurrentTime());
340  if(pattr->Breakpoint()) mBreakCondition=true;
341  }
342  // negative edge
343  if(pattr->Satisfied())
344  if(pattr->EventCondition().mStop.Exists(mRecentEvent)) {
345  pattr->Satisfied(false,CurrentTime());
346  }
347  continue;
348  }
349  // case 2: state condition
350  if(pattr->IsStateCondition()) {
351  // stage a: figure state
352  bool satisfied;
353  if(pattr->StateCondition().mAllFlag) {
354  // conjunctive
355  satisfied=true;
356  for(Idx i=0; i<Size(); i++) {
357  Idx state = CurrentParallelState().at(i);
358  const StateSet& set = pattr->StateCondition().mStateSets.at(i);
359  if(set.Empty()) continue;
360  if(!set.Exists(state)) {
361  satisfied=false;
362  break;
363  }
364  }
365  } else {
366  // disjunctive
367  satisfied=false;
368  for(Idx i=0; i<Size(); i++) {
369  Idx state = CurrentParallelState().at(i);
370  if(pattr->StateCondition().mStateSets.at(i).Exists(state)) {
371  satisfied=true;
372  break;
373  }
374  }
375  }
376  // state b: figure edge
377  if(!pattr->Satisfied() && satisfied) {
378  pattr->Satisfied(true,CurrentTime());
379  if(pattr->Breakpoint()) mBreakCondition=true;
380  }
381  if(pattr->Satisfied() && !satisfied) {
382  pattr->Satisfied(false,CurrentTime());
383  }
384  continue;
385  }
386  } // loop conditions
387 }
388 
389 
390 // logging io: start
391 void LoggingExecutor::LogOpen(TokenWriter& rTw, int logmode) {
392  FD_DX("LoggingExecutor(" << this << ")::LogOpen()");
393  pLogTokenWriter= &rTw;
394  mLogFile="";
395  mLogMode=logmode;
396  pLogTokenWriter->WriteBegin("ExecutionLog");
397  pLogTokenWriter->WriteBegin("Mode");
398  if(mLogMode & LogStatistics) pLogTokenWriter->WriteOption("Statistics");
402  pLogTokenWriter->WriteEnd("Mode");
403  LogWriteTime();
404  LogWriteState();
405 }
406 
407 // logging io: start
408 void LoggingExecutor::LogOpen(const std::string& rFileName, int logmode, std::ios::openmode openmode) {
409  FD_DX("LoggingExecutor(" << this << ")::LogOpen(" << rFileName << ")");
410  pLogTokenWriter= new TokenWriter(rFileName,openmode);
411  LogOpen(*pLogTokenWriter, logmode);
412  mLogFile=rFileName;
413 }
414 
415 
416 // logging io: stop
418  if(mLogMode & LogStatistics) {
420  }
421  if(mLogMode != 0) {
422  FD_DX("LoggingExecutor(" << this << ")::LogClose(" << mLogFile << ")");
423  *pLogTokenWriter << "\n";
424  *pLogTokenWriter << "\n";
425  pLogTokenWriter->WriteEnd("ExecutionLog");
426  }
427  if(mLogFile!="") {
428  delete pLogTokenWriter;
429  }
430  mLogFile="";
431  pLogTokenWriter=0;
432  mLogMode=0;
433 }
434 
435 // logging: report statistics
437  if(!(mLogMode & LogStatistics)) return;
438  FD_DX("LoggingExecutor(" << this << ")::LogWriteStatistics()");
439  *pLogTokenWriter << "\n";
440  *pLogTokenWriter << "\n";
441  pLogTokenWriter->WriteBegin("Statistics");
442  std::vector<AttributeSimCondition*>::iterator ait=mEnabledConditions.begin();
443  for(; ait != mEnabledConditions.end(); ++ait) {
444  AttributeSimCondition* pattr= *ait;
445  pattr->mSamplesPeriod.Compile();
447  pattr->mSamplesDuration.Compile();
449  *pLogTokenWriter << "\n";
450  }
451  pLogTokenWriter->WriteEnd("Statistics");
452  *pLogTokenWriter << "\n";
453  *pLogTokenWriter << "\n";
454 }
455 
456 // logging: report state
458  if(!(mLogMode & LogStates)) return;
459  if(mLogMode & LogTime) {
460  CurrentParallelTimedState().Write(*pLogTokenWriter,"TimedState",this);
461  } else
462  CurrentParallelTimedState().Write(*pLogTokenWriter,"DiscreteState",this);
463  *pLogTokenWriter << "\n";
464 }
465 
466 // logging: report event
468  if(!(mLogMode & LogEvents)) return;
469  if(!(mLogMode & LogStates)) {
471  *pLogTokenWriter << "\n";
472  } else {
473  pLogTokenWriter->WriteBegin("Event");
475  pLogTokenWriter->WriteEnd("Event");
476  }
477 }
478 
479 // loggging report time
481  if(!(mLogMode & LogTime)) return;
482  if(!(mLogMode & LogStates)) {
484  *pLogTokenWriter << "\n";
485  } else {
486  pLogTokenWriter->WriteBegin("Time");
488  pLogTokenWriter->WriteEnd("Time");
489  }
490 }
491 
492 // logging: pause
494  FD_DX("LoggingExecutor(" << this << ")::LogWritePause()");
495  if(mLogMode == 0) return;
497  *pLogTokenWriter << "\n";
498  pLogTokenWriter->WriteEnd("ExecutionLog");
499  *pLogTokenWriter << "\n";
500  *pLogTokenWriter << "\n";
501  *pLogTokenWriter << "\n";
502 }
503 
504 // logging report pause
506  FD_DX("LoggingExecutor(" << this << ")::LogWriteResume()");
507  if(mLogMode == 0) return;
508  pLogTokenWriter->WriteBegin("ExecutionLog");
509  LogWriteState();
510 }
511 
512 // trace: clear all
513 void LoggingExecutor::TraceClear(int length) {
514  FD_DX("LoggingExecutor(" << this << ")::TraceClear(" << length <<")");
515  // clear
516  mTraceBuffer.clear();
517  mTraceTimeToStep.clear();
518  // set max length
519  if(length>-2) mTraceMax=length;
520  // set first step
522  // bail out
523  if(mTraceMax==0) return;
524  // set first entry
525  TraceAddSample();
526 }
527 
528 // trace: access
530  return mTraceBuffer.begin();
531 }
532 
533 // trace: access
535  return mTraceBuffer.end();
536 }
537 
538 // trace: access
540  int n = step-mTraceFirstStep;
541  if(n<0) return 0;
542  if(((unsigned int)n)>=mTraceBuffer.size()) return 0;
543  return &mTraceBuffer[n];
544 }
545 
546 // trace: access
548  std::map<Time::Type,int>::const_iterator sit=mTraceTimeToStep.find(time);
549  if(sit== mTraceTimeToStep.end())
550  return 0;
551  int step = sit->second;
552  return TraceAtStep(step);
553 }
554 
555 // trace: access
557  if(mTraceBuffer.size()==0) return 0;
558  return &mTraceBuffer.back();
559 }
560 
561 // trace: access
563  if(mTraceBuffer.size()<2) return 0;
564  return &mTraceBuffer[mTraceBuffer.size()-2];
565 }
566 
567 // trace: access
569  if(mTraceBuffer.size()<1) return 0;
570  return &mTraceBuffer[0];
571 }
572 
573 // trace: access
575  return mTraceBuffer.size();
576 }
577 
578 // trace: add empty sample
580  // initialize new sample
581  TraceSample sample;
583  sample.mStep=CurrentStep();
584  sample.mTime=CurrentTime();
585  sample.mDuration=0;
586  sample.mEvent=0;
587  // add to buffer
588  mTraceBuffer.push_back(sample);
589  // drop first sample
590  if(mTraceMax>0)
591  while(mTraceBuffer.size()> (unsigned int) mTraceMax)
592  mTraceBuffer.pop_front();
593  // fix timing
594  if(mTraceMax>0)
595  mTraceFirstStep=mTraceBuffer.front().mStep;
596  // todo: time map
597 }
598 
599 // trace:: update after transition
601  // bail out
602  if(mTraceMax==0) return;
603  // fix last entry
604  TraceSample& sample=mTraceBuffer.back();
605  sample.mEvent=event;
606  sample.mDuration=CurrentTime()-sample.mTime;
607  // add entry
608  TraceAddSample();
609 }
610 
611 // trace:: update time
613  // bail out
614  if(mTraceMax==0) return;
615  // fix last entry
616  TraceSample& sample=mTraceBuffer.back();
617  sample.mDuration=CurrentTime()-sample.mTime;
618 }
619 
620 
621 
622 // trace: tokenwriter output
623 void LoggingExecutor::TraceWrite(TokenWriter& rTw, const TraceSample& sample) const {
624  rTw.WriteBegin("Sample");
625  rTw.WriteComment(" State " + PTSStr(sample.mState));
626  rTw << sample.mStep;
627  rTw << sample.mTime;
628  rTw << sample.mDuration;
629  rTw << "\n";
630  if(sample.mEvent>0)
631  rTw << EventName(sample.mEvent);
632  rTw.WriteEnd("Sample");
633 }
634 
635 // trace: console output
636 void LoggingExecutor::TraceWrite(const TraceSample& sample) const {
638  TraceWrite(tw, sample);
639 }
640 
641 // trace: console output (all)
643  for(TraceIterator sit=TraceBegin(); sit!=TraceEnd(); sit++) {
644  TraceWrite(*sit);
645  };
646 }
647 
648 // trace: string output
649 std::string LoggingExecutor::TraceToString(const TraceSample& sample) const {
651  TraceWrite(tw, sample);
652  return tw.Str();
653 }
654 
655 // Revert executors state to past step from buffer
657  FD_DX("LoggingExecutor(" << this << ")::RevertToStep("<< step << ")");
658  bool res=true;
659  const TraceSample* samplep = TraceAtStep(step);
660  if(!samplep) return false;
661  FD_DX("LoggingExecutor(" << this << ")::RevertToStep("<< step << "): found step");
662  // set state
664  if(!res) return false;
665  // care log trace
666  LogWritePause();
667  // set time
670  LogWriteResume();
671  // care trace: remove
672  FD_DX("LoggingExecutor(" << this << ")::RevertToStep("<< step << "): fixing trace");
673  while(mTraceBuffer.size()>0) {
674  const TraceSample& lsample= mTraceBuffer.back();
675  if(lsample.mStep<=step) break;
676  mTraceBuffer.pop_back();
677  }
678  // care trace: invalidate last sample
679  if(mTraceBuffer.size()>0) {
680  TraceSample& lsample= mTraceBuffer.back();
681  lsample.mEvent=0;
682  lsample.mDuration=0;
683  }
684  // clear condition state
685  mConditions.Reset();
686  FD_DX("LoggingExecutor(" << this << ")::RevertToStep("<< step << "): done");
687  return true;
688 }
689 
690 } // namespace faudes
691 
692 
#define FD_DC(message)
Debug: optional report on container operations.
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
faudes type implementation macros, overall
Definition: cfl_types.h:946
Attribute for a simulation condition.
bool Enabled(void) const
Test whether condition is enabled.
void StateCondition(const SimStateCondition &rStateConditionAttribute)
Set state condition attribute.
void EventCondition(const SimEventCondition &rEventConditionAttribute)
Set event condition attribute.
SampledDensityFunction mSamplesDuration
Sampled durations, for which this condition remains satisfied.
bool Breakpoint(void) const
Test for break condition.
bool Satisfied(void) const
Test whether the condition is currently satisfied.
bool IsEventCondition(void) const
Test for event condition.
SampledDensityFunction mSamplesPeriod
Sampled period, at which this condition becomes satisfied.
bool IsStateCondition(void) const
Test for state condition.
void Write(TokenWriter &rTw) const
Faudes exception class.
Set of indices.
Definition: cfl_indexset.h:78
Executor with logging facilities.
Definition: sp_lpexecutor.h:85
void TraceClear(int length=-2)
Clear buffer and set max buffer.
std::deque< TraceSample >::const_iterator TraceIterator
Access buffer: iterator.
virtual ~LoggingExecutor(void)
Explicit destructor.
int mTraceFirstStep
Trace data: step no of first sample.
std::vector< AttributeSimCondition * > mEnabledConditions
Enabled simulation conditions.
Idx SetCondition(const std::string &rName, const AttributeSimCondition &rCondition)
Set (or add) a condition by name.
TraceIterator TraceEnd(void) const
Condition iterator: end
virtual bool RevertToStep(Idx step)
Revert executors state to past step from buffer.
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Write to TokenWriter, see also public wrappers in faudes::Type.
void LogWriteStatistics(void)
Logging hook: dump statistics.
void TraceAddSample(void)
Trace: helper, append one void sample.
std::map< Time::Type, int > mTraceTimeToStep
Trace data: time to step mapping (first step)
void LogWriteEvent(void)
Logging hook: dump recent event.
int TraceLength(void) const
Access buffer: current length.
const TraceSample * TraceAtTime(Time::Type time) const
Access buffer: sample by faudes time (returns first sample)
const TraceSample * TraceRecent(void) const
Access buffer: recent sample.
virtual void Compile()
Compile internal data (all)
void LogWritePause(void)
Logging hook: halt simulation.
void DoAssign(const LoggingExecutor &rSrc)
Assignment method.
ConditionIterator ConditionsEnd(void) const
Condition iterator: end
virtual void Clear(void)
Clear all data.
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 bool ExecuteTime(Time::Type duration)
Let time pass without executing a transition.
int mTraceMax
Trace data: max fifo length.
void TraceWrite(void) const
Access buffer: console output (list all)
const SimConditionSet & Conditions(void) const
Read-only access to simulation conditions.
std::string mLogFile
Logging: file name.
LoggingExecutor(void)
Construct an emtpy LoggingExecuter.
SimConditionSet::Iterator ConditionIterator
Condition iterator: typedef.
void ConditionsRead(TokenReader &rTr, const std::string &rLabel="SimConditions")
Read conditions from labled section
int CurrentStep(void) const
Get logical time, ie number of transitions so far,.
const ParallelTimedState & CurrentParallelTimedState(void) const
Get current state of the ParallelExecutor.
const TraceSample * TraceFirst(void) const
Access buffer: first sample.
void LogWriteResume(void)
Logging hook: continue simulation.
const TraceSample * TraceAtStep(int step) const
Access buffer: sample by step.
void LogOpen(TokenWriter &rTw, int mode)
Start logging to TokenWriter.
virtual bool ExecuteEvent(Idx event)
Execute transition.
void ConditionsWrite(TokenWriter &rTw, const std::string &rLabel="SimConditions") const
Write conditions so labled section
void LogWriteState(void)
Logging hook: dump current state.
SimConditionSet mConditions
Simulation conditions.
void ConditionsProcess(void)
Process condition hook.
void CompileConditions(void)
Compile condition internal data.
std::string TraceToString(const TraceSample &sample) const
Access buffer: convert to string.
TokenWriter * pLogTokenWriter
Logging: tokenwriter ref.
Time::Type CurrentTime(void) const
Get clock time.
void ConditionsReset(void)
Reset condition simulation state.
bool mBreakCondition
Indicate break.
void LogWriteTime(void)
Logging hook: dump current time.
virtual void Reset(void)
Goto initial state.
ConditionIterator ConditionsBegin(void) const
Condition iterator: begin.
void ClrCondition(const std::string &rName)
Remove a condition by name
void TraceUpdateTransition(Idx event)
Trace: append sample (if necessary) and update to current state via given event
TraceIterator TraceBegin(void) const
Condition iterator: begin.
const AttributeSimCondition & Condition(const std::string &rName) const
Read-only access to a simulation condition by name.
int mLogMode
Logging: mode.
const TraceSample * TraceCurrent(void) const
Access buffer: current sample.
void LogClose(void)
Stop logging.
std::deque< TraceSample > mTraceBuffer
Trace data: fifo buffer.
void TraceUpdateTime(void)
Trace: append sample (if necessary) and update to current time
Idx Index(const std::string &rName) const
Index lookup.
Typedef for parallel timed state, incl token io.
Definition: sp_pexecutor.h:76
Synchronized parallel execution of TimedGenerators.
Definition: sp_pexecutor.h:64
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Write to TokenWriter, see also public wrappers Write() in faudes::Type.
Time::Type CurrentTime(void) const
Get clock time.
Idx Size(void) const
Number of TimedGenerators.
const ParallelState & CurrentParallelState(void) const
Get current discrete state vector of the ParallelExecutor.
virtual void Compile()
compile internal data (eg overall alphabet)
virtual bool ExecuteTime(Time::Type duration)
Let time pass without executing a transition.
Idx mRecentEvent
recent event
Definition: sp_pexecutor.h:567
const ParallelTimedState & CurrentParallelTimedState(void) const
Get current state of the ParallelExecutor.
int CurrentStep(void) const
Get logical time, ie number of transitions so far,.
std::string PTSStr(const ParallelTimedState &ptstate) const
Pretty printable string of timed parallel state.
virtual void Clear(void)
Clear all data.
virtual bool ExecuteEvent(Idx event)
Execute transition.
virtual void Reset(void)
Goto initial state.
virtual void DoReadGenerators(TokenReader &rTr)
Reads generator files section from TokenReader.
const EventSet & Alphabet(void) const
Overall alphabet.
void DoAssign(const ParallelExecutor &rSrc)
Assignment method.
std::string EventName(Idx index) const
Event name lookup.
Definition: sp_pexecutor.h:210
Set of simulation named conditions.
void Reset(void)
Reset all condition states.
virtual bool Insert(const Idx &rIndex)
Add an element by index.
Definition: cfl_nameset.h:988
std::string Str(const Idx &rIndex) const
Return pretty printable symbolic name for index.
Definition: cfl_nameset.h:1185
Attr * Attributep(const Idx &rElem)
Definition: cfl_nameset.h:843
virtual bool Erase(const Idx &rIndex)
Delete element by index.
Definition: cfl_nameset.h:1067
const Attr & Attribute(const Idx &rElem) const
Definition: cfl_nameset.h:844
virtual TaNameSet & Assign(const TBaseSet< Idx > &rSrc)
Relaxed assignment method (uses base class to maintain attributes)
Definition: cfl_nameset.h:968
Int Type
Datatype for point on time axis.
A TokenReader reads sequential tokens from a file or string.
std::string FileLine(void) const
Return "filename:line".
bool Eos(const std::string &rLabel)
Peek a token and check whether it ends the specified section.
void ReadEnd(const std::string &rLabel)
Close the current section by matching the previous ReadBegin().
void ReadBegin(const std::string &rLabel)
Open a section by specified label.
bool Peek(Token &token)
Peek next token.
A TokenWriter writes sequential tokens to a file, a string or stdout.
std::string Str(void)
Retrieve output as string (if in String mode)
void WriteFloat(const double &val)
Write float.
void WriteComment(const std::string &rComment)
Write comment in faudes format.
void WriteString(const std::string &rString)
Write string.
void WriteEnd(const std::string &rLabel)
Write end label.
void WriteBegin(const std::string &rLabel)
Write begin label.
void WriteOption(const std::string &rOpt)
Write option (may not contain any "+")
Tokens model atomic data for stream IO.
Definition: cfl_token.h:53
const std::string & StringValue(void) const
Get string value of a name token.
Definition: cfl_token.cpp:177
@ Begin
<label> (begin of section)
Definition: cfl_token.h:83
TokenType Type(void) const
Get token Type.
Definition: cfl_token.cpp:198
Base class of all libFAUDES objects that participate in the run-time interface.
Definition: cfl_types.h:239
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from file with label specified.
Definition: cfl_types.cpp:261
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
void Lock(void) const
Detach and lock any further reallocation.
Definition: cfl_baseset.h:1462
bool Empty(void) const
Test whether if the TBaseSet is Empty.
Definition: cfl_baseset.h:1824
bool Exists(const T &rElem) const
Test existence of element.
Definition: cfl_baseset.h:2115
virtual void Clear(void)
Clear all set.
Definition: cfl_baseset.h:1902
Iterator End(void) const
Iterator to the end of set.
Definition: cfl_baseset.h:1896
Iterator Begin(void) const
Iterator to the begin of set.
Definition: cfl_baseset.h:1891
void DValid(const std::string &rMessage="") const
Some validation of deferred copy mechanism (provoke abort)
Definition: cfl_baseset.h:1606
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
#define FD_DX(message)
Definition: sp_executor.h:27
Executor with logging facilities

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