<?php
// Toowoomba City Council Water Monitoring System
// Developed by Sam Moffatt (hide@address.com)
// Rain Gauge Data Class
require_once("functions.php");
class raingauge {
// Variables
var $raingaugeid; // Rain Gauge ID
var $datasource; // Location of the CSV file
var $dbinfo; // Details about the database (array)
var $name; // res name (human friendly)
var $shortname; // res name (short)
var $data; // Data from CSV
var $top,$left; // res HTML position
// Constructor
function raingauge($newraingaugeid, $shortname, $left,$top, $newdatasource="http://www.toowoomba.qld.gov.au/eBiz/artis/SCADA2000.CSV", $newdbinfo="") {
$this->dbinfo = Array();
if(is_array($newdbinfo)) {
// New database information
} else {
// Default database
}
if(($newdatasource != "") && (is_string($newdatasource))) {
$this->datasource = $newdatasource;
} else if(is_array($newdatasource)) {
$this->data = $newdatasource;
} else {
// Isn't a string and isn't an array, fall back
$this->datasource = "http://www.toowoomba.qld.gov.au/eBiz/artis/SCADA2000.CSV";
}
if(!isset($this->data)) { $this->data = loadCSV($this->datasource); }
$this->top = $top;
$this->left = $left;
$this->raingaugeid = $newraingaugeid;
$this->shortname = $shortname;
}
function getID() {
return $this->raingaugeid;
}
function getName() {
return "{$this->data[$this->raingaugeid]['title']} ($this->raingaugeid)";
}
function getShortName() {
return $this->shortname;
}
function getTimeStamp() {
return $this->data[$this->raingaugeid]['stamp'];
}
function getStatus() {
return $this->data[$this->raingaugeid]['state'];
}
function setTop($top) {
$this->top = $top;
}
function setLeft($left) {
$this->left = $left;
}
function getUnits() {
return $this->data[$this->raingaugeid]['units'];
}
// Return the raingaugeervoir with div
// - Allows position override
function getHTML($left=0,$top=0) {
if($top == 0) {
$top = $this->top;
}
if($left == 0) {
$left = $this->left;
}
?>
<div style="z-index: 2; position: absolute; left: <?php echo $left; ?>; top: <?php echo $top; ?>; border: 1px solid; width: 70; background: #80ff80; padding: 0;" align="center">
<?php echo $this->getShortName(); ?><br>Rain Gauge<br><?php echo $this->getStatus(); echo " "; echo $this->getUnits(); ?> </div>
<?php
}
}
?>