www-thermferm/units.php

changeset 306
97602274eb58
parent 291
d74b56ae669e
child 310
53774295e14a
--- a/www-thermferm/units.php	Wed Jan 14 13:20:16 2015 +0100
+++ b/www-thermferm/units.php	Sat Feb 07 23:12:55 2015 +0100
@@ -1,6 +1,6 @@
 <?php
 /*****************************************************************************
- * Copyright (C) 2014
+ * Copyright (C) 2014-2015
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -99,7 +99,10 @@
 	$cmd[] = "COOLER_ADDRESS,".$_POST['CoolerAddress'];
 	$cmd[] = "COOLER_DELAY,".$_POST['CoolerDelay'];
 	$cmd[] = "FAN_ADDRESS,".$_POST['FanAddress'];
+	$cmd[] = "LIGHT_ADDRESS,".$_POST['LightAddress'];
+	$cmd[] = "LIGHT_DELAY,".$_POST['LightDelay'];
 	$cmd[] = "DOOR_ADDRESS,".$_POST['DoorAddress'];
+	$cmd[] = "PSU_ADDRESS,".$_POST['PSUAddress'];
 	$cmd[] = "TEMP_SET_MIN,".$_POST['TempSetMin'];
 	$cmd[] = "TEMP_SET_MAX,".$_POST['TempSetMax'];
 	$cmd[] = "IDLE_RANGE_L,".$_POST['IdleRangeL'];
@@ -119,8 +122,11 @@
     unset($_POST['HeaterDelay']);
     unset($_POST['CoolerAddress']);
     unset($_POST['CoolerDelay']);
+    unset($_POST['LightAddress']);
+    unset($_POST['LightDelay']);
     unset($_POST['FanAddress']);
     unset($_POST['DoorAddress']);
+    unset($_POST['PSUAddress']);
     unset($_POST['TempSetMin']);
     unset($_POST['TempSetMax']);
     unset($_POST['IdleRangeL']);
@@ -147,6 +153,9 @@
  *         6 = TempSetMin < -5 or > 15
  *         7 = HeaterDelay out of range
  *         8 = CoolerDelay out of range
+ *         9 = IdleRangeL out of range
+ *        10 = IdleRangeH out of range
+ *        11 = LightDelay out of range
  *        99 = Cancel key
  */
 function test_thedata() {
@@ -154,8 +163,8 @@
     global $arr;
 
     if (isset($_POST['UUID']) && isset($_POST['Name']) && isset($_POST['Volume']) && isset($_POST['AirAddress']) &&
-	isset($_POST['BeerAddress']) && isset($_POST['HeaterAddress']) && isset($_POST['CoolerAddress']) &&
-	isset($_POST['HeaterDelay']) && isset($_POST['CoolerDelay']) &&
+	isset($_POST['BeerAddress']) && isset($_POST['HeaterAddress']) && isset($_POST['CoolerAddress']) && isset($_POST['LightAddress']) &&
+	isset($_POST['HeaterDelay']) && isset($_POST['CoolerDelay']) && isset($_POST['LightDelay']) && isset($_POST['PSUAddress']) &&
 	isset($_POST['FanAddress']) && isset($_POST['DoorAddress']) && isset($_POST['TempSetMin']) && isset($_POST['TempSetMax']) &&
 	isset($_POST['IdleRangeL']) && isset($_POST['IdleRangeH']) && isset($_POST['key']) && isset($_POST['command'])) {
 
@@ -199,6 +208,9 @@
 	if (($_POST['IdleRangeH'] < 0) || ($_POST['IdleRangeH'] > 5))
 	    return 10;
 
+	if (($_POST['LightDelay'] < 0) || ($_POST['LightDelay'] > 45))
+	    return 11;
+
     } else {
 	return 1;
     }
@@ -245,6 +257,8 @@
 		break;
 	case 10: $error = 'Idle Range High must be between 0 and 5';
 		break;
+	case 11: $error = 'Light Delay must be bewteen 0 and 45';
+		break;
 	case 99:        
 		load('units.php');
 		break;
@@ -427,6 +441,33 @@
 		$outstr .= '        </select></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
+	    if ($f[0] == "LIGHT_ADDRESS") {
+		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Lights Address</td>'.PHP_EOL;
+		$outstr .= '        <td class="editfield"><select name="LightAddress">'.PHP_EOL;
+		$outstr .= '         <option value="">Not Assigned</option>'.PHP_EOL;
+		if (startsWith($devices[0], "212")) {
+		    $j = 1;
+		    while (1) {
+			if (strcmp($devices[$j], ".") == 0)
+			    break;
+			$g = explode(",", $devices[$j]);
+			if (($g[5] == "OUT_ANALOG") || ($g[5] == "OUT_BIN")) {
+			    ($f[1] == $g[0]) ? $se = " selected" : $se = "";
+			    $outstr .= '         <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL;
+			}
+			$j++;
+		    }
+		}
+		$outstr .= '        </select></td>'.PHP_EOL;
+		$outstr .= '       </tr>'.PHP_EOL;
+	    }
+	    if ($f[0] == "LIGHT_DELAY") {
+		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Lights Delay</td>'.PHP_EOL;
+		$outstr .= '        <td class="editfield"><input type="text" name="LightDelay" size="5" value="'.$f[1].'"> * 15 seconds</td>'.PHP_EOL;
+		$outstr .= '       </tr>'.PHP_EOL;
+	    }
 	    if ($f[0] == "DOOR_ADDRESS") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Door Sensor Address</td>'.PHP_EOL;
@@ -448,6 +489,27 @@
 		$outstr .= '        </select></td>'.PHP_EOL;                        
 		$outstr .= '       </tr>'.PHP_EOL;                                  
 	    }
+	    if ($f[0] == "PSU_ADDRESS") {
+		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Power Supply Sensor Address</td>'.PHP_EOL;
+		$outstr .= '        <td class="editfield"><select name="PSUAddress">'.PHP_EOL;
+		$outstr .= '         <option value="">Not Assigned</option>'.PHP_EOL;
+		if (startsWith($devices[0], "212")) {
+		    $j = 1;
+		    while (1) {
+			if (strcmp($devices[$j], ".") == 0)
+			    break;
+			$g = explode(",", $devices[$j]);
+			if ($g[5] == "IN_BIN") {
+			    ($f[1] == $g[0]) ? $se = " selected" : $se = "";
+			    $outstr .= '         <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL;
+			}
+			$j++;
+		    }
+		}
+		$outstr .= '        </select></td>'.PHP_EOL;
+		$outstr .= '       </tr>'.PHP_EOL;
+	    }
 	    if ($f[0] == "TEMP_SET_MIN") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Min. temp setting</td>'.PHP_EOL;
@@ -568,7 +630,10 @@
     $outstr .= '<input type="hidden" value="" name="CoolerAddress">';
     $outstr .= '<input type="hidden" value="20" name="CoolerDelay">';
     $outstr .= '<input type="hidden" value="" name="FanAddress">';
+    $outstr .= '<input type="hidden" value="" name="LightAddress">';
+    $outstr .= '<input type="hidden" value="1" name="LightDelay">';
     $outstr .= '<input type="hidden" value="" name="DoorAddress">';
+    $outstr .= '<input type="hidden" value="" name="PSUAdress">';
     $outstr .= '<input type="hidden" value="1.0" name="TempSetMin">';
     $outstr .= '<input type="hidden" value="30.0" name="TempSetMax">';
     $outstr .= '<input type="hidden" value="-1.0" name="IdleRangeL">';

mercurial