Location: PHPKode > projects > ARTIS WaterMon > artis-watermon-beta/prim_water.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<HEAD>
<style>
a {color: red}
</style>

<script language="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function setDataType(cValue)
  {
    // THIS FUNCTION CONVERTS DATES AND NUMBERS FOR PROPER ARRAY
    // SORTING WHEN IN THE SORT FUNCTION
    var isDate = new Date(cValue);
    if (isDate == "NaN")
      {
        if (isNaN(cValue))
          {
            // THE VALUE IS A STRING, MAKE ALL CHARACTERS IN
            // STRING UPPER CASE TO ASSURE PROPER A-Z SORT
            cValue = cValue.toUpperCase();
            return cValue;
          }
        else
          {
            // VALUE IS A NUMBER, TO PREVENT STRING SORTING OF A NUMBER
            // ADD AN ADDITIONAL DIGIT THAT IS THE + TO THE LENGTH OF
            // THE NUMBER WHEN IT IS A STRING
            var myNum;
            myNum = String.fromCharCode(48 + cValue.length) + cValue;
            return myNum;
          }
        }
  else
      {
        // VALUE TO SORT IS A DATE, REMOVE ALL OF THE PUNCTUATION AND
        // AND RETURN THE STRING NUMBER
        //BUG - STRING AND NOT NUMERICAL SORT .....
        // ( 1 - 10 - 11 - 2 - 3 - 4 - 41 - 5  etc.)
        var myDate = new String();
        myDate = isDate.getFullYear() + " " ;
        myDate = myDate + isDate.getMonth() + " ";
        myDate = myDate + isDate.getDate(); + " ";
        myDate = myDate + isDate.getHours(); + " ";
        myDate = myDate + isDate.getMinutes(); + " ";
        myDate = myDate + isDate.getSeconds();
        //myDate = String.fromCharCode(48 + myDate.length) + myDate;
        return myDate ;
      }
  }
function sortTable(col, tableToSort)
  {
    var iCurCell = col + tableToSort.cols;
    var totalRows = tableToSort.rows.length;
    var bSort = 0;
    var colArray = new Array();
    var oldIndex = new Array();
    var indexArray = new Array();
    var bArray = new Array();
    var newRow;
    var newCell;
    var i;
    var c;
    var j;
    // ** POPULATE THE ARRAY colArray WITH CONTENTS OF THE COLUMN SELECTED
    for (i=1; i < tableToSort.rows.length; i++)
      {
        colArray[i - 1] = setDataType(tableToSort.cells(iCurCell).innerText);
        iCurCell = iCurCell + tableToSort.cols;
      }
    // ** COPY ARRAY FOR COMPARISON AFTER SORT
    for (i=0; i < colArray.length; i++)
      {
        bArray[i] = colArray[i];
      }
    // ** SORT THE COLUMN ITEMS
    //alert ( colArray );
    colArray.sort();
    //alert ( colArray );
    for (i=0; i < colArray.length; i++)
      { // LOOP THROUGH THE NEW SORTED ARRAY
        indexArray[i] = (i+1);
        for(j=0; j < bArray.length; j++)
          { // LOOP THROUGH THE OLD ARRAY
            if (colArray[i] == bArray[j])
              {  // WHEN THE ITEM IN THE OLD AND NEW MATCH, PLACE THE
                // CURRENT ROW NUMBER IN THE PROPER POSITION IN THE
                // NEW ORDER ARRAY SO ROWS CAN BE MOVED ....
                // MAKE SURE CURRENT ROW NUMBER IS NOT ALREADY IN THE
                // NEW ORDER ARRAY
                for (c=0; c<i; c++)
                  {
                    if ( oldIndex[c] == (j+1) )
                    {
                      bSort = 1;
                    }
                      }
                      if (bSort == 0)
                        {
                          oldIndex[i] = (j+1);
                        }
                          bSort = 0;
                        }
          }
    }
  // ** SORTING COMPLETE, ADD NEW ROWS TO BASE OF TABLE ....
  for (i=0; i<oldIndex.length; i++)
    {
      newRow = tableToSort.insertRow();
      for (c=0; c<tableToSort.cols; c++)
        {
          newCell = newRow.insertCell();
          newCell.innerHTML = tableToSort.rows(oldIndex[i]).cells(c).innerHTML;
        }
      }
  //MOVE NEW ROWS TO TOP OF TABLE ....
  for (i=1; i<totalRows; i++)
    {
      tableToSort.moveRow((tableToSort.rows.length -1),1);
    }
  //DELETE THE OLD ROWS FROM THE BOTTOM OF THE TABLE ....
  for (i=1; i<totalRows; i++)
    {
      tableToSort.deleteRow();
    }
  }
