Skip to content

Commit 802a085

Browse files
Add getAnalysingStrings and getRecordingStrings and fix getStatusStrings, removing Tape
1 parent a7e25ad commit 802a085

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

web/includes/Monitor.php

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public static function getAnalysingOptions() {
4949
}
5050
return $AnalysingOptions;
5151
}
52+
public static function getAnalysingString($option) {
53+
$options = Monitor::getAnalysingOptions();
54+
return $options[$option];
55+
}
5256

5357
protected static $AnalysisSourceOptions = null;
5458
public static function getAnalysisSourceOptions() {
@@ -84,6 +88,11 @@ public static function getRecordingOptions() {
8488
return $RecordingOptions;
8589
}
8690

91+
public static function getRecordingString($option) {
92+
$options = Monitor::getRecordingOptions();
93+
return $options[$option];
94+
}
95+
8796
protected static $RecordingSourceOptions = null;
8897
public static function getRecordingSourceOptions() {
8998
if (!isset($RecordingSourceOptions)) {
@@ -114,17 +123,21 @@ public static function getDecodingOptions() {
114123
public static function getStatuses() {
115124
if (!isset($Statuses)) {
116125
$Statuses = array(
117-
-1 => 'Unknown',
118-
0 => 'Idle',
119-
1 => 'PreAlarm',
120-
2 => 'Alarm',
121-
3 => 'Alert',
122-
4 => 'Tape'
126+
0 => 'Unknown',
127+
1 => 'Idle',
128+
2 => 'PreAlarm',
129+
3 => 'Alarm',
130+
4 => 'Alert',
123131
);
124132
}
125133
return $Statuses;
126134
}
127135

136+
public static function getStateString($option) {
137+
$statuses = Monitor::getStatuses();
138+
return $statuses[$option];
139+
}
140+
128141
protected static $table = 'Monitors';
129142

130143
protected $defaults = array(
@@ -265,6 +278,11 @@ public static function getStatuses() {
265278
'AnalysisFPS' => null,
266279
'CaptureFPS' => null,
267280
'CaptureBandwidth' => null,
281+
'Capturing' => 0,
282+
'Analysing' => 0,
283+
'State' => 0,
284+
'LastEventId' => null,
285+
'EventId' => null,
268286
);
269287
private $summary_fields = array(
270288
'TotalEvents' => array('type'=>'integer', 'default'=>null, 'do_not_update'=>1),
@@ -420,16 +438,8 @@ public function __call($fn, array $args) {
420438
return $this->defaults[$fn];
421439
} else if (array_key_exists($fn, $this->status_fields)) {
422440
if ($this->Id()) {
423-
$sql = 'SELECT * FROM `Monitor_Status` WHERE `MonitorId`=?';
424-
$row = dbFetchOne($sql, NULL, array($this->{'Id'}));
425-
if (!$row) {
426-
Warning('Unable to load Monitor status record for Id='.$this->{'Id'}.' using '.$sql);
427-
} else {
428-
foreach ($row as $k => $v) {
429-
$this->{$k} = $v;
430-
}
431-
return $this->{$fn};
432-
}
441+
$row = $this->Monitor_Status();
442+
if ($row) return $row[$fn];
433443
} # end if this->Id
434444
return null;
435445
} else if (array_key_exists($fn, $this->summary_fields)) {
@@ -452,6 +462,15 @@ public function __call($fn, array $args) {
452462
}
453463
}
454464

465+
public function Monitor_Status() {
466+
if (!property_exists($this, 'Monitor_Status')) {
467+
$sql = 'SELECT * FROM `Monitor_Status` WHERE `MonitorId`=?';
468+
$row = $this->{'Monitor_Status'} = dbFetchOne($sql, NULL, array($this->{'Id'}));
469+
if (!$row) Warning('Unable to load Monitor status record for Id='.$this->{'Id'}.' using '.$sql);
470+
}
471+
return $this->{'Monitor_Status'};
472+
}
473+
455474
public function getStreamSrc($args, $querySep='&') {
456475
$streamSrc = $this->Server()->UrlToZMS(
457476
ZM_MIN_STREAMING_PORT ?

0 commit comments

Comments
 (0)