From 9609c3b4c7f702fcf23ad69cecbde4384bdcf71d Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Tue, 21 Dec 2021 22:39:35 +0300 Subject: [PATCH] =?UTF-8?q?[+]=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B0=D0=BD=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=BE=D1=80=D1=82=D0=B0=20A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/lib/CIoT.class.php | 21 ++++++++------------- index.php | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 18 deletions(-) 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 + +