<?php
$gett = $_GET["q"];//获取数据
$selectTimeMin = $_GET['selectTimeMin'];
$selectTimeMax = $_GET['selectTimeMax'];
ini_set("precision", "3");  //浮点数小数位数
   class MyDB extends SQLite3
   {
      function __construct()
      {
			//$this->open('C:/Users/Administrator/Desktop/workFile/ElecWaterPrj/水文协议SL651 配置软件20220120/DB/SL651.sqlite.db3');
			//$this->open('C:/Users/Administrator/Desktop/workFile/HlsPrj/河流_50888/DB/SL651.sqlite.db3');
			//$this->open('SL651.sqlite.db3');
			$this->open('C:/Users/Administrator/Desktop/workFile/HlsPrj/河流_50888/DB/SL651.sqlite.db3');
      }
   }
   $con = new MyDB();
   if(!$con){
      echo $con->lastErrorMsg();
   } 
   
// 选择数据库
$sql="SELECT * FROM waterLayerInfo WHERE dataTime > '$selectTimeMin' and dataTime < '$selectTimeMax' and devID = '".$gett."' ORDER by `dataTime` DESC LIMIT 10;";
$result = $con->query($sql);
//echo $sql;
if (!$result) {
    printf("Error: SELECT DB ERR\n");
	$con->close();
    exit();
}
echo "<table border='1'>
<tr>
<th>序号</th>
<th>采集时间</th>
<th>上报时间</th>
<th>设备ID</th>
<th>电压</th>
<th>电流</th>
<th>系统报警状态</th>
<th>温度</th>
<th>运行时间</th>
<th>传感器位置</th>
<th>横电机电源_H</th>
<th>驱动器状态_H</th>
<th>运行状态_H</th>
<th>告警_H</th>
<th>电流_H</th>
<th>电机推算位置_H</th>
<th>每层间隔距离_H</th>
<th>电机状态_H</th>
<th>当前层_H</th>
<th>电机方向_H</th>
<th>RES_H</th>
<th>横电机电源_V</th>
<th>驱动器状态_V</th>
<th>运行状态_V</th>
<th>告警_V</th>
<th>电流_V</th>
<th>电机推算位置_V</th>
<th>每层间隔距离_V</th>
<th>电机状态_V</th>
<th>当前层_V</th>
<th>电机方向_V</th>
<th>RES_V</th>
<th>升降电机电源_L</th>
<th>驱动器状态_L</th>
<th>运行状态_L</th>
<th>告警_L</th>
<th>电流_L</th>
<th>电机推算位置_L</th>
<th>每层间隔距离_L</th>
<th>电机状态_L</th>
<th>当前层_L</th>
<th>电机方向_L</th>
<th>RES_L</th>
<th>抽水电机电源_W</th>
<th>电流_W</th>
<th>瓶状态1to32</th>
<th>瓶状态32To64</th>
<th>瓶状态65To96</th>
<th>瓶状态97To128</th>
<th>瓶状态129To160</th>
<th>系统业务状态</th>
<th>RES_2</th>
<th>RES_3</th>
<th>RES_4</th>
</tr>";

// SELECT 操作
while($row = $result->fetchArray(SQLITE3_ASSOC)) {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['dataTime'] . "</td>";
    echo "<td>" . $row['reportTime'] . "</td>";
    echo "<td>" . $row['devID'] . "</td>";
    echo "<td>" . $row['Vol']/1000 . "</td>";
    echo "<td>" . $row['iCur'] . "</td>";
    echo "<td>" . $row['SysAlarmState'] . "</td>";
    echo "<td>" . $row['Temperature'] . "</td>";
    echo "<td>" . $row['Runtime'] . "</td>";
    echo "<td>" . $row['SensorPosition'] . "</td>";
    echo "<td>" . $row['PowerOn_H'] . "</td>";
    echo "<td>" . $row['DevOnline_H'] . "</td>";
    echo "<td>" . $row['DevState_H'] . "</td>";
    echo "<td>" . $row['DevAlarm_H'] . "</td>";
    echo "<td>" . $row['iCur_H'] . "</td>";
    echo "<td>" . $row['MoterClcPosition_H'] . "</td>";
    echo "<td>" . $row['IntervalDis_H'] . "</td>";
    echo "<td>" . $row['MotorStatus_H'] . "</td>";
    echo "<td>" . $row['CurLayer_H'] . "</td>";
    echo "<td>" . $row['MotorDirection_H'] . "</td>";
    echo "<td>" . $row['RES_H'] . "</td>";
    echo "<td>" . $row['PowerOn_V'] . "</td>";
    echo "<td>" . $row['DevOnline_V'] . "</td>";
    echo "<td>" . $row['DevState_V'] . "</td>";
    echo "<td>" . $row['DevAlarm_V'] . "</td>";
    echo "<td>" . $row['iCur_V'] . "</td>";
    echo "<td>" . $row['MoterClcPosition_V'] . "</td>";
    echo "<td>" . $row['IntervalDis_V'] . "</td>";
    echo "<td>" . $row['MotorStatus_V'] . "</td>";
    echo "<td>" . $row['CurLayer_V'] . "</td>";
    echo "<td>" . $row['MotorDirection_V'] . "</td>";
    echo "<td>" . $row['RES_V'] . "</td>";
    echo "<td>" . $row['PowerOn_L'] . "</td>";
    echo "<td>" . $row['DevOnline_L'] . "</td>";
    echo "<td>" . $row['DevState_L'] . "</td>";
    echo "<td>" . $row['DevAlarm_L'] . "</td>";
    echo "<td>" . $row['iCur_L'] . "</td>";
    echo "<td>" . $row['MoterClcPosition_L'] . "</td>";
    echo "<td>" . $row['IntervalDis_L'] . "</td>";
    echo "<td>" . $row['MotorStatus_L'] . "</td>";
    echo "<td>" . $row['CurLayer_L'] . "</td>";
    echo "<td>" . $row['MotorDirection_L'] . "</td>";
    echo "<td>" . $row['RES_L'] . "</td>";
    echo "<td>" . $row['PowerOn_W'] . "</td>";
    echo "<td>" . $row['RES_W'] . "</td>";
    echo "<td>" . $row['Bottle1to32'] . "</td>";
	echo "<td>" . $row['Bottle33to64'] . "</td>";
	echo "<td>" . $row['Bottle65to96'] . "</td>";
	echo "<td>" . $row['Bottle97to128'] . "</td>";
	echo "<td>" . $row['Bottle129to160'] . "</td>";
    echo "<td>" . $row['RES_1'] . "</td>";
    echo "<td>" . $row['RES_2'] . "</td>";
    echo "<td>" . $row['RES_3'] . "</td>";
    echo "<td>" . $row['RES_4'] . "</td>";
    echo "</tr>";
}
echo "</table>";


$con->close();
 ?>