Subversion Repositories HomeAutomation

Rev

Rev 2060 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
2051 linlun 1
<?php
2060 linlun 2
require 'config.php';
2051 linlun 3
 
4
function GetLastData($alias2)
5
{
2060 linlun 6
  global $AtomURL;
7
  global $AtomPort;
8
 
2051 linlun 9
  $level2 = 0;
10
  $buffer = "";
11
  $result = array();
12
  try
13
  {
2060 linlun 14
    $socket = atomd_initialize($AtomURL, $AtomPort);
2051 linlun 15
    atomd_send_command($socket, "Module_GetLastDataRaw $alias2");
16
 
17
    $buffer = atomd_read_command_response($socket);
18
    $array = json_decode(trim($buffer), true);
19
  }
20
  catch (Exception $e)
21
  {
22
    die($e);
23
  }
24
  return $array["results"];
25
}
26
 
27
 
28
 
2062 linlun 29
function SendGenericCommand($command)
2051 linlun 30
{
2060 linlun 31
  global $AtomURL;
32
  global $AtomPort;
33
 
2051 linlun 34
  $buffer = "";
35
 
36
  try
37
  {
2060 linlun 38
    $socket = atomd_initialize($AtomURL, $AtomPort);
2051 linlun 39
 
2062 linlun 40
    atomd_send_command($socket, $command);
2051 linlun 41
 
42
    $buffer = atomd_read_command_response($socket);
43
  }
44
  catch (Exception $e)
45
  {
46
    die($e);
47
  }
2062 linlun 48
  return $buffer;
2051 linlun 49
}
50
 
2062 linlun 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");
68
}
69
 
2051 linlun 70
?>
71