Added new forced alarms off state.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@425 e3e1d417-86f3-4887-817a-d78f3d33393f
pull/27/merge
stan 2003-03-26 13:18:26 +00:00
parent d2033873ce
commit ee8b5e8e14
3 changed files with 39 additions and 19 deletions

View File

@ -64,7 +64,7 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_ch
shared_images->last_write_index = image_buffer_count;
shared_images->last_read_index = image_buffer_count;
shared_images->last_event = 0;
shared_images->forced_alarm = false;
shared_images->force_state = FORCE_NEUTRAL;
}
shared_images->timestamps = (struct timeval *)(shm_ptr+sizeof(SharedImages));
shared_images->images = (unsigned char *)(shm_ptr+sizeof(SharedImages)+(image_buffer_count*sizeof(struct timeval)));
@ -169,7 +169,7 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, const char *p_host, co
shared_images->last_write_index = image_buffer_count;
shared_images->last_read_index = image_buffer_count;
shared_images->last_event = 0;
shared_images->forced_alarm = false;
shared_images->force_state = FORCE_NEUTRAL;
}
shared_images->timestamps = (struct timeval *)(shm_ptr+sizeof(SharedImages));
shared_images->images = (unsigned char *)(shm_ptr+sizeof(SharedImages)+(image_buffer_count*sizeof(struct timeval)));
@ -325,14 +325,19 @@ double Monitor::GetFPS() const
return( fps );
}
void Monitor::ForceAlarm()
void Monitor::ForceAlarmOn()
{
shared_images->forced_alarm = true;
shared_images->force_state = FORCE_ON;
}
void Monitor::CancelAlarm()
void Monitor::ForceAlarmOff()
{
shared_images->forced_alarm = false;
shared_images->force_state = FORCE_OFF;
}
void Monitor::CancelForced()
{
shared_images->force_state = FORCE_NEUTRAL;
}
void Monitor::DumpZoneImage()
@ -407,9 +412,9 @@ bool Monitor::Analyse()
unsigned int score = 0;
if ( Ready() )
{
score = Compare( *image );
if ( shared_images->forced_alarm )
if ( shared_images->force_state != FORCE_OFF )
score = Compare( *image );
if ( shared_images->force_state == FORCE_ON )
score = ZM_FORCED_ALARM_SCORE;
if ( score )

View File

@ -85,13 +85,15 @@ protected:
Snapshot *image_buffer;
typedef enum { FORCE_NEUTRAL, FORCE_ON, FORCE_OFF } ForceState;
typedef struct
{
State state;
int last_write_index;
int last_read_index;
int last_event;
bool forced_alarm;
ForceState force_state;
struct timeval *timestamps;
unsigned char *images;
} SharedImages;
@ -124,8 +126,9 @@ public:
unsigned int GetLastWriteIndex() const;
unsigned int GetLastEvent() const;
double GetFPS() const;
void ForceAlarm();
void CancelAlarm();
void ForceAlarmOn();
void ForceAlarmOff();
void CancelForced();
bool DumpSettings( char *output, bool verbose );
void DumpZoneImage();

View File

@ -44,7 +44,8 @@ void Usage( int status=-1 )
fprintf( stderr, " -f, --fps : Output last Frames Per Second captured reading\n" );
fprintf( stderr, " -z, --zones : Write last captured image overlaid with zones to <monitor_name>-Zones.jpg\n" );
fprintf( stderr, " -a, --alarm : Force alarm in monitor, this will trigger recording until cancelled with -c\n" );
fprintf( stderr, " -c, --cancel : Cancel a forced alarm in monitor, required after being enabled with -a\n" );
fprintf( stderr, " -n, --noalarm : Force no alarms in monitor, this will prevent alarms until cancelled with -c\n" );
fprintf( stderr, " -c, --cancel : Cancel a forced alarm/noalarm in monitor, required after being enabled with -a or -n\n" );
fprintf( stderr, " -h, --help - This screen\n" );
fprintf( stderr, "Note, only the -q/--query option is valid with -d/--device\n" );
@ -66,6 +67,7 @@ int main( int argc, char *argv[] )
{"fps", 0, 0, 'f'},
{"zones", 0, 0, 'z'},
{"alarm", 0, 0, 'a'},
{"noalarm", 0, 0, 'n'},
{"cancel", 0, 0, 'c'},
{"query", 0, 0, 'q'},
{"help", 0, 0, 'h'},
@ -86,8 +88,9 @@ int main( int argc, char *argv[] )
FPS=0x0040,
ZONES=0x0080,
ALARM=0x0100,
CANCEL=0x0200,
QUERY=0x0400
NOALARM=0x0200,
CANCEL=0x0400,
QUERY=0x0800
} Function;
Function function = BOGUS;
@ -150,6 +153,9 @@ int main( int argc, char *argv[] )
case 'a':
function = Function(function | ALARM);
break;
case 'n':
function = Function(function | NOALARM);
break;
case 'c':
function = Function(function | CANCEL);
break;
@ -306,14 +312,20 @@ int main( int argc, char *argv[] )
if ( function & ALARM )
{
if ( verbose )
printf( "Forcing alarm\n" );
monitor->ForceAlarm();
printf( "Forcing alarm on\n" );
monitor->ForceAlarmOn();
}
if ( function & NOALARM )
{
if ( verbose )
printf( "Forcing alarm off\n" );
monitor->ForceAlarmOff();
}
if ( function & CANCEL )
{
if ( verbose )
printf( "Cancelling alarm\n" );
monitor->CancelAlarm();
printf( "Cancelling forced alarm on/off\n" );
monitor->CancelForced();
}
if ( function & QUERY )
{