Ejemplo n.º 1
0
		<img src="header.png">
		<table class="features-table">
				<thead>
					<tr>
						<td align='right'></td>
<?php 
//$deviceSensorList = json_decode($jsonSensors, TRUE);
//Print table header columns
foreach ($deviceSensorList['sensors'] as $key => $val) {
    $tmpList = $sensors->get_sensor_area($val['sensorID']);
    foreach ($tmpList as $row) {
        $typeName = $row['moredesc'];
    }
    $tmpList = $sensors->get_sensorupdate_time($val['sensorID']);
    foreach ($tmpList as $row) {
        $dateUpdate = unixtime2Date($row['datetime']);
    }
    $stringSensors = implode(":", $val['sensorList']);
    echo '<td><b>' . $typeName . '</b><br><font size="1" color="gray">' . $dateUpdate . '</td>';
}
echo '</tr></thead>';
//select sensors which sensorID are necessary to display, and put them to $sensoridDisplay array.
$displaySensorList = [];
foreach ($SensorsList as $sensorType) {
    $sensoridDisplay = [];
    foreach ($deviceSensorList['sensors'] as $key => $val) {
        if (in_array($sensorType, $val['sensorList'])) {
            $sensoridDisplay[$val['sensorIndex']] = $val['sensorID'];
        }
    }
    $displaySensorList[$sensorType] = $sensoridDisplay;
Ejemplo n.º 2
0
require "../conn/pdo.php";
require "../conn/conninfo.php";
require "functions.php";
$sensors = new conninfo($pdo);
$lastMinutes = trim($_GET["min"]);
$typeSensor = trim($_GET["type"]);
$endDate = time();
$startDate = $endDate - 60 * $lastMinutes;
$arrayDATA = [];
$arrayLABLE = [];
$tmpList = $sensors->get_sensordata_range($typeSensor, $startDate, $endDate);
$counts = count($tmpList);
$i = 0;
if ($counts > 0) {
    foreach ($tmpList as $row) {
        $i++;
        //$arrayLABLE = $arrayLABLE . "'" . unixtime2Date($row['datetime']) . "'";
        //$arrayDATA = $arrayDATA . $row['txtdata'];
        //$unit = $row['unit'];
        array_push($arrayDATA, (int) $row['txtdata']);
        array_push($arrayLABLE, "'" . unixtime2Date($row['datetime']) . "'");
        /*
        if($i<$counts) {
        	$arrayDATA = $arrayDATA . ', ';
        	$arrayLABLE = $arrayLABLE . ', ';
        }
        */
    }
    echo '{ "labels": "[' . implode(", ", $arrayLABLE) . ']", "data": "[' . implode(", ", $arrayDATA) . ']" }';
}