You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SensorsController.php 2.2KB

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