Use ORM Zone Object for Zone insertion on new monitor
parent
231b0ab631
commit
b1df318491
|
@ -24,6 +24,9 @@ if (!canEdit('Monitors')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once('includes/Monitor.php');
|
||||||
|
require_once('includes/Zone.php');
|
||||||
|
|
||||||
global $error_message;
|
global $error_message;
|
||||||
|
|
||||||
if ($action == 'save') {
|
if ($action == 'save') {
|
||||||
|
@ -237,10 +240,11 @@ if ($action == 'save') {
|
||||||
$changes['Sequence'] = $maxSeq+1;
|
$changes['Sequence'] = $maxSeq+1;
|
||||||
if ( $mid ) $changes['Id'] = $mid; # mid specified in request, doesn't exist in db, will re-use slot
|
if ( $mid ) $changes['Id'] = $mid; # mid specified in request, doesn't exist in db, will re-use slot
|
||||||
|
|
||||||
|
|
||||||
if ( $monitor->insert($changes) ) {
|
if ( $monitor->insert($changes) ) {
|
||||||
$mid = $monitor->Id();
|
$mid = $monitor->Id();
|
||||||
$zoneArea = $newMonitor['Width'] * $newMonitor['Height'];
|
$zoneArea = $newMonitor['Width'] * $newMonitor['Height'];
|
||||||
dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid,
|
if (!$zone->save(['MonitorId'=>$monitor->Id(), 'Name'=>'All', 'Coords'=>
|
||||||
sprintf( '%d,%d %d,%d %d,%d %d,%d', 0, 0,
|
sprintf( '%d,%d %d,%d %d,%d %d,%d', 0, 0,
|
||||||
$newMonitor['Width']-1,
|
$newMonitor['Width']-1,
|
||||||
0,
|
0,
|
||||||
|
@ -248,13 +252,16 @@ if ($action == 'save') {
|
||||||
$newMonitor['Height']-1,
|
$newMonitor['Height']-1,
|
||||||
0,
|
0,
|
||||||
$newMonitor['Height']-1),
|
$newMonitor['Height']-1),
|
||||||
$zoneArea,
|
'Area'=>$zoneArea,
|
||||||
intval(($zoneArea*3)/100),
|
'MinAlarmPixels'=>intval(($zoneArea*1)/100),
|
||||||
intval(($zoneArea*75)/100),
|
'MaxAlarmPixels'=>intval(($zoneArea*75)/100),
|
||||||
intval(($zoneArea*3)/100),
|
'MinFilterPixels'=>intval(($zoneArea*1)/100),
|
||||||
intval(($zoneArea*75)/100),
|
'MaxFilterPixels'=>intval(($zoneArea*75)/100),
|
||||||
intval(($zoneArea*2)/100)
|
'MinBlobPixels'=>intval(($zoneArea*1)/100)
|
||||||
));
|
])) {
|
||||||
|
$error_message .= $zone->get_last_error();
|
||||||
|
ZM\Error('Error adding zone:' . $error_message);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ZM\Error('Error saving new Monitor.');
|
ZM\Error('Error saving new Monitor.');
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue