Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

SensorsController.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace App\Http\Controller;
  3. use App\Http\Business\SensorTypesBusiness;
  4. use Luticate\Auth\DBO\LuticateUsersDbo;
  5. use Luticate\Utils\LuController;
  6. use App\Http\Business\SensorsBusiness;
  7. use App\Http\DBO\SensorsDbo;
  8. use Luticate\Utils\LuMultipleDbo;
  9. class SensorsController extends LuController {
  10. protected function getBusiness()
  11. {
  12. return new SensorsBusiness();
  13. }
  14. /**
  15. * Get all sensor types
  16. * @param int $page The page number, 0 based
  17. * @param int $perPage The number of items per page
  18. * @param string $query The filter query
  19. * @return LuMultipleDbo
  20. */
  21. public function getAllTypes($page = 0, $perPage = PHP_INT_MAX, $query = "")
  22. {
  23. return SensorTypesBusiness::getAll($page, $perPage, $query);
  24. }
  25. /**
  26. * Get all sensors, sorted by name
  27. * @param int $page The page number, 0 based
  28. * @param int $perPage The number of items per page
  29. * @param string $query The filter query
  30. * @param $_user LuticateUsersDbo Injected parameter
  31. * @return \Luticate\Utils\LuMultipleDbo
  32. */
  33. public function getAll($_user, $page = 0, $perPage = PHP_INT_MAX, $query = "")
  34. {
  35. return SensorsBusiness::getAllLight($_user, $page, $perPage, $query);
  36. }
  37. /**
  38. * Get a sensor
  39. * @param $sensor_id int The sensor id
  40. * @param $_user LuticateUsersDbo Injected parameter
  41. * @return SensorsDbo
  42. */
  43. public function get($_user, $sensor_id)
  44. {
  45. return SensorsBusiness::getLight($_user, $sensor_id);
  46. }
  47. /**
  48. * Add a new sensor
  49. * @param SensorsDbo $sensor The sensor
  50. * @return int
  51. */
  52. public function add(SensorsDbo $sensor)
  53. {
  54. return SensorsBusiness::add($sensor);
  55. }
  56. /**
  57. * Edit an existing sensor
  58. * @param SensorsDbo $sensor The sensor
  59. * @param $sensor_id int The sensor id
  60. * @return bool
  61. */
  62. public function edit(SensorsDbo $sensor, $sensor_id)
  63. {
  64. return SensorsBusiness::edit($sensor, $sensor_id);
  65. }
  66. /**
  67. * Delete an existing sensor
  68. * @param $sensor_id int The sensor id
  69. * @return bool
  70. */
  71. public function del($sensor_id)
  72. {
  73. return SensorsBusiness::deleteById($sensor_id);
  74. }
  75. /**
  76. * Get the sensor value
  77. * @param $sensor_id int The sensor id
  78. * @return float
  79. */
  80. public function getValue($sensor_id)
  81. {
  82. return SensorsBusiness::getValue($sensor_id);
  83. }
  84. }