:Merge branch 'storageareas' into zma_to_thread

Conflicts:
	src/zm_ffmpeg_camera.cpp
	src/zm_monitor.cpp
This commit is contained in:
Isaac Connor 2018-01-24 11:55:32 -05:00
commit 71263c525b
8 changed files with 88 additions and 9 deletions

View File

@ -608,9 +608,6 @@ CREATE TABLE `Monitors` (
`WebColour` varchar(32) NOT NULL default 'red', `WebColour` varchar(32) NOT NULL default 'red',
`Exif` tinyint(1) unsigned NOT NULL default '0', `Exif` tinyint(1) unsigned NOT NULL default '0',
`Sequence` smallint(5) unsigned default NULL, `Sequence` smallint(5) unsigned default NULL,
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
`TotalEvents` int(10) unsigned, `TotalEvents` int(10) unsigned,
`TotalEventDiskSpace` bigint unsigned, `TotalEventDiskSpace` bigint unsigned,
`HourEvents` int(10) unsigned, `HourEvents` int(10) unsigned,
@ -629,6 +626,14 @@ CREATE TABLE `Monitors` (
CREATE INDEX `Monitors_ServerId_idx` ON `Monitors` (`ServerId`); CREATE INDEX `Monitors_ServerId_idx` ON `Monitors` (`ServerId`);
DROP TABLE IF EXISTS `Monitor_Status`;
CREATE TABLE `Monitor_Status` (
`Id` int(10) unsigned NOT NULL,
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
PRIMARY KEY (`Id`)
) ENGINE=MEMORY;
-- --
-- Table structure for table `States` -- Table structure for table `States`
-- PP - Added IsActive to track custom run states -- PP - Added IsActive to track custom run states

57
db/zm_update-1.31.28.sql Normal file
View File

@ -0,0 +1,57 @@
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitor_Status'
) > 0
,
"SELECT 'Monitor_Status Already exists'",
"
CREATE TABLE `Monitor_Status` (
`Id` int(10) unsigned NOT NULL,
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
PRIMARY KEY (`Id`)
) ENGINE=MEMORY"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitors'
AND column_name = 'Status'
) > 0
,
"ALTER TABLE Monitors DROP COLUMN Status"
"SELECT 'Monitor Status already removed.'",
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitors'
AND column_name = 'CaptureFPS'
) > 0
,
"ALTER TABLE Monitors DROP COLUMN CaptureFPS"
"SELECT 'Monitor CaptureFPS already removed.'",
));
PREPARE stmt FROM @s;
EXECUTE stmt;
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Monitors'
AND column_name = 'AnalysisFPS'
) > 0
,
"ALTER TABLE Monitors DROP COLUMN AnalysisFPS"
"SELECT 'Monitor AnalysisFPS already removed.'",
));
PREPARE stmt FROM @s;
EXECUTE stmt;

View File

