diff --git a/inc/lib/CIoT.class.php b/inc/lib/CIoT.class.php index cc0758b..008efa5 100644 --- a/inc/lib/CIoT.class.php +++ b/inc/lib/CIoT.class.php @@ -144,7 +144,7 @@ class CIoT { * @param $deviceId * @return int */ - public static function getCountDallas($deviceId):int{ + public static function getCountSensors($deviceId):int{ $res = self::$DB->query('SELECT DISTINCT sensor FROM sensors WHERE device = "'.$deviceId.'"'); if($res) { @@ -215,8 +215,8 @@ class CIoT { * @param $deviceId * @return array */ - public static function getDallasArrData($deviceId) { - $count = self::getCountDallas($deviceId); + public static function getSensorsArrData($deviceId) { + $count = self::getCountSensors($deviceId); $res = self::$DB->query('SELECT DISTINCT sensor, value, time, id FROM sensors WHERE device="'.$deviceId.'" ORDER BY id DESC LIMIT 10'); $result = []; @@ -230,6 +230,7 @@ class CIoT { } } + /** * Получаем массив с данными об устройстве * @@ -306,20 +307,14 @@ class CIoT { * @return array */ public static function getPlotDallasValues($deviceId, $sensor) { - $result = []; - /*$res = self::$DB->query('SELECT id, device, sensor, value, time FROM sensors WHERE device="'.$deviceId.'" and sensor="ds'.$sensor.'" AND (time % 300) = 0 AND time > '.(time()-86400*24).' ORDER BY id DESC LIMIT 100'); - //SELECT id, device, sensor, value, time FROM sensors WHERE device="'.$deviceId.'" and sensor="ds'.$sensor.'" AND (time % 300) = 0 AND time > '.(time()-86400*24).' ORDER BY id DESC LIMIT 100*/ - $res = self::$DB->query('SELECT * FROM sensors WHERE mod(minute(date),5) = 0 AND sensor="'.$sensor.'" AND device="'.$deviceId.'" GROUP BY date ORDER BY id DESC LIMIT 1000'); if($res) { - //return $res; return array_reverse($res); } else { return []; } } - /** * Получение списка прошивок * @@ -479,7 +474,7 @@ class CIoT { scrollPositionX: 1 }, title: { - text: "Показания температурного датчика (ID:'.$sensor.')" + text: "Показания датчика (ID:'.$sensor.')" }, subtitle: { text: "IoT Core System" @@ -489,7 +484,7 @@ class CIoT { }, yAxis: { title: { - text: "Температура (°C)" + text: "Показания (ед)" } }, plotOptions: { @@ -504,11 +499,11 @@ class CIoT { tooltip: { shared: true, crosshairs: true, - pointFormat: "Температура: {point.y:.2f} С" + pointFormat: "Значение: {point.y:.2f} ед." }, series: [{ - name: "Показания температуры (ID:)", + name: "Показания датчика (ID:)", data: ['.$temps.'] }] }); diff --git a/index.php b/index.php index 22fcc7c..475373a 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,7 @@ $cacheId = md5('CIoT::getDallasArrData_'.$USER['deviceId']); if(CCache::check($cacheId)) { $arSensors = CCache::get($cacheId); } else { - $arSensors = CIoT::getDallasArrData($USER['deviceId']); + $arSensors = CIoT::getSensorsArrData($USER['deviceId']); CCache::write($cacheId, $arSensors); } @@ -35,7 +35,12 @@ if(CCache::check($cacheId)) { } else { echo 'ion-thermometer'; } ?>"> - Датчик + + Датчик + + Датчик ANALOG + +