Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Jan 25, 2024
1 parent 23c80e9 commit 027266f
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 223 deletions.
62 changes: 29 additions & 33 deletions ONVIF Digital Input/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,6 @@ public function Create()
parent::Create();
$this->RegisterAttributeArray(\ONVIF\Input\Attribute::DigitalInputs, []);
}
public function ApplyChanges()
{
//Never delete this line!
parent::ApplyChanges();
if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}
if ($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic) == '') {
$this->SetStatus(IS_INACTIVE);
return;
}
if ($this->HasActiveParent()) {
$Capabilities = @$this->GetCapabilities();
if (!$Capabilities) {
$this->SetStatus(IS_EBASE + 1);
return;
}
$this->WriteAttributeArray(\ONVIF\Input\Attribute::DigitalInputs, $Capabilities['DigitalInputs']);
foreach ($Capabilities['DigitalInputs'] as $Name => $DigitalInput) {
$Ident = str_replace([' - ', ':'], ['_', ''], (string) $Name);
$Ident = preg_replace('/[^a-zA-Z\d]/u', '_', $Ident);
$this->RegisterVariableBoolean($Ident, $Name, '~Switch', 0);
}

$Events = $this->GetEvents($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic));
$this->SendDebug('EventConfig', $Events, 0);
if (count($Events) != 1) {
$this->SetStatus(IS_EBASE + 1);
} else {
$this->SetStatus(IS_ACTIVE);
}
}
}

public function ReceiveData($JSONString)
{
Expand Down Expand Up @@ -120,4 +87,33 @@ public function GetConfigurationForm()

return json_encode($Form);
}
protected function InitFilterAndEvents()
{
parent::InitFilterAndEvents();
if ($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic) == '') {
$this->SetStatus(IS_INACTIVE);
return;
}
if ($this->HasActiveParent()) {
$Capabilities = @$this->GetCapabilities();
if (!$Capabilities) {
$this->SetStatus(IS_EBASE + 1);
return;
}
$this->WriteAttributeArray(\ONVIF\Input\Attribute::DigitalInputs, $Capabilities['DigitalInputs']);
foreach ($Capabilities['DigitalInputs'] as $Name => $DigitalInput) {
$Ident = str_replace([' - ', ':'], ['_', ''], (string) $Name);
$Ident = preg_replace('/[^a-zA-Z\d]/u', '_', $Ident);
$this->RegisterVariableBoolean($Ident, $Name, '~Switch', 0);
}

$Events = $this->GetEvents($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic));
$this->SendDebug('EventConfig', $Events, 0);
if (count($Events) != 1) {
$this->SetStatus(IS_EBASE + 1);
} else {
$this->SetStatus(IS_ACTIVE);
}
}
}
}
80 changes: 38 additions & 42 deletions ONVIF Digital Output/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,6 @@ public function Create()
$this->RegisterAttributeArray(\ONVIF\Output\Attribute::RelayOutputs, []);
}

public function ApplyChanges()
{
//Never delete this line!
parent::ApplyChanges();
if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}
if ($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic) == '') {
$this->SetStatus(IS_INACTIVE);
return;
}
if ($this->HasActiveParent()) {
$Capabilities = @$this->GetCapabilities();
if (!$Capabilities) {
$this->SetStatus(IS_EBASE + 1);
return;
}
if ($Capabilities['XAddr'][\ONVIF\NS::DeviceIO]) {
$this->xAddr = $Capabilities['XAddr'][\ONVIF\NS::DeviceIO];
$this->wsdl = \ONVIF\WSDL::DeviceIO;
} else {
$this->xAddr = $Capabilities['XAddr'][\ONVIF\NS::Management];
$this->wsdl = \ONVIF\WSDL::Management;
}
$this->WriteAttributeArray(\ONVIF\Output\Attribute::RelayOutputs, $Capabilities['RelayOutputs']);
foreach ($Capabilities['RelayOutputs'] as $Name => $RelayOutput) {
$Ident = str_replace([' - ', ':'], ['_', ''], (string) $Name);
$Ident = preg_replace('/[^a-zA-Z\d]/u', '_', $Ident);
$this->RegisterVariableBoolean($Ident, $Name, '~Switch', 0);
$this->EnableAction($Ident);
}
$Events = $this->ReadAttributeArray(\ONVIF\Device\Attribute::EventProperties);
if (count($Events) != 1) {
$this->SetStatus(IS_EBASE + 1);
} else {
$this->SetStatus(IS_ACTIVE);
}
return;
}
$this->SetStatus(IS_ACTIVE);
}

