Allows users to set an specific "Onvif alarm text" for each monitor (#3535)

* Allows users to set an specific "Onvif alarm text" for each monitor

With this personalization the cameras that use strings different to "MotionAlarm"
such as Dahua, will be able to process their Onvif alarms. To make it easier, the change
sets a default "Alarm Text"  value for it to work out of the box and then allows to
modify it according to the particular necessities of each brand. It consists of
a new column on table Monitors, changes on Monitors.h, Monitors.cpp and a change
on UI to manage the value of Alarm Text per camera.

Updated es_la.php language file.

Co-authored-by: ovargasp <ovargasp@hoitmail.com>
pull/3538/head
ovargasp 2022-07-20 11:51:13 -06:00 committed by GitHub
parent 2c32d09759
commit 981769b9db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 5 deletions

1
db/monitors_dbupdate.sql Normal file
View File

@ -0,0 +1 @@
ALTER TABLE zm.Monitors ADD Onvif_Alarm_Txt varchar(30) DEFAULT 'MotionAlarm' NULL;

View File

@ -95,10 +95,11 @@ std::string load_monitor_sql =
"`ImageBufferCount`, `MaxImageBufferCount`, `WarmupCount`, `PreEventCount`, `PostEventCount`, `StreamReplayBuffer`, `AlarmFrameCount`, "
"`SectionLength`, `MinSectionLength`, `FrameSkip`, `MotionFrameSkip`, "
"`FPSReportInterval`, `RefBlendPerc`, `AlarmRefBlendPerc`, `TrackMotion`, `Exif`,"
"`RTSPServer`, `RTSPStreamName`,"
"`RTSPServer`, `RTSPStreamName`, `ONVIF_Alarm_Txt`,"
"`ONVIF_URL`, `ONVIF_Username`, `ONVIF_Password`, `ONVIF_Options`, `ONVIF_Event_Listener`, `use_Amcrest_API`, "
"`SignalCheckPoints`, `SignalCheckColour`, `Importance`-1, ZoneCount FROM `Monitors`";
std::string CameraType_Strings[] = {
"Unknown",
"Local",
@ -229,6 +230,7 @@ Monitor::Monitor()
embed_exif(false),
rtsp_server(false),
rtsp_streamname(""),
onvif_alarm_txt(""),
importance(0),
zone_count(0),
capture_max_fps(0),
@ -494,6 +496,9 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
/* "`RTSPServer`,`RTSPStreamName`, */
rtsp_server = (*dbrow[col] != '0'); col++;
rtsp_streamname = dbrow[col]; col++;
// get alarm text from table.
onvif_alarm_txt = std::string(dbrow[col] ? dbrow[col] : ""); col++;
/* "`ONVIF_URL`, `ONVIF_Username`, `ONVIF_Password`, `ONVIF_Options`, `ONVIF_Event_Listener`, `use_Amcrest_API`, " */
onvif_url = std::string(dbrow[col] ? dbrow[col] : ""); col++;
@ -1705,7 +1710,7 @@ bool Monitor::Poll() {
Debug(1, "Got Good Response! %i", result);
for (auto msg : tev__PullMessagesResponse.wsnt__NotificationMessage) {
if (msg->Topic->__any.text != NULL &&
std::strstr(msg->Topic->__any.text, "MotionAlarm") &&
std::strstr(msg->Topic->__any.text, onvif_alarm_txt.c_str()) &&
msg->Message.__any.elts != NULL &&
msg->Message.__any.elts->next != NULL &&
msg->Message.__any.elts->next->elts != NULL &&
@ -2065,7 +2070,7 @@ bool Monitor::Analyse() {
(event_close_mode == CLOSE_ALARM));
}
if ((!pre_event_count) || (Event::PreAlarmCount() >= alarm_frame_count-1)) {
Info("%s: %03d - Gone into alarm state PreAlarmCount: %u > AlarmFrameCount:%u Cause:%s",
Info("%s: %03d - ExtAlm - Gone into alarm state PreAlarmCount: %u > AlarmFrameCount:%u Cause:%s",
name.c_str(), snap->image_index, Event::PreAlarmCount(), alarm_frame_count, cause.c_str());
shared_data->state = state = ALARM;
@ -2078,7 +2083,7 @@ bool Monitor::Analyse() {
Debug(1, "%s: %03d - Alarmed frame while in alert state. Consecutive alarmed frames left to return to alarm state: %03d",
name.c_str(), analysis_image_count, alert_to_alarm_frame_count);
if (alert_to_alarm_frame_count == 0) {
Info("%s: %03d - Gone back into alarm state", name.c_str(), analysis_image_count);
Info("%s: %03d - ExtAlm - Gone back into alarm state Cause:ONVIF", name.c_str(), analysis_image_count);
shared_data->state = state = ALARM;
}
} else if (state == TAPE) {

View File

@ -457,6 +457,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
std::string onvif_alarm_txt; // def onvif_alarm_txt
int importance; // Importance of this monitor, affects Connection logging errors.
unsigned int zone_count;

View File

@ -154,6 +154,7 @@ public static function getStatuses() {
'ONVIF_Username' => '',
'ONVIF_Password' => '',
'ONVIF_Options' => '',
'Onvif_Alarm_Txt' => '',
'ONVIF_Event_Listener' => '0',
'use_Amcrest_API' => '0',
'Device' => '',

View File

@ -907,7 +907,7 @@ $SLANG = array(
'Showing Analysis' => 'Mostrar Analisis',
'ConfirmDeleteTitle' => 'Borrar Seleccionados',
'Continuous' => 'Continuo',
'ONVIF_Alarm_Txt' => 'Texto Alarma ONVIF', //added 18/07/2022
);

View File

@ -578,6 +578,10 @@ switch ($name) {
<td class="text-right pr-3"><?php echo translate('ONVIF_Options') ?></td>
<td><input type="text" name="newMonitor[ONVIF_Options]" value="<?php echo validHtmlStr($monitor->ONVIF_Options()) ?>"/></td>
</tr>
<tr>
<td class="text-right pr-3"><?php echo translate('ONVIF_Alarm_Txt') ?></td>
<td><input type="text" name="newMonitor[Onvif_Alarm_Txt]" value="<?php echo validHtmlStr($monitor->Onvif_Alarm_Txt()) ?>"/></td>
</tr>
<tr>
<td class="text-right pr-3"><?php echo translate('ONVIF_Event_Listener') ?></td>
<td><?php echo html_radio('newMonitor[ONVIF_Event_Listener]', array('1'=>translate('Enabled'), '0'=>translate('Disabled')), $monitor->ONVIF_Event_Listener()); ?></td>