Subversion Repositories HomeAutomation

Rev

Rev 2060 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 2060 Rev 2062
1
<?php
1
<?php
2
require 'config.php';
2
require 'config.php';
3
 
3
 
4
function GetLastData($alias2)
4
function GetLastData($alias2)
5
{
5
{
6
  global $AtomURL;
6
  global $AtomURL;
7
  global $AtomPort;
7
  global $AtomPort;
8
 
8
 
9
  $level2 = 0;
9
  $level2 = 0;
10
  $buffer = "";
10
  $buffer = "";
11
  $result = array();
11
  $result = array();
12
  try
12
  try
13
  {
13
  {
14
    $socket = atomd_initialize($AtomURL, $AtomPort);
14
    $socket = atomd_initialize($AtomURL, $AtomPort);
15
    atomd_send_command($socket, "Module_GetLastDataRaw $alias2");
15
    atomd_send_command($socket, "Module_GetLastDataRaw $alias2");
16
 
16
 
17
    $buffer = atomd_read_command_response($socket);
17
    $buffer = atomd_read_command_response($socket);
18
    $array = json_decode(trim($buffer), true);
18
    $array = json_decode(trim($buffer), true);
19
  }
19
  }
20
  catch (Exception $e)
20
  catch (Exception $e)
21
  {
21
  {
22
    die($e);
22
    die($e);
23
  }
23
  }
24
  return $array["results"];
24
  return $array["results"];
25
}
25
}
26
 
26
 
27
 
27
 
28
 
28
 
29
function SetDimmerValue($alias2, $level)
29
function SendGenericCommand($command)
30
{
30
{
31
  global $AtomURL;
31
  global $AtomURL;
32
  global $AtomPort;
32
  global $AtomPort;
33
 
33
 
34
  $level2 = 0;
-
 
35
  $buffer = "";
34
  $buffer = "";
36
 
35
 
37
  try
36
  try
38
  {
37
  {
39
    $socket = atomd_initialize($AtomURL, $AtomPort);
38
    $socket = atomd_initialize($AtomURL, $AtomPort);
40
 
39
 
41
    atomd_send_command($socket, "Dimmer_AbsoluteFade $alias2 255 $level");
40
    atomd_send_command($socket, $command);
42
   
41
   
43
    $buffer = atomd_read_command_response($socket);
42
    $buffer = atomd_read_command_response($socket);
44
  }
43
  }
45
  catch (Exception $e)
44
  catch (Exception $e)
46
  {
45
  {
47
    die($e);
46
    die($e);
48
  }
47
  }
-
 
48
  return $buffer;
-
 
49
}
-
 
50
 
-
 
51
 
-
 
52
 
-
 
53
function SetDimmerValue($alias2, $level)
-
 
54
{
-
 
55
    SendGenericCommand("Dimmer_AbsoluteFade $alias2 255 $level");
-
 
56
}
-
 
57
 
-
 
58
 
-
 
59
function SetPidTemperature($alias, $temperature)
-
 
60
{
-
 
61
  SendGenericCommand("PID_setValue $alias $temperature");
-
 
62
}
-
 
63
 
-
 
64
 
-
 
65
function SetPidParameters($alias, $KP, $KI, $KD, $Time, $Unit)
-
 
66
{
-
 
67
  SendGenericCommand("PID_setParameters $alias $KP $KI $KD $Time $Unit");
49
}
68
}
50
 
69
 
51
?>
70
?>
52
 
71
 
53
 
72