Пример #1
0
<?php

require "../conn/pdo.php";
require "../conn/conninfo.php";
require "functions.php";
$sensors = new conninfo($pdo);
$maxA1 = $_POST['maxA1'];
$maxA2 = $_POST['maxA2'];
$maxA5 = $_POST['maxA5'];
$maxB1 = $_POST['maxB1'];
$maxB2 = $_POST['maxB2'];
$maxB7 = $_POST['maxB7'];
$maxB8 = $_POST['maxB8'];
$maxC1 = $_POST['maxC1'];
$maxC2 = $_POST['maxC2'];
$maxC7 = $_POST['maxC7'];
$maxC8 = $_POST['maxC8'];
$tmpList = $sensors->update_alarm_config("A1", $maxA1);
$tmpList = $sensors->update_alarm_config("A2", $maxA2);
$tmpList = $sensors->update_alarm_config("A5", $maxA5);
$tmpList = $sensors->update_alarm_config("B1", $maxB1);
$tmpList = $sensors->update_alarm_config("B2", $maxB2);
$tmpList = $sensors->update_alarm_config("B7", $maxB7);
$tmpList = $sensors->update_alarm_config("B8", $maxB8);
$tmpList = $sensors->update_alarm_config("C1", $maxC1);
$tmpList = $sensors->update_alarm_config("C2", $maxC2);
$tmpList = $sensors->update_alarm_config("C7", $maxC7);
$tmpList = $sensors->update_alarm_config("C8", $maxC8);
$conn = null;
header('Location: alarmconfig.php?update=OK');
Пример #2
0
				"sensorID": "MR",                         
                "sensorList": [ 1, 2, 3, 4, 11] },                              
              { "sensorIndex": 1,
				"sensorID": "OR",                         
                "sensorList": [ 1, 2, 8, 10, 11] },
              { "sensorIndex": 2,
				"sensorID": "HR",                         
                "sensorList": [ 1, 2, 5, 6, 11] }
            ]}                                           
            ';
$SensorsList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
$deviceSensorList = json_decode($jsonSensors, TRUE);
require "../conn/pdo.php";
require "../conn/conninfo.php";
require "functions.php";
$sensors = new conninfo($pdo);
require '../PHPMailer-master/PHPMailerAutoload.php';
$email_sendout = false;
//是否要寄出email?
$email_minutes_period = 15 * 60;
//每隔幾分鐘寄一次alarm email
$tmpList = $sensors->get_email_time();
$alarm_trigger = false;
//若有超過警戒值,則為true, 並執行mp3
foreach ($tmpList as $row) {
    ${"email_last_time_" . $row['idname']} = $row['email_time'];
}
$A_datetime = $row['datetime'];
$date = new DateTime();
$nowTime = $date->getTimestamp();
$output = shell_exec('./alarm.sh');
Пример #3
0
<?php

require "../conn/pdo.php";
require "../conn/conninfo.php";
require "functions.php";
$sensors = new conninfo($pdo);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="tw"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="60" >
    <title>[凌陽創新] 環控系統設定</title>
    <style type="text/css">
