simfaudes.cpp
Go to the documentation of this file.
1/** @file simfaudes.cpp Simple simulator application for faudes generators
2
3This tutorial demonstrates how to build a simulator application from
4the class faudes::ProposingExecutor. When compiled with the
5IO device plugin, the faudes::DeviceExecutor is used to run a
6hardware-in-the-loop simulation.
7
8@code
9~/libfaudes/plugins/simulator/tutorial> ./simfaudes -?
10
11simfaudes: usage:
12
13 simfaudes [-q][-v][-i][-bc] [-bt <nnn>][-bs <nnn>] [-l <logfile>] [-ls] [-le] [-lt] <simfile>
14
15where
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
41You may test the simulator with the examples provided in the data
42directory:
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
98The code is straight forward: after some command line parsing
99for behavioural configuration, it reads a proposing executor from file
100and 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
114using namespace faudes;
115
116
117// global vars used in exit handler
120std::string mMark="% simfaudes: ========================================= ";
121
122// simulator clean-up on exit
123void simfaudes_exit(void);
124
125// signal handler to stop devices
126void catch_termsignal(int sig) {
127 // report
128 std::cout << std::endl;
129 std::cout << mMark << "simfaudes: signal " << faudes_strsignal(sig) << std::endl;
130 // clean up
132 // re-install default handler
133 signal(sig, SIG_DFL);
134 // pass on
135 raise(sig);
136}
137
138// clean-up on exit
139void simfaudes_exit(void) {
140 // clean up only once
141 static sig_atomic_t exit_in_progress = 0;
142 if(exit_in_progress>0) return;
143 exit_in_progress++;
144 std::cout << mMark << "simfaudes: exit handler" << std::endl;
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
171}
172
173// print usage info and exit
174void 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
215int main(int argc, char* argv[])
216{
217
218 // install my signal handler
220
221 // install my exit fnct
222 atexit(simfaudes_exit);
223
224 // default behaviour
225 mConsoleOut=0;
226 bool mInteractive=false;
227 std::string mSimFile="";
228 std::string mDevFile="";
229 Time::Type mTolerance=-1;
230 bool mBreakCondition=false;
231 Time::Type mBreakTime=Time::Max();
232 int mBreakStep=-1;
233 std::string mLogFile="";
234 int mLogMode=0;
235 int mTraceLength=5;
236 bool mResetRequest=false;
237
238 // primitive commad line parsing
239 for(int i=1; i<argc; i++) {
240 std::string option(argv[i]);
241 // option: quiet
242 if((option=="-q") || (option=="--quiet")) {
243 mConsoleOut=-1;
244 continue;
245 }
246 // option: more quiet
247 if((option=="-qq") || (option=="--quietquiet")) {
248 mConsoleOut=-2;
249 continue;
250 }
251 // option: verbose
252 if((option=="-v") || (option=="--verbose")) {
253 mConsoleOut=1;
254 continue;
255 }
256 // option: more verbose
257 if((option=="-vv") || (option=="--verboseverbose")) {
258 mConsoleOut=2;
259 continue;
260 }
261 // option: interactive
262 if((option=="-i") || (option=="--interactive")) {
263 mInteractive=true;
264 continue;
265 }
266 // option: io device
267 if((option=="-d") || (option=="--device")) {
268 i++; if(i>=argc) usage_exit();
269 mDevFile=argv[i];
270 continue;
271 }
272 // option: io device tolerance
273 if((option=="-dt") || (option=="--tolerance")) {
274 i++; if(i>=argc) usage_exit();
275 mTolerance=(Time::Type) ToIdx(argv[i]);
276 continue;
277 }
278 // option: io device reset request
279 if((option=="-dr") || (option=="--resetrequest")) {
280 mResetRequest=true;
281 continue;
282 }
283 // option: break condition
284 if((option=="-bc") || (option=="--breakcondition")) {
285 mBreakCondition=true;
286 continue;
287 }
288 // option: break time
289 if((option=="-bt") || (option=="--breaktime")) {
290 i++; if(i>=argc) usage_exit();
291 mBreakTime=(Time::Type) ToIdx(argv[i]);
292 continue;
293 }
294 // option: break step
295 if((option=="-bs") || (option=="--breakstep")) {
296 i++; if(i>=argc) usage_exit();
297 mBreakStep=(int) ToIdx(argv[i]);
298 continue;
299 }
300 // option: log file
301 if((option=="-l") || (option=="--logfile")) {
302 i++; if(i>=argc) usage_exit();
303 mLogFile=argv[i];
304 continue;
305 }
306 // option: log states
307 if((option=="-ls") || (option=="--logstates")) {
308 mLogMode |= LoggingExecutor::LogStates;
309 continue;
310 }
311 // option: log events
312 if((option=="-le") || (option=="--logevents")) {
313 mLogMode |= LoggingExecutor::LogEvents;
314 continue;
315 }
316 // option: log time
317 if((option=="-lt") || (option=="--logtime")) {
318 mLogMode |= LoggingExecutor::LogTime;
319 continue;
320 }
321 // option: log all
322 if((option=="-la") || (option=="--logall")) {
323 mLogMode |= 0xff;
324 continue;
325 }
326 // option: trace
327 if((option=="-t") || (option=="--trace")) {
328 i++; if(i>=argc) usage_exit();
329 mTraceLength=(int) ToIdx(argv[i]);
330 continue;
331 }
332 // option: help
333 if((option=="-?") || (option=="--help")) {
334 usage_exit();
335 continue;
336 }
337 // option: unknown
338 if(option.c_str()[0]=='-') {
339 usage_exit("unknown option "+ option);
340 continue;
341 }
342 // filename
343 if(mSimFile!="")
344 usage_exit("more than one filname specified" );
345 mSimFile=option;
346 }
347
348 // insist in filename
349 if(mSimFile=="")
350 usage_exit("you must specify a filename" );
351
352 // dont have both, interactive and sync physics
353 if(mDevFile!="" && mInteractive)
354 usage_exit("you must not specify both interactive and synchrone mode");
355
356 // mute libFAUDES console out
357 if(mConsoleOut<0)
358 ConsoleOut::G()->Verb(0);
359
360 try{
361
362 // relaxed read configuration: test for generator file
363 bool gfile=false;
364 TokenReader* tr = new TokenReader(mSimFile);
365 Token token;
366 tr->Peek(token);
367 if(token.Type()==Token::Begin)
368 if(token.StringValue()=="Generator")
369 gfile=true;
370 // read configuration
371 if(gfile) {
372 mExecutor.Insert(mSimFile);
374 } else {
375 mExecutor.Read(mSimFile);
377 }
378
379 } catch(const Exception& fe) {
380 std::cout << std::flush;
381 std::cerr << "simfaudes: caught [[" << fe.Message() << "]]" << std::endl;
382 std::cerr << "simfaudes: presumably missing/missformed configuration file" << std::endl;
383 return 1;
384 }
385
386 // report configuration
387 if(mConsoleOut>=1) {
388 std::cout << mMark << "dumping configuration" << std::endl;
389 // generators
390 for(Idx i=0; i< mExecutor.Size(); i++) {
391 std::cout << mMark << "found generator #" << i+1 <<
392 ": " << mExecutor.At(i).Generator().Name() << std::endl;
393 }
394 // event attributes
395 for(EventSet::Iterator eit=mExecutor.Alphabet().Begin();
396 eit!=mExecutor.Alphabet().End(); eit++) {
397 std::cout << mMark << "found event attributes for \"" <<
398 mExecutor.EventName(*eit) << "\"" << std::endl;
399 std::cout << mExecutor.Alphabet().Attribute(*eit).ToString() << std::endl;
400 }
401 // conditions
403 cit!=mExecutor.ConditionsEnd(); cit++) {
404 std::cout << mMark << "found simulation condition \"" <<
405 mExecutor.Conditions().SymbolicName(*cit) << "\"" << std::endl;
406 std::cout << mExecutor.Condition(*cit).ToString() << std::endl;
407 }
408 }
409
410 // report generators (disabled, max output level is 2)
411 if(mConsoleOut>=3) {
412 // generators
413 for(Idx i=0; i< mExecutor.Size(); i++) {
414 std::cout << mMark << "generator #" << i+1 << std::endl;
415 mExecutor.At(i).Generator().DWrite();
416 }
417 }
418
419 // initialze log file
420 if(mLogFile!="") {
422 }
423 if(mLogFile=="" && mLogMode!=0) {
426 }
427
428 // set trace buffer
429 mExecutor.TraceClear(mTraceLength);
430
431 // ************************************************ synchronous prep
432 if(mDevFile!="") {
433#ifdef FAUDES_PLUGIN_IODEVICE
434
435 // create device from file
436 vDevice* dev;
437 try {
438 dev=vDevice::FromFile(mDevFile);
439 } catch(const Exception& fe) {
440 std::cout << std::flush;
441 std::cerr << "simfaudes: [[" << fe.Message() << "]]" << std::endl;
442 std::cerr << "simfaudes: presumably missing/missformed configuration file" << std::endl;
443 return 1;
444 }
445
446
447#ifdef FAUDES_NETWORK
448#ifdef FAUDES_WINDOWS
449 // initialise winsocks
450 if(mConsoleOut>=0)
451 std::cout << mMark << "Initialze network" << std::endl;
452 WSADATA wsaData;
453 if(WSAStartup(MAKEWORD(2,2), &wsaData)!=0) {
454 usage_exit("cannot start winsock (network error)");
455 }
456#endif
457#endif
458
459 // report
460 if(mConsoleOut>=0)
461 std::cout << mMark << "Execute via IO device: \""<< dev->Name() << "\"" << std::endl;
462
463 // set tolerance
464 if(mTolerance!=-1) mExecutor.ToleranceTime(mTolerance);
465
466 // assign device to executor and wait for startup to complete
467 mExecutor.Devicep(dev);
468 mExecutor.Reset();
469 if(mBreakTime==Time::UnDef()) mBreakTime=Time::Max();
471 while(dev->Status()!=vDevice::Up) {
472 std::cout << mMark << "Starting IO device \""<< dev->Name() << "\" Status: " << dev->StatusString() << std::endl;
473 faudes_sleep(1);
474 }
475 dev->CurrentTime(0); // sync time; dont use reset, since we would loose events
476 std::cout << mMark << "IO device \""<< dev->Name() << "\" is Up" << std::endl;
477#else
478 // cannot run device without plugin
479 usage_exit("cannot load device \""+mDevFile+"\": device plugin not present");
480#endif
481
482 }
483
484
485 // ************************************************* interactive loop
486 std::cout << mMark << " begin simulation #" << mExecutor.Size() << std::endl;
487 bool mRunning=true;
488 bool mInterTemp=mInteractive;
489 SimConditionSet mSatisfied;
490 mSatisfied.Name("SatisfiedConditions");
491 while(mRunning) {
492 // report current state
493 if(mConsoleOut>=2) {
494 std::cout << mMark << "current state:" << std::endl;
495 std::cout << mExecutor.CurrentParallelTimedState().ToString("TimedState",&mExecutor) << std::endl;
496 std::cout << mMark << "marking reached:" << std::endl;
497 for(Idx i=0; i<mExecutor.Size(); i++) {
498 if(mExecutor.At(i).Generator().ExistsMarkedState( mExecutor.At(i).CurrentState() ))
499 std::cout << mExecutor.At(i).Name() << ": marked" << std::endl;
500 }
501 }
502 // report current state
503 if(mConsoleOut>=0 && mConsoleOut<2) {
504 std::cout << mMark << "current state:" << std::endl;
505 std::cout << mExecutor.CurrentParallelTimedState().ToString("DiscreteState",&mExecutor) << std::endl;
506 }
507 // report current time
508 if(mConsoleOut>=1) {
509 std::cout << mMark << "current time:" << std::endl;
510 std::cout << "<Time> " << mExecutor.CurrentTime() << " </Time>" << std::endl;
511 std::cout << "<Step> " << mExecutor.CurrentStep() << " </Step>" << std::endl;
512 }
513 // report current time
514 if(mConsoleOut==0) {
515 std::cout << mMark << "current time:" << std::endl;
516 std::cout << "<Time> " << mExecutor.CurrentTime() << " </Time>" << std::endl;
517 }
518 // report satisfied conditions
519 if(mConsoleOut>=0) {
520 mSatisfied.Clear();
522 cit!=mExecutor.ConditionsEnd(); cit++) {
523 if(mExecutor.Condition(*cit).Satisfied()) mSatisfied.Insert(*cit);
524 }
525 if(mSatisfied.Size()>0) {
526 std::cout << mMark << "found conditions satisfied:" << std::endl;
527 std::cout << mSatisfied.ToString() << std::endl;
528 }
529 }
530 // report internal state
531 if(mConsoleOut>=2) {
532 std::cout << mMark << "simulation event states:" << std::endl;
533 std::cout << mExecutor.EventStatesToString() << std::endl;
534 }
535 // report enables per component
536 if(mConsoleOut>=2 && mExecutor.Size()>1) {
537 std::cout << mMark << "disabled events (per component):" << std::endl;
538 for(Idx i=0; i<mExecutor.Size(); i++) {
539 std::string enevs = mExecutor.At(i).DisabledEvents().ToString();
540 std::cout << mExecutor.At(i).Name() << ": " << enevs << std::endl;
541 }
542 }
543 // report enabled transitions
544 if(mConsoleOut>=1) {
545 std::cout << mMark << "enabled events:" << std::endl;
546 std::cout << mExecutor.EnabledEvents().ToString() << std::endl;
547 std::cout << mMark << "enabled interval:" << std::endl;
548 std::cout << mExecutor.EnabledInterval().Str() << std::endl;
549 std::cout << mMark << "enabled time:" << std::endl;
550 std::cout << mExecutor.EnabledTime().Str() << std::endl;
551 }
552 // test break: time up
553 if(mExecutor.CurrentTime() >= Time::Max()) {
554 if(mConsoleOut>=-1) std::cout << mMark << "time is up" << std::endl;
555 mInterTemp=false;
556 mRunning=false;
557 break;
558 }
559 // test break: condition
560 if(mExecutor.BreakCondition() && (mBreakCondition || mInteractive)) {
561 if(mConsoleOut>=-1) std::cout << mMark << "break condition triggered" << std::endl;
562 mInterTemp=mInteractive;
563 mRunning=mInteractive;
564 }
565 // test break: time
566 if(mBreakTime!=Time::UnDef())
567 if(mExecutor.CurrentTime() >= mBreakTime) {
568 if(mConsoleOut>=-1) std::cout << mMark << "break time reached" << std::endl;
569 mInterTemp=mInteractive;
570 mRunning=mInteractive;
571 }
572 // test break: step
573 if(mBreakStep>=0)
574 if(mExecutor.CurrentStep() >= mBreakStep) {
575 if(mConsoleOut>=-1) std::cout << mMark << "break step reached" << std::endl;
576 mInterTemp=mInteractive;
577 mRunning=mInteractive;
578 }
579 // test break: synchronous device
580 if(!mExecutor.IsSynchronous()) {
581 if(mConsoleOut>=-1) std::cout << mMark << "device out of sync" << std::endl;
582 mInterTemp=false;
583 mRunning=false;
584 break;
585 }
586 // proposed action
588 if(mConsoleOut>=0) {
589 std::cout << mMark << "proposed action:" << std::endl;
590 if(mPropTrans.mTime>0)
591 std::cout << "<ProposedTime> " << ToStringInteger(mPropTrans.mTime) << " </ProposedTime>" << std::endl;
592 if(mPropTrans.mEvent!=0)
593 std::cout << "<ProposedEvent> \"" << mExecutor.EventName(mPropTrans.mEvent) << "\" </ProposedEvent>" << std::endl;
594 if((mPropTrans.mTime<=0) && (mPropTrans.mEvent==0) )
595 std::cout << "+DeadLock+" << std::endl;
596 }
597 // record transition
598 Idx mEvent=0;
599 // ask choice
600 while(mInterTemp) {
601 // get user input
602 std::cout << mMark << "enter command:" << std::endl;
603 std::string line;
604 std::getline(std::cin,line);
605 // separate cmd from arg
606 std::string choice;
607 std::string param;
608 std::istringstream sline(line);
609 sline >> choice;
610 sline >> param;
611 // convert to int
612 int ichoice =-1;
613 std::istringstream schoice(choice);
614 schoice >> ichoice;
615 if(!schoice) ichoice=-1;
616 int iparam =-1;
617 std::istringstream sparam(param);
618 sparam >> iparam;
619 if(!sparam) iparam=-1;
620 // convert to symbol
621 std::string nchoice=choice;
622 if(choice.length()>2)
623 if(choice.at(0)=='"' && choice.at(choice.length()-1)== '"')
624 nchoice=choice.substr(1,choice.length()-2);
625 // switch cases
626 bool err=false;
627 if(choice=="x" || choice == "exit") {
628 mRunning=false;
629 } else
630 if(choice=="p" || choice=="proposal" || choice=="") {
631 mExecutor.ExecuteTime(mPropTrans.mTime);
632 if(mExecutor.ExecuteEvent(mPropTrans.mEvent))
633 mEvent=mPropTrans.mEvent;
634 } else
635 if(choice=="r" || choice=="run") {
636 mInterTemp=false;
637 } else
638 if(choice=="v" || choice=="revert") {
639 int step = mExecutor.CurrentStep()-1;
640 if(iparam!=-1) step=iparam;
641 std::cout << mMark << "revert to step " << step << std::endl;
642 mExecutor.RevertToStep(step);
643 } else
644 if(choice=="t" || choice=="trace") {
645 std::cout << mMark << "system trace" << std::endl;
647 continue;
648 } else
649 if(ichoice>0) {
650 mExecutor.ExecuteTime(ichoice);
651 } else
652 if(mExecutor.Alphabet().Exists(nchoice)) {
654 mEvent=mExecutor.EventIndex(nchoice);
655 } else {
656 std::cout << mMark << "simfaudes interactive mode" << std::endl;
657 std::cout << "%" << std::endl;
658 std::cout << "% execute time and/or transitions" << std::endl;
659 std::cout << "% * <nn> to pass a specified duration <nn> (excl brackets)" << std::endl;
660 std::cout << "% * \"event\" to execute an event (incl quotes)" << std::endl;
661 std::cout << "% * [P] or [Ret] to execute the recent proPosal " << std::endl;
662 std::cout << "%" << std::endl;
663 std::cout << "% show trace and revert" << std::endl;
664 std::cout << "% * [T] to show a Trace of recent events and states" << std::endl;
665 std::cout << "% * [V] <nn> to reVert to step <nn> (obmit <nn> for one step backward) "<< std::endl;
666 std::cout << "%" << std::endl;
667 std::cout << "% other" << std::endl;
668 std::cout << "% * [X] to eXit" << std::endl<< std::endl;
669 err=true;
670 }
671 if(!err) break;
672 }
673 // execute proposal
674 if(!mInterTemp && mDevFile=="") {
675 mExecutor.ExecuteTime(mPropTrans.mTime);
676 if(mExecutor.ExecuteEvent(mPropTrans.mEvent))
677 mEvent=mPropTrans.mEvent;
678 }
679#ifdef FAUDES_PLUGIN_IODEVICE
680 // sync step
681 if(mDevFile!="") {
682 // reset request ?
683 bool rr= mExecutor.DeviceResetRequest();
684 if(rr && mConsoleOut>=0 && !mResetRequest) {
685 std::cout << mMark << "ignoring reset request" << std::endl;
686 rr=false;
687 }
688 if(rr && mConsoleOut>=0)
689 std::cout << mMark << "reset on request" << std::endl;
690 if(rr)
692 // sync proposal
693 if(!rr) {
694 if(mConsoleOut>=0 && mPropTrans.mTime>0)
695 std::cout << mMark << "sync wait" << std::endl;
696 mEvent=mExecutor.SyncStep();
698 }
699 }
700#endif
701 // report event
702 if(mConsoleOut>=0 && mEvent!=0) {
703 std::cout << mMark << "execute event:" << std::endl;
704 std::cout << "<ExecutedEvent> \"" << mExecutor.EventName(mEvent) << "\" </ExecutedEvent>"
705 << std::endl;
706 }
707
708 } // loop: while mRunning
709
710 // done
711 return 0;
712}
int main()
void faudes_termsignal(void(*sighandler)(int))
void faudes_sleep(long int sec)
const char * faudes_strsignal(int sig)
SampledDensityFunction mSamplesDuration
SampledDensityFunction mSamplesPeriod
static ConsoleOut * G(void)
void Verb(int verb)
Definition cfl_utils.h:357
void Devicep(vDevice *dev)
bool IsSynchronous(void) const
Idx SyncStep(Time::Type duration=Time::Max())
virtual bool DeviceResetRequest(void)
void ToleranceTime(Time::Type maxgap)
virtual void Reset(long int seed=0)
virtual const char * Message() const
bool CurrentState(Idx index)
const std::string & Name(void) const
void Generator(const TimedGenerator &rGen)
const EventSet & DisabledEvents() const
const std::string & Name(void) const
void TraceClear(int length=-2)
bool BreakCondition(void) const
void TraceWrite(TokenWriter &rTw, const TraceSample &sample) const
ConditionIterator ConditionsEnd(void) const
const SimConditionSet & Conditions(void) const
SimConditionSet::Iterator ConditionIterator
int CurrentStep(void) const
void LogOpen(TokenWriter &rTw, int mode)
Time::Type CurrentTime(void) const
ConditionIterator ConditionsBegin(void) const
bool CurrentParallelTimedState(const ParallelTimedState &ptstate)
const AttributeSimCondition & Condition(const std::string &rName) const
void SymbolicName(Idx index, const std::string &rName)
const EventSet & EnabledEvents() const
Idx EventIndex(const std::string &rName) const
void Insert(const std::string &rFileName)
const TimeInterval & EnabledInterval() const
const Executor & At(int i) const
const TimeInterval & EnabledTime() const
std::string EventName(Idx index) const
void Alphabet(const sEventSet &rAlphabet)
bool ExecuteTime(Time::Type duration)
std::string EventStatesToString(void) const
const TimedEvent & ProposeNextTransition()
virtual bool Insert(const Idx &rIndex)
std::string Str(void) const
static Type UnDef(void)
static Type Max(void)
bool Peek(Token &token)
const std::string & StringValue(void) const
@ Begin
<label> (begin of section)
Definition cfl_token.h:84
TokenType Type(void) const
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
virtual std::string StatusString(void)
static void StopAll(void)
virtual DeviceState Status(void)
static vDevice * FromFile(const std::string &rFileName)
void Name(const std::string &rName)
virtual Time::Type CurrentTime(void)
virtual void Clear(void)
Idx Size(void) const
uint32_t Idx
std::string VersionString()
Idx ToIdx(const std::string &rString)
std::string ToStringInteger(Int number)
Definition cfl_utils.cpp:43
void catch_termsignal(int sig)
int mConsoleOut
DeviceExecutor mExecutor
void simfaudes_exit(void)
std::string mMark
void usage_exit(const std::string &message="")

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen