From 21c7c8b56f4cbfb49a4db31e2aaf31ec661d4b4b Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 23 Sep 2003 09:52:45 +0000 Subject: [PATCH] Updated for v.16 git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@637 e3e1d417-86f3-4887-817a-d78f3d33393f --- db/zmalter-0.9.15.sql | 48 +++++++ db/zmschema.sql.z | 21 ++- scripts/zmpkg.pl.z | 4 +- src/zm_event.cpp | 7 +- src/zm_event.h | 3 + src/zm_monitor.cpp | 223 +++++++++++++++++++++++------ src/zm_monitor.h | 37 +++-- web/zm_actions.php | 121 +++++++++++----- web/zm_config.php.z | 2 +- web/zm_db.php | 5 + web/zm_funcs.php | 46 +++--- web/zm_html.php | 2 +- web/zm_html_view_console.php | 18 +-- web/zm_html_view_events.php | 61 ++++---- web/zm_html_view_filter.php | 2 +- web/zm_html_view_monitor.php | 164 ++++++++++++++++++--- web/zm_html_view_montagestatus.php | 4 + web/zm_html_view_watchstatus.php | 16 ++- web/zm_html_view_zone.php | 14 ++ web/zm_styles.css | 5 + 20 files changed, 623 insertions(+), 180 deletions(-) create mode 100644 db/zmalter-0.9.15.sql diff --git a/db/zmalter-0.9.15.sql b/db/zmalter-0.9.15.sql new file mode 100644 index 000000000..0bbb630de --- /dev/null +++ b/db/zmalter-0.9.15.sql @@ -0,0 +1,48 @@ +-- +-- This updates a 0.9.15 database to 0.9.16 +-- +-- Make changes to Monitor table +-- +alter table Monitors change column Function OldFunction enum('None','Passive','Active','X10') NOT NULL default 'Passive'; +alter table Monitors add column Function enum('None','Monitor','Modect','Record','Mocord') NOT NULL default 'Monitor'; +alter table Monitors add column RunMode enum('Continuous','Triggered') NOT NULL default 'Continuous' after Function; +alter table Monitors add column Triggers set('X10') NOT NULL after RunMode; +alter table Monitors add column SectionLength int(10) unsigned not null default 600 after PostEventCount; +-- +-- Update to reflect existing setup +-- +update Monitors set Function = 'Monitor' where OldFunction = 'Passive'; +update Monitors set Function = 'Modect' where OldFunction = 'Active'; +update Monitors set Function = 'Modect' where OldFunction = 'X10'; +update Monitors set RunMode = 'Triggered' where OldFunction = 'X10'; +update Monitors set Triggers = 'X10' where OldFunction = 'X10'; +-- +-- Create the X10 triggers table +-- +CREATE TABLE TriggersX10 ( + MonitorId int(10) unsigned NOT NULL default '0', + Activation varchar(32) default NULL, + AlarmInput varchar(32) default NULL, + AlarmOutput varchar(32) default NULL, + PRIMARY KEY (MonitorId) +) TYPE=MyISAM; +-- +-- Update to reflect existing setup +-- +insert into TriggersX10 select Id, X10Activation, X10AlarmInput, X10AlarmOutput from Monitors where Function = 'X10'; +-- +-- Clean up temporary and unused columns +-- +alter table Monitors drop column OldFunction ; +alter table Monitors drop column X10Activation ; +alter table Monitors drop column X10AlarmInput ; +alter table Monitors drop column X10AlarmOutput ; +-- +-- These are optional, but we might as well +-- +optimize table Frames; +optimize table Events; +optimize table Filters; +optimize table Zones; +optimize table Monitors; +optimize table Stats; diff --git a/db/zmschema.sql.z b/db/zmschema.sql.z index 4f63bb912..434aa80fb 100644 --- a/db/zmschema.sql.z +++ b/db/zmschema.sql.z @@ -106,7 +106,9 @@ CREATE TABLE Monitors ( Id int(10) unsigned NOT NULL auto_increment, Name tinytext NOT NULL, Type enum('Local','Remote') NOT NULL default 'Local', - Function enum('None','Passive','Active','X10') NOT NULL default 'Passive', + Function enum('None','Monitor','Modect','Record','Mocord') NOT NULL default 'Monitor', + RunMode enum('Continuous','Triggered') NOT NULL default 'Continuous', + Triggers set('X10') NOT NULL default '', Device tinyint(3) unsigned NOT NULL default '0', Channel tinyint(3) unsigned NOT NULL default '0', Format tinyint(3) unsigned NOT NULL default '0', @@ -124,12 +126,10 @@ CREATE TABLE Monitors ( WarmupCount smallint(5) unsigned NOT NULL default '25', PreEventCount smallint(5) unsigned NOT NULL default '10', PostEventCount smallint(5) unsigned NOT NULL default '10', + SectionLength int(10) unsigned NOT NULL default '600', MaxFPS decimal(5,2) NOT NULL default '0.00', FPSReportInterval smallint(5) unsigned NOT NULL default '250', RefBlendPerc tinyint(3) unsigned NOT NULL default '10', - X10Activation varchar(32) default NULL, - X10AlarmInput varchar(32) default NULL, - X10AlarmOutput varchar(32) default NULL, PRIMARY KEY (Id) ) TYPE=MyISAM; @@ -158,6 +158,18 @@ CREATE TABLE Stats ( KEY ZoneId (ZoneId) ) TYPE=MyISAM; +-- +-- Table structure for table 'TriggersX10' +-- + +CREATE TABLE TriggersX10 ( + MonitorId int(10) unsigned NOT NULL default '0', + Activation varchar(32) default NULL, + AlarmInput varchar(32) default NULL, + AlarmOutput varchar(32) default NULL, + PRIMARY KEY (MonitorId) +) TYPE=MyISAM; + -- -- Table structure for table 'Users' -- @@ -211,4 +223,3 @@ CREATE TABLE Zones ( -- Create a default admin user. -- insert into Users values ('','admin',password('admin'),1,'View','Edit','Edit','Edit',NULL); - diff --git a/scripts/zmpkg.pl.z b/scripts/zmpkg.pl.z index f68d39cec..cc152c0f9 100755 --- a/scripts/zmpkg.pl.z +++ b/scripts/zmpkg.pl.z @@ -178,7 +178,9 @@ if ( $command =~ /^(?:start|restart)$/ ) { execute( ZM_PATH_BIN."/zmdc.pl start zmc -H $monitor->{Host} -P $monitor->{Port} -p '$monitor->{Path}'" ); } - if ( $monitor->{Function} eq 'Active' ) + if (( $monitor->{Function} eq 'Modect' ) + || ( $monitor->{Function} eq 'Record' ) + || ( $monitor->{Function} eq 'Mocord' )) { if ( ZM_OPT_FRAME_SERVER ) { diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 34fe967de..1b596f0c4 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -43,6 +43,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time ) : monitor( p_mon exit( mysql_errno( &dbconn ) ); } id = mysql_insert_id( &dbconn ); + end_time.tv_sec = 0; frames = 0; alarm_frames = 0; tot_score = 0; @@ -66,12 +67,16 @@ Event::~Event() static char sql[BUFSIZ]; static char end_time_str[32]; + if ( !end_time.tv_sec ) + { + gettimeofday( &end_time, &dummy_tz ); + } struct DeltaTimeval delta_time; DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); strftime( end_time_str, sizeof(end_time_str), "%Y-%m-%d %H:%M:%S", localtime( &end_time.tv_sec ) ); - sprintf( sql, "update Events set Name='Event-%d', EndTime = '%s', Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", id, end_time_str, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(tot_score/alarm_frames), max_score, id ); + sprintf( sql, "update Events set Name='Event-%d', EndTime = '%s', Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", id, end_time_str, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't update event: %s", mysql_error( &dbconn ) )); diff --git a/src/zm_event.h b/src/zm_event.h index 1722404ad..0c036a1c1 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -73,6 +73,9 @@ public: int Frames() const { return( frames ); } int AlarmFrames() const { return( alarm_frames ); } + const struct timeval &StartTime() const { return( start_time ); } + const struct timeval &EndTime() const { return( end_time ); } + bool SendFrameImage( const Image *image, bool alarm_frame=false ); bool WriteFrameImage( const Image *image, const char *event_file, bool alarm_frame=false ); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index e718139e3..e38316513 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -26,32 +26,117 @@ #include "zm_local_camera.h" #include "zm_remote_camera.h" -Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), width( p_width ), height( p_height ), orientation( (Orientation)p_orientation ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), mode( p_mode ), n_zones( p_n_zones ), zones( p_zones ) +Monitor::Monitor( + int p_id, + char *p_name, + int p_function, + int p_device, + int p_channel, + int p_format, + int p_width, + int p_height, + int p_palette, + int p_orientation, + char *p_label_format, + const Coord &p_label_coord, + int p_image_buffer_count, + int p_warmup_count, + int p_pre_event_count, + int p_post_event_count, + int p_section_length, + int p_capture_delay, + int p_fps_report_interval, + int p_ref_blend_perc, + Purpose p_purpose, + int p_n_zones, + Zone *p_zones[] +) : id( p_id ), + function( (Function)p_function ), + width( p_width ), + height( p_height ), + orientation( (Orientation)p_orientation ), + label_coord( p_label_coord ), + image_buffer_count( p_image_buffer_count ), + warmup_count( p_warmup_count ), + pre_event_count( p_pre_event_count ), + post_event_count( p_post_event_count ), + section_length( p_section_length ), + capture_delay( p_capture_delay ), + fps_report_interval( p_fps_report_interval ), + ref_blend_perc( p_ref_blend_perc ), + image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), + ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), + purpose( p_purpose ), + n_zones( p_n_zones ), + zones( p_zones ) { name = new char[strlen(p_name)+1]; strcpy( name, p_name ); strcpy( label_format, p_label_format ); - camera = new LocalCamera( p_device, p_channel, p_format, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, mode==CAPTURE ); + camera = new LocalCamera( p_device, p_channel, p_format, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, purpose==CAPTURE ); Initialise(); } -Monitor::Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), width( p_width ), height( p_height ), orientation( (Orientation)p_orientation ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), mode( p_mode ), n_zones( p_n_zones ), zones( p_zones ) +Monitor::Monitor( + int p_id, + char *p_name, + int p_function, + const char *p_host, + const char *p_port, + const char *p_path, + int p_width, + int p_height, + int p_palette, + int p_orientation, + char *p_label_format, + const Coord &p_label_coord, + int p_image_buffer_count, + int p_warmup_count, + int p_pre_event_count, + int p_post_event_count, + int p_section_length, + int p_capture_delay, + int p_fps_report_interval, + int p_ref_blend_perc, + Purpose p_purpose, + int p_n_zones, + Zone *p_zones[] +) : id( p_id ), + function( (Function)p_function ), + width( p_width ), + height( p_height ), + orientation( (Orientation)p_orientation ), + label_coord( p_label_coord ), + image_buffer_count( p_image_buffer_count ), + warmup_count( p_warmup_count ), + pre_event_count( p_pre_event_count ), + post_event_count( p_post_event_count ), + section_length( p_section_length ), + capture_delay( p_capture_delay ), + fps_report_interval( p_fps_report_interval ), + ref_blend_perc( p_ref_blend_perc ), + image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), + ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), + purpose( p_purpose ), + n_zones( p_n_zones ), + zones( p_zones ) { name = new char[strlen(p_name)+1]; strcpy( name, p_name ); strcpy( label_format, p_label_format ); - camera = new RemoteCamera( p_host, p_port, p_path, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, mode==CAPTURE ); + camera = new RemoteCamera( p_host, p_port, p_path, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, purpose==CAPTURE ); Initialise(); } Monitor::~Monitor() { + delete event; delete[] image_buffer; struct shmid_ds shm_data; @@ -80,7 +165,7 @@ void Monitor::Initialise() last_alarm_count = 0; state = IDLE; - Info(( "monitor mode=%d", mode )); + Info(( "monitor purpose=%d", purpose )); int shared_data_size = sizeof(SharedData)+(image_buffer_count*sizeof(time_t))+(image_buffer_count*camera->ImageSize()); Info(( "shm.size=%d", shared_data_size )); @@ -98,7 +183,7 @@ void Monitor::Initialise() exit( -1 ); } - if ( mode == CAPTURE ) + if ( purpose == CAPTURE ) { memset( shared_data, 0, shared_data_size ); shared_data->valid = true; @@ -144,7 +229,7 @@ void Monitor::Initialise() record_event_stats = (bool)config.Item( ZM_RECORD_EVENT_STATS ); - if ( mode == ANALYSIS ) + if ( purpose == ANALYSIS ) { static char path[PATH_MAX]; @@ -271,7 +356,7 @@ void Monitor::CancelForced() int Monitor::Brightness( int p_brightness ) { - if ( mode != CAPTURE ) + if ( purpose != CAPTURE ) { if ( p_brightness >= 0 ) { @@ -305,7 +390,7 @@ int Monitor::Brightness( int p_brightness ) int Monitor::Contrast( int p_contrast ) { - if ( mode != CAPTURE ) + if ( purpose != CAPTURE ) { if ( p_contrast >= 0 ) { @@ -339,7 +424,7 @@ int Monitor::Contrast( int p_contrast ) int Monitor::Hue( int p_hue ) { - if ( mode != CAPTURE ) + if ( purpose != CAPTURE ) { if ( p_hue >= 0 ) { @@ -373,7 +458,7 @@ int Monitor::Hue( int p_hue ) int Monitor::Colour( int p_colour ) { - if ( mode != CAPTURE ) + if ( purpose != CAPTURE ) { if ( p_colour >= 0 ) { @@ -514,30 +599,62 @@ bool Monitor::Analyse() unsigned int score = 0; if ( Ready() ) { - if ( shared_data->force_state != FORCE_OFF ) + if ( function != RECORD && shared_data->force_state != FORCE_OFF ) score = Compare( *image ); if ( shared_data->force_state == FORCE_ON ) score = (int)config.Item( ZM_FORCED_ALARM_SCORE ); + if ( function == RECORD || function == MOCORD ) + { + if ( !event ) + { + // Create event + event = new Event( this, *timestamp ); + + Info(( "%s: %03d - Starting new event", name, image_count )); + + //if ( (bool)config.Item( ZM_OVERLAP_TIMED_EVENTS ) ) + if ( 1 ) + { + int pre_index = ((index+image_buffer_count)-pre_event_count)%image_buffer_count; + struct timeval *timestamps[pre_event_count]; + const Image *images[pre_event_count]; + for ( int i = 0; i < pre_event_count; i++ ) + { + timestamps[i] = image_buffer[pre_index].timestamp; + images[i] = image_buffer[pre_index].image; + + pre_index = (pre_index+1)%image_buffer_count; + } + event->AddFrames( pre_event_count, timestamps, images ); + //event->AddFrame( now, &image ); + } + shared_data->state = state = TAPE; + } + //last_alarm_count = image_count; + } if ( score ) { if ( state == IDLE ) { - event = new Event( this, *timestamp ); - Info(( "%s: %03d - Gone into alarm state", name, image_count )); - int pre_index = ((index+image_buffer_count)-pre_event_count)%image_buffer_count; - struct timeval *timestamps[pre_event_count]; - const Image *images[pre_event_count]; - for ( int i = 0; i < pre_event_count; i++ ) + if ( function != MOCORD ) { - timestamps[i] = image_buffer[pre_index].timestamp; - images[i] = image_buffer[pre_index].image; + event = new Event( this, *timestamp ); - pre_index = (pre_index+1)%image_buffer_count; + int pre_index = ((index+image_buffer_count)-pre_event_count)%image_buffer_count; + struct timeval *timestamps[pre_event_count]; + const Image *images[pre_event_count]; + for ( int i = 0; i < pre_event_count; i++ ) + { + timestamps[i] = image_buffer[pre_index].timestamp; + images[i] = image_buffer[pre_index].image; + + pre_index = (pre_index+1)%image_buffer_count; + } + event->AddFrames( pre_event_count, timestamps, images ); + //event->AddFrame( now, &image ); } - event->AddFrames( pre_event_count, timestamps, images ); - //event->AddFrame( now, &image ); } shared_data->state = state = ALARM; last_alarm_count = image_count; @@ -554,8 +671,16 @@ bool Monitor::Analyse() { Info(( "%s: %03d - Left alarm state (%d) - %d(%d) images", name, image_count, event->Id(), event->Frames(), event->AlarmFrames() )); shared_data->last_event = event->Id(); - delete event; - shared_data->state = state = IDLE; + if ( function != MOCORD ) + { + shared_data->state = state = IDLE; + delete event; + event = 0; + } + else + { + shared_data->state = state = TAPE; + } } } } @@ -582,6 +707,18 @@ bool Monitor::Analyse() event->AddFrame( now, image ); } } + if ( function == RECORD || function == MOCORD ) + { + if ( state == IDLE || state == TAPE ) + { + if ( ((timestamp->tv_sec%section_length) == 0) && ((timestamp->tv_sec - event->StartTime().tv_sec) > (section_length/2)) ) + { + Info(( "Ended event" )); + delete event; + event = 0; + } + } + } } if ( (bool)config.Item( ZM_BLEND_ALARMED_IMAGES ) || state != ALARM ) @@ -608,16 +745,16 @@ void Monitor::ReloadZones() DumpZoneImage(); } -int Monitor::Load( int device, Monitor **&monitors, Mode mode ) +int Monitor::Load( int device, Monitor **&monitors, Purpose purpose ) { static char sql[BUFSIZ]; if ( device == -1 ) { - strcpy( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local'" ); + strcpy( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local'" ); } else { - sprintf( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local' and Device = %d", device ); + sprintf( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local' and Device = %d", device ); } if ( mysql_query( &dbconn, sql ) ) { @@ -637,7 +774,7 @@ int Monitor::Load( int device, Monitor **&monitors, Mode mode ) monitors = new Monitor *[n_monitors]; for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) { - monitors[i] = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[2]), atoi(dbrow[3]), atoi(dbrow[4]), atoi(dbrow[5]), atoi(dbrow[6]), atoi(dbrow[7]), atoi(dbrow[8]), atoi(dbrow[9]), dbrow[10], Coord( atoi(dbrow[11]), atoi(dbrow[12]) ), atoi(dbrow[13]), atoi(dbrow[14]), atoi(dbrow[15]), atoi(dbrow[16]), atof(dbrow[17])>0.0?int(DT_PREC_3/atof(dbrow[17])):0, atoi(dbrow[18]), atoi(dbrow[19]), mode ); + monitors[i] = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[2]), atoi(dbrow[3]), atoi(dbrow[4]), atoi(dbrow[5]), atoi(dbrow[6]), atoi(dbrow[7]), atoi(dbrow[8]), atoi(dbrow[9]), dbrow[10], Coord( atoi(dbrow[11]), atoi(dbrow[12]) ), atoi(dbrow[13]), atoi(dbrow[14]), atoi(dbrow[15]), atoi(dbrow[16]), atoi(dbrow[17]), atof(dbrow[18])>0.0?int(DT_PREC_3/atof(dbrow[18])):0, atoi(dbrow[19]), atoi(dbrow[20]), purpose ); Zone **zones = 0; int n_zones = Zone::Load( monitors[i], zones ); monitors[i]->AddZones( n_zones, zones ); @@ -654,16 +791,16 @@ int Monitor::Load( int device, Monitor **&monitors, Mode mode ) return( n_monitors ); } -int Monitor::Load( const char *host, const char*port, const char *path, Monitor **&monitors, Mode mode ) +int Monitor::Load( const char *host, const char*port, const char *path, Monitor **&monitors, Purpose purpose ) { static char sql[BUFSIZ]; if ( !host ) { - strcpy( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote'" ); + strcpy( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote'" ); } else { - sprintf( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote' and Host = '%s' and Port = '%s' and Path = '%s'", host, port, path ); + sprintf( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote' and Host = '%s' and Port = '%s' and Path = '%s'", host, port, path ); } if ( mysql_query( &dbconn, sql ) ) { @@ -683,7 +820,7 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor monitors = new Monitor *[n_monitors]; for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) { - monitors[i] = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[2]), dbrow[3], dbrow[4], dbrow[5], atoi(dbrow[6]), atoi(dbrow[7]), atoi(dbrow[8]), atoi(dbrow[9]), dbrow[10], Coord( atoi(dbrow[11]), atoi(dbrow[12]) ), atoi(dbrow[13]), atoi(dbrow[14]), atoi(dbrow[15]), atoi(dbrow[16]), atof(dbrow[17])>0.0?int(DT_PREC_3/atof(dbrow[17])):0, atoi(dbrow[18]), atoi(dbrow[19]), mode ); + monitors[i] = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[2]), dbrow[3], dbrow[4], dbrow[5], atoi(dbrow[6]), atoi(dbrow[7]), atoi(dbrow[8]), atoi(dbrow[9]), dbrow[10], Coord( atoi(dbrow[11]), atoi(dbrow[12]) ), atoi(dbrow[13]), atoi(dbrow[14]), atoi(dbrow[15]), atoi(dbrow[16]), atoi(dbrow[17]), atof(dbrow[18])>0.0?int(DT_PREC_3/atof(dbrow[18])):0, atoi(dbrow[19]), atoi(dbrow[20]), purpose ); Zone **zones = 0; int n_zones = Zone::Load( monitors[i], zones ); monitors[i]->AddZones( n_zones, zones ); @@ -700,10 +837,10 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor return( n_monitors ); } -Monitor *Monitor::Load( int id, bool load_zones, Mode mode ) +Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) { static char sql[BUFSIZ]; - sprintf( sql, "select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = %d", id ); + sprintf( sql, "select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = %d", id ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't run query: %s", mysql_error( &dbconn ) )); @@ -723,11 +860,11 @@ Monitor *Monitor::Load( int id, bool load_zones, Mode mode ) { if ( !strcmp( dbrow[2], "Local" ) ) { - monitor = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[3]), atoi(dbrow[4]), atoi(dbrow[5]), atoi(dbrow[6]), atoi(dbrow[10]), atoi(dbrow[11]), atoi(dbrow[12]), atoi(dbrow[13]), dbrow[14], Coord( atoi(dbrow[15]), atoi(dbrow[16]) ), atoi(dbrow[17]), atoi(dbrow[18]), atoi(dbrow[19]), atoi(dbrow[20]), atof(dbrow[21])>0.0?int(DT_PREC_3/atof(dbrow[21])):0, atoi(dbrow[22]), atoi(dbrow[23]), mode ); + monitor = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[3]), atoi(dbrow[4]), atoi(dbrow[5]), atoi(dbrow[6]), atoi(dbrow[10]), atoi(dbrow[11]), atoi(dbrow[12]), atoi(dbrow[13]), dbrow[14], Coord( atoi(dbrow[15]), atoi(dbrow[16]) ), atoi(dbrow[17]), atoi(dbrow[18]), atoi(dbrow[19]), atoi(dbrow[20]), atoi(dbrow[21]), atof(dbrow[22])>0.0?int(DT_PREC_3/atof(dbrow[22])):0, atoi(dbrow[23]), atoi(dbrow[24]), purpose ); } else { - monitor = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[3]), dbrow[7], dbrow[8], dbrow[9], atoi(dbrow[10]), atoi(dbrow[11]), atoi(dbrow[12]), atoi(dbrow[13]), dbrow[14], Coord( atoi(dbrow[15]), atoi(dbrow[16]) ), atoi(dbrow[17]), atoi(dbrow[18]), atoi(dbrow[19]), atoi(dbrow[20]), atof(dbrow[21])>0.0?int(DT_PREC_3/atof(dbrow[21])):0, atoi(dbrow[22]), atoi(dbrow[23]), mode ); + monitor = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[3]), dbrow[7], dbrow[8], dbrow[9], atoi(dbrow[10]), atoi(dbrow[11]), atoi(dbrow[12]), atoi(dbrow[13]), dbrow[14], Coord( atoi(dbrow[15]), atoi(dbrow[16]) ), atoi(dbrow[17]), atoi(dbrow[18]), atoi(dbrow[19]), atoi(dbrow[20]), atoi(dbrow[21]), atof(dbrow[22])>0.0?int(DT_PREC_3/atof(dbrow[22])):0, atoi(dbrow[23]), atoi(dbrow[24]), purpose ); } int n_zones = 0; if ( load_zones ) @@ -830,14 +967,16 @@ bool Monitor::DumpSettings( char *output, bool verbose ) sprintf( output+strlen(output), "Warmup Count : %d\n", warmup_count ); sprintf( output+strlen(output), "Pre Event Count : %d\n", pre_event_count ); sprintf( output+strlen(output), "Post Event Count : %d\n", post_event_count ); + sprintf( output+strlen(output), "Section Length : %d\n", section_length ); sprintf( output+strlen(output), "Maximum FPS : %.2f\n", capture_delay?DT_PREC_3/capture_delay:0.0 ); sprintf( output+strlen(output), "Reference Blend %%ge : %d\n", ref_blend_perc ); sprintf( output+strlen(output), "Function: %d - %s\n", function, - function==NONE?"None":( - function==ACTIVE?"Active":( - function==PASSIVE?"Passive":( - function==X10?"X10":"Unknown" - )))); + function==OFF?"None":( + function==MONITOR?"Monitor":( + function==MODECT?"Motion Detection":( + function==RECORD?"Continuous Record":( + function==MOCORD?"Continuous Record with Motion Detection":"Unknown" + ))))); sprintf( output+strlen(output), "Zones : %d\n", n_zones ); for ( int i = 0; i < n_zones; i++ ) { diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 62b2b6d0d..b6fdd472c 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -41,19 +41,26 @@ public: QUERY=0, CAPTURE, ANALYSIS - } Mode; + } Purpose; typedef enum { - NONE=1, - PASSIVE, - ACTIVE, - X10 + CONTINUOUS=0, + TRIGGERED, + } RunMode; + + typedef enum + { + OFF=1, + MONITOR, + MODECT, + RECORD, + MOCORD } Function; typedef enum { ROTATE_0=1, ROTATE_90, ROTATE_180, ROTATE_270 } Orientation; - typedef enum { IDLE, ALARM, ALERT } State; + typedef enum { IDLE, ALARM, ALERT, TAPE } State; protected: // These are read from the DB and thereafter remain unchanged @@ -62,6 +69,7 @@ protected: unsigned int width; // Normally the same as the camera, but not if partly rotated unsigned int height; // Normally the same as the camera, but not if partly rotated Function function; // What the monitor is doing + RunMode run_mode; // Whether the monitor is running continuously or is triggered Orientation orientation; // Whether the image has to be rotated at all char label_format[64]; // The format of the timestamp on the images Coord label_coord; // The coordinates of the timestamp on the images @@ -69,11 +77,12 @@ protected: int warmup_count; // How many images to process before looking for events int pre_event_count; // How many images to hold and prepend to an alarm event int post_event_count; // How many unalarmed images must occur before the alarm state is reset + int section_length; // How long events should last in continuous modes int capture_delay; // How long we wait between capture frames int fps_report_interval;// How many images should be captured/processed between reporting the current FPS int ref_blend_perc; // Percentage of new image going into reference image. - Mode mode; // What this monitor has been created to do + Purpose purpose; // What this monitor has been created to do double fps; Image image; @@ -125,8 +134,8 @@ protected: Camera *camera; public: - Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode=QUERY, int p_n_zones=0, Zone *p_zones[]=0 ); - Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Mode p_mode=QUERY, int p_n_zones=0, Zone *p_zones[]=0 ); + Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_section_length, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 ); + Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_section_length, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 ); ~Monitor(); void Initialise(); @@ -195,7 +204,7 @@ public: int index = image_count%image_buffer_count; - if ( index == shared_data->last_read_index && function == ACTIVE ) + if ( index == shared_data->last_read_index && function > MONITOR ) { Warning(( "Buffer overrun at index %d\n", index )); } @@ -237,7 +246,7 @@ public: inline bool Ready() { - return( function >= ACTIVE && image_count > warmup_count ); + return( function > MONITOR && image_count > warmup_count ); } void DumpImage( Image *image ) const; @@ -250,9 +259,9 @@ public: unsigned int Compare( const Image &image ); void ReloadZones(); - static int Load( int device, Monitor **&monitors, Mode mode=QUERY ); - static int Load( const char *host, const char*port, const char*path, Monitor **&monitors, Mode mode=QUERY ); - static Monitor *Load( int id, bool load_zones=false, Mode mode=QUERY ); + static int Load( int device, Monitor **&monitors, Purpose purpose=QUERY ); + static int Load( const char *host, const char*port, const char*path, Monitor **&monitors, Purpose purpose=QUERY ); + static Monitor *Load( int id, bool load_zones=false, Purpose purpose=QUERY ); void StreamImages( unsigned long idle=5000, unsigned long refresh=50, FILE *fd=stdout, time_t ttl=0 ); }; diff --git a/web/zm_actions.php b/web/zm_actions.php index f38817d30..7975c98e5 100644 --- a/web/zm_actions.php +++ b/web/zm_actions.php @@ -222,50 +222,94 @@ if ( $action ) } $changes = array(); - if ( $new_name != $monitor[Name] ) $changes[] = "Name = '$new_name'"; - if ( $new_function != $monitor['Function'] ) $changes[] = "Function = '$new_function'"; - if ( $new_type != $monitor['Type'] ) $changes[] = "Type = '$new_type'"; - if ( $new_type == "Local" ) + switch( $tab ) { - if ( $new_device != $monitor['Device'] ) $changes[] = "Device = '$new_device'"; - if ( $new_channel != $monitor['Channel'] ) $changes[] = "Channel = '$new_channel'"; - if ( $new_format != $monitor['Format'] ) $changes[] = "Format = '$new_format'"; + case 'monitor' : + { + if ( $new_name != $monitor[Name] ) $changes[] = "Name = '$new_name'"; + if ( $new_function != $monitor['Function'] ) $changes[] = "Function = '$new_function'"; + if ( $new_runmode != $monitor['RunMode'] ) $changes[] = "RunMode = '$new_runmode'"; + if ( join(',',$new_triggers) != $monitor['Triggers'] ) $changes[] = "Triggers = '".join(',',$new_triggers)."'"; + if ( $new_type != $monitor['Type'] ) $changes[] = "Type = '$new_type'"; + break; + } + case 'source' : + { + if ( $monitor['Type'] == "Local" ) + { + if ( $new_device != $monitor['Device'] ) $changes[] = "Device = '$new_device'"; + if ( $new_channel != $monitor['Channel'] ) $changes[] = "Channel = '$new_channel'"; + if ( $new_format != $monitor['Format'] ) $changes[] = "Format = '$new_format'"; + } + else + { + if ( $new_host != $monitor['Device'] ) $changes[] = "Host = '$new_host'"; + if ( $new_port != $monitor['Channel'] ) $changes[] = "port = '$new_port'"; + if ( $new_path != $monitor['Format'] ) $changes[] = "Path = '$new_path'"; + } + if ( $new_width != $monitor['Width'] ) $changes[] = "Width = '$new_width'"; + if ( $new_height != $monitor['Height'] ) $changes[] = "Height = '$new_height'"; + if ( $new_palette != $monitor['Palette'] ) $changes[] = "Palette = '$new_palette'"; + if ( $new_orientation != $monitor['Orientation'] ) $changes[] = "Orientation = '$new_orientation'"; + break; + } + case 'timestamp' : + { + if ( $new_label_format != $monitor['LabelFormat'] ) $changes[] = "LabelFormat = '$new_label_format'"; + if ( $new_label_x != $monitor['LabelX'] ) $changes[] = "LabelX = '$new_label_x'"; + if ( $new_label_y != $monitor['LabelY'] ) $changes[] = "LabelY = '$new_label_y'"; + break; + } + case 'buffers' : + { + if ( $new_image_buffer_count != $monitor['ImageBufferCount'] ) $changes[] = "ImageBufferCount = '$new_image_buffer_count'"; + if ( $new_warmup_count != $monitor['WarmupCount'] ) $changes[] = "WarmupCount = '$new_warmup_count'"; + if ( $new_pre_event_count != $monitor['PreEventCount'] ) $changes[] = "PreEventCount = '$new_pre_event_count'"; + if ( $new_post_event_count != $monitor['PostEventCount'] ) $changes[] = "PostEventCount = '$new_post_event_count'"; + break; + } + case 'misc' : + { + if ( $new_section_length != $monitor['SectionLength'] ) $changes[] = "SectionLength = '$new_section_length'"; + if ( $new_max_fps != $monitor['MaxFPS'] ) $changes[] = "MaxFPS = '$new_max_fps'"; + if ( $new_fps_report_interval != $monitor['FPSReportInterval'] ) $changes[] = "FPSReportInterval = '$new_fps_report_interval'"; + if ( $new_ref_blend_perc != $monitor['RefBlendPerc'] ) $changes[] = "RefBlendPerc = '$new_ref_blend_perc'"; + break; + } + case 'x10' : + { + if ( $new_activation != $monitor['Activation'] ) $changes[] = "Activation = '$new_activation'"; + if ( $new_alarm_input != $monitor['AlarmInput'] ) $changes[] = "AlarmInput = '$new_alarm_input'"; + if ( $new_alarm_output != $monitor['AlarmOutput'] ) $changes[] = "AlarmOutput = '$new_alarm_output'"; + break; + } } - else - { - if ( $new_host != $monitor['Device'] ) $changes[] = "Host = '$new_host'"; - if ( $new_port != $monitor['Channel'] ) $changes[] = "port = '$new_port'"; - if ( $new_path != $monitor['Format'] ) $changes[] = "Path = '$new_path'"; - } - if ( $new_width != $monitor['Width'] ) $changes[] = "Width = '$new_width'"; - if ( $new_height != $monitor['Height'] ) $changes[] = "Height = '$new_height'"; - if ( $new_palette != $monitor['Palette'] ) $changes[] = "Palette = '$new_palette'"; - if ( $new_orientation != $monitor['Orientation'] ) $changes[] = "Orientation = '$new_orientation'"; - if ( $new_label_format != $monitor['LabelFormat'] ) $changes[] = "LabelFormat = '$new_label_format'"; - if ( $new_label_x != $monitor['LabelX'] ) $changes[] = "LabelX = '$new_label_x'"; - if ( $new_label_y != $monitor['LabelY'] ) $changes[] = "LabelY = '$new_label_y'"; - if ( $new_image_buffer_count != $monitor['ImageBufferCount'] ) $changes[] = "ImageBufferCount = '$new_image_buffer_count'"; - if ( $new_warmup_count != $monitor['WarmupCount'] ) $changes[] = "WarmupCount = '$new_warmup_count'"; - if ( $new_pre_event_count != $monitor['PreEventCount'] ) $changes[] = "PreEventCount = '$new_pre_event_count'"; - if ( $new_post_event_count != $monitor['PostEventCount'] ) $changes[] = "PostEventCount = '$new_post_event_count'"; - if ( $new_max_fps != $monitor['MaxFPS'] ) $changes[] = "MaxFPS = '$new_max_fps'"; - if ( $new_fps_report_interval != $monitor['FPSReportInterval'] ) $changes[] = "FPSReportInterval = '$new_fps_report_interval'"; - if ( $new_ref_blend_perc != $monitor['RefBlendPerc'] ) $changes[] = "RefBlendPerc = '$new_ref_blend_perc'"; - if ( $new_x10_activation != $monitor['X10Activation'] ) $changes[] = "X10Activation = '$new_x10_activation'"; - if ( $new_x10_alarm_input != $monitor['X10AlarmInput'] ) $changes[] = "X10AlarmInput = '$new_x10_alarm_input'"; - if ( $new_x10_alarm_output != $monitor['X10AlarmOutput'] ) $changes[] = "X10AlarmOutput = '$new_x10_alarm_output'"; - if ( count( $changes ) ) { if ( $mid > 0 ) { - $sql = "update Monitors set ".implode( ", ", $changes )." where Id = '$mid'"; - $result = mysql_query( $sql ); - if ( !$result ) - die( mysql_error() ); - if ( $new_name != $monitor[Name] ) + switch( $tab ) { - exec( escapeshellcmd( "mv ".EVENTS_PATH."/$monitor[Name] ".EVENTS_PATH."/$new_name" ) ); + case 'x10' : + { + $sql = "update TriggersX10 set ".implode( ", ", $changes )." where MonitorId = '$mid'"; + $result = mysql_query( $sql ); + if ( !$result ) + die( mysql_error() ); + break; + } + default : + { + $sql = "update Monitors set ".implode( ", ", $changes )." where Id = '$mid'"; + $result = mysql_query( $sql ); + if ( !$result ) + die( mysql_error() ); + if ( $new_name != $monitor[Name] ) + { + exec( escapeshellcmd( "mv ".EVENTS_PATH."/$monitor[Name] ".EVENTS_PATH."/$new_name" ) ); + } + break; + } } } elseif ( !$user[MonitorIds] ) @@ -279,7 +323,7 @@ if ( $action ) $result = mysql_query( $sql ); if ( !$result ) die( mysql_error() ); - $view = 'none'; + //$view = 'none'; } $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) @@ -488,6 +532,7 @@ if ( $action ) { $HTTP_SESSION_VARS[event_reset_time] = strftime( "%Y-%m-%d %H:%M:%S" ); setcookie( "event_reset_time", $HTTP_SESSION_VARS[event_reset_time], time()+3600*24*30*12*10 ); + session_write_close(); } } diff --git a/web/zm_config.php.z b/web/zm_config.php.z index 7265a73bd..ce3b9582b 100644 --- a/web/zm_config.php.z +++ b/web/zm_config.php.z @@ -127,7 +127,7 @@ $jws = array( 'console' => array( 'w'=>720, 'h'=>400 ), 'cycle' => array( 'w'=>46, 'h'=>80 ), 'montage' => array( 'w'=>20, 'h'=>20 ), - 'monitor' => array( 'w'=>420, 'h'=>512 ), + 'monitor' => array( 'w'=>360, 'h'=>300 ), 'watch' => array( 'w'=>72, 'h'=>315 ), 'device' => array( 'w'=>196, 'h'=>164 ), 'function' => array( 'w'=>248, 'h'=>92 ), diff --git a/web/zm_db.php b/web/zm_db.php index 5847d75a6..34c5a7d80 100644 --- a/web/zm_db.php +++ b/web/zm_db.php @@ -38,4 +38,9 @@ function getEnumValues( $table, $column ) } return $enum_values; } + +function getSetValues( $table, $column ) +{ + return( getEnumValues( $table, $column ) ); +} ?> diff --git a/web/zm_funcs.php b/web/zm_funcs.php index 2a4e871ef..37d3ac6b8 100644 --- a/web/zm_funcs.php +++ b/web/zm_funcs.php @@ -37,6 +37,7 @@ function userLogin( $username, $password ) { $HTTP_SESSION_VARS[user] = array(); } + session_write_close(); } function userLogout() @@ -195,12 +196,12 @@ function zmcControl( $monitor, $restart=false ) { if ( $monitor[Type] == "Local" ) { - $sql = "select count(if(Function='Passive',1,NULL)) as PassiveCount, count(if(Function='Active',1,NULL)) as ActiveCount, count(if(Function='X10',1,NULL)) as X10Count from Monitors where Device = '$monitor[Device]'"; + $sql = "select count(if(Function='Monitor',1,NULL)) as PassiveCount, count(if(Function>'Monitor',1,NULL)) as ActiveCount, count(if(Function='X10',1,NULL)) as X10Count from Monitors where Device = '$monitor[Device]'"; $zmc_args = "-d $monitor[Device]"; } else { - $sql = "select count(if(Function='Passive',1,NULL)) as PassiveCount, count(if(Function='Active',1,NULL)) as ActiveCount, count(if(Function='X10',1,NULL)) as X10Count from Monitors where Host = '$monitor[Host]' and Port = '$monitor[Port]' and Path = '$monitor[Path]'"; + $sql = "select count(if(Function='Monitor',1,NULL)) as PassiveCount, count(if(Function>'Monitor',1,NULL)) as ActiveCount, count(if(Function='X10',1,NULL)) as X10Count from Monitors where Host = '$monitor[Host]' and Port = '$monitor[Port]' and Path = '$monitor[Path]'"; $zmc_args = "-H $monitor[Host] -P $monitor[Port] -p '$monitor[Path]'"; } $result = mysql_query( $sql ); @@ -235,9 +236,30 @@ function zmaControl( $monitor, $restart=false ) echo mysql_error(); $monitor = mysql_fetch_assoc( $result ); } - if ( $monitor['Function'] == 'Active' ) + switch ( $monitor['Function'] ) { - if ( $restart ) + case 'Modect' : + case 'Record' : + case 'Mocord' : + { + if ( $restart ) + { + daemonControl( "stop", "zmfilter.pl", "-m $monitor[Id] -e -1" ); + daemonControl( "stop", "zma", "-m $monitor[Id]" ); + if ( ZM_OPT_FRAME_SERVER ) + { + daemonControl( "stop", "zmf", "-m $monitor[Id]" ); + } + } + if ( ZM_OPT_FRAME_SERVER ) + { + daemonControl( "start", "zmf", "-m $monitor[Id]" ); + } + daemonControl( "start", "zma", "-m $monitor[Id]" ); + daemonControl( "start", "zmfilter.pl", "-m $monitor[Id] -e -1" ); + break; + } + default : { daemonControl( "stop", "zmfilter.pl", "-m $monitor[Id] -e -1" ); daemonControl( "stop", "zma", "-m $monitor[Id]" ); @@ -245,21 +267,7 @@ function zmaControl( $monitor, $restart=false ) { daemonControl( "stop", "zmf", "-m $monitor[Id]" ); } - } - if ( ZM_OPT_FRAME_SERVER ) - { - daemonControl( "start", "zmf", "-m $monitor[Id]" ); - } - daemonControl( "start", "zma", "-m $monitor[Id]" ); - daemonControl( "start", "zmfilter.pl", "-m $monitor[Id] -e -1" ); - } - else - { - daemonControl( "stop", "zmfilter.pl", "-m $monitor[Id] -e -1" ); - daemonControl( "stop", "zma", "-m $monitor[Id]" ); - if ( ZM_OPT_FRAME_SERVER ) - { - daemonControl( "stop", "zmf", "-m $monitor[Id]" ); + break; } } } diff --git a/web/zm_html.php b/web/zm_html.php index a5372342b..e779d1762 100644 --- a/web/zm_html.php +++ b/web/zm_html.php @@ -28,7 +28,7 @@ ini_set( "session.use_trans_sid", "0" ); ini_set( "session.name", "ZMSESSID" ); //ini_set( "magic_quotes_gpc", "Off" ); -session_start(); +//session_start(); require_once( 'zm_config.php' ); diff --git a/web/zm_html_view_console.php b/web/zm_html_view_console.php index 503c9ec69..400eb0192 100644 --- a/web/zm_html_view_console.php +++ b/web/zm_html_view_console.php @@ -5,10 +5,12 @@ if ( $stop ) { + session_write_close(); packageControl( 'stop' ); } if ( $start ) { + session_write_close(); packageControl( 'start' ); } @@ -203,21 +205,21 @@ window.setTimeout( "window.location.replace('')", diff --git a/web/zm_html_view_events.php b/web/zm_html_view_events.php index 9b77a2591..a05f353e3 100644 --- a/web/zm_html_view_events.php +++ b/web/zm_html_view_events.php @@ -136,14 +136,6 @@ } $sql .= " order by $sort_column $sort_order"; //echo $sql; - $result = mysql_query( $sql ); - if ( !$result ) - { - die( mysql_error() ); - } - $n_rows = mysql_num_rows( $result ); - - //echo $filter_query; ?> @@ -201,11 +193,21 @@ function configureButton(form,name) } window.focus(); - -opener.location.reload(true); + +//opener.location.reload(true); filterWindow( '?view=filter&mid=', 'zmFilter' ); -location.href = '?view=events&mid='; - +location.replace( '?view=events&mid=' ); + + + + @@ -231,11 +233,19 @@ location.href = '?view=events&mid=  @@ -250,13 +260,13 @@ location.href = '?view=events&mid=Mark > @@ -271,7 +281,7 @@ location.href = '?view=events&mid= disabled>
Id
@@ -281,3 +291,6 @@ location.href = '?view=events&mid= + diff --git a/web/zm_html_view_filter.php b/web/zm_html_view_filter.php index 7b48be99f..9cd36532f 100644 --- a/web/zm_html_view_filter.php +++ b/web/zm_html_view_filter.php @@ -112,7 +112,7 @@ function submitToEvents( form ) var Height = ; var Options = 'resizable,scrollbars,width='+Width+',height='+Height; - window.open( Url, Name, Options ); + //window.open( Url, Name, Options ); form.target = Name; form.view.value = 'events'; form.submit(); diff --git a/web/zm_html_view_monitor.php b/web/zm_html_view_monitor.php index 41d922628..047c4b0d4 100644 --- a/web/zm_html_view_monitor.php +++ b/web/zm_html_view_monitor.php @@ -4,18 +4,45 @@ $view = "error"; return; } + + $tabs = array(); + $tabs["monitor"] = "Monitor"; + $tabs["source"] = "Source"; + $tabs["timestamp"] = "Timestamp"; + $tabs["buffers"] = "Buffers"; + $tabs["misc"] = "Misc"; + if ( ZM_OPT_X10 ) + { + $tabs["x10"] = "X10"; + } + + if ( !$tab ) + $tab = "monitor"; + if ( $mid > 0 ) { $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); + if ( ZM_OPT_X10 ) + { + $result = mysql_query( "select * from TriggersX10 where MonitorId = '$mid'" ); + if ( !$result ) + die( mysql_error() ); + $x10_monitor = mysql_fetch_assoc( $result ); + foreach( $x10_monitor as $key=>$value ) + { + $monitor['X10'.$key] = $value; + } + } } else { $monitor = array(); $monitor[Name] = "New"; $monitor['Function'] = "None"; + $monitor['RunMode'] = "Continuous"; $monitor[Type] = "Local"; $monitor[Port] = "80"; $monitor[Orientation] = "0"; @@ -26,6 +53,7 @@ $monitor[WarmupCount] = 25; $monitor[PreEventCount] = 10; $monitor[PostEventCount] = 10; + $monitor[SectionLength] = 600; $monitor[MaxFPS] = 0; $monitor[FPSReportInterval] = 1000; $monitor[RefBlendPerc] = 10; @@ -62,76 +90,174 @@ function closeWindow() - + + + + +
Monitor Monitor
 
+ + +$value ) + { + if ( $tab == $name ) + { +?> + + + + + + +
 
+ - + + - + + + +"Local", "Remote"=>"Remote" ); ?> - + + + + + - - - - - + + + + + - - +
ParameterValueParameterValue
Name
Function
Run Mode
Triggers +"; +?> + checked> + +None available + +
Source Type
Source Type
Device Number (/dev/video?)
Device Channel
Device Format (0=PAL,1=NTSC etc)
Capture Palette
Remote Host Name
Remote Host Port
Remote Host Path
Remote Image Colours
Capture Width (pixels)
Capture Height (pixels)
Orientation
Timestamp Label Format
Timestamp Label X
Timestamp Label Y
Image Buffer Size (frames)
Warmup Frames
Pre Event Image Buffer
Post Event Image Buffer
Section Length
Maximum FPS
FPS Report Interval
Reference Image Blend %ge
X10 Activation String
X10 Input Alarm String
X10 Output Alarm String
X10 Activation String
X10 Input Alarm String
X10 Output Alarm String
 
  disabled>   disabled>  
diff --git a/web/zm_html_view_montagestatus.php b/web/zm_html_view_montagestatus.php index 685c6b668..bf191892c 100644 --- a/web/zm_html_view_montagestatus.php +++ b/web/zm_html_view_montagestatus.php @@ -24,6 +24,10 @@ $status_string = "Alert"; $class = "ambtext"; } + elseif ( $status == 3 ) + { + $status_string = "Record"; + } $fps_string = sprintf( "%.2f", $fps ); $new_alarm = ( $status > 0 && $last_status == 0 ); $old_alarm = ( $status == 0 && $last_status > 0 ); diff --git a/web/zm_html_view_watchstatus.php b/web/zm_html_view_watchstatus.php index ed7ebfc98..f28034e08 100644 --- a/web/zm_html_view_watchstatus.php +++ b/web/zm_html_view_watchstatus.php @@ -29,6 +29,10 @@ $status_string = "Alert"; $class = "ambtext"; } + elseif ( $status == 3 ) + { + $status_string = "Record"; + } $fps_string = sprintf( "%.2f", $fps ); $new_alarm = ( $status > 0 && $last_status == 0 ); $old_alarm = ( $status == 0 && $last_status > 0 ); @@ -70,27 +74,27 @@ window.setTimeout( "window.location.replace( '' )", - +
- - + + - + - + - + diff --git a/web/zm_html_view_zone.php b/web/zm_html_view_zone.php index 038b250bf..d839bc5fb 100644 --- a/web/zm_html_view_zone.php +++ b/web/zm_html_view_zone.php @@ -42,7 +42,21 @@ opener.location.reload(true); window.focus(); function validateForm( Form ) { + var errors = new Array(); Form.new_alarm_rgb.value = (Form.new_alarm_rgb_r.value<<16)|(Form.new_alarm_rgb_g.value<<8)|Form.new_alarm_rgb_b.value; + if ( Form.new_min_alarm_pixels.value < Form.new_min_filter_pixels.value ) + { + errors[errors.length] = "Minimum alarm pixels should be greater than or equal to minimum filter pixels"; + } + if ( Form.new_min_filter_pixels.value < Form.new_min_blob_pixels.value ) + { + errors[errors.length] = "Minimum filter pixels should be greater than or equal to minimum blob pixels"; + } + if ( errors.length ) + { + alert( errors.join( "\n" ) ); + return( false ); + } return( true ); } diff --git a/web/zm_styles.css b/web/zm_styles.css index 64aae096f..881e32514 100644 --- a/web/zm_styles.css +++ b/web/zm_styles.css @@ -84,6 +84,11 @@ a:hover { font-size: 10px; color: #333333 } +.form-noborder { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + color: #333333 +} .textsmall { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:9px;
 Status:  -  fps Status:  -  fps Cancel Forced AlarmCancel Forced Alarm Force AlarmForce Alarm