Subversion Repositories HomeAutomation

Rev

Rev 2060 | Blame | Last modification | View Log | SVN | RSS feed

  1. <?php
  2. require 'config.php';
  3.  
  4. function GetLastData($alias2)
  5. {
  6.   global $AtomURL;
  7.   global $AtomPort;
  8.  
  9.   $level2 = 0;
  10.   $buffer = "";
  11.   $result = array();
  12.   try
  13.   {
  14.     $socket = atomd_initialize($AtomURL, $AtomPort);
  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.  
  29. function SendGenericCommand($command)
  30. {
  31.   global $AtomURL;
  32.   global $AtomPort;
  33.  
  34.   $buffer = "";
  35.  
  36.   try
  37.   {
  38.     $socket = atomd_initialize($AtomURL, $AtomPort);
  39.  
  40.     atomd_send_command($socket, $command);
  41.    
  42.     $buffer = atomd_read_command_response($socket);
  43.   }
  44.   catch (Exception $e)
  45.   {
  46.     die($e);
  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");
  68. }
  69.  
  70. ?>
  71.  
  72.