@ -357,6 +357,9 @@ sub delete {
my $res = $sth->execute( $event->{Id} ) my $res = $sth->execute( $event->{Id} )
or Error( "Can't execute '$sql': ".$sth->errstr() ); or Error( "Can't execute '$sql': ".$sth->errstr() );
$sth->finish(); $sth->finish();
if ( $ZoneMinder::Database::dbh->errstr() ) {
return;
}
$sql = 'DELETE FROM Stats WHERE EventId=?'; $sql = 'DELETE FROM Stats WHERE EventId=?';
$sth = $ZoneMinder::Database::dbh->prepare_cached( $sql ) $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
@ -364,6 +367,9 @@ sub delete {
$res = $sth->execute( $event->{Id} ) $res = $sth->execute( $event->{Id} )
or Error( "Can't execute '$sql': ".$sth->errstr() ); or Error( "Can't execute '$sql': ".$sth->errstr() );
$sth->finish(); $sth->finish();
if ( $ZoneMinder::Database::dbh->errstr() ) {
return;
}
$event->delete_files( ); $event->delete_files( );
} else { } else {

View File

@ -1229,7 +1229,7 @@ void Monitor::UpdateAnalysisFPS() {
analysis_fps = double(fps_report_interval)/(now.tv_sec - last_analysis_fps_time); analysis_fps = double(fps_report_interval)/(now.tv_sec - last_analysis_fps_time);
Info( "%s: %d - Analysing at %.2f fps", name, image_count, analysis_fps ); Info( "%s: %d - Analysing at %.2f fps", name, image_count, analysis_fps );
static char sql[ZM_SQL_SML_BUFSIZ]; static char sql[ZM_SQL_SML_BUFSIZ];
snprintf( sql, sizeof(sql), "UPDATE Monitors SET AnalysisFPS = '%.2lf' WHERE Id = '%d'", analysis_fps, id ); snprintf( sql, sizeof(sql), "INSERT INTO Monitor_Status (Id,AnalysisFPS) VALUES (%d, %.2lf) ON DUPLICATE KEY UPDATE AnalysisFPS = %.2lf", id, fps, fps );
if ( mysql_query( &dbconn, sql ) ) { if ( mysql_query( &dbconn, sql ) ) {
Error( "Can't run query: %s", mysql_error( &dbconn ) ); Error( "Can't run query: %s", mysql_error( &dbconn ) );
} }
@ -2941,7 +2941,7 @@ int Monitor::Capture() {
Info( "%s: %d - Capturing at %.2lf fps", name, image_count, capture_fps ); Info( "%s: %d - Capturing at %.2lf fps", name, image_count, capture_fps );
last_fps_time = now; last_fps_time = now;
static char sql[ZM_SQL_SML_BUFSIZ]; static char sql[ZM_SQL_SML_BUFSIZ];
snprintf( sql, sizeof(sql), "UPDATE Monitors SET CaptureFPS='%.2lf' WHERE Id=%d", capture_fps, id ); snprintf( sql, sizeof(sql), "INSERT INTO Monitor_Status (Id,CaptureFPS) VALUES (%d, %.2lf) ON DUPLICATE KEY UPDATE CaptureFPS = %.2lf", id, fps, fps );
if ( mysql_query( &dbconn, sql ) ) { if ( mysql_query( &dbconn, sql ) ) {
Error( "Can't run query: %s", mysql_error( &dbconn ) ); Error( "Can't run query: %s", mysql_error( &dbconn ) );
} }

View File

@ -224,7 +224,7 @@ int main(int argc, char *argv[]) {
Info("Starting Capture version %s", ZM_VERSION); Info("Starting Capture version %s", ZM_VERSION);
static char sql[ZM_SQL_SML_BUFSIZ]; static char sql[ZM_SQL_SML_BUFSIZ];
for ( int i = 0; i < n_monitors; i ++ ) { for ( int i = 0; i < n_monitors; i ++ ) {
snprintf( sql, sizeof(sql), "UPDATE Monitors SET Status = 'Running' WHERE Id = '%d'", monitors[i]->Id() ); snprintf( sql, sizeof(sql), "REPLACE INTO Monitor_Status (Id, Status ) VALUES ('%d','Running')", monitors[i]->Id() );
if ( mysql_query( &dbconn, sql ) ) { if ( mysql_query( &dbconn, sql ) ) {
Error( "Can't run query: %s", mysql_error( &dbconn ) ); Error( "Can't run query: %s", mysql_error( &dbconn ) );
} }

View File

@ -1 +1 @@
1.31.27 1.31.28

View File

@ -89,7 +89,7 @@ if ( ! is_array( $selected_monitor_ids ) ) {
$values += $ids; $values += $ids;
} }
$sql = 'SELECT * FROM Monitors' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC'; $sql = 'SELECT *,S.Status AS Status, S.CaptureFPS AS CaptureFPS FROM Monitors AS M LEFT JOIN Monitor_Status AS S ON S.Id=M.Id ' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
$monitors = dbFetchAll( $sql, null, $values ); $monitors = dbFetchAll( $sql, null, $values );
$displayMonitors = array(); $displayMonitors = array();
$monitors_dropdown = array(); $monitors_dropdown = array();

View File

@ -213,7 +213,18 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
<td class="colName"><a <?php echo (canView('Stream') && $monitor['Function'] != 'None' ? 'href="?view=watch&amp;mid='.$monitor['Id'].'">' : '>') . $monitor['Name'] ?></a></td> <td class="colName"><a <?php echo (canView('Stream') && $monitor['Function'] != 'None' ? 'href="?view=watch&amp;mid='.$monitor['Id'].'">' : '>') . $monitor['Name'] ?></a></td>
<td class="colFunction"> <td class="colFunction">
<?php echo makePopupLink( '?view=function&amp;mid='.$monitor['Id'], 'zmFunction', 'function', '<span class="'.$fclass.'">'.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'</span>', canEdit( 'Monitors' ) ) ?><br/> <?php echo makePopupLink( '?view=function&amp;mid='.$monitor['Id'], 'zmFunction', 'function', '<span class="'.$fclass.'">'.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'</span>', canEdit( 'Monitors' ) ) ?><br/>
<?php echo $monitor['CaptureFPS'] . ( ( $monitor['Function'] == 'Mocord' or $monitor['Function'] == 'Modect' ) ? ' / ' . $monitor['AnalysisFPS'] : '' ) . ' FPS' ?> <?php
$fps_string = '';
if ( isset($monitor['CaptureFPS']) ) {
$fps_string .= $monitor['CaptureFPS'];
}
if ( isset($monitor['AnalysisFPS']) and ( $monitor['Function'] == 'Mocord' or $monitor['Function'] == 'Modect' ) ) {
$fps_string .= ' / ' . $monitor['AnalysisFPS'];
}
if ($fps_string) $fps_string .= ' FPS';
echo $fps_string;
?>
</td> </td>
<?php <?php
if ( count($servers) ) { ?> if ( count($servers) ) { ?>