178 lines
5.9 KiB
PHP
178 lines
5.9 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* This class looks after Ness D8/Clipsal panel events
|
|
*
|
|
* @package HAlMon
|
|
* @category Helpers
|
|
* @author Deon George
|
|
* @copyright (c) 2010 Deon George
|
|
* @license http://dev.leenooks.net/license.html
|
|
*/
|
|
class Panel_NessD8 extends Panel {
|
|
public function __toString() {
|
|
try {
|
|
return ($this->_eo->type() !== '18') ? 'Unkown Alarm: '.$this->_eo->event() : $this->event();
|
|
} catch (exception $e) {
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
|
|
private function area() {
|
|
$x = $this->_ao->panelzone->where('zoneid','=',$this->_eo->area())->find();
|
|
return $x->loaded() ? $x->description : 'Area '.$this->_eo->area();
|
|
}
|
|
|
|
public function event() {
|
|
switch ($this->_eo->etype()) {
|
|
// Medical
|
|
case 100:
|
|
return (($this->_eo->equal() == 1) AND ($this->_eo->area() == '01') AND ($this->_eo->info() == '033')) ? 'Medical Alarm' : 'Unknown Alarm '.$this->_eo->etype();
|
|
|
|
// Fire
|
|
case 110:
|
|
return (($this->_eo->equal() == 1) AND ($this->_eo->area() == '01') AND ($this->_eo->info() == '034')) ? 'Fire Alarm' : 'Unknown Alarm '.$this->_eo->etype();
|
|
|
|
// Panic
|
|
case 120:
|
|
switch ($this->_eo->info()) {
|
|
case '031': return ($this->_eo->area() == '01') ? 'Keyswitch Panic' : 'Unknown Panic Alarm '.$this->_eo->area();
|
|
case '032': return ($this->_eo->area() == '01') ? 'Keypad Panic' : 'Unknown Panic Alarm '.$this->_eo->area();
|
|
default: return ($this->_eo->area() == '01') ? 'Radio Key Panic: '.$this->_eo->info() : 'Unknown Panic Alarm '.$this->_eo->area();
|
|
}
|
|
|
|
// Duress Alarm
|
|
case 121:
|
|
return (($this->_eo->equal() == 1) AND ($this->_eo->area() == '01') AND ($this->_eo->info() == '030')) ? 'Duress Alaram' : 'Unknown Alarm '.$this->_eo->etype();
|
|
|
|
// Alarm
|
|
case 130:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Alarm'; break;
|
|
case 3: $action = 'Reset'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
return sprintf('Alarm %s (Area: %s) (Zone: %s)',$action,$this->area(),$this->zone());
|
|
|
|
// Mains Fail
|
|
case 301:
|
|
return (($this->_eo->equal() == 1) AND ($this->_eo->area() == '01') AND ($this->_eo->info() == '050')) ? 'Mains Fail' : 'Unknown Alarm '.$this->_eo->etype();
|
|
|
|
// Exit Installer Mode
|
|
case 306:
|
|
return (($this->_eo->equal() == 1) AND ($this->_eo->area() == '01') AND ($this->_eo->info() == '035')) ? 'Exit Install Mode' : 'Unknown Alarm '.$this->_eo->etype();
|
|
|
|
// Tamper
|
|
case 307:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Alarm'; break;
|
|
case 3: $action = 'Reset'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
switch ($this->_eo->info()) {
|
|
case '040': return ($this->_eo->area() == '01') ? sprintf('External Tamper %s',$action) : 'Unknown Tamper Alarm '.$this->_eo->area();
|
|
case '041': return ($this->_eo->area() == '01') ? sprintf('Internal Tamper %s',$action) : 'Unknown Tamper Alarm '.$this->_eo->area();
|
|
case '042': return ($this->_eo->area() == '01') ? sprintf('keypad Tamper %s',$action) : 'Unknown Tamper Alarm '.$this->_eo->area();
|
|
default: return 'Unknown Tamper Alarm '.$this->_eo->info();
|
|
}
|
|
|
|
// Panel Battery Fail
|
|
case 309:
|
|
return (($this->_eo->equal() == 1) AND ($this->_eo->area() == '01') AND ($this->_eo->info() == '051')) ? 'Panel Battery Fail' : 'Unknown Alarm '.$this->_eo->etype();
|
|
|
|
// Auto Exclude
|
|
case 380:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Start'; break;
|
|
case 3: $action = 'Stop'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
return sprintf('Auto Exclude %s (Area: %s) (Zone: %s)',$action,$this->area(),$this->zone());
|
|
|
|
// Radio Sensor Supervision
|
|
case 381:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Start'; break;
|
|
case 3: $action = 'Stop'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
return sprintf('Radio Sensor Supervision %s (Zone: %s)',$action,$this->_eo->info());
|
|
|
|
// Radio Sensor Tamper
|
|
case 383:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Start'; break;
|
|
case 3: $action = 'Stop'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
return sprintf('Radio Sensor Tamper %s (Zone: %s)',$action,$this->_eo->info());
|
|
|
|
// Radio Sensor Low Battery
|
|
case 384:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Start'; break;
|
|
case 3: $action = 'Stop'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
return sprintf('Radio Sensor Low Battery %s (Zone: %s)',$action,$this->_eo->info());
|
|
|
|
// Arm/Disarm Call
|
|
case 402:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Disarmed'; break;
|
|
case 3: $action = 'Armed'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
return sprintf('Panel %s (Area: %s) (By: %s)',$action,$this->area(),$this->user());
|
|
|
|
// Force Arm/Disarm Call
|
|
case 406:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Disarmed'; break;
|
|
case 3: $action = 'Armed'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
return sprintf('Force Panel %s (Area: %s) (By: %s)',$action,$this->area(),$this->user());
|
|
|
|
// Manual Exclude
|
|
case 573:
|
|
switch ($this->_eo->equal()) {
|
|
case 1: $action = 'Start'; break;
|
|
case 3: $action = 'Stop'; break;
|
|
default: $action = 'Unknown';
|
|
}
|
|
|
|
return sprintf('Manual Exclude %s (Area: %s) (Zone: %s)',$action,$this->area(),$this->zone());
|
|
|
|
// Test Call
|
|
case 602:
|
|
return (($this->_eo->equal() == 1) AND ($this->_eo->area() == '01') AND ($this->_eo->info() == '063')) ? 'Test Call' : 'Unknown Alarm '.$this->_eo->etype();
|
|
|
|
default:
|
|
return 'Unkown Event Code: '.$this->_eo->etype();
|
|
}
|
|
}
|
|
|
|
public function user() {
|
|
if ($this->_eo->info()==58)
|
|
Return 'Short Cut';
|
|
|
|
$x = $this->_ao->paneluser->where('userid','=',$this->_eo->info())->find();
|
|
return $x->loaded() ? $x->username : 'User '.$this->_eo->info();
|
|
}
|
|
|
|
public function zone() {
|
|
$x = $this->_ao->panelzone->where('zoneid','=',$this->_eo->info())->find();
|
|
return $x->loaded() ? $x->username : 'Zone '.$this->_eo->info();
|
|
}
|
|
}
|
|
?>
|