|
Go to the documentation of this file.
114 using namespace faudes;
120 std::string mMark= "% simfaudes: ========================================= ";
128 std::cout << std::endl;
133 signal(sig, SIG_DFL);
141 static sig_atomic_t exit_in_progress = 0;
142 if(exit_in_progress>0) return;
144 std::cout << mMark << "simfaudes: exit handler" << std::endl;
145 #ifdef FAUDES_PLUGIN_IODEVICE
148 dev->WritePerformance();
159 std::cout << mMark << "statistics for simulation condition \"" <<
176 std::cout << "simfaudes: " << message << std::endl;
177 std::cout << "" << std::endl;
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;
209 std::cout << "" << std::endl;
210 std::cout << "" << std::endl;
215 int main( int argc, char* argv[])
226 bool mInteractive= false;
227 std::string mSimFile= "";
228 std::string mDevFile= "";
230 bool mBreakCondition= false;
233 std::string mLogFile= "";
236 bool mResetRequest= false;
239 for( int i=1; i<argc; i++) {
240 std::string option(argv[i]);
242 if((option== "-q") || (option== "--quiet")) {
247 if((option== "-qq") || (option== "--quietquiet")) {
252 if((option== "-v") || (option== "--verbose")) {
257 if((option== "-vv") || (option== "--verboseverbose")) {
262 if((option== "-i") || (option== "--interactive")) {
267 if((option== "-d") || (option== "--device")) {
273 if((option== "-dt") || (option== "--tolerance")) {
279 if((option== "-dr") || (option== "--resetrequest")) {
284 if((option== "-bc") || (option== "--breakcondition")) {
285 mBreakCondition= true;
289 if((option== "-bt") || (option== "--breaktime")) {
295 if((option== "-bs") || (option== "--breakstep")) {
297 mBreakStep=(int) ToIdx(argv[i]);
301 if((option== "-l") || (option== "--logfile")) {
307 if((option== "-ls") || (option== "--logstates")) {
312 if((option== "-le") || (option== "--logevents")) {
317 if((option== "-lt") || (option== "--logtime")) {
322 if((option== "-la") || (option== "--logall")) {
327 if((option== "-t") || (option== "--trace")) {
329 mTraceLength=(int) ToIdx(argv[i]);
333 if((option== "-?") || (option== "--help")) {
338 if(option.c_str()[0]== '-') {
344 usage_exit( "more than one filname specified" );
353 if(mDevFile!= "" && mInteractive)
354 usage_exit( "you must not specify both interactive and synchrone mode");
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;
388 std::cout << mMark << "dumping configuration" << std::endl;
391 std::cout << mMark << "found generator #" << i+1 <<
397 std::cout << mMark << "found event attributes for \"" <<
404 std::cout << mMark << "found simulation condition \"" <<
414 std::cout << mMark << "generator #" << i+1 << std::endl;
423 if(mLogFile== "" && mLogMode!=0) {
433 #ifdef FAUDES_PLUGIN_IODEVICE
440 std::cout << std::flush;
441 std::cerr << "simfaudes: [[" << fe. Message() << "]]" << std::endl;
442 std::cerr << "simfaudes: presumably missing/missformed configuration file" << std::endl;
447 #ifdef FAUDES_NETWORK
448 #ifdef FAUDES_WINDOWS
451 std::cout << mMark << "Initialze network" << std::endl;
453 if(WSAStartup(MAKEWORD(2,2), &wsaData)!=0) {
454 usage_exit( "cannot start winsock (network error)");
461 std::cout << mMark << "Execute via IO device: \""<< dev-> Name() << "\"" << std::endl;
472 std::cout << mMark << "Starting IO device \""<< dev-> Name() << "\" Status: " << dev-> StatusString() << std::endl;
476 std::cout << mMark << "IO device \""<< dev-> Name() << "\" is Up" << std::endl;
479 usage_exit( "cannot load device \""+mDevFile+ "\": device plugin not present");
488 bool mInterTemp=mInteractive;
490 mSatisfied. Name( "SatisfiedConditions");
494 std::cout << mMark << "current state:" << std::endl;
496 std::cout << mMark << "marking reached:" << std::endl;
504 std::cout << mMark << "current state:" << std::endl;
509 std::cout << mMark << "current time:" << std::endl;
515 std::cout << mMark << "current time:" << std::endl;
525 if(mSatisfied. Size()>0) {
526 std::cout << mMark << "found conditions satisfied:" << std::endl;
527 std::cout << mSatisfied. ToString() << std::endl;
532 std::cout << mMark << "simulation event states:" << std::endl;
537 std::cout << mMark << "disabled events (per component):" << std::endl;
545 std::cout << mMark << "enabled events:" << std::endl;
547 std::cout << mMark << "enabled interval:" << std::endl;
549 std::cout << mMark << "enabled time:" << std::endl;
561 if( mConsoleOut>=-1) std::cout << mMark << "break condition triggered" << std::endl;
562 mInterTemp=mInteractive;
563 mRunning=mInteractive;
568 if( mConsoleOut>=-1) std::cout << mMark << "break time reached" << std::endl;
569 mInterTemp=mInteractive;
570 mRunning=mInteractive;
575 if( mConsoleOut>=-1) std::cout << mMark << "break step reached" << std::endl;
576 mInterTemp=mInteractive;
577 mRunning=mInteractive;
581 if( mConsoleOut>=-1) std::cout << mMark << "device out of sync" << std::endl;
589 std::cout << mMark << "proposed action:" << std::endl;
590 if(mPropTrans. mTime>0)
591 std::cout << "<ProposedTime> " << ToStringInteger(mPropTrans. mTime) << " </ProposedTime>" << std::endl;
594 if((mPropTrans. mTime<=0) && (mPropTrans. mEvent==0) )
595 std::cout << "+DeadLock+" << std::endl;
602 std::cout << mMark << "enter command:" << std::endl;
604 std::getline(std::cin,line);
608 std::istringstream sline(line);
613 std::istringstream schoice(choice);
615 if(!schoice) ichoice=-1;
617 std::istringstream sparam(param);
619 if(!sparam) iparam=-1;
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);
627 if(choice== "x" || choice == "exit") {
630 if(choice== "p" || choice== "proposal" || choice== "") {
635 if(choice== "r" || choice== "run") {
638 if(choice== "v" || choice== "revert") {
640 if(iparam!=-1) step=iparam;
641 std::cout << mMark << "revert to step " << step << std::endl;
644 if(choice== "t" || choice== "trace") {
645 std::cout << mMark << "system trace" << std::endl;
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;
674 if(!mInterTemp && mDevFile== "") {
679 #ifdef FAUDES_PLUGIN_IODEVICE
685 std::cout << mMark << "ignoring reset request" << std::endl;
689 std::cout << mMark << "reset on request" << std::endl;
695 std::cout << mMark << "sync wait" << std::endl;
703 std::cout << mMark << "execute event:" << std::endl;
704 std::cout << "<ExecutedEvent> \"" << mExecutor. EventName(mEvent) << "\" </ExecutedEvent>"
libFAUDES 2.28a
--- 2016.09.13
--- c++ api documentaion by doxygen
|