diff --git a/db/zmalter-0.0.1.sql b/db/zmalter-0.0.1.sql index 568d800bb..3df803c4e 100644 --- a/db/zmalter-0.0.1.sql +++ b/db/zmalter-0.0.1.sql @@ -20,6 +20,8 @@ alter table Monitors modify column Function enum('None','Passive','Active','X10' update Monitors set LabelFormat = '%%s - %y/%m/%d %H:%M:%S'; update Monitors set LabelX = 0; update Monitors set LabelY = Height-8; +alter table Events add column TotScore int unsigned not null default 0 after AlarmFrames; +update Events set TotScore = AlarmFrames * AvgScore where TotScore = 0; alter table Events modify column Archived tinyint unsigned not null default 0; alter table Events add column Uploaded tinyint unsigned not null default 0 after Archived; alter table Events add column LearnState char(1) default '' after Uploaded; diff --git a/db/zmschema.sql.z b/db/zmschema.sql.z index b2f2a9955..4a5b9fc12 100644 --- a/db/zmschema.sql.z +++ b/db/zmschema.sql.z @@ -25,6 +25,7 @@ CREATE TABLE Events ( Length int(10) unsigned default NULL, Frames int(10) unsigned default NULL, AlarmFrames int(10) unsigned default NULL, + TotScore int(10) unsigned NOT NULL default '0', AvgScore tinyint(3) unsigned default '0', MaxScore tinyint(3) unsigned default '0', Archived tinyint(3) unsigned NOT NULL default '0', diff --git a/scripts/zmfilter.pl.z b/scripts/zmfilter.pl.z index 2b569f792..418de39d8 100755 --- a/scripts/zmfilter.pl.z +++ b/scripts/zmfilter.pl.z @@ -299,7 +299,7 @@ sub GetFilters } } #print( Dumper( %filter_terms ) ); - my $sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.AvgScore,E.MaxScore,E.Archived,E.Uploaded,E.LearnState from Events as E inner join Monitors as M on M.Id = E.MonitorId where M.Id = '$monitor'"; + my $sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived,E.Uploaded,E.LearnState from Events as E inner join Monitors as M on M.Id = E.MonitorId where M.Id = '$monitor'"; my $filter_sql = ''; for ( my $i = 1; $i <= $filter_terms{trms}; $i++ ) { diff --git a/src/zm.cpp b/src/zm.cpp index 4d8498bfe..4e1ffef03 100644 --- a/src/zm.cpp +++ b/src/zm.cpp @@ -1332,7 +1332,7 @@ Event::~Event() static char end_time_str[32]; strftime( end_time_str, sizeof(end_time_str), "%Y-%m-%d %H:%M:%S", localtime( &end_time ) ); - sprintf( sql, "update Events set Name='Event-%d', EndTime = '%s', Length = %d, Frames = %d, AlarmFrames = %d, AvgScore = %d, MaxScore = %d where Id = %d", id, end_time_str, (end_time-start_time), frames, alarm_frames, (int)(tot_score/alarm_frames), max_score, id ); + sprintf( sql, "update Events set Name='Event-%d', EndTime = '%s', Length = %d, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", id, end_time_str, (end_time-start_time), frames, alarm_frames, tot_score, (int)(tot_score/alarm_frames), max_score, id ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't update event: %s\n", mysql_error( &dbconn ) )); diff --git a/web/zmhtml.php b/web/zmhtml.php index 2ff1b5957..f01116b71 100644 --- a/web/zmhtml.php +++ b/web/zmhtml.php @@ -652,6 +652,9 @@ function configureButton(form,name) case 'AlarmFrames' : $sort_column = "E.AlarmFrames"; break; + case 'TotScore' : + $sort_column = "E.TotScore"; + break; case 'AvgScore' : $sort_column = "E.AvgScore"; break; @@ -672,7 +675,7 @@ function configureButton(form,name) $monitor = mysql_fetch_assoc( $result ); // XXX - $sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.AvgScore,E.MaxScore,E.Archived,E.LearnState from Monitors as M, Events as E where M.Id = '$mid' and M.Id = E.MonitorId"; + $sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived,E.LearnState from Monitors as M, Events as E where M.Id = '$mid' and M.Id = E.MonitorId"; $filter_query = ''; $filter_sql = ''; $filter_fields = ''; @@ -734,6 +737,7 @@ function configureButton(form,name) case 'Length': case 'Frames': case 'AlarmFrames': + case 'TotScore': case 'AvgScore': case 'MaxScore': $filter_sql .= "E.".$$attr_name." ".$$op_name." ".$$value_name; @@ -855,9 +859,10 @@ location.href = '?view=events&mid=Time Length Frames -Alarm Frames -Avg. Score -Max. Score +Alarm
Frames
+Total
Score
+Avg.
Score
+Max.
Score
Mark ?view=events&mid= + @@ -944,7 +950,7 @@ location.href = '?view=events&mid='Date/Time', 'Date'=>'Date', 'Time'=>'Time', 'Weekday'=>'Weekday', 'Length'=>'Length', 'Frames'=>'Frames', 'AlarmFrames'=>'Alarm Frames', 'AvgScore'=>'Avg. Score', 'MaxScore'=>'Max. Score', 'Archived'=>'Archive Status' ); + $attr_types = array( 'DateTime'=>'Date/Time', 'Date'=>'Date', 'Time'=>'Time', 'Weekday'=>'Weekday', 'Length'=>'Length', 'Frames'=>'Frames', 'AlarmFrames'=>'Alarm Frames', 'TotScore'=>'Total Score', 'AvgScore'=>'Avg. Score', 'MaxScore'=>'Max. Score', 'Archived'=>'Archive Status' ); $op_types = array( '='=>'equal to', '!='=>'not equal to', '>='=>'greater than or equal to', '>'=>'greater than', '<'=>'less than', '<='=>'less than or equal to' ); $archive_types = array( '0'=>'Unarchived Only', '1'=>'Archived Only' ); ?>