2014-05-25 02:18:41 +00:00
|
|
|
<?php
|
|
|
|
//土壤水分
|
|
|
|
namespace Westdc\Visual\Reader;
|
|
|
|
|
|
|
|
use Westdc\Visual\Record;
|
|
|
|
use Westdc\Visual\RecordInterface;
|
|
|
|
|
|
|
|
class SoilMoisture extends Record implements RecordInterface
|
|
|
|
{
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct(__CLASS__);
|
|
|
|
}
|
|
|
|
|
|
|
|
public $subset;
|
|
|
|
|
|
|
|
public function switchDataset()
|
|
|
|
{
|
|
|
|
if(empty($this->subset))
|
|
|
|
{
|
|
|
|
$this->subset = "20cm";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch($this->subset){
|
|
|
|
case "10cm":
|
|
|
|
$this->subset = "vwc_avg10";
|
|
|
|
break;
|
|
|
|
case "20cm" :
|
|
|
|
$this->subset = "vwc_avg20";
|
|
|
|
break;
|
|
|
|
case "30cm" :
|
|
|
|
$this->subset = "vwc_avg30";
|
|
|
|
break;
|
|
|
|
case "40cm" :
|
|
|
|
$this->subset = "vwc_avg40";
|
|
|
|
break;
|
|
|
|
case "50cm" :
|
|
|
|
$this->subset = "vwc_avg50";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getData()
|
|
|
|
{
|
|
|
|
$this->switchDataset();
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM data_watercontent
|
|
|
|
WHERE
|
|
|
|
$this->subset > 0
|
|
|
|
ORDER BY
|
|
|
|
extract(year from \"timestamp\") ASC,
|
|
|
|
extract(month from \"timestamp\") ASC,
|
|
|
|
extract(day from \"timestamp\") ASC,
|
|
|
|
extract(hour from \"timestamp\") ASC
|
|
|
|
";
|
|
|
|
//exit($sql);
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
return $rs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function outPut()
|
|
|
|
{
|
|
|
|
|
|
|
|
$rs = $this->getData();
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
|
|
|
|
while($row = $rs->fetch())
|
|
|
|
{
|
|
|
|
$row['utctime'] = $this->utcMsTime(strtotime($row['timestamp']));
|
|
|
|
$data[] = array($row['utctime'],$row[$this->subset]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2014-05-21 09:26:15 +00:00
|
|
|
}
|