www-thermferm/devices.php

changeset 344
acd840c9fcc0
parent 252
2197976f2bc5
child 345
9894b559441c
--- a/www-thermferm/devices.php	Thu Mar 26 16:40:53 2015 +0100
+++ b/www-thermferm/devices.php	Thu Mar 26 20:34:53 2015 +0100
@@ -1,6 +1,6 @@
 <?php
 /*****************************************************************************
- * Copyright (C) 2014
+ * Copyright (C) 2014-2015
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -272,12 +272,22 @@
 		 */
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Device Type</td>'.PHP_EOL;
-		if (($type == "W1") || ($type == "GPIO"))
+		if (($type == "W1") || ($type == "GPIO") || ($type == "SIM"))
 		    $outstr .= '        <td class="editfield"><input type="hidden" name="Type" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
 		else
 		    $outstr .= '        <td class="editfield"><input type="text" name="Type" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
+	    if ($f[0] == "ADDRESS") {
+		$address = $f[1];
+		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Address</td>'.PHP_EOL;
+		if (($type == "W1") || ($type == "GPIO"))
+		    $outstr .= '        <td class="editfield"><input type="hidden" name="Address" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
+		else
+		    $outstr .= '        <td class="editfield"><input type="text" name="Address" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
+		$outstr .= '       </tr>'.PHP_EOL;
+	    }
 	    if ($f[0] == "DIRECTION") {
 		$direction = $f[1];
 		/*
@@ -285,9 +295,22 @@
 		 */
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">IO Direction and mode</td>'.PHP_EOL;
-		if ($type == "W1")
-		    $outstr .= '        <td class="editfield"><input type="hidden" name="Direction" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
-		else {
+		if ($type == "W1") {
+		    if ((strncmp($address, "29", 2) == 0) || (strncmp($address, "3a", 2) == 0)) {
+			$outstr .= '        <td class="editfield"><select name="Direction">'.PHP_EOL;
+			$se = ($f[1] == "UNDEF")?" selected":"";
+			$outstr .= '         <option value="UNDEF"'.$se.'>Undefined</option>'.PHP_EOL;
+			$se = ($f[1] == "IN_BIN")?" selected":"";
+			$outstr .= '         <option value="IN_BIN"'.$se.'>Binary input</option>'.PHP_EOL;
+			$se = ($f[1] == "OUT_BIN")?" selected":"";
+			$outstr .= '         <option value="OUT_BIN"'.$se.'>Binary output</option>'.PHP_EOL;
+			$se = ($f[1] == "OUT_PWM")?" selected":"";
+			$outstr .= '         <option value="OUT_PWM"'.$se.'>PWM output</option>'.PHP_EOL;
+			$outstr .= '        </select></td>'.PHP_EOL;
+		    } else {
+			$outstr .= '        <td class="editfield"><input type="hidden" name="Direction" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
+		    }
+		} else {
 		    $outstr .= '        <td class="editfield"><select name="Direction">'.PHP_EOL;
 		    if ($type == "GPIO") {
 			$se = ($f[1] == "UNDEF")?" selected":"";
@@ -319,6 +342,10 @@
 			$se = ($f[1] == "UNDEF")?" selected":"";
 			$outstr .= '         <option value="UNDEF"'.$se.'>Undefined</option>'.PHP_EOL;
 		    }
+		    if ($type == "SIM") {
+			$se = ($f[1] == "UNDEF")?" selected":"";
+			$outstr .= '         <option value="UNDEF"'.$se.'>Undefined</option>'.PHP_EOL;
+		    }
 		    $outstr .= '        </select></td>'.PHP_EOL;
 		}
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -337,7 +364,7 @@
 	    }
 	    if ($f[0] == "OFFSET") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
-		$outstr .= '        <td class="editname">Value</td>'.PHP_EOL;
+		$outstr .= '        <td class="editname">Offset</td>'.PHP_EOL;
 		if ($direction == "IN_ANALOG")
 		    $outstr .= '        <td class="editfield"><input type="text" name="Offset" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
 		else
@@ -366,15 +393,6 @@
 		}
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
-	    if ($f[0] == "ADDRESS") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
-		$outstr .= '        <td class="editname">Address</td>'.PHP_EOL;
-		if (($type == "W1") || ($type == "GPIO"))
-		    $outstr .= '        <td class="editfield"><input type="hidden" name="Address" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
-		else
-		    $outstr .= '        <td class="editfield"><input type="text" name="Address" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
-	    }
 	    if ($f[0] == "SUBDEVICE") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Subdevice</td>'.PHP_EOL;

mercurial