Browse Source

send get sensor value query to backend

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
012ac0eefe
1 changed files with 13 additions and 2 deletions
  1. 13
    2
      app/Http/Business/SensorsBusiness.php

+ 13
- 2
app/Http/Business/SensorsBusiness.php View File

2
 
2
 
3
 namespace App\Http\Business;
3
 namespace App\Http\Business;
4
 
4
 
5
+use App\Http\DBO\HostsDbo;
6
+use App\Http\DBO\SensorTypesDbo;
5
 use Luticate\Utils\LuBusiness;
7
 use Luticate\Utils\LuBusiness;
6
 use App\Http\DataAccess\SensorsDataAccess;
8
 use App\Http\DataAccess\SensorsDataAccess;
7
 use App\Http\DBO\SensorsDbo;
9
 use App\Http\DBO\SensorsDbo;
10
+use Luticate\Utils\LuRequest;
8
 
11
 
9
 class SensorsBusiness extends LuBusiness {
12
 class SensorsBusiness extends LuBusiness {
10
     protected static function getDataAccess()
13
     protected static function getDataAccess()
51
 
54
 
52
     public static function getValue($sensor_id)
55
     public static function getValue($sensor_id)
53
     {
56
     {
54
-        self::getById($sensor_id);
55
-        return rand(0, 42) * ($sensor_id % 2 == 0 ? 1 : -1);
57
+        /**
58
+         * @var $sensor SensorsDbo
59
+         * @var $host HostsDbo
60
+         * @var $type SensorTypesDbo
61
+         */
62
+        $sensor = self::getById($sensor_id);
63
+        $host = HostsBusiness::getById($sensor->getHostId());
64
+        $type = SensorTypesBusiness::getById($sensor->getSensorTypeId());
65
+        return LuRequest::proxy('POST', $host->getUrl() . "/sensors/value", [],
66
+            ["sensor" => $sensor->__toString(), "type" => $type->__toString()], ["X-Token" => $host->getToken()]);
56
     }
67
     }
57
 }
68
 }

Loading…
Cancel
Save