Merge branch 'add_startup_delay' of github.com:ZoneMinder/zoneminder into add_startup_delay

This commit is contained in:
Isaac Connor
2024-03-18 22:15:44 -04:00
7 changed files with 30 additions and 3 deletions

View File

@@ -617,6 +617,7 @@ CREATE TABLE `Monitors` (
`Importance` enum('Normal','Less','Not') NOT NULL default 'Normal',
`MQTT_Enabled` BOOLEAN NOT NULL DEFAULT false,
`MQTT_Subscriptions` varchar(255) default '',
`StartupDelay` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`Id`)
) ENGINE=@ZM_MYSQL_ENGINE@;

18
db/zm_update-1.37.56.sql Normal file
View File

@@ -0,0 +1,18 @@
--
-- Update Monitors table to have StartupDelay
--
SELECT 'Checking for StartupDelay in Monitors';
SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'Monitors'
AND table_schema = DATABASE()
AND column_name = 'StartupDelay'
) > 0,
"SELECT 'Column StartupDelay already exists on Monitors'",
"ALTER TABLE Monitors ADD `StartupDelay` INT NOT NULL DEFAULT 0 AFTER `MQTT_Subscriptions`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;

View File

@@ -18,7 +18,7 @@
%global zmtargetdistro %{?rhel:el%{rhel}}%{!?rhel:fc%{fedora}}
Name: zoneminder
Version: 1.37.55
Version: 1.37.56
Release: 2%{?dist}
Summary: A camera monitoring and analysis tool
Group: System Environment/Daemons

View File

@@ -111,6 +111,7 @@ std::string load_monitor_sql =
#if MOSQUITTOPP_FOUND
", `MQTT_Enabled`, `MQTT_Subscriptions`"
#endif
", `StartupDelay`"
" FROM `Monitors`";
std::string CameraType_Strings[] = {
@@ -365,7 +366,7 @@ Monitor::Monitor() :
"FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif,"
"`RTSPServer`, `RTSPStreamName`, `SOAP_wsa_compl`,"
"`ONVIF_URL`, `ONVIF_Username`, `ONVIF_Password`, `ONVIF_Options`, `ONVIF_Event_Listener`, `use_Amcrest_API`, "
"SignalCheckPoints, SignalCheckColour, Importance-1, ZoneCount, `MQTT_Enabled`, `MQTT_Subscriptions` FROM Monitors";
"SignalCheckPoints, SignalCheckColour, Importance-1, ZoneCount, `MQTT_Enabled`, `MQTT_Subscriptions`, StartupDelay FROM Monitors";
*/
void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
@@ -620,6 +621,7 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
mqtt_subscriptions = Split(mqtt_subscriptions_string, ','); col++;
Error("MQTT enabled ? %d, subs %s", mqtt_enabled, mqtt_subscriptions_string.c_str());
#endif
startup_delay = dbrow[col] ? atoi(dbrow[col]) : 0; col++;
// How many frames we need to have before we start analysing
ready_count = std::max(warmup_count, pre_event_count);

View File

@@ -509,6 +509,7 @@ protected:
bool soap_wsa_compl; // Whether the camera supports soap_wsa or not.
std::string onvif_alarm_txt; // def onvif_alarm_txt
int importance; // Importance of this monitor, affects Connection logging errors.
int startup_delay; // Seconds to sleep before connecting to camera
unsigned int zone_count;
int capture_max_fps;
@@ -909,6 +910,7 @@ public:
return shared_data ? shared_data->analysis_fps : 0.0;
}
int Importance() const { return importance; }
int StartupDelay() const { return startup_delay; }
};
#define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit))

View File

@@ -252,6 +252,10 @@ int main(int argc, char *argv[]) {
monitor->Id());
zmDbDo(sql);
if (monitor->StartupDelay() > 0) {
Debug(1, "Doing startup sleep for %ds", monitor->StartupDelay());
std::this_thread::sleep_for(Seconds(monitor->StartupDelay()));
}
Seconds sleep_time = Seconds(0);
while ((monitor->PrimeCapture() <= 0) and !zm_terminate) {

View File

@@ -1 +1 @@
1.37.55
1.37.56