Browse Source

sensor get random values

tags/0.1.0
Robin Thoni 8 years ago
parent
commit
355a3186bc

+ 6
- 0
app/Http/Business/SensorsBusiness.php View File

@@ -48,4 +48,10 @@ class SensorsBusiness extends LuBusiness {
48 48
         $sensor->setId($sensor_id);
49 49
         return SensorsDataAccess::editById($sensor_id, $sensor);
50 50
     }
51
+
52
+    public static function getValue($sensor_id)
53
+    {
54
+        self::getById($sensor_id);
55
+        return rand(0, 42) * ($sensor_id % 2 == 0 ? 1 : -1);
56
+    }
51 57
 }

+ 10
- 0
app/Http/Controller/SensorsController.php View File

@@ -78,4 +78,14 @@ class SensorsController extends LuController {
78 78
     {
79 79
         return SensorsBusiness::deleteById($sensor_id);
80 80
     }
81
+
82
+    /**
83
+     * Get the sensor value
84
+     * @param $sensor_id int The sensor id
85
+     * @return float
86
+     */
87
+    public function getValue($sensor_id)
88
+    {
89
+        return SensorsBusiness::getValue($sensor_id);
90
+    }
81 91
 }

+ 1
- 0
app/Http/routes.php View File

@@ -38,6 +38,7 @@ $route->get("/sensors/$sensor_id", "Sensors", "get", CamotionPermissions::SENSOR
38 38
 $route->post("/sensors/add", "Sensors", "add", array(CamotionPermissions::SENSOR_GET, CamotionPermissions::SENSOR_ADD));
39 39
 $route->post("/sensors/$sensor_id/edit", "Sensors", "edit", array(CamotionPermissions::SENSOR_GET, CamotionPermissions::SENSOR_EDIT));
40 40
 $route->post("/sensors/$sensor_id/del", "Sensors", "del", array(CamotionPermissions::SENSOR_GET, CamotionPermissions::SENSOR_DEL));
41
+$route->post("/sensors/$sensor_id/value", "Sensors", "getValue", array(CamotionPermissions::SENSOR_GET, CamotionPermissions::SENSOR_EXEC));
41 42
 
42 43
 
43 44
 $route->get("/commands/types", "Commands", "getAllTypes", array(CamotionPermissions::COMMAND_GET, CamotionPermissions::COMMAND_ADD));

Loading…
Cancel
Save