/*General styles*/
body
{
        margin: 0;
        padding: 0;
        background: white url(http://www.red-team-design.com/wp-content/themes/redv2/images/back.jpg) no-repeat left top;
	overflow-y: hidden;
        overflow-x: hidden;
}
#main
{
        width: 800px;
        margin: 0 auto 0 auto;
        background: white;
        -moz-border-radius: 8px;
        -webkit-border-radius: 8px;
        padding: 5px;
        border: 1px solid #adaa9f;
Пример #4
0
                    $sql = $conn->prepare("select id from sensor_list where idname='$sensorNameID'");
                    $sql->execute();
    
                    $result = $sql->setFetchMode(PDO::FETCH_ASSOC);
                    foreach(new TableRows(new RecursiveArrayIterator($sql->fetchAll())) as $k=>$v) {
           	                echo "Found sensor nameID is ".$v;
                    }
    
                    if($v>0) {
                            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}')";
Пример #5
0
<?php

require "../conn/pdo.php";
require "../conn/conninfo.php";
require_once "../../phpChart_Lite/conf.php";
$sensors = new conninfo($pdo);
$data_sensor_name = trim($_GET["sensor"]);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>phpChart - Basic Chart</title>
</head>
  
<body>
<?php 
if (strlen($data_sensor_name) > 0) {
    $tmpList = $sensors->get_sensordata_range($data_sensor_name, 60);
    $arrayData = array();
    $i = 0;
    foreach ($tmpList as $row) {
        $arrayData[$i] = $row['txtdata'];
        if ($i == 0) {
            $startTime = $row['datetime'];
        }
        $endTime = $row['datetime'];
        $i++;
    }
    $dateTitle = date("Y-m-d H:i", $startTime) . "~" . date("Y-m-d H:i", $endTime) . "溫度趨線圖";
    //print_r($arrayData);
Пример #6
0
<?php

require "../conn/pdo.php";
require "../conn/conninfo.php";
$sensors = new conninfo($pdo);
//$data_sensor_name = trim($_GET["sensor"]);
$lastMinutes = trim($_GET["min"]);
$arraySensors = array("A1");
$arrayNum = 0;
$sensorName = array();
$jsonCategories = array();
$jsonData = array();
//if(strlen($data_sensor_name)>0) {
foreach ($arraySensors as $data_sensor_name) {
    $nowtime = time();
    $startDate = $nowtime - 60 * $lastMinutes;
    $endDate = $nowtime;
    $tmpList = $sensors->get_sensordata_range($data_sensor_name, $startDate, $endDate);
    $numX = count($tmpList) / 10;
    $i = 0;
    $jsonCategories[$arrayNum] = '[';
    $jsonData[$arrayNum] = '[';
    foreach ($tmpList as $row) {
        if ($i == 0) {
            $startTime = $row['datetime'];
        }
        $endTime = $row['datetime'];
        $sensorName[$arrayNum] = $row['name'];
        if ($i > 0) {
            $jsonCategories[$arrayNum] = $jsonCategories[$arrayNum] . ', ';
            $jsonData[$arrayNum] = $jsonData[$arrayNum] . ', ';
Пример #7
0
<?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);
Пример #8
0
<?php

require "../conn/pdo.php";
require "../conn/conninfo.php";
$sensors = new conninfo($pdo);
$data_sensor_name = trim($_GET["sensor"]);
$data_num = trim($_GET["num"]);
include "../libchart/libchart/classes/libchart.php";
$chart = new LineChart(1200, 600);
$dataSet = new XYDataSet();
if (strlen($data_sensor_name) > 0) {
    $tmpList = $sensors->get_sensordata_num($data_sensor_name, $data_num);
    $totalRecords = count($tmpList);
    $numX = $totalRecords / 12;
    $i = 0;
    foreach ($tmpList as $row) {
        if ($i == 0) {
            $startTime = $row['datetime'];
        }
        $endTime = $row['datetime'];
        $sensorName = $row['name'];
        if ($numX > 12) {
            if ($i % $numX == 0) {
                $dataSet->addPoint(new Point(date("H:i", $row['datetime']), $row['txtdata']));
            } else {
                $dataSet->addPoint(new Point("", $row['txtdata']));
            }
        } else {
            $dataSet->addPoint(new Point(date("H:i", $row['datetime']), $row['txtdata']));
        }
        $i++;
Пример #9
0
<?php

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 = '';
$arrayValueDisplay = '';
$arrayUNIT = '';
$tmpList = $sensors->get_sensordata_range($typeSensor, $startDate, $endDate);
$counts = count($tmpList);
$i = 0;
if ($counts > 0) {
    foreach ($tmpList as $row) {
        $i++;
        if ($counts <= 4) {
            $arrayLABLE = $arrayLABLE . '"' . $row['datetime'] . '"';
            $arrayValueDisplay = $arrayValueDisplay . '"' . round($row['txtdata'], 1) . $row['unit'] . '"';
        } else {
            if ($counts > 4 and $counts <= 10) {
                if ($i % 2 == 0) {
                    $arrayLABLE = $arrayLABLE . '"' . $row['datetime'] . '"';
                    $arrayValueDisplay = $arrayValueDisplay . '"' . round($row['txtdata'], 1) . $row['unit'] . '"';
                } else {
                    $arrayLABLE = $arrayLABLE . '"\\r\\n' . $row['datetime'] . '"';
                    $arrayValueDisplay = $arrayValueDisplay . '"\\r\\n' . round($row['txtdata'], 1) . $row['unit'] . '"';