//  End -->
</script>
<body bgcolor="#FFFFDD"></body>
<script language="JavaScript">
<!--

/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/

//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="2:00"

if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+":"+cursec+" left until next page refresh..."
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
} }

 window.onload=beginrefresh
 //-->
 </script></head>

 <?php

 // Pump Icon
 $pumprun = "images/pump_run_S.gif";
 $pumpstop = "images/pump_stop_s.gif";
 $pumpalarm = "images/pump_alarm_s.gif";

 // Font Clour
 $runblue = "<b><medium><font color=\"#0000FF\">Run</font></medium></b>";
 $stopgreen = "<b><medium><font color=\"#008000\">Stop</font></medium></b>";
 $fault = "<b><medium><font color=\"#FF0000\">Fault</font></medium></b>";
 $clear = "<b><medium><font color=\"#008000\">Clear</font></medium></b>";
 $alarmred = "<b><medium><font color=\"#FF0000\">Alarm</font></medium></b>";

 $filter = @$_GET['filter'];
 if (!$filter) {	$filter = 'raw'; }

 // replace the status value with another string
 $states = array('pumpsc1psc2ps'=>array("0"=>$stopgreen,"1"=>$runblue,"3"=>$clear,"4"=>$fault,"5"=>$clear,"6"=>$alarmred),

 'thingos'=>array('0'=>'foo','1'=>'bar') );

 // grab the file
 $filename = "/local/web/eBiz/artis/SCADA2000.CSV";	// Web machine (local)
 $filename = "http://www.toowoomba.qld.gov.au/eBiz/artis/SCADA2000.CSV"; // Pull off web
 $contents = implode("",  file ($filename));


 $delimiter = ",";
 $elements = explode($delimiter, $contents); //assign to individual elements

 // get the meta-data (remove first 7 - date & time)
 $e1 = array_shift( $elements );
 $e2 = array_shift( $elements );
 $e3 = array_shift( $elements );
 $e4 = array_shift( $elements );
 $e5 = array_shift( $elements );
 $e6 = array_shift( $elements );
 $e7 = array_shift( $elements );

 //inialise plant array
 $plants = array();

 //count number of elements remaining
 $n = count( $elements );

 // loop throught the rest of the array in blocks of five
 for ($i=0; $i < $n; $i+=5) {
	 $add = false;
	 $id = $elements[$i];
	 $title = $elements[$i+1];
	 $stamp = $elements[$i+2];
	 $state = $elements[$i+3];
	 $units = $elements[$i+4];
 	 
	 //C1PS Pump 1
	 if ($id == 138 and $state == 0) {$pump1C1PS  = $pumpstop; }
	 if ($id == 138 and $state == 1) {$pump1C1PS  = $pumprun; }
	 if ($id == 138 and $state == 4) {$pump1C1PS  = $pumpalarm; }
	 if ($id == 138) {$stamp1C1PS = $stamp;}
 	 
	 // C1PS Pump 2
	 if ($id == 139 and $state == 0) {$pump2C1PS  = $pumpstop; }
	 if ($id == 139 and $state == 1) {$pump2C1PS  = $pumprun; }
	 if ($id == 139 and $state == 4) {$pump2C1PS  = $pumpalarm; }
	 if ($id == 139) {$stamp2C1PS = $stamp;}
 	 
	 //C1PS W22 Pump Flow
	 if ($id == 105)  {$flowC1PS = $state;}
 	 
	 //C2PS Pump 1
	 if ($id == 145 and $state == 0) {$pump1C2PS  = $pumpstop; }
	 if ($id == 145 and $state == 1) {$pump1C2PS  = $pumprun; }
	 if ($id == 145 and $state == 4) {$pump1C2PS  = $pumpalarm; }
	 if ($id == 145) {$stamp1C2PS = $stamp;}
 	 
	 // C2PS Pump 2
	 if ($id == 146 and $state == 0) {$pump2C2PS  = $pumpstop; }
	 if ($id == 146 and $state == 1) {$pump2C2PS  = $pumprun; }
	 if ($id == 146 and $state == 4) {$pump2C2PS  = $pumpalarm; }
	 if ($id == 146) {$stamp2C2PS = $stamp;}
 	 
	 //C2PS W22 Pump Flow
	 if ($id == 284)  {$flowC2PS = $state;}
 	 
	 // P1PS Pump 1
	 if ($id == 188 and $state == 0) {$pump1P1PS  = $pumpstop; }
	 if ($id == 188 and $state == 1) {$pump1P1PS  = $pumprun; }
	 if ($id == 188 and $state == 4) {$pump1P1PS  = $pumpalarm; }
	 if ($id == 188) {$stamp1P1PS = $stamp;}
 	 
	 // P1PS Pump 2
	 if ($id == 190 and $state == 0) {$pump2P1PS  = $pumpstop; }
	 if ($id == 190 and $state == 1) {$pump2P1PS  = $pumprun; }
	 if ($id == 190 and $state == 4) {$pump2P1PS  = $pumpalarm; }
	 if ($id == 190) {$stamp2P1PS = $stamp;}
	 //  P1PS Pump Flow
	 if ($id == 302)  {$flowP1PS = $state;}
 	 
	 //Jockey Reservoir
	 if ($id == 61) {$valuejockey  = $state ; $stampjockey = $stamp;}
 	 
	 //Pechey Reservoir
	 if ($id == 94) {$valuepechey = $state ; $stamppechey = $stamp;}
 	 
	 if ($filter == 'raw') 	{
 		 // show all items
 		 $add = true;
	 } else {
		 if (in_array( $id, $lookup[$filter] )) {
 			 // this element is of type '$filter'
 			 $add = true;
		 }
	 }
	 if ($add == true)
	 {
	 	 
	 }
 }
	 ?>
	 
	 <font color=black><b><center>Last Data Update <?php echo $e4 ?> / <?php echo $e3?> / <?php echo $e2?>   Time <?php echo $e5?>:<?php echo $e6?><font><p></p>
	       	 <FONT color=blue>This page will automatically refresh every Two minutes.</FONT></b>
		 </DIV>
		 
		 <!-- C1PS Pump 1-->
		 <div style="position: absolute; left: 150; top: 75;">
		 <DIV ID="1" STYLE="position:relative;"><font size="-1">1 C1PS<br><?php echo $stamp1C1PS ?></b></div>
			 
		 <DIV ID="2">
		       	 <IMG SRC="<?php echo $pump1C1PS ?>" BORDER=0></div>
		 </div>
				 
		 <!-- C2PS Pump 2 -->
	    	 <div style="position: absolute; left: 150; top: 180;">
			<DIV ID="4" STYLE="position:relative;"><font size="-1">2 C1PS<br><?php echo $stamp2C1PS ?></b></div>
				 
		       	<DIV ID="5" >
			    	 <IMG SRC="<?php echo $pump2C1PS ?>" BORDER=0></div>
		       	</div>
						 
			<!-- C1PS Flow
			<DIV ID="7" STYLE="position:absolute; left:250; top:155;">C1PS Flow<br><?php echo $flowC1PS ?> l/s</b></div>  -->
							 
			<!-- C2PS Pump 1 -->
			<div style="position: absolute; left: 500; top: 75;">
			<DIV ID="10" STYLE="position:relative;"><font size="-1">1 C2PS<br><?php echo $stamp1C2PS ?></b></div>

  <DIV ID="11"> 
   <IMG SRC="<?php echo $pump1C2PS ?>" BORDER=0></div>
  </div>

 <!-- C2PS Pump 2 -->
  <div style="position: absolute; left: 500; top: 180;">
  <DIV ID="13" STYLE="position:relative;"><font size="-1">2 C2PS<br><?php echo $stamp2C2PS ?></b></div>

  <DIV ID="14"">
  <IMG SRC="<?php echo $pump2C2PS ?>" BORDER=0></div>
  </div>

  <!-- C2PS Flow   -->
  <DIV ID="16" STYLE="position:absolute; left:600; top:165;">C2PS Flow<br><?php echo $flowC2PS ?> l/s</b></div>


  <!-- P1PS Pump  -->
  <div style="position: absolute; left: 150; top: 330;">
  <DIV ID="17" STYLE="position:relative;"><font size="-1">1 P1PS<br><?php echo $stamp1P1PS ?></b></div>

  <DIV ID="18"">
  <IMG SRC="<?php echo $pump1P1PS ?>" BORDER=0></div>
  </div>

 <!-- P1PS Pump 2 -->
  <div style="position: absolute; left: 150; top: 430;">
 <DIV ID="20" STYLE="position:relative;"><font size="-1">2 P1PS<br><?php echo $stamp2P1PS ?></b></div>

  <DIV ID="21">
 <IMG SRC="<?php echo $pump2P1PS ?>" BORDER=0></div>
  </div>

 <!-- P1PS Flow   -->
 <DIV ID="23" STYLE="position:absolute; left:250; top:420;">P1PS Flow<br><?php echo $flowP1PS ?> l/s</b></div>

 <!-- Pechey Reservoir -->
   <div style="position: absolute; left: 740; top: 70;">
 <DIV ID="25" STYLE="position:relative;">Pechey<br><?php echo $stamppechey ?></b></div>

 <div style="position:relative; width: 100;"><table border="1">

 <table STYLE=" border:1px solid #B3ABF4;" cellspacing=0 cellpadding=0 border=1   >
 <tr>

 <td style="border-bottom:1px solid #B3ABF4;" align="center" bgcolor="#90D3D3" valign="middle" nowrap colspan=3 class="texttiny"><font color="#000080"> <?php echo round($valuepechey,1) ?> % </td></tr>
 <tr>

 <td background="" align="right" valign="bottom" height=100 width=0><img src="images/bbar.gif" width = 60 height=<?php echo $valuepechey ?> border=0 alt=" "></td>

 </table><br></div> </div>
  </body>
  </html>

 <!-- Jockey Reservoir -->
  <div style="position: absolute; left: 340; top: 70;">
 <DIV ID="9" STYLE="position:relative;">Jockey<br><?php echo $stampjockey ?></b></div>

 <div style="position:relative; width: 100;"><table border="1">

 <table STYLE=" border:1px solid #B3ABF4;" cellspacing=0 cellpadding=0 border=1   >
 <tr>

 <td style="border-bottom:1px solid #B3ABF4;" align="center" bgcolor="#90D3D3" valign="middle" nowrap colspan=3 class="texttiny"><font color="#000080"> <?php echo round($valuejockey,1) ?> % </td></tr>
 <tr>

 <td background="" align="right" valign="bottom" height=100 width=0><img src="images/bbar.gif" width = 60 height=<?php echo $valuejockey ?> border=0 alt=" "></td>

 </table><br></div> </div>

 </body>
 </html>

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>Untitled</title>
	<style>
	div.tomsbox {
		border: 1px solid;
		position: absolute;
		left: 255;
		top: 155;
		width: 70;
        background: #80ff80;
        padding: 0;
	}
	</style>
</head>
<body>
<div class="tomsbox">
C1PS Flow<br><?php echo $flowC1PS ?> l/s
</div></div>
</body>
</html>
<!--
<html>
<head>
	<title>Untitled</title>
	<style>
	div.tomsbox {
		border: 1px solid;
		position: absolute;
		left: 600;
		top: 165;
		width: 70;
        background: #80ff80;
        padding: 0;
	}
	</style>
</head>
<body>
<div class="tomsbox">
P1PS Flow<br>C2PS Flow<br><?php echo $flowC2PS ?> l/s
</div></div>
</body>
</html>

html>
<head>
	<title>Untitled</title>
	<style>
	div.tomsbox {
		border: 1px solid;
		position: absolute;
		left: 250;
		top: 450;
		width: 70;
        background: #80ff80;
        padding: 0;
	}
	</style>
</head>
<body>
<div class="tomsbox">
P1PS Flow<br>P1PS Flow<br><?php echo $flowP1PS ?> l/s
</div></div>
</body>
</html>        -->
Return current item: ARTIS WaterMon