public function SetRelayOutputState(string $Ident, bool $Value)
{
if (!array_key_exists($Ident, $this->ReadAttributeArray(\ONVIF\Output\Attribute::RelayOutputs))) {
Expand Down Expand Up @@ -199,4 +157,42 @@ public function GetConfigurationForm()

return json_encode($Form);
}

protected function InitFilterAndEvents()
{
parent::InitFilterAndEvents();
if ($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic) == '') {
$this->SetStatus(IS_INACTIVE);
return;
}
if ($this->HasActiveParent()) {
$Capabilities = @$this->GetCapabilities();
if (!$Capabilities) {
$this->SetStatus(IS_EBASE + 1);
return;
}
if ($Capabilities['XAddr'][\ONVIF\NS::DeviceIO]) {
$this->xAddr = $Capabilities['XAddr'][\ONVIF\NS::DeviceIO];
$this->wsdl = \ONVIF\WSDL::DeviceIO;
} else {
$this->xAddr = $Capabilities['XAddr'][\ONVIF\NS::Management];
$this->wsdl = \ONVIF\WSDL::Management;
}
$this->WriteAttributeArray(\ONVIF\Output\Attribute::RelayOutputs, $Capabilities['RelayOutputs']);
foreach ($Capabilities['RelayOutputs'] as $Name => $RelayOutput) {
$Ident = str_replace([' - ', ':'], ['_', ''], (string) $Name);
$Ident = preg_replace('/[^a-zA-Z\d]/u', '_', $Ident);
$this->RegisterVariableBoolean($Ident, $Name, '~Switch', 0);
$this->EnableAction($Ident);
}
$Events = $this->ReadAttributeArray(\ONVIF\Device\Attribute::EventProperties);
if (count($Events) != 1) {
$this->SetStatus(IS_EBASE + 1);
} else {
$this->SetStatus(IS_ACTIVE);
}
return;
}
$this->SetStatus(IS_ACTIVE);
}
}
35 changes: 16 additions & 19 deletions ONVIF Events/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,6 @@ public function Create()
{
parent::Create();
}
public function ApplyChanges()
{
//Never delete this line!
parent::ApplyChanges();
if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}
if ($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic) == '') {
$this->SetStatus(IS_INACTIVE);
} else {
$Events = $this->GetEvents($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic));
$this->SendDebug('EventConfig', $Events, 0);
if (count($Events) == 0) {
$this->SetStatus(IS_INACTIVE);
} else {
$this->SetStatus(IS_ACTIVE);
}
}
}

public function ReceiveData($JSONString)
{
Expand All @@ -56,4 +37,20 @@ public function GetConfigurationForm()
$this->SendDebug('FORM', json_last_error_msg(), 0);
return json_encode($Form);
}

protected function InitFilterAndEvents()
{
parent::InitFilterAndEvents();
if ($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic) == '') {
$this->SetStatus(IS_INACTIVE);
} else {
$Events = $this->GetEvents($this->ReadPropertyString(\ONVIF\Device\Property::EventTopic));
$this->SendDebug('EventConfig', $Events, 0);
if (count($Events) == 0) {
$this->SetStatus(IS_INACTIVE);
} else {
$this->SetStatus(IS_ACTIVE);
}
}
}
}
61 changes: 30 additions & 31 deletions ONVIF Image Grabber/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,6 @@ public function Create()
$this->RegisterTimer(\ONVIF\ImageGrabber\Timer::UpdateImage, 0, 'ONVIF_UpdateImage(' . $this->InstanceID . ');');
$this->ImageURL = false;
}
public function ApplyChanges()
{
//Never delete this line!
parent::ApplyChanges();
$MediaId = $this->GetMediaId();
IPS_SetMediaCached($MediaId, $this->ReadPropertyBoolean(\ONVIF\ImageGrabber\Property::UseCaching));

if ($this->ReadPropertyString(\ONVIF\ImageGrabber\Property::VideoSource) == '') {
$this->SetStatus(IS_INACTIVE);
$this->SetTimerInterval(\ONVIF\ImageGrabber\Timer::UpdateImage, 0);
return;
}
if ($this->ReadPropertyString(\ONVIF\ImageGrabber\Property::Profile) == '') {
$this->SetStatus(IS_INACTIVE);
$this->SetTimerInterval(\ONVIF\ImageGrabber\Timer::UpdateImage, 0);
return;
}
if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}

$this->ImageURL = $SnapshotURL = $this->GetSnapshotUri();
if ($SnapshotURL) {
$this->SetStatus(IS_ACTIVE);
$this->UpdateImage();
$this->SetTimerInterval(\ONVIF\ImageGrabber\Timer::UpdateImage, $this->ReadPropertyInteger(\ONVIF\ImageGrabber\Property::Interval) * 1000);
} else {
$this->SetTimerInterval(\ONVIF\ImageGrabber\Timer::UpdateImage, 0);
$this->SetStatus(IS_EBASE + 1);
}
}
public function UpdateImage()
{
$URL = $this->ImageURL;
Expand Down Expand Up @@ -343,6 +312,36 @@ public function RequestAction($Ident, $Value)
return;
}
}
protected function InitFilterAndEvents()
{
parent::InitFilterAndEvents();
$MediaId = $this->GetMediaId();
IPS_SetMediaCached($MediaId, $this->ReadPropertyBoolean(\ONVIF\ImageGrabber\Property::UseCaching));

if ($this->ReadPropertyString(\ONVIF\ImageGrabber\Property::VideoSource) == '') {
$this->SetStatus(IS_INACTIVE);
$this->SetTimerInterval(\ONVIF\ImageGrabber\Timer::UpdateImage, 0);
return;
}
if ($this->ReadPropertyString(\ONVIF\ImageGrabber\Property::Profile) == '') {
$this->SetStatus(IS_INACTIVE);
$this->SetTimerInterval(\ONVIF\ImageGrabber\Timer::UpdateImage, 0);
return;
}
if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}

$this->ImageURL = $SnapshotURL = $this->GetSnapshotUri();
if ($SnapshotURL) {
$this->SetStatus(IS_ACTIVE);
$this->UpdateImage();
$this->SetTimerInterval(\ONVIF\ImageGrabber\Timer::UpdateImage, $this->ReadPropertyInteger(\ONVIF\ImageGrabber\Property::Interval) * 1000);
} else {
$this->SetTimerInterval(\ONVIF\ImageGrabber\Timer::UpdateImage, 0);
$this->SetStatus(IS_EBASE + 1);
}
}
protected function IOChangeState($State)
{
parent::IOChangeState($State);
Expand Down
Loading

0 comments on commit 027266f

Please sign in to comment.