print_r($displaySensorList); */ foreach ($SensorsList as $sensorType) { $tmpList = $sensors->get_sensor_type($sensorType); foreach ($tmpList as $row) { $typeName = $row['name']; $typeUnit = $row['unit']; } $rawDisplay = '<tr><th><font size="5">' . $typeName . '</font></th>'; if (count($displaySensorList[$sensorType]) > 0) { for ($iColumn = 0; $iColumn < count($deviceSensorList[sensors]); $iColumn++) { if (empty($displaySensorList[$sensorType][$iColumn])) { $rawDisplay = $rawDisplay . '<td></td>'; } else { $sensorID = $displaySensorList[$sensorType][$iColumn] . $sensorType; $tmpList = $sensors->get_sensor_list($sensorID); foreach ($tmpList as $row) { $alarm_MAX = $row['alarm_max']; $alarm_MIN = $row['alarm_min']; } $tmpList = $sensors->get_sensordata_now($sensorID); foreach ($tmpList as $row) { $datetimeSensor = $row['datetime']; $sensorValue = (int) $row['txtdata']; $statusIcon = ($sensorValue <= $alarm_MAX and $sensorValue >= $alarm_MIN) ? "green.png" : "red.png"; if ($sensorValue > $alarm_MAX) { $alarm_trigger = true; } $email_lasttime = ${"email_last_time_" . $sensorID}; } $fmtDate = date("Y-m-d H:i", $datetimeSensor);
<tr> <th scope="col" width="130"> </th> <th scope="col"><h3>溫度</h3></th> <th scope="col"><h3>溼度</h3></th> <th scope="col"><h3>煙霧</h3></th> <th scope="col"><h3>PM10</h3></th> <th scope="col"><h3>PM2.5</h3></th> <th scope="col"><h3>CO2</h3></th> </tr> </thead> <tbody> <tr> <th scope="col"><h2>電腦<br>機房</h1></th> <td align="center"><strong><select name="maxA1" id="maxA1" size="1"> <?php $tmpList = $sensors->get_sensor_list("A1"); foreach ($tmpList as $row) { $alarm_MAX_A1 = $row['alarm_max']; } $tmpList = $sensors->get_sensor_list("A2"); foreach ($tmpList as $row) { $alarm_MAX_A2 = $row['alarm_max']; } $tmpList = $sensors->get_sensor_list("A5"); foreach ($tmpList as $row) { $alarm_MAX_A5 = $row['alarm_max']; } ?> <?php for ($i = 0; $i <= 100; $i += 2) { ?>
return $v; }else{ return 0; } */ } $sensors = new conninfo($pdo); $data_sensor_name = trim($_GET["sensor"]) . trim($_GET["type"]); $data_device_name = trim($_GET["sensor"]); $data_desc = trim($_GET["device"]); $data_sensor_type = trim($_GET["type"]); $data_sensor_value = trim($_GET["vdata"]); $sensorID = 0; if (strlen($data_sensor_name) > 0 and strlen($data_sensor_value) > 0) { //Get this sensor's ID $tmpList = $sensors->get_sensor_list($data_sensor_name); foreach ($tmpList as $row) { $sensorID = $row['id']; } if (!$sensorID > 0) { $nowtime = time(); $sql = "INSERT INTO sensor_list (idname, name, moredesc, type_id, create_date)\n\t VALUES ('{$data_sensor_name}', '{$data_device_name}', '{$data_desc}', '{$data_sensor_type}', '{$nowtime}')"; // use exec() because no results are returned echo $sql; $pdo->exec($sql); echo "New sensor ID created successfully!"; } $nowtime = time(); $sql = "INSERT INTO data_storage (sensor_id, datetime, txtdata)\n \t VALUES ('{$sensorID}', '{$nowtime}', '{$data_sensor_value}')"; // use exec() because no results are returned echo $sql;
<?php require "../conn/pdo.php"; require "../conn/conninfo.php"; require "functions.php"; $sensors = new conninfo($pdo); //$data_sensor_name = trim($_GET["sensor"]); $lastMinutes = trim($_GET["min"]); $typeSensor = trim($_GET["type"]); $numdata = trim($_GET["num"]); $tmpList = $sensors->get_sensor_list($typeSensor); foreach ($tmpList as $row) { $typeName = $row['name']; $typeUnit = $row['unit']; } $arraySensors = array("\"" . $typeSensor . "\""); $lineTitle = $typeName . "曲線圖"; $y_title = $typeUnit; $txtUnit = $typeUnit; $arrayNum = 0; $sensorName = array(); $jsonCategories = array(); $jsonData = array(); //if(strlen($data_sensor_name)>0) { print_r($arraySensors); foreach ($arraySensors as $data_sensor_name) { if (strlen($lastMinutes) > 0) { $nowtime = time(); $startDate = $nowtime - 60 * $lastMinutes; $endDate = $nowtime; $tmpList = $sensors->get_sensordata_range($data_sensor_name, $startDate, $endDate);