Revision: 7590
http://playerstage.svn.sourceforge.net/playerstage/?rev=7590&view=rev
Author: rtv
Date: 2009-04-09 18:16:27 +0000 (Thu, 09 Apr 2009)
Log Message:
-----------
added clock output option
Modified Paths:
--------------
code/stage/trunk/libstage/main.cc
code/stage/trunk/libstage/stage.hh
code/stage/trunk/libstage/world.cc
Modified: code/stage/trunk/libstage/main.cc
===================================================================
--- code/stage/trunk/libstage/main.cc 2009-04-09 17:53:34 UTC (rev 7589)
+++ code/stage/trunk/libstage/main.cc 2009-04-09 18:16:27 UTC (rev 7590)
@@ -13,8 +13,10 @@
const char* USAGE =
"USAGE: stage [options] [<worldfile>]\n"
"Available [options] are:\n"
- " --gui : run without a GUI (same as -g)\n"
- " -g : run without a GUI (same as --gui)\n"
+ " --clock : print simulation time peridically on standard output\n"
+ " -c : print simulation time peridically on standard output\n"
+ " --gui : run without a GUI\n"
+ " -g : run without a GUI\n"
" --help : print this message.\n"
" -h : print this message.\n"
" -? : print this message.\n"
@@ -23,6 +25,7 @@
/* options descriptor */
static struct option longopts[] = {
{ "gui", optional_argument, NULL, 'g' },
+ { "clock", optional_argument, NULL, 'c' },
{ "help", optional_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 }
};
@@ -36,14 +39,19 @@
int ch=0, optindex=0;
bool usegui = true;
+ bool showclock = false;
- while ((ch = getopt_long(argc, argv, "gh?", longopts, &optindex)) != -1)
+ while ((ch = getopt_long(argc, argv, "cgh?", longopts, &optindex)) != -1)
{
switch( ch )
{
case 0: // long option given
printf( "option %s given\n", longopts[optindex].name );
break;
+ case 'c':
+ showclock = true;
+ printf( "[Clock enabled]" );
+ break;
case 'g':
usegui = false;
printf( "[GUI disabled]" );
@@ -76,6 +84,7 @@
new WorldGui( 400, 300, worldfilename ) :
new World( worldfilename ) );
world->Load( worldfilename );
+ world->ShowClock( showclock );
loaded_world_file = true;
}
optindex++;
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2009-04-09 17:53:34 UTC (rev 7589)
+++ code/stage/trunk/libstage/stage.hh 2009-04-09 18:16:27 UTC (rev 7590)
@@ -864,6 +864,8 @@
stg_usec_t quit_time;
stg_usec_t real_time_now; ///< The current real time in microseconds
stg_usec_t real_time_start; ///< the real time at which this world was
created
+ bool show_clock; ///< iff true, print the sim time on stdout
+ unsigned int show_clock_interval; ///< updates between clock xoutputs
GMutex* thread_mutex; ///< protect the worker thread management stuff
GThreadPool *threadpool; ///<worker threads for updating some sensor
models in parallel
int total_subs; ///< the total number of subscriptions to all models
@@ -1041,6 +1043,9 @@
/// Register an Option for pickup by the GUI
void RegisterOption( Option* opt );
+
+ /// Control printing time to stdout
+ void ShowClock( bool enable ){ show_clock = enable; };
};
class Block
Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc 2009-04-09 17:53:34 UTC (rev 7589)
+++ code/stage/trunk/libstage/world.cc 2009-04-09 18:16:27 UTC (rev 7590)
@@ -83,6 +83,8 @@
quit_time( 0 ),
real_time_now( RealTimeNow() ),
real_time_start( real_time_now ),
+ show_clock( false ),
+ show_clock_interval( 100 ), // 10 simulated seconds using defaults
thread_mutex( g_mutex_new() ),
threadpool( NULL ),
total_subs( 0 ),
@@ -506,7 +508,7 @@
LISTMETHOD( reentrant_update_list, Model*, CallUpdateCallbacks );
}
- if( this->updates % 100 == 0 )
+ if( show_clock && ((this->updates % show_clock_interval) == 0) )
{
printf( "\r[Stage: %s]", ClockString().c_str() );
fflush( stdout );
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit