simfaudes.cpp
Go to the documentation of this file.
1 /** @file simfaudes.cpp Simple simulator application for faudes generators
2 
3 This tutorial demonstrates how to build a simulator application from
4 the class faudes::ProposingExecutor. When compiled with the
5 IO device plugin, the faudes::DeviceExecutor is used to run a
6 hardware-in-the-loop simulation.
7 
8 @code
9 ~/libfaudes/plugins/simulator/tutorial> ./simfaudes -?
10 
11 simfaudes: usage:
12 
13  simfaudes [-q][-v][-i][-bc] [-bt <nnn>][-bs <nnn>] [-l <logfile>] [-ls] [-le] [-lt] <simfile>
14 
15 where
16  <simfile>: simulation configuration file or generator file
17 
18  -q: less console output
19  -qq: absolutely no console output
20  -v: more console output
21  -vv: even more console output
22  -i: interactive mode
23 
24  -bc: break on condition
25  -bt <nnn>: break on time <nnn>
26  -bs <nnn>: break on step <nnn>
27 
28  -l <logfile>: log to <logfile>
29  -ls: log states
30  -le: log events
31  -lt: log time
32  -la: log all
33  -t <nnn>: fifo trace buffer length <nnn>
34 
35  -d <devfile>: use io device configured from file
36  -dt <nnn>: tolerance in time synchronisation
37  -dr: executer reset on device request
38 @endcode
39 
40 
41 You may test the simulator with the examples provided in the data
42 directory:
43 
44 @code
45 
46 ~/libfaudes/plugins/simulator/tutorial>./simfaudes -bs 5 data/gausstest.sim
47 % simfaudes: ========================================= current state:
48 <DiscreteState> "idle" </DiscreteState>
49 % simfaudes: ========================================= current time:
50 <Time> 0 </Time>
51 % simfaudes: ========================================= proposed action:
52 <ProposedTime> 205 </ProposedTime>
53 <ProposedEvent> "alpha" </ProposedEvent>
54 % simfaudes: ========================================= execute event:
55 <ExecutedEvent> "alpha" </ExecutedEvent>
56 % simfaudes: ========================================= current state:
57 <DiscreteState> "busy" </DiscreteState>
58 % simfaudes: ========================================= current time:
59 <Time> 205 </Time>
60 % simfaudes: ========================================= found conditions satisfied:
61 <SatisfiedConditions> "BusyCond" </SatisfiedConditions>
62 % simfaudes: ========================================= proposed action:
63 <ProposedTime> 51 </ProposedTime>
64 % simfaudes: ========================================= current state:
65 <DiscreteState> "busy" </DiscreteState>
66 % simfaudes: ========================================= current time:
67 <Time> 256 </Time>
68 % simfaudes: ========================================= found conditions satisfied:
69 <SatisfiedConditions> "BusyCond" </SatisfiedConditions>
70 % simfaudes: ========================================= proposed action:
71 <ProposedTime> 39 </ProposedTime>
72 <ProposedEvent> "beta" </ProposedEvent>
73 % simfaudes: ========================================= execute event:
74 <ExecutedEvent> "beta" </ExecutedEvent>
75 % simfaudes: ========================================= current state:
76 <DiscreteState> "idle" </DiscreteState>
77 % simfaudes: ========================================= current time:
78 <Time> 295 </Time>
79 % simfaudes: ========================================= found conditions satisfied:
80 <SatisfiedConditions> "IdleCond" </SatisfiedConditions>
81 % simfaudes: ========================================= proposed action:
82 <ProposedTime> 191 </ProposedTime>
83 <ProposedEvent> "alpha" </ProposedEvent>
84 % simfaudes: ========================================= execute event:
85 <ExecutedEvent> "alpha" </ExecutedEvent>
86 % simfaudes: ========================================= current state:
87 <DiscreteState> "busy" </DiscreteState>
88 % simfaudes: ========================================= current time:
89 <Time> 486 </Time>
90 % simfaudes: ========================================= found conditions satisfied:
91 <SatisfiedConditions> "BusyCond" </SatisfiedConditions>
92 % simfaudes: ========================================= proposed action:
93 <ProposedTime> 51 </ProposedTime>
94 % simfaudes: ========================================= end simulation
95 
96 @endcode
97 
98 The code is straight forward: after some command line parsing
99 for behavioural configuration, it reads a proposing executor from file
100 and loops to execute the proposed transitions.
101 
102 
103 @ingroup Tutorials
104 
105 @include simfaudes.cpp
106 
107 */
108 
109 
110 #include "libfaudes.h"
111 #include <signal.h>
112 
113 using namespace faudes;
114 
115 
116 // global vars used in exit handler
119 std::string mMark="% simfaudes: ========================================= ";
120 
121 // simulator clean-up on exit
122 void simfaudes_exit(void);
123 
124 // signal handler recursion flag
125 volatile sig_atomic_t signal_in_progress = 0;
126 
127 // signal handler to stop devices
128 void catch_signal(int sig) {
129  // detect recursion, pass on
130  if(signal_in_progress) raise(sig);
131  signal_in_progress = 1;
132  // report
133  std::cerr << "simfaudes: signal " << faudes_strsignal(sig) << std::endl;
134  // call my exit function
135  simfaudes_exit();
136  // re-install default handler
137  signal(sig, SIG_DFL);
138  // pass on signal
139  raise(sig);
140 }
141 
142 
143 // clean-up on exit
144 void simfaudes_exit(void) {
145 #ifdef FAUDES_PLUGIN_IODEVICE
146  // report device performance
147  if(vDevice* dev=mExecutor.Devicep()) {
148  dev->WritePerformance();
149  }
150  // stop all devices
152 #endif
153  // report statistics
154  if(mConsoleOut>=-1) {
155  std::cout << mMark << " end simulation #" << mExecutor.Size() << std::endl;
157  cit!=mExecutor.ConditionsEnd(); cit++) {
158  if(!mExecutor.Condition(*cit).Enabled()) continue;
159  std::cout << mMark << "statistics for simulation condition \"" <<
160  mExecutor.Conditions().SymbolicName(*cit) << "\"" << std::endl;
162  std::cout << mExecutor.Condition(*cit).mSamplesPeriod.Str();
164  std::cout << mExecutor.Condition(*cit).mSamplesDuration.Str() << std::endl;
165  }
166  }
167  // close log file
169  // reset incl device if such
170  mExecutor.Reset();
171 }
172 
173 // print usage info and exit
174 void usage_exit(const std::string& message="") {
175  if(message!="") {
176  std::cout << "simfaudes: " << message << std::endl;
177  std::cout << "" << std::endl;
178  exit(-1);
179  }
180  std::cout << "simfaudes: version " << VersionString() << std::endl;
181  std::cout << "" << std::endl;
182  std::cout << "simfaudes: usage: " << std::endl;
183  std::cout << " simfaudes [-q][-v][-i][-bc] [-bt <nnn>][-bs <nnn>] [-l <logfile>] [-ls] [-le] [-lt] <simfile> " << std::endl;
184  std::cout << "where " << std::endl;
185  std::cout << " <simfile>: simulation configuration file" << std::endl;
186  std::cout << "" << std::endl;
187  std::cout << " -q: less console output " << std::endl;
188  std::cout << " -qq: absolutely no console output " << std::endl;
189  std::cout << " -v: more console output" << std::endl;
190  std::cout << " -vv: even more console output" << std::endl;
191  std::cout << " -i: interactive mode " << std::endl;
192  std::cout << "" << std::endl;
193  std::cout << " -bc: break on condition" << std::endl;
194  std::cout << " -bt <nnn>: break on time <nnn> " << std::endl;
195  std::cout << " -bs <nnn>: break on step <nnn> " << std::endl;
196  std::cout << "" << std::endl;
197  std::cout << " -l <logfile>: log to <logfile> " << std::endl;
198  std::cout << " -ls: log states" << std::endl;
199  std::cout << " -le: log events" << std::endl;
200  std::cout << " -lt: log time" << std::endl;
201  std::cout << " -la: log all" << std::endl;
202  std::cout << " -t <nnn>: fifo trace buffer length <nnn> " << std::endl;
203 #ifdef FAUDES_PLUGIN_IODEVICE
204  std::cout << "" << std::endl;
205  std::cout << " -d <devfile>: use io device configured from file" << std::endl;
206  std::cout << " -dt <nnn>: tolerance in time synchronisation" << std::endl;
207  std::cout << " -dr: executer reset on device request" << std::endl;
208 #endif
209  std::cout << "" << std::endl;
210  std::cout << "" << std::endl;
211  exit(-1);
212 }
213 
214 // parse commandline, read executor and run executor
215 int main(int argc, char* argv[])
216 {
217 
218 
219  // install my signal handler
221 
222  // install my exit fnct
223  atexit(simfaudes_exit);
224 
225  // default behaviour
226  mConsoleOut=0;
227  bool mInteractive=false;
228  std::string mSimFile="";
229  std::string mDevFile="";
230  tpTime::Type mTolerance=-1;
231  bool mBreakCondition=false;
232  tpTime::Type mBreakTime=tpTime::Max;
233  int mBreakStep=-1;
234  std::string mLogFile="";
235  int mLogMode=0;
236  int mTraceLength=5;
237  bool mResetRequest=false;
238 
239  // primitive commad line parsing
240  for(int i=1; i<argc; i++) {
241  std::string option(argv[i]);
242  // option: quiet
243  if((option=="-q") || (option=="--quiet")) {
244  mConsoleOut=-1;
245  continue;
246  }
247  // option: more quiet
248  if((option=="-qq") || (option=="--quietquiet")) {
249  mConsoleOut=-2;
250  continue;
251  }
252  // option: verbose
253  if((option=="-v") || (option=="--verbose")) {
254  mConsoleOut=1;
255  continue;
256  }
257  // option: more verbose
258  if((option=="-vv") || (option=="--verboseverbose")) {
259  mConsoleOut=2;
260  continue;
261  }
262  // option: interactive
263  if((option=="-i") || (option=="--interactive")) {
264  mInteractive=true;
265  continue;
266  }
267  // option: io device
268  if((option=="-d") || (option=="--device")) {
269  i++; if(i>=argc) usage_exit();
270  mDevFile=argv[i];
271  continue;
272  }
273  // option: io device tolerance
274  if((option=="-dt") || (option=="--tolerance")) {
275  i++; if(i>=argc) usage_exit();
276  mTolerance=(tpTime::Type) ToIdx(argv[i]);
277  continue;
278  }
279  // option: io device reset request
280  if((option=="-dr") || (option=="--resetrequest")) {
281  mResetRequest=true;
282  continue;
283  }
284  // option: break condition
285  if((option=="-bc") || (option=="--breakcondition")) {
286  mBreakCondition=true;
287  continue;
288  }
289  // option: break time
290  if((option=="-bt") || (option=="--breaktime")) {
291  i++; if(i>=argc) usage_exit();
292  mBreakTime=(tpTime::Type) ToIdx(argv[i]);
293  continue;
294  }
295  // option: break step
296  if((option=="-bs") || (option=="--breakstep")) {
297  i++; if(i>=argc) usage_exit();
298  mBreakStep=(int) ToIdx(argv[i]);
299  continue;
300  }
301  // option: log file
302  if((option=="-l") || (option=="--logfile")) {
303  i++; if(i>=argc) usage_exit();
304  mLogFile=argv[i];
305  continue;
306  }
307  // option: log states
308  if((option=="-ls") || (option=="--logstates")) {
309  mLogMode |= LoggingExecutor::States;
310  continue;
311  }
312  // option: log events
313  if((option=="-le") || (option=="--logevents")) {
314  mLogMode |= LoggingExecutor::Events;
315  continue;
316  }
317  // option: log time
318  if((option=="-lt") || (option=="--logtime")) {
319  mLogMode |= LoggingExecutor::Time;
320  continue;
321  }
322  // option: log all
323  if((option=="-la") || (option=="--logall")) {
324  mLogMode |= 0xff;
325  continue;
326  }
327  // option: trace
328  if((option=="-t") || (option=="--trace")) {
329  i++; if(i>=argc) usage_exit();
330  mTraceLength=(int) ToIdx(argv[i]);
331  continue;
332  }
333  // option: help
334  if((option=="-?") || (option=="--help")) {
335  usage_exit();
336  continue;
337  }
338  // option: unknown
339  if(option.c_str()[0]=='-') {
340  usage_exit("unknown option "+ option);
341  continue;
342  }
343  // filename
344  if(mSimFile!="")
345  usage_exit("more than one filname specified" );
346  mSimFile=option;
347  }
348 
349  // insist in filename
350  if(mSimFile=="")
351  usage_exit("you must specify a filename" );
352 
353  // dont have both, interactive and sync physics
354  if(mDevFile!="" && mInteractive)
355  usage_exit("you must not specify both interactive and synchrone mode");
356 
357  // mute libFAUDES console out
358  if(mConsoleOut<0)
359  ConsoleOut::G()->Mute(true);
360 
361  // relaxed read configuration: test for generator file
362  bool gfile=false;
363  TokenReader* tr = new TokenReader(mSimFile);
364  Token token;
365  tr->Peek(token);
366  if(token.Type()==Token::Begin)
367  if(token.StringValue()=="Generator")
368  gfile=true;
369 
370  // read congiguration
371  if(gfile) {
372  mExecutor.Insert(mSimFile);
373  mExecutor.Reset();
374  } else {
375  mExecutor.Read(mSimFile);
376  mExecutor.Reset();
377  }
378 
379  // report configuration
380  if(mConsoleOut>=1) {
381  std::cout << mMark << "dumping configuration" << std::endl;
382  // generators
383  for(Idx i=0; i< mExecutor.Size(); i++) {
384  std::cout << mMark << "found generator #" << i+1 <<
385  ": " << mExecutor.At(i).Generator().Name() << std::endl;
386  }
387  // event attributes
388  for(EventSet::Iterator eit=mExecutor.Alphabet().Begin();
389  eit!=mExecutor.Alphabet().End(); eit++) {
390  std::cout << mMark << "found event attributes for \"" <<
391  mExecutor.EventName(*eit) << "\"" << std::endl;
392  std::cout << mExecutor.Alphabet().Attribute(*eit).ToString() << std::endl;
393  }
394  // conditions
396  cit!=mExecutor.ConditionsEnd(); cit++) {
397  std::cout << mMark << "found simulation condition \"" <<
398  mExecutor.Conditions().SymbolicName(*cit) << "\"" << std::endl;
399  std::cout << mExecutor.Condition(*cit).ToString() << std::endl;
400  }
401  }
402 
403  // report generators (disabled, max output level is 2)
404  if(mConsoleOut>=3) {
405  // generators
406  for(Idx i=0; i< mExecutor.Size(); i++) {
407  std::cout << mMark << "generator #" << i+1 << std::endl;
408  mExecutor.At(i).Generator().DWrite();
409  }
410  }
411 
412  // initialze log file
413  if(mLogFile!="") {
414  mExecutor.LogOpen(mLogFile,mLogMode | LoggingExecutor::Statistics);
415  }
416  if(mLogFile=="" && mLogMode!=0) {
419  }
420 
421  // set trace buffer
422  mExecutor.TraceClear(mTraceLength);
423 
424  // ************************************************ synchronous prep
425  if(mDevFile!="") {
426 #ifdef FAUDES_PLUGIN_IODEVICE
427 
428  // create device from file
429  vDevice* dev=vDevice::FromFile(mDevFile);
430 
431 
432 #ifdef FAUDES_NETWORK
433 #ifdef FAUDES_WINDOWS
434  // initialise winsocks
435  if(mConsoleOut>=0)
436  std::cout << mMark << "Initialze network" << std::endl;
437  WSADATA wsaData;
438  if(WSAStartup(MAKEWORD(2,2), &wsaData)!=0) {
439  usage_exit("cannot start winsock (network error)");
440  }
441 #endif
442 #endif
443 
444  // report
445  if(mConsoleOut>=0)
446  std::cout << mMark << "Execute via IO device: \""<< dev->Name() << "\"" << std::endl;
447 
448  // set tolerance
449  if(mTolerance!=-1) mExecutor.ToleranceTime(mTolerance);
450 
451  // assign device to executor ad wait for startuo to complete
452  mExecutor.Devicep(dev);
453  mExecutor.Reset();
454  if(mBreakTime==tpTime::UnDef) mBreakTime=tpTime::Max;
456  while(dev->Status()!=vDevice::Up) {
457  std::cout << mMark << "Starting IO device \""<< dev->Name() << "\" Status: " << dev->StatusString() << std::endl;
458  faudes_sleep(1);
459  }
460  dev->CurrentTime(0); // sync time; dont use reset, since we would loose events
461  std::cout << mMark << "IO device \""<< dev->Name() << "\" is Up" << std::endl;
462 #else
463  // cannot run device without plugin
464  usage_exit("cannot load device \""+mDevFile+"\": device plugin not present");
465 #endif
466 
467  }
468 
469 
470  // ************************************************* interactive loop
471  std::cout << mMark << " begin simulation #" << mExecutor.Size() << std::endl;
472  bool mRunning=true;
473  bool mInterTemp=mInteractive;
474  SimConditionSet mSatisfied;
475  mSatisfied.Name("SatisfiedConditions");
476  while(mRunning) {
477  // report current state
478  if(mConsoleOut>=2) {
479  std::cout << mMark << "current state:" << std::endl;
480  std::cout << mExecutor.CurrentParallelTimedState().ToString("TimedState",&mExecutor) << std::endl;
481  std::cout << mMark << "marking reached:" << std::endl;
482  for(Idx i=0; i<mExecutor.Size(); i++) {
483  if(mExecutor.At(i).Generator().ExistsMarkedState( mExecutor.At(i).CurrentState() ))
484  std::cout << mExecutor.At(i).Name() << ": marked" << std::endl;
485  }
486  }
487  // report current state
488  if(mConsoleOut>=0 && mConsoleOut<2) {
489  std::cout << mMark << "current state:" << std::endl;
490  std::cout << mExecutor.CurrentParallelTimedState().ToString("DiscreteState",&mExecutor) << std::endl;
491  }
492  // report current time
493  if(mConsoleOut>=1) {
494  std::cout << mMark << "current time:" << std::endl;
495  std::cout << "<Time> " << mExecutor.CurrentTime() << " </Time>" << std::endl;
496  std::cout << "<Step> " << mExecutor.CurrentStep() << " </Step>" << std::endl;
497  }
498  // report current time
499  if(mConsoleOut==0) {
500  std::cout << mMark << "current time:" << std::endl;
501  std::cout << "<Time> " << mExecutor.CurrentTime() << " </Time>" << std::endl;
502  }
503  // report satisfied conditions
504  if(mConsoleOut>=0) {
505  mSatisfied.Clear();
507  cit!=mExecutor.ConditionsEnd(); cit++) {
508  if(mExecutor.Condition(*cit).Satisfied()) mSatisfied.Insert(*cit);
509  }
510  if(mSatisfied.Size()>0) {
511  std::cout << mMark << "found conditions satisfied:" << std::endl;
512  std::cout << mSatisfied.ToString() << std::endl;
513  }
514  }
515  // report internal state
516  if(mConsoleOut>=2) {
517  std::cout << mMark << "simulation event states:" << std::endl;
518  std::cout << mExecutor.EventStatesToString() << std::endl;
519  }
520  // report enables per component
521  if(mConsoleOut>=2 && mExecutor.Size()>1) {
522  std::cout << mMark << "disabled events (per component):" << std::endl;
523  for(Idx i=0; i<mExecutor.Size(); i++) {
524  std::string enevs = mExecutor.At(i).DisabledEvents().ToString();
525  std::cout << mExecutor.At(i).Name() << ": " << enevs << std::endl;
526  }
527  }
528  // report enabled transitions
529  if(mConsoleOut>=1) {
530  std::cout << mMark << "enabled events:" << std::endl;
531  std::cout << mExecutor.EnabledEvents().ToString() << std::endl;
532  std::cout << mMark << "enabled interval:" << std::endl;
533  std::cout << mExecutor.EnabledInterval().Str() << std::endl;
534  std::cout << mMark << "enabled time:" << std::endl;
535  std::cout << mExecutor.EnabledTime().Str() << std::endl;
536  }
537  // test break: time up
539  if(mConsoleOut>=-1) std::cout << mMark << "time is up" << std::endl;
540  mInterTemp=false;
541  mRunning=false;
542  break;
543  }
544  // test break: condition
545  if(mExecutor.BreakCondition() && (mBreakCondition || mInteractive)) {
546  if(mConsoleOut>=-1) std::cout << mMark << "break condition triggered" << std::endl;
547  mInterTemp=mInteractive;
548  mRunning=mInteractive;
549  }
550  // test break: time
551  if(mBreakTime!=tpTime::UnDef)
552  if(mExecutor.CurrentTime() >= mBreakTime) {
553  if(mConsoleOut>=-1) std::cout << mMark << "break time reached" << std::endl;
554  mInterTemp=mInteractive;
555  mRunning=mInteractive;
556  }
557  // test break: step
558  if(mBreakStep>=0)
559  if(mExecutor.CurrentStep() >= mBreakStep) {
560  if(mConsoleOut>=-1) std::cout << mMark << "break step reached" << std::endl;
561  mInterTemp=mInteractive;
562  mRunning=mInteractive;
563  }
564  // test break: synchronous device
565  if(!mExecutor.IsSynchronous()) {
566  if(mConsoleOut>=-1) std::cout << mMark << "device out of sync" << std::endl;
567  mInterTemp=false;
568  mRunning=false;
569  break;
570  }
571  // proposed action
573  if(mConsoleOut>=0) {
574  std::cout << mMark << "proposed action:" << std::endl;
575  if(mPropTrans.Time>0)
576  std::cout << "<ProposedTime> " << ToStringInteger(mPropTrans.Time) << " </ProposedTime>" << std::endl;
577  if(mPropTrans.Event!=0)
578  std::cout << "<ProposedEvent> \"" << mExecutor.EventName(mPropTrans.Event) << "\" </ProposedEvent>" << std::endl;
579  if((mPropTrans.Time<=0) && (mPropTrans.Event==0) )
580  std::cout << "+DeadLock+" << std::endl;
581  }
582  // record transition
583  Idx mEvent=0;
584  // ask choice
585  while(mInterTemp) {
586  std::cout << mMark << "enter command:" << std::endl;
587  std::string line;
588  std::getline(std::cin,line);
589  // separate cmd from arg
590  std::string choice;
591  std::string param;
592  std::istringstream sline(line);
593  sline >> choice;
594  sline >> param;
595  // convert to int
596  int ichoice =-1;
597  std::istringstream schoice(choice);
598  schoice >> ichoice;
599  if(!schoice) ichoice=-1;
600  int iparam =-1;
601  std::istringstream sparam(param);
602  sparam >> iparam;
603  if(!sparam) iparam=-1;
604  // convert to symbol
605  std::string nchoice=choice;
606  if(choice.length()>2)
607  if(choice.at(0)=='"' && choice.at(choice.length()-1)== '"')
608  nchoice=choice.substr(1,choice.length()-2);
609  // switch cases
610  bool err=false;
611  if(choice=="x" || choice == "exit") {
612  mRunning=false;
613  } else
614  if(choice=="p" || choice=="proposal" || choice=="") {
615  mExecutor.ExecuteTime(mPropTrans.Time);
616  if(mExecutor.ExecuteEvent(mPropTrans.Event))
617  mEvent=mPropTrans.Event;
618  } else
619  if(choice=="r" || choice=="run") {
620  mInterTemp=false;
621  } else
622  if(choice=="v" || choice=="revert") {
623  int step = mExecutor.CurrentStep()-1;
624  if(iparam!=-1) step=iparam;
625  std::cout << mMark << "revert to step " << step << std::endl;
626  mExecutor.RevertToStep(step);
627  } else
628  if(choice=="t" || choice=="trace") {
629  std::cout << mMark << "system trace" << std::endl;
631  continue;
632  } else
633  if(ichoice>0) {
634  mExecutor.ExecuteTime(ichoice);
635  } else
636  if(mExecutor.Alphabet().Exists(nchoice)) {
638  mEvent=mExecutor.EventIndex(nchoice);
639  } else {
640  std::cout << mMark << "simfaudes interactive mode" << std::endl;
641  std::cout << "%" << std::endl;
642  std::cout << "% execute time and/or transitions" << std::endl;
643  std::cout << "% * <nn> to pass a specified duration <nn> (excl brackets)" << std::endl;
644  std::cout << "% * \"event\" to execute an event (incl quotes)" << std::endl;
645  std::cout << "% * [P] or [Ret] to execute the recent proPosal " << std::endl;
646  std::cout << "%" << std::endl;
647  std::cout << "% show trace and revert" << std::endl;
648  std::cout << "% * [T] to show a Trace of recent events and states" << std::endl;
649  std::cout << "% * [V] <nn> to reVert to step <nn> (obmit <nn> for one step backward) "<< std::endl;
650  std::cout << "%" << std::endl;
651  std::cout << "% other" << std::endl;
652  std::cout << "% * [X] to eXit" << std::endl<< std::endl;
653  err=true;
654  }
655  if(!err) break;
656  }
657  // execute proposal
658  if(!mInterTemp && mDevFile=="") {
659  mExecutor.ExecuteTime(mPropTrans.Time);
660  if(mExecutor.ExecuteEvent(mPropTrans.Event))
661  mEvent=mPropTrans.Event;
662  }
663 #ifdef FAUDES_PLUGIN_IODEVICE
664  // sync step
665  if(mDevFile!="") {
666  // reset request ?
667  bool rr= mExecutor.DeviceResetRequest();
668  if(rr && mConsoleOut>=0 && !mResetRequest) {
669  std::cout << mMark << "ignoring reset request" << std::endl;
670  rr=false;
671  }
672  if(rr && mConsoleOut>=0)
673  std::cout << mMark << "reset on request" << std::endl;
674  if(rr)
675  mExecutor.Reset();
676  // sync proposal
677  if(!rr) {
678  if(mConsoleOut>=0 && mPropTrans.Time>0)
679  std::cout << mMark << "sync wait" << std::endl;
680  mEvent=mExecutor.SyncStep();
682  }
683  }
684 #endif
685  // report event
686  if(mConsoleOut>=0 && mEvent!=0) {
687  std::cout << mMark << "execute event:" << std::endl;
688  std::cout << "<ExecutedEvent> \"" << mExecutor.EventName(mEvent) << "\" </ExecutedEvent>"
689  << std::endl;
690  }
691 
692  } // loop: while mRunning
693 
694  return 0;
695 }

libFAUDES 2.26g --- 2015.08.17 --- c++ api documentaion by doxygen