-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.php
More file actions
73 lines (57 loc) · 1.54 KB
/
module.php
File metadata and controls
73 lines (57 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?
require_once(__DIR__ . DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."IntertechnoBase.php");
class IntertechnoSwitch extends IntertechnoBase
{
public function Create()
{
parent::Create();
$this->RegisterPropertyString("MasterDIP", "A");
$this->RegisterPropertyString("SlaveDIP", "1");
$this->RegisterVariableBoolean("STATE", "STATE", "~Switch");
$this->EnableAction("STATE");
$this->RegisterScript("SWITCHON", "Switch On", '<? ITSW_SwitchOn(IPS_GetParent($_IPS["SELF"])); ?>');
$this->RegisterScript("SWITCHOFF", "Switch Off", '<? ITSW_SwitchOff(IPS_GetParent($_IPS["SELF"])); ?>');
}
public function RequestAction($Ident, $Value)
{
switch($Ident) {
case "STATE":
$this->SwitchState($Value);
break;
default:
throw new Exception("Invalid ident");
}
}
public function ApplyChanges()
{
parent::ApplyChanges();
}
protected function GetAdress()
{
return $this->ReadPropertyString("MasterDIP") . $this->ReadPropertyString("SlaveDIP");
}
public function SwitchOn()
{
$this->SendCommand("12,4,4,12,12,4");
SetValue($this->GetIDForIdent("STATE"), true);
}
public function SwitchOff()
{
$this->SendCommand("12,4,4,12,4,12");
SetValue($this->GetIDForIdent("STATE"), false);
}
public function SwitchState($value)
{
if ($value)
$this->SwitchOn();
else
$this->SwitchOff();
}
protected function SendCommand($command)
{
parent::SendMsg($this->ReadPropertyString("MasterDIP"),
$this->ReadPropertyString("SlaveDIP"),
$command);
}
}
?>