|
Go to the documentation of this file.
113 using namespace faudes;
119 std::string mMark= "% simfaudes: ========================================= ";
137 signal(sig, SIG_DFL);
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[])
227 bool mInteractive= false;
228 std::string mSimFile= "";
229 std::string mDevFile= "";
231 bool mBreakCondition= false;
234 std::string mLogFile= "";
237 bool mResetRequest= false;
240 for( int i=1; i<argc; i++) {
241 std::string option(argv[i]);
243 if((option== "-q") || (option== "--quiet")) {
248 if((option== "-qq") || (option== "--quietquiet")) {
253 if((option== "-v") || (option== "--verbose")) {
258 if((option== "-vv") || (option== "--verboseverbose")) {
263 if((option== "-i") || (option== "--interactive")) {
268 if((option== "-d") || (option== "--device")) {
274 if((option== "-dt") || (option== "--tolerance")) {
280 if((option== "-dr") || (option== "--resetrequest")) {
285 if((option== "-bc") || (option== "--breakcondition")) {
286 mBreakCondition= true;
290 if((option== "-bt") || (option== "--breaktime")) {
296 if((option== "-bs") || (option== "--breakstep")) {
298 mBreakStep=(int) ToIdx(argv[i]);
302 if((option== "-l") || (option== "--logfile")) {
308 if((option== "-ls") || (option== "--logstates")) {
313 if((option== "-le") || (option== "--logevents")) {
318 if((option== "-lt") || (option== "--logtime")) {
323 if((option== "-la") || (option== "--logall")) {
328 if((option== "-t") || (option== "--trace")) {
330 mTraceLength=(int) ToIdx(argv[i]);
334 if((option== "-?") || (option== "--help")) {
339 if(option.c_str()[0]== '-') {
345 usage_exit( "more than one filname specified" );
354 if(mDevFile!= "" && mInteractive)
355 usage_exit( "you must not specify both interactive and synchrone mode");
381 std::cout << mMark << "dumping configuration" << std::endl;
384 std::cout << mMark << "found generator #" << i+1 <<
390 std::cout << mMark << "found event attributes for \"" <<
397 std::cout << mMark << "found simulation condition \"" <<
407 std::cout << mMark << "generator #" << i+1 << std::endl;
416 if(mLogFile== "" && mLogMode!=0) {
426 #ifdef FAUDES_PLUGIN_IODEVICE
432 #ifdef FAUDES_NETWORK
433 #ifdef FAUDES_WINDOWS
436 std::cout << mMark << "Initialze network" << std::endl;
438 if(WSAStartup(MAKEWORD(2,2), &wsaData)!=0) {
439 usage_exit( "cannot start winsock (network error)");
446 std::cout << mMark << "Execute via IO device: \""<< dev-> Name() << "\"" << std::endl;
457 std::cout << mMark << "Starting IO device \""<< dev-> Name() << "\" Status: " << dev-> StatusString() << std::endl;
461 std::cout << mMark << "IO device \""<< dev-> Name() << "\" is Up" << std::endl;
464 usage_exit( "cannot load device \""+mDevFile+ "\": device plugin not present");
473 bool mInterTemp=mInteractive;
475 mSatisfied. Name( "SatisfiedConditions");
479 std::cout << mMark << "current state:" << std::endl;
481 std::cout << mMark << "marking reached:" << std::endl;
489 std::cout << mMark << "current state:" << std::endl;
494 std::cout << mMark << "current time:" << std::endl;
500 std::cout << mMark << "current time:" << std::endl;
510 if(mSatisfied. Size()>0) {
511 std::cout << mMark << "found conditions satisfied:" << std::endl;
512 std::cout << mSatisfied. ToString() << std::endl;
517 std::cout << mMark << "simulation event states:" << std::endl;
522 std::cout << mMark << "disabled events (per component):" << std::endl;
530 std::cout << mMark << "enabled events:" << std::endl;
532 std::cout << mMark << "enabled interval:" << std::endl;
534 std::cout << mMark << "enabled time:" << std::endl;
546 if( mConsoleOut>=-1) std::cout << mMark << "break condition triggered" << std::endl;
547 mInterTemp=mInteractive;
548 mRunning=mInteractive;
553 if( mConsoleOut>=-1) std::cout << mMark << "break time reached" << std::endl;
554 mInterTemp=mInteractive;
555 mRunning=mInteractive;
560 if( mConsoleOut>=-1) std::cout << mMark << "break step reached" << std::endl;
561 mInterTemp=mInteractive;
562 mRunning=mInteractive;
566 if( mConsoleOut>=-1) std::cout << mMark << "device out of sync" << std::endl;
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;
586 std::cout << mMark << "enter command:" << std::endl;
588 std::getline(std::cin,line);
592 std::istringstream sline(line);
597 std::istringstream schoice(choice);
599 if(!schoice) ichoice=-1;
601 std::istringstream sparam(param);
603 if(!sparam) iparam=-1;
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);
611 if(choice== "x" || choice == "exit") {
614 if(choice== "p" || choice== "proposal" || choice== "") {
617 mEvent=mPropTrans. Event;
619 if(choice== "r" || choice== "run") {
622 if(choice== "v" || choice== "revert") {
624 if(iparam!=-1) step=iparam;
625 std::cout << mMark << "revert to step " << step << std::endl;
628 if(choice== "t" || choice== "trace") {
629 std::cout << mMark << "system trace" << std::endl;
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;
658 if(!mInterTemp && mDevFile== "") {
661 mEvent=mPropTrans. Event;
663 #ifdef FAUDES_PLUGIN_IODEVICE
669 std::cout << mMark << "ignoring reset request" << std::endl;
673 std::cout << mMark << "reset on request" << std::endl;
679 std::cout << mMark << "sync wait" << std::endl;
687 std::cout << mMark << "execute event:" << std::endl;
688 std::cout << "<ExecutedEvent> \"" << mExecutor. EventName(mEvent) << "\" </ExecutedEvent>"
libFAUDES 2.26g
--- 2015.08.17
--- c++ api documentaion by doxygen
|