Location: PHPKode > projects > ARTIS WaterMon > artis-watermon-beta/flow.class.php
<?php

// Toowoomba City Council Water Monitoring System
// Developed by Sam Moffatt (hide@address.com)
// Flow Meter Data Class

require_once("functions.php");

class flowmeter {
	// Variables
	var $meterid;		// Flow Meter 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 flowmeter($newmeterid, $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->meterid = $newmeterid;
		$this->shortname = $shortname;
	}

	function getID() {
		return $this->meterid;
	}
	
	function getName() {		
		return "{$this->data[$this->meterid]['title']} ($this->meterid)";
	}
	
	function getShortName() {
		return $this->shortname;
	}
	
	function getTimeStamp() {
		return $this->data[$this->meterid]['stamp'];
	}
	
	function getStatus() {
		return $this->data[$this->meterid]['state'];
	}
	
	function setTop($top) {
		$this->top = $top;
	}
	
	function setLeft($left) {
		$this->left = $left;
	}
	
	function getUnits() {
		return $this->data[$this->meterid]['units'];
	}
	
	// Return the meterervoir 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="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><?php echo $this->getStatus(); echo " "; echo $this->getUnits(); ?></div>
		 <?php
	}
	

}
?>
Return current item: ARTIS WaterMon