本文整理汇总了C++中Monitor::Active方法的典型用法代码示例。如果您正苦于以下问题:C++ Monitor::Active方法的具体用法?C++ Monitor::Active怎么用?C++ Monitor::Active使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monitor
的用法示例。
在下文中一共展示了Monitor::Active方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char *argv[] )
{
srand( getpid() * time( 0 ) );
int id = -1;
static struct option long_options[] = {
{"monitor", 1, 0, 'm'},
{"help", 0, 0, 'h'},
{0, 0, 0, 0}
};
while (1)
{
int option_index = 0;
int c = getopt_long (argc, argv, "m:h", long_options, &option_index);
if (c == -1)
{
break;
}
switch (c)
{
case 'm':
id = atoi(optarg);
break;
case 'h':
case '?':
Usage();
break;
default:
//fprintf( stderr, "?? getopt returned character code 0%o ??\n", c );
break;
}
}
if (optind < argc)
{
fprintf( stderr, "Extraneous options, " );
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
Usage();
}
if ( id < 0 )
{
fprintf( stderr, "Bogus monitor %d\n", id );
Usage();
exit( 0 );
}
char log_id_string[16];
snprintf( log_id_string, sizeof(log_id_string), "zma_m%d", id );
zmLoadConfig();
logInit( log_id_string );
Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS );
if ( monitor )
{
Info( "In mode %d/%d, warming up", monitor->GetFunction(), monitor->Enabled() );
if ( config.opt_frame_server )
{
Event::OpenFrameSocket( monitor->Id() );
}
zmSetDefaultHupHandler();
zmSetDefaultTermHandler();
zmSetDefaultDieHandler();
sigset_t block_set;
sigemptyset( &block_set );
while( !zm_terminate )
{
// Process the next image
sigprocmask( SIG_BLOCK, &block_set, 0 );
if ( !monitor->Analyse() )
{
usleep( monitor->Active()?ZM_SAMPLE_RATE:ZM_SUSPENDED_RATE );
}
if ( zm_reload )
{
monitor->Reload();
zm_reload = false;
}
sigprocmask( SIG_UNBLOCK, &block_set, 0 );
}
delete monitor;
}
else
{
fprintf( stderr, "Can't find monitor with id of %d\n", id );
}
return( 0 );
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
exit(0);
default:
//fprintf( stderr, "?? getopt returned character code 0%o ??\n", c );
break;
}
}
if (optind < argc)
{
fprintf( stderr, "Extraneous options, " );
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
Usage();
}
if ( id < 0 )
{
fprintf( stderr, "Bogus monitor %d\n", id );
Usage();
exit( 0 );
}
char log_id_string[16];
snprintf( log_id_string, sizeof(log_id_string), "zma_m%d", id );
zmLoadConfig();
logInit( log_id_string );
ssedetect();
Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS );
if ( monitor )
{
Info( "In mode %d/%d, warming up", monitor->GetFunction(), monitor->Enabled() );
if ( config.opt_frame_server )
{
Event::OpenFrameSocket( monitor->Id() );
}
zmSetDefaultHupHandler();
zmSetDefaultTermHandler();
zmSetDefaultDieHandler();
sigset_t block_set;
sigemptyset( &block_set );
useconds_t analysis_rate = monitor->GetAnalysisRate();
unsigned int analysis_update_delay = monitor->GetAnalysisUpdateDelay();
time_t last_analysis_update_time, cur_time;
monitor->UpdateAdaptiveSkip();
last_analysis_update_time = time( 0 );
while( !zm_terminate )
{
// Process the next image
sigprocmask( SIG_BLOCK, &block_set, 0 );
// Some periodic updates are required for variable capturing framerate
if ( analysis_update_delay )
{
cur_time = time( 0 );
if ( ( cur_time - last_analysis_update_time ) > analysis_update_delay )
{
analysis_rate = monitor->GetAnalysisRate();
monitor->UpdateAdaptiveSkip();
last_analysis_update_time = cur_time;
}
}
if ( !monitor->Analyse() )
{
usleep( monitor->Active()?ZM_SAMPLE_RATE:ZM_SUSPENDED_RATE );
}
else if ( analysis_rate )
{
usleep( analysis_rate );
}
if ( zm_reload )
{
monitor->Reload();
zm_reload = false;
}
sigprocmask( SIG_UNBLOCK, &block_set, 0 );
}
delete monitor;
}
else
{
fprintf( stderr, "Can't find monitor with id of %d\n", id );
}
Image::Deinitialise();
logTerm();
zmDbClose();
return( 0 );
}