From e4072d56af6a1c0fbac2dd82afdbe352b93a67ba Mon Sep 17 00:00:00 2001 From: stan Date: Wed, 27 Nov 2002 16:23:04 +0000 Subject: [PATCH] Added last event id to shared memory for auto-filtering etc. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@125 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/zm.cpp | 7 +++++++ src/zm.h | 2 ++ src/zmu.cpp | 11 ++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/zm.cpp b/src/zm.cpp index 440d60a19..1579a3b38 100644 --- a/src/zm.cpp +++ b/src/zm.cpp @@ -1460,6 +1460,7 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_ch shared_images->state = IDLE; shared_images->last_write_index = image_buffer_count; shared_images->last_read_index = image_buffer_count; + shared_images->last_event = 0; } shared_images->timestamps = (time_t *)(shm_ptr+sizeof(SharedImages)); shared_images->images = (unsigned char *)(shm_ptr+sizeof(SharedImages)+(image_buffer_count*sizeof(time_t))); @@ -1593,6 +1594,11 @@ unsigned int Monitor::GetLastWriteIndex() const return( shared_images->last_write_index ); } +unsigned int Monitor::GetLastEvent() const +{ + return( shared_images->last_event ); +} + double Monitor::GetFPS() const { int index1 = shared_images->last_write_index; @@ -1775,6 +1781,7 @@ bool Monitor::Analyse() if ( image_count-last_alarm_count > post_event_count ) { Info(( "%s: %03d - Left alarm state (%d) - %d(%d) images\n", name, image_count, event->id, event->frames, event->alarm_frames )); + shared_images->last_event = event->id; delete event; shared_images->state = state = IDLE; } diff --git a/src/zm.h b/src/zm.h index 9c6e711eb..4c32ea51a 100644 --- a/src/zm.h +++ b/src/zm.h @@ -604,6 +604,7 @@ protected: State state; int last_write_index; int last_read_index; + int last_event; time_t *timestamps; unsigned char *images; } SharedImages; @@ -623,6 +624,7 @@ public: time_t GetTimestamp( int index=-1 ) const; unsigned int GetLastReadIndex() const; unsigned int GetLastWriteIndex() const; + unsigned int GetLastEvent() const; double GetFPS() const; void CheckFunction(); diff --git a/src/zmu.cpp b/src/zmu.cpp index 3d00aec57..f3793d73a 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -32,6 +32,7 @@ void Usage() fprintf( stderr, " ring buffer index if given\n" ); fprintf( stderr, " -r, --read_index : Output ring buffer read index\n" ); fprintf( stderr, " -w, --write_index : Output ring buffer write index\n" ); + fprintf( stderr, " -e, --event : Output last event index\n" ); fprintf( stderr, " -f, --fps : Output last Frames Per Second captured reading\n" ); fprintf( stderr, " -z, --zones : Write last captured image overlaid with zones to -Zones.jpg\n" ); fprintf( stderr, " -h, --help - This screen\n" ); @@ -48,6 +49,7 @@ int main( int argc, char *argv[] ) {"state", 0, 0, 's'}, {"read_index", 0, 0, 'r'}, {"write_index", 0, 0, 'w'}, + {"event", 0, 0, 'e'}, {"fps", 0, 0, 'f'}, {"zones", 0, 0, 'z'}, {"help", 0, 0, 'h'}, @@ -55,7 +57,7 @@ int main( int argc, char *argv[] ) }; int id = 1; - enum { BOGUS, STATE, IMAGE, TIME, READ_IDX, WRITE_IDX, FPS, ZONES } function = BOGUS; + enum { BOGUS, STATE, IMAGE, TIME, READ_IDX, WRITE_IDX, EVENT, FPS, ZONES } function = BOGUS; int image_idx = -1; while (1) { @@ -97,6 +99,9 @@ int main( int argc, char *argv[] ) case 'w': function = WRITE_IDX; break; + case 'e': + function = EVENT; + break; case 'f': function = FPS; break; @@ -171,6 +176,10 @@ int main( int argc, char *argv[] ) { printf( "%d\n", monitor->GetLastWriteIndex() ); } + else if ( function == EVENT ) + { + printf( "%d\n", monitor->GetLastEvent() ); + } else if ( function == FPS ) { printf( "%.2f\n", monitor->GetFPS() );