diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 4bbe2d821..8343443a3 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -538,6 +538,7 @@ CREATE TABLE `Monitors` ( `Longitude` DECIMAL(10,8), `RTSPServer` BOOLEAN NOT NULL DEFAULT FALSE, `RTSPStreamName` varchar(255) NOT NULL default '', + `Importance` enum('Not','Less','Normal'), PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/db/zm_update-1.35.25.sql b/db/zm_update-1.35.25.sql new file mode 100644 index 000000000..387ef09b0 --- /dev/null +++ b/db/zm_update-1.35.25.sql @@ -0,0 +1,144 @@ +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'TotalEvents' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `TotalEvents`", +"SELECT 'Column TotalEvents already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'TotalEventDiskSpace' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `TotalEventDiskSpace`", +"SELECT 'Column TotalEventDiskSpace already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'HourEvents' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `HourEvents`", +"SELECT 'Column HourEvents already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'HourEventDiskSpace' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `HourEventDiskSpace`", +"SELECT 'Column HourEventDiskSpace already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'DayEvents' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `DayEvents`", +"SELECT 'Column DayEvents already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'DayEvents' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `DayEventDiskSpace`", +"SELECT 'Column DayEventDiskSpace already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'WeekEvents' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `WeekEvents`", +"SELECT 'Column WeekEvents already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'WeekEventDiskSpace' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `WeekEventDiskSpace`", +"SELECT 'Column WeekEventDiskSpace already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'MonthEvents' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `MonthEvents`", +"SELECT 'Column MonthEvents already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'MonthEventDiskSpace' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `MonthEventDiskSpace`", +"SELECT 'Column MonthEventDiskSpace already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'ArchivedEvents' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `ArchivedEvents`", +"SELECT 'Column ArchivedEvents already removed from Monitor_Status'" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + AND column_name = 'ArchivedEventDiskSpace' + ) > 0, +"ALTER TABLE `Monitor_Status` DROP `ArchivedEventDiskSpace`", +"SELECT 'Column ArchivedEventDiskSpace already removed from Monitor_Status'" +)); +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 = 'Importance' + ) > 0, +"SELECT 'Column Importance already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `Importance` enum('Not','Less','Normal') AFTER `RTSPStreamName`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 458d74a87..35102c416 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -356,6 +356,7 @@ Monitor::Monitor() embed_exif(0), rtsp_server(0), rtsp_streamname(""), + importance(0), capture_max_fps(0), purpose(QUERY), last_camera_bytes(0), @@ -442,7 +443,7 @@ Monitor::Monitor() "SectionLength, MinSectionLength, FrameSkip, MotionFrameSkip, " "FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif," "`RTSPServer`,`RTSPStreamName`, - "SignalCheckPoints, SignalCheckColour FROM Monitors"; + "SignalCheckPoints, SignalCheckColour, Importance-2 FROM Monitors"; */ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) { @@ -588,6 +589,7 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) { rtsp_streamname = dbrow[col]; col++; signal_check_points = atoi(dbrow[col]); col++; signal_check_colour = strtol(dbrow[col][0] == '#' ? dbrow[col]+1 : dbrow[col], 0, 16); col++; + importance = atoi(dbrow[col]); col++; // How many frames we need to have before we start analysing ready_count = std::max(warmup_count, pre_event_count); @@ -3201,9 +3203,6 @@ int Monitor::PrimeCapture() { } else { analysis_thread->Start(); } - - } else { - Debug(2, "Failed to prime %d", ret); } return ret; } // end int Monitor::PrimeCapture() diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 04fde6301..29f03d512 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -319,6 +319,7 @@ protected: bool embed_exif; // Whether to embed Exif data into each image frame or not bool rtsp_server; // Whether to include this monitor as an rtsp server stream std::string rtsp_streamname; // path in the rtsp url for this monitor + int importance; // Importance of this monitor, affects Connection logging errors. int capture_max_fps; @@ -592,6 +593,7 @@ public: double get_analysis_fps( ) const { return shared_data ? shared_data->analysis_fps : 0.0; } + int Importance() { return importance; } }; #define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit)) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 7526868db..f65211e0d 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -1252,6 +1252,19 @@ echo htmlSelect('newMonitor[ReturnLocation]', $return_options, $monitor->ReturnL