From 802a0854b522545cdf40807e3174ed25ce9da9c3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 18 Aug 2024 12:17:21 -0400 Subject: [PATCH] Add getAnalysingStrings and getRecordingStrings and fix getStatusStrings, removing Tape --- web/includes/Monitor.php | 51 +++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index 03cc720a44..c73575631d 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -49,6 +49,10 @@ public static function getAnalysingOptions() { } return $AnalysingOptions; } +public static function getAnalysingString($option) { + $options = Monitor::getAnalysingOptions(); + return $options[$option]; +} protected static $AnalysisSourceOptions = null; public static function getAnalysisSourceOptions() { @@ -84,6 +88,11 @@ public static function getRecordingOptions() { return $RecordingOptions; } +public static function getRecordingString($option) { + $options = Monitor::getRecordingOptions(); + return $options[$option]; +} + protected static $RecordingSourceOptions = null; public static function getRecordingSourceOptions() { if (!isset($RecordingSourceOptions)) { @@ -114,17 +123,21 @@ public static function getDecodingOptions() { public static function getStatuses() { if (!isset($Statuses)) { $Statuses = array( - -1 => 'Unknown', - 0 => 'Idle', - 1 => 'PreAlarm', - 2 => 'Alarm', - 3 => 'Alert', - 4 => 'Tape' + 0 => 'Unknown', + 1 => 'Idle', + 2 => 'PreAlarm', + 3 => 'Alarm', + 4 => 'Alert', ); } return $Statuses; } +public static function getStateString($option) { + $statuses = Monitor::getStatuses(); + return $statuses[$option]; +} + protected static $table = 'Monitors'; protected $defaults = array( @@ -265,6 +278,11 @@ public static function getStatuses() { 'AnalysisFPS' => null, 'CaptureFPS' => null, 'CaptureBandwidth' => null, + 'Capturing' => 0, + 'Analysing' => 0, + 'State' => 0, + 'LastEventId' => null, + 'EventId' => null, ); private $summary_fields = array( 'TotalEvents' => array('type'=>'integer', 'default'=>null, 'do_not_update'=>1), @@ -420,16 +438,8 @@ public function __call($fn, array $args) { return $this->defaults[$fn]; } else if (array_key_exists($fn, $this->status_fields)) { if ($this->Id()) { - $sql = 'SELECT * FROM `Monitor_Status` WHERE `MonitorId`=?'; - $row = dbFetchOne($sql, NULL, array($this->{'Id'})); - if (!$row) { - Warning('Unable to load Monitor status record for Id='.$this->{'Id'}.' using '.$sql); - } else { - foreach ($row as $k => $v) { - $this->{$k} = $v; - } - return $this->{$fn}; - } + $row = $this->Monitor_Status(); + if ($row) return $row[$fn]; } # end if this->Id return null; } else if (array_key_exists($fn, $this->summary_fields)) { @@ -452,6 +462,15 @@ public function __call($fn, array $args) { } } + public function Monitor_Status() { + if (!property_exists($this, 'Monitor_Status')) { + $sql = 'SELECT * FROM `Monitor_Status` WHERE `MonitorId`=?'; + $row = $this->{'Monitor_Status'} = dbFetchOne($sql, NULL, array($this->{'Id'})); + if (!$row) Warning('Unable to load Monitor status record for Id='.$this->{'Id'}.' using '.$sql); + } + return $this->{'Monitor_Status'}; + } + public function getStreamSrc($args, $querySep='&') { $streamSrc = $this->Server()->UrlToZMS( ZM_MIN_STREAMING_PORT ?