www-thermferm/units.php

changeset 554
ab9f22ab57b5
parent 518
fd36bedab944
child 564
3fc61dd28656
equal deleted inserted replaced
553:4091d4fe217f 554:ab9f22ab57b5
1 <?php 1 <?php
2 /***************************************************************************** 2 /*****************************************************************************
3 * Copyright (C) 2014-2017 3 * Copyright (C) 2014-2018
4 * 4 *
5 * Michiel Broek <mbroek at mbse dot eu> 5 * Michiel Broek <mbroek at mbse dot eu>
6 * 6 *
7 * This file is part of ThermFerm 7 * This file is part of ThermFerm
8 * 8 *
54 */ 54 */
55 55
56 /* 56 /*
57 * Unit add 57 * Unit add
58 * 58 *
59 * @param string $_POST['Name'] The rpofile name 59 * @param string $_POST['Name'] The product name
60 */ 60 */
61 function unit_add() { 61 function unit_add() {
62 62
63 if ($_POST['key'] == 'Add') { 63 if ($_POST['key'] == 'Add') {
64 send_cmd("UNIT ADD ".$_POST['Name']); 64 send_cmd("UNIT ADD ".$_POST['ProductName']);
65 } 65 }
66 66
67 unset($_POST['UUID']); 67 unset($_POST['UUID']);
68 unset($_POST['Name']); 68 unset($_POST['roductName']);
69 unset($_POST['key']); 69 unset($_POST['key']);
70 unset($_POST['command']); 70 unset($_POST['command']);
71 load('units.php'); 71 load('units.php');
72 } 72 }
73 73
75 75
76 /* 76 /*
77 * Unit update 77 * Unit update
78 * 78 *
79 * @param string $_POST['UUID'] The unit UUID 79 * @param string $_POST['UUID'] The unit UUID
80 * @param string $_POST['Name'] The unit name
81 * @param string $_POST['key'] The button pressed. 80 * @param string $_POST['key'] The button pressed.
82 */ 81 */
83 function unit_update() { 82 function unit_update() {
84 /* 83 /*
85 * Build the update command 84 * Build the update command
88 send_cmd("UNIT DEL ".$_POST['UUID']); 87 send_cmd("UNIT DEL ".$_POST['UUID']);
89 } 88 }
90 89
91 if ($_POST['key'] == 'Save') { 90 if ($_POST['key'] == 'Save') {
92 $cmd = array("UNIT PUT ".$_POST['UUID']); 91 $cmd = array("UNIT PUT ".$_POST['UUID']);
93 $cmd[] = "NAME,".$_POST['Name']; 92 $cmd[] = "PRODUCT_CODE,".$_POST['ProductCode'];
93 $cmd[] = "PRODUCT_NAME,".$_POST['ProductName'];
94 $cmd[] = "VOLUME,".$_POST['Volume']; 94 $cmd[] = "VOLUME,".$_POST['Volume'];
95 $cmd[] = "AIR_ADDRESS,".$_POST['AirAddress']; 95 $cmd[] = "AIR_ADDRESS,".$_POST['AirAddress'];
96 $cmd[] = "AIR_IDX,".$_POST['AirIdx']; 96 $cmd[] = "AIR_IDX,".$_POST['AirIdx'];
97 $cmd[] = "BEER_ADDRESS,".$_POST['BeerAddress']; 97 $cmd[] = "BEER_ADDRESS,".$_POST['BeerAddress'];
98 $cmd[] = "BEER_IDX,".$_POST['BeerIdx']; 98 $cmd[] = "BEER_IDX,".$_POST['BeerIdx'];
129 $cmd[] = "."; 129 $cmd[] = ".";
130 send_array($cmd); 130 send_array($cmd);
131 } 131 }
132 132
133 unset($_POST['UUID']); 133 unset($_POST['UUID']);
134 unset($_POST['Name']); 134 unset($_POST['ProductName']);
135 unset($_POST['ProductCode']);
135 unset($_POST['Volume']); 136 unset($_POST['Volume']);
136 unset($_POST['key']); 137 unset($_POST['key']);
137 unset($_POST['command']); 138 unset($_POST['command']);
138 unset($_POST['AirAddress']); 139 unset($_POST['AirAddress']);
139 unset($_POST['AirIdx']); 140 unset($_POST['AirIdx']);
173 } 174 }
174 175
175 176
176 177
177 /* 178 /*
178 * Test input of a modified or new profile. 179 * Test input of a modified or new fermentation unit.
179 * 180 *
180 * @param string $_POST['UUID'] Unique record UUID 181 * @param string $_POST['UUID'] Unique record UUID
181 * @param string $_POST['Name'] Profile name
182 * @param string $_POST['key'] Key choice, Save or Cancel 182 * @param string $_POST['key'] Key choice, Save or Cancel
183 * @param string $_POST['command'] Command used, 'add' or 'update' 183 * @param string $_POST['command'] Command used, 'add' or 'update'
184 * 184 *
185 * Return: 0 = Ok 185 * Return: 0 = Ok
186 * 1 = Missing data 186 * 1 = Missing data
187 * 2 = Name field too short 187 * // 2 = Name field too short
188 * 3 = Name already in use 188 * // 3 = Name already in use
189 * 4 = TempSetMax <= TempSetMin 189 * 4 = TempSetMax <= TempSetMin
190 * 5 = TempSetMax < 25 or > 35 190 * 5 = TempSetMax < 25 or > 35
191 * 6 = TempSetMin < -5 or > 15 191 * 6 = TempSetMin < -5 or > 15
192 * 7 = HeaterDelay out of range 192 * 7 = HeaterDelay out of range
193 * 8 = CoolerDelay out of range 193 * 8 = CoolerDelay out of range
199 */ 199 */
200 function test_thedata() { 200 function test_thedata() {
201 201
202 global $arr; 202 global $arr;
203 203
204 if (isset($_POST['UUID']) && isset($_POST['Name']) && isset($_POST['Volume']) && isset($_POST['AirAddress']) && isset($_POST['ChillerAddress']) && 204 if (isset($_POST['UUID']) && isset($_POST['ProductCode']) && isset($_POST['ProductName']) && isset($_POST['Volume']) &&
205 isset($_POST['BeerAddress']) && isset($_POST['HeaterAddress']) && isset($_POST['CoolerAddress']) && isset($_POST['LightAddress']) && 205 isset($_POST['AirAddress']) && isset($_POST['ChillerAddress']) &&
206 isset($_POST['BeerAddress']) && isset($_POST['HeaterAddress']) &&
207 isset($_POST['CoolerAddress']) && isset($_POST['LightAddress']) &&
206 isset($_POST['HeaterDelay']) && isset($_POST['CoolerDelay']) && isset($_POST['LightDelay']) && isset($_POST['PSUAddress']) && 208 isset($_POST['HeaterDelay']) && isset($_POST['CoolerDelay']) && isset($_POST['LightDelay']) && isset($_POST['PSUAddress']) &&
207 isset($_POST['FanAddress']) && isset($_POST['DoorAddress']) && isset($_POST['TempSetMin']) && isset($_POST['TempSetMax']) && 209 isset($_POST['FanAddress']) && isset($_POST['DoorAddress']) && isset($_POST['TempSetMin']) && isset($_POST['TempSetMax']) &&
208 isset($_POST['PIDC_pGain']) && isset($_POST['PIDC_iGain']) && isset($_POST['PIDC_dGain']) && isset($_POST['PIDC_idleRange']) && 210 isset($_POST['PIDC_pGain']) && isset($_POST['PIDC_iGain']) && isset($_POST['PIDC_dGain']) && isset($_POST['PIDC_idleRange']) &&
209 isset($_POST['PIDH_pGain']) && isset($_POST['PIDH_iGain']) && isset($_POST['PIDH_dGain']) && isset($_POST['PIDH_idleRange']) && 211 isset($_POST['PIDH_pGain']) && isset($_POST['PIDH_iGain']) && isset($_POST['PIDH_dGain']) && isset($_POST['PIDH_idleRange']) &&
210 isset($_POST['PIDC_iMax']) && isset($_POST['PIDH_iMax']) && isset($_POST['AirIdx']) && isset($_POST['BeerIdx']) && 212 isset($_POST['PIDC_iMax']) && isset($_POST['PIDH_iMax']) && isset($_POST['AirIdx']) && isset($_POST['BeerIdx']) &&
213 isset($_POST['FanDelay']) && isset($_POST['key']) && isset($_POST['command'])) { 215 isset($_POST['FanDelay']) && isset($_POST['key']) && isset($_POST['command'])) {
214 216
215 if ($_POST['key'] == 'Cancel') 217 if ($_POST['key'] == 'Cancel')
216 return 99; 218 return 99;
217 219
218 if (strlen($_POST['Name']) < 2) 220 // if (strlen($_POST['Name']) < 2)
219 return 2; 221 // return 2;
220 222
221 if (startsWith($arr[0], "212")) { 223 /* if (startsWith($arr[0], "212")) {
222 $j = 1; 224 $j = 1;
223 while (1) { 225 while (1) {
224 if (strcmp($arr[$j], ".") == 0) 226 if (strcmp($arr[$j], ".") == 0)
225 break; 227 break;
226 $f = explode(",", $arr[$j]); 228 $f = explode(",", $arr[$j]);
227 if (strcmp($f[0], $_POST['UUID']) && (strcmp($f[1], $_POST['Name']) == 0)) { 229 if (strcmp($f[0], $_POST['UUID']) && (strcmp($f[1], $_POST['Name']) == 0)) {
228 return 3; 230 return 3;
229 } 231 }
230 $j++; 232 $j++;
231 } 233 }
232 } 234 } */
233 235
234 if ($_POST['TempSetMax'] <= $_POST['TempSetMin']) 236 if ($_POST['TempSetMax'] <= $_POST['TempSetMin'])
235 return 4; 237 return 4;
236 238
237 if (($_POST['TempSetMax'] < 25) || ($_POST['TempSetMax'] > 35)) 239 if (($_POST['TempSetMax'] < 25) || ($_POST['TempSetMax'] > 35))
359 while (1) { 361 while (1) {
360 if (strcmp($reply[$i], ".") == 0) 362 if (strcmp($reply[$i], ".") == 0)
361 break; 363 break;
362 $f = explode(",", $reply[$i]); 364 $f = explode(",", $reply[$i]);
363 365
364 if ($f[0] == "NAME") { 366 if ($f[0] == "PRODUCT_CODE") {
367 $outstr .= ' <tr class="editor">'.PHP_EOL;
368 $outstr .= ' <td class="editname">Product Code</td>'.PHP_EOL;
369 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="ProductCode" size="32" value="'.$f[1].'"></td>'.PHP_EOL;
370 $outstr .= ' </tr>'.PHP_EOL;
371 }
372
373 if ($f[0] == "PRODUCT_NAME") {
365 $outstr .= ' <tr class="editor">'.PHP_EOL; 374 $outstr .= ' <tr class="editor">'.PHP_EOL;
366 $outstr .= ' <td class="editname">Unit Name</td>'.PHP_EOL; 375 $outstr .= ' <td class="editname">Product Name</td>'.PHP_EOL;
367 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="Name" size="50" value="'.$f[1].'"></td>'.PHP_EOL; 376 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="ProductName" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
368 $outstr .= ' </tr>'.PHP_EOL; 377 $outstr .= ' </tr>'.PHP_EOL;
369 } 378 }
379
370 if ($f[0] == "VOLUME") { 380 if ($f[0] == "VOLUME") {
371 $outstr .= ' <tr class="editor">'.PHP_EOL; 381 $outstr .= ' <tr class="editor">'.PHP_EOL;
372 $outstr .= ' <td class="editname">Unit Volume</td>'.PHP_EOL; 382 $outstr .= ' <td class="editname">Unit Volume</td>'.PHP_EOL;
373 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="Volume" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 383 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="Volume" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
374 $outstr .= ' </tr>'.PHP_EOL; 384 $outstr .= ' </tr>'.PHP_EOL;
375 } 385 }
386
376 if ($f[0] == "AIR_ADDRESS") { 387 if ($f[0] == "AIR_ADDRESS") {
377 $outstr .= ' <tr class="editor">'.PHP_EOL; 388 $outstr .= ' <tr class="editor">'.PHP_EOL;
378 $outstr .= ' <td class="editname">Air Sensor Address</td>'.PHP_EOL; 389 $outstr .= ' <td class="editname">Air Sensor Address</td>'.PHP_EOL;
379 $outstr .= ' <td class="editfield"><select name="AirAddress">'.PHP_EOL; 390 $outstr .= ' <td class="editfield"><select name="AirAddress">'.PHP_EOL;
380 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; 391 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
390 } 401 }
391 $j++; 402 $j++;
392 } 403 }
393 } 404 }
394 $outstr .= ' </select></td>'.PHP_EOL; 405 $outstr .= ' </select></td>'.PHP_EOL;
395 // $outstr .= ' </tr>'.PHP_EOL;
396 } 406 }
397 if ($f[0] == "AIR_IDX") { 407 if ($f[0] == "AIR_IDX") {
398 // $outstr .= ' <tr class="editor">'.PHP_EOL;
399 $outstr .= ' <td class="editname">Air domoticz idx</td>'.PHP_EOL; 408 $outstr .= ' <td class="editname">Air domoticz idx</td>'.PHP_EOL;
400 $outstr .= ' <td class="editfield"><input type="text" name="AirIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 409 $outstr .= ' <td class="editfield"><input type="text" name="AirIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
401 $outstr .= ' </tr>'.PHP_EOL; 410 $outstr .= ' </tr>'.PHP_EOL;
402 } 411 }
412
403 if ($f[0] == "BEER_ADDRESS") { 413 if ($f[0] == "BEER_ADDRESS") {
404 $outstr .= ' <tr class="editor">'.PHP_EOL; 414 $outstr .= ' <tr class="editor">'.PHP_EOL;
405 $outstr .= ' <td class="editname">Beer Sensor Address</td>'.PHP_EOL; 415 $outstr .= ' <td class="editname">Beer Sensor Address</td>'.PHP_EOL;
406 $outstr .= ' <td class="editfield"><select name="BeerAddress">'.PHP_EOL; 416 $outstr .= ' <td class="editfield"><select name="BeerAddress">'.PHP_EOL;
407 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; 417 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
417 } 427 }
418 $j++; 428 $j++;
419 } 429 }
420 } 430 }
421 $outstr .= ' </select></td>'.PHP_EOL; 431 $outstr .= ' </select></td>'.PHP_EOL;
422 // $outstr .= ' </tr>'.PHP_EOL;
423 } 432 }
424 if ($f[0] == "BEER_IDX") { 433 if ($f[0] == "BEER_IDX") {
425 // $outstr .= ' <tr class="editor">'.PHP_EOL;
426 $outstr .= ' <td class="editname">Beer domoticz idx</td>'.PHP_EOL; 434 $outstr .= ' <td class="editname">Beer domoticz idx</td>'.PHP_EOL;
427 $outstr .= ' <td class="editfield"><input type="text" name="BeerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 435 $outstr .= ' <td class="editfield"><input type="text" name="BeerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
428 $outstr .= ' </tr>'.PHP_EOL; 436 $outstr .= ' </tr>'.PHP_EOL;
429 } 437 }
438
430 if ($f[0] == "CHILLER_ADDRESS") { 439 if ($f[0] == "CHILLER_ADDRESS") {
431 $outstr .= ' <tr class="editor">'.PHP_EOL; 440 $outstr .= ' <tr class="editor">'.PHP_EOL;
432 $outstr .= ' <td class="editname">Chiller Sensor Address</td>'.PHP_EOL; 441 $outstr .= ' <td class="editname">Chiller Sensor Address</td>'.PHP_EOL;
433 $outstr .= ' <td class="editfield"><select name="ChillerAddress">'.PHP_EOL; 442 $outstr .= ' <td class="editfield"><select name="ChillerAddress">'.PHP_EOL;
434 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; 443 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
444 } 453 }
445 $j++; 454 $j++;
446 } 455 }
447 } 456 }
448 $outstr .= ' </select></td>'.PHP_EOL; 457 $outstr .= ' </select></td>'.PHP_EOL;
449 // $outstr .= ' </tr>'.PHP_EOL;
450 } 458 }
451 if ($f[0] == "CHILLER_IDX") { 459 if ($f[0] == "CHILLER_IDX") {
452 // $outstr .= ' <tr class="editor">'.PHP_EOL;
453 $outstr .= ' <td class="editname">Chiller domoticz idx</td>'.PHP_EOL; 460 $outstr .= ' <td class="editname">Chiller domoticz idx</td>'.PHP_EOL;
454 $outstr .= ' <td class="editfield"><input type="text" name="ChillerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 461 $outstr .= ' <td class="editfield"><input type="text" name="ChillerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
455 $outstr .= ' </tr>'.PHP_EOL; 462 $outstr .= ' </tr>'.PHP_EOL;
456 } 463 }
464
457 if ($f[0] == "HEATER_ADDRESS") { 465 if ($f[0] == "HEATER_ADDRESS") {
458 $outstr .= ' <tr class="editor">'.PHP_EOL; 466 $outstr .= ' <tr class="editor">'.PHP_EOL;
459 $outstr .= ' <td class="editname">Heater Switch Address</td>'.PHP_EOL; 467 $outstr .= ' <td class="editname">Heater Switch Address</td>'.PHP_EOL;
460 $outstr .= ' <td class="editfield"><select name="HeaterAddress">'.PHP_EOL; 468 $outstr .= ' <td class="editfield"><select name="HeaterAddress">'.PHP_EOL;
461 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; 469 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
471 } 479 }
472 $j++; 480 $j++;
473 } 481 }
474 } 482 }
475 $outstr .= ' </select></td>'.PHP_EOL; 483 $outstr .= ' </select></td>'.PHP_EOL;
476 // $outstr .= ' </tr>'.PHP_EOL;
477 } 484 }
478 if ($f[0] == "HEATER_DELAY") { 485 if ($f[0] == "HEATER_DELAY") {
479 // $outstr .= ' <tr class="editor">'.PHP_EOL;
480 $outstr .= ' <td class="editname">Heater Switch Delay</td>'.PHP_EOL; 486 $outstr .= ' <td class="editname">Heater Switch Delay</td>'.PHP_EOL;
481 $outstr .= ' <td class="editfield"><input type="text" name="HeaterDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL; 487 $outstr .= ' <td class="editfield"><input type="text" name="HeaterDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL;
482 $outstr .= ' </tr>'.PHP_EOL; 488 $outstr .= ' </tr>'.PHP_EOL;
483 } 489 }
490
484 if ($f[0] == "HEATER_IDX") { 491 if ($f[0] == "HEATER_IDX") {
485 $outstr .= ' <tr class="editor">'.PHP_EOL; 492 $outstr .= ' <tr class="editor">'.PHP_EOL;
486 $outstr .= ' <td class="editname">Heater domoticz idx</td>'.PHP_EOL; 493 $outstr .= ' <td class="editname">Heater domoticz idx</td>'.PHP_EOL;
487 $outstr .= ' <td class="editfield"><input type="text" name="HeaterIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 494 $outstr .= ' <td class="editfield"><input type="text" name="HeaterIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
488 // $outstr .= ' </tr>'.PHP_EOL;
489 } 495 }
490 if ($f[0] == "PIDH_IMAX") { 496 if ($f[0] == "PIDH_IMAX") {
491 // $outstr .= ' <tr class="editor">'.PHP_EOL;
492 $outstr .= ' <td class="editname">PID Heat Maximum</td>'.PHP_EOL; 497 $outstr .= ' <td class="editname">PID Heat Maximum</td>'.PHP_EOL;
493 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_iMax" size="6" value="'.$f[1].'"> % (1..100)</td>'.PHP_EOL; 498 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_iMax" size="6" value="'.$f[1].'"> % (1..100)</td>'.PHP_EOL;
494 $outstr .= ' </tr>'.PHP_EOL; 499 $outstr .= ' </tr>'.PHP_EOL;
495 } 500 }
501
496 if ($f[0] == "PIDH_IDLERANGE") { 502 if ($f[0] == "PIDH_IDLERANGE") {
497 $outstr .= ' <tr class="editor">'.PHP_EOL; 503 $outstr .= ' <tr class="editor">'.PHP_EOL;
498 $outstr .= ' <td class="editname">Heater Idle Range</td>'.PHP_EOL; 504 $outstr .= ' <td class="editname">Heater Idle Range</td>'.PHP_EOL;
499 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_idleRange" size="6" value="'.$f[1].'"> &deg;C (Heater margin)</td>'.PHP_EOL; 505 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_idleRange" size="6" value="'.$f[1].'"> &deg;C (Heater margin)</td>'.PHP_EOL;
500 // $outstr .= ' </tr>'.PHP_EOL;
501 } 506 }
502 if ($f[0] == "PIDH_PGAIN") { 507 if ($f[0] == "PIDH_PGAIN") {
503 // $outstr .= ' <tr class="editor">'.PHP_EOL;
504 $outstr .= ' <td class="editname">PID Heat pGain</td>'.PHP_EOL; 508 $outstr .= ' <td class="editname">PID Heat pGain</td>'.PHP_EOL;
505 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_pGain" size="6" value="'.$f[1].'"> Proportional</td>'.PHP_EOL; 509 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_pGain" size="6" value="'.$f[1].'"> Proportional</td>'.PHP_EOL;
506 $outstr .= ' </tr>'.PHP_EOL; 510 $outstr .= ' </tr>'.PHP_EOL;
507 } 511 }
512
508 if ($f[0] == "PIDH_IGAIN") { 513 if ($f[0] == "PIDH_IGAIN") {
509 $outstr .= ' <tr class="editor">'.PHP_EOL; 514 $outstr .= ' <tr class="editor">'.PHP_EOL;
510 $outstr .= ' <td class="editname">PID Heat iGain</td>'.PHP_EOL; 515 $outstr .= ' <td class="editname">PID Heat iGain</td>'.PHP_EOL;
511 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_iGain" size="6" value="'.$f[1].'"> Intergral</td>'.PHP_EOL; 516 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_iGain" size="6" value="'.$f[1].'"> Intergral</td>'.PHP_EOL;
512 // $outstr .= ' </tr>'.PHP_EOL;
513 } 517 }
514 if ($f[0] == "PIDH_DGAIN") { 518 if ($f[0] == "PIDH_DGAIN") {
515 // $outstr .= ' <tr class="editor">'.PHP_EOL;
516 $outstr .= ' <td class="editname">PID Heat dGain</td>'.PHP_EOL; 519 $outstr .= ' <td class="editname">PID Heat dGain</td>'.PHP_EOL;
517 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_dGain" size="6" value="'.$f[1].'"> Derivative</td>'.PHP_EOL; 520 $outstr .= ' <td class="editfield"><input type="text" name="PIDH_dGain" size="6" value="'.$f[1].'"> Derivative</td>'.PHP_EOL;
518 $outstr .= ' </tr>'.PHP_EOL; 521 $outstr .= ' </tr>'.PHP_EOL;
519 } 522 }
523
520 if ($f[0] == "COOLER_ADDRESS") { 524 if ($f[0] == "COOLER_ADDRESS") {
521 $outstr .= ' <tr class="editor">'.PHP_EOL; 525 $outstr .= ' <tr class="editor">'.PHP_EOL;
522 $outstr .= ' <td class="editname">Cooler Switch Address</td>'.PHP_EOL; 526 $outstr .= ' <td class="editname">Cooler Switch Address</td>'.PHP_EOL;
523 $outstr .= ' <td class="editfield"><select name="CoolerAddress">'.PHP_EOL; 527 $outstr .= ' <td class="editfield"><select name="CoolerAddress">'.PHP_EOL;
524 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; 528 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
534 } 538 }
535 $j++; 539 $j++;
536 } 540 }
537 } 541 }
538 $outstr .= ' </select></td>'.PHP_EOL; 542 $outstr .= ' </select></td>'.PHP_EOL;
539 // $outstr .= ' </tr>'.PHP_EOL;
540 } 543 }
541 if ($f[0] == "COOLER_DELAY") { 544 if ($f[0] == "COOLER_DELAY") {
542 // $outstr .= ' <tr class="editor">'.PHP_EOL;
543 $outstr .= ' <td class="editname">Cooler Switch Delay</td>'.PHP_EOL; 545 $outstr .= ' <td class="editname">Cooler Switch Delay</td>'.PHP_EOL;
544 $outstr .= ' <td class="editfield"><input type="text" name="CoolerDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL; 546 $outstr .= ' <td class="editfield"><input type="text" name="CoolerDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL;
545 $outstr .= ' </tr>'.PHP_EOL; 547 $outstr .= ' </tr>'.PHP_EOL;
546 } 548 }
549
547 if ($f[0] == "COOLER_IDX") { 550 if ($f[0] == "COOLER_IDX") {
548 $outstr .= ' <tr class="editor">'.PHP_EOL; 551 $outstr .= ' <tr class="editor">'.PHP_EOL;
549 $outstr .= ' <td class="editname">Cooler domoticz idx</td>'.PHP_EOL; 552 $outstr .= ' <td class="editname">Cooler domoticz idx</td>'.PHP_EOL;
550 $outstr .= ' <td class="editfield"><input type="text" name="CoolerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 553 $outstr .= ' <td class="editfield"><input type="text" name="CoolerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
551 // $outstr .= ' </tr>'.PHP_EOL;
552 } 554 }
553 if ($f[0] == "PIDC_IMAX") { 555 if ($f[0] == "PIDC_IMAX") {
554 // $outstr .= ' <tr class="editor">'.PHP_EOL;
555 $outstr .= ' <td class="editname">PID Cool Maximum</td>'.PHP_EOL; 556 $outstr .= ' <td class="editname">PID Cool Maximum</td>'.PHP_EOL;
556 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_iMax" size="6" value="'.$f[1].'"> % (1..100)</td>'.PHP_EOL; 557 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_iMax" size="6" value="'.$f[1].'"> % (1..100)</td>'.PHP_EOL;
557 $outstr .= ' </tr>'.PHP_EOL; 558 $outstr .= ' </tr>'.PHP_EOL;
558 } 559 }
560
559 if ($f[0] == "PIDC_IDLERANGE") { 561 if ($f[0] == "PIDC_IDLERANGE") {
560 $outstr .= ' <tr class="editor">'.PHP_EOL; 562 $outstr .= ' <tr class="editor">'.PHP_EOL;
561 $outstr .= ' <td class="editname">Cooler Idle Range</td>'.PHP_EOL; 563 $outstr .= ' <td class="editname">Cooler Idle Range</td>'.PHP_EOL;
562 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_idleRange" size="6" value="'.$f[1].'"> &deg;C (Cooler margin)</td>'.PHP_EOL; 564 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_idleRange" size="6" value="'.$f[1].'"> &deg;C (Cooler margin)</td>'.PHP_EOL;
563 // $outstr .= ' </tr>'.PHP_EOL;
564 } 565 }
565 if ($f[0] == "PIDC_PGAIN") { 566 if ($f[0] == "PIDC_PGAIN") {
566 // $outstr .= ' <tr class="editor">'.PHP_EOL;
567 $outstr .= ' <td class="editname">PID Cool pGain</td>'.PHP_EOL; 567 $outstr .= ' <td class="editname">PID Cool pGain</td>'.PHP_EOL;
568 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_pGain" size="6" value="'.$f[1].'"> Proportional</td>'.PHP_EOL; 568 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_pGain" size="6" value="'.$f[1].'"> Proportional</td>'.PHP_EOL;
569 $outstr .= ' </tr>'.PHP_EOL; 569 $outstr .= ' </tr>'.PHP_EOL;
570 } 570 }
571
571 if ($f[0] == "PIDC_IGAIN") { 572 if ($f[0] == "PIDC_IGAIN") {
572 $outstr .= ' <tr class="editor">'.PHP_EOL; 573 $outstr .= ' <tr class="editor">'.PHP_EOL;
573 $outstr .= ' <td class="editname">PID Cool iGain</td>'.PHP_EOL; 574 $outstr .= ' <td class="editname">PID Cool iGain</td>'.PHP_EOL;
574 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_iGain" size="6" value="'.$f[1].'"> Intergral</td>'.PHP_EOL; 575 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_iGain" size="6" value="'.$f[1].'"> Intergral</td>'.PHP_EOL;
575 // $outstr .= ' </tr>'.PHP_EOL;
576 } 576 }
577 if ($f[0] == "PIDC_DGAIN") { 577 if ($f[0] == "PIDC_DGAIN") {
578 // $outstr .= ' <tr class="editor">'.PHP_EOL;
579 $outstr .= ' <td class="editname">PID Cool dGain</td>'.PHP_EOL; 578 $outstr .= ' <td class="editname">PID Cool dGain</td>'.PHP_EOL;
580 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_dGain" size="6" value="'.$f[1].'"> Derivative</td>'.PHP_EOL; 579 $outstr .= ' <td class="editfield"><input type="text" name="PIDC_dGain" size="6" value="'.$f[1].'"> Derivative</td>'.PHP_EOL;
581 $outstr .= ' </tr>'.PHP_EOL; 580 $outstr .= ' </tr>'.PHP_EOL;
582 } 581 }
582
583 if ($f[0] == "FAN_ADDRESS") { 583 if ($f[0] == "FAN_ADDRESS") {
584 $outstr .= ' <tr class="editor">'.PHP_EOL; 584 $outstr .= ' <tr class="editor">'.PHP_EOL;
585 $outstr .= ' <td class="editname">Fan Switch Address</td>'.PHP_EOL; 585 $outstr .= ' <td class="editname">Fan Switch Address</td>'.PHP_EOL;
586 $outstr .= ' <td class="editfield"><select name="FanAddress">'.PHP_EOL; 586 $outstr .= ' <td class="editfield"><select name="FanAddress">'.PHP_EOL;
587 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; 587 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
597 } 597 }
598 $j++; 598 $j++;
599 } 599 }
600 } 600 }
601 $outstr .= ' </select></td>'.PHP_EOL; 601 $outstr .= ' </select></td>'.PHP_EOL;
602 // $outstr .= ' </tr>'.PHP_EOL;
603 } 602 }
604 if ($f[0] == "FAN_DELAY") { 603 if ($f[0] == "FAN_DELAY") {
605 // $outstr .= ' <tr class="editor">'.PHP_EOL;
606 $outstr .= ' <td class="editname">Fan Switch Delay</td>'.PHP_EOL; 604 $outstr .= ' <td class="editname">Fan Switch Delay</td>'.PHP_EOL;
607 $outstr .= ' <td class="editfield"><input type="text" name="FanDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL; 605 $outstr .= ' <td class="editfield"><input type="text" name="FanDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL;
608 $outstr .= ' </tr>'.PHP_EOL; 606 $outstr .= ' </tr>'.PHP_EOL;
609 } 607 }
608
610 if ($f[0] == "FAN_IDX") { 609 if ($f[0] == "FAN_IDX") {
611 $outstr .= ' <tr class="editor">'.PHP_EOL; 610 $outstr .= ' <tr class="editor">'.PHP_EOL;
612 $outstr .= ' <td class="editname">Fan domoticz idx</td>'.PHP_EOL; 611 $outstr .= ' <td class="editname">Fan domoticz idx</td>'.PHP_EOL;
613 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="FanIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 612 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="FanIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
614 $outstr .= ' </tr>'.PHP_EOL; 613 $outstr .= ' </tr>'.PHP_EOL;
630 } 629 }
631 $j++; 630 $j++;
632 } 631 }
633 } 632 }
634 $outstr .= ' </select></td>'.PHP_EOL; 633 $outstr .= ' </select></td>'.PHP_EOL;
635 // $outstr .= ' </tr>'.PHP_EOL; 634 }
636 } 635
637 if ($f[0] == "LIGHT_DELAY") { 636 if ($f[0] == "LIGHT_DELAY") {
638 // $outstr .= ' <tr class="editor">'.PHP_EOL;
639 $outstr .= ' <td class="editname">Lights Delay</td>'.PHP_EOL; 637 $outstr .= ' <td class="editname">Lights Delay</td>'.PHP_EOL;
640 $outstr .= ' <td class="editfield"><input type="text" name="LightDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL; 638 $outstr .= ' <td class="editfield"><input type="text" name="LightDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL;
641 $outstr .= ' </tr>'.PHP_EOL; 639 $outstr .= ' </tr>'.PHP_EOL;
642 } 640 }
641
643 if ($f[0] == "LIGHT_IDX") { 642 if ($f[0] == "LIGHT_IDX") {
644 $outstr .= ' <tr class="editor">'.PHP_EOL; 643 $outstr .= ' <tr class="editor">'.PHP_EOL;
645 $outstr .= ' <td class="editname">Light domoticz idx</td>'.PHP_EOL; 644 $outstr .= ' <td class="editname">Light domoticz idx</td>'.PHP_EOL;
646 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="LightIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 645 $outstr .= ' <td colspan="3" class="editfield"><input type="text" name="LightIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
647 $outstr .= ' </tr>'.PHP_EOL; 646 $outstr .= ' </tr>'.PHP_EOL;
648 } 647 }
648
649 if ($f[0] == "DOOR_ADDRESS") { 649 if ($f[0] == "DOOR_ADDRESS") {
650 $outstr .= ' <tr class="editor">'.PHP_EOL; 650 $outstr .= ' <tr class="editor">'.PHP_EOL;
651 $outstr .= ' <td class="editname">Door Sensor Address</td>'.PHP_EOL; 651 $outstr .= ' <td class="editname">Door Sensor Address</td>'.PHP_EOL;
652 $outstr .= ' <td class="editfield"><select name="DoorAddress">'.PHP_EOL; 652 $outstr .= ' <td class="editfield"><select name="DoorAddress">'.PHP_EOL;
653 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; 653 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
663 } 663 }
664 $j++; 664 $j++;
665 } 665 }
666 } 666 }
667 $outstr .= ' </select></td>'.PHP_EOL; 667 $outstr .= ' </select></td>'.PHP_EOL;
668 // $outstr .= ' </tr>'.PHP_EOL;
669 } 668 }
670 if ($f[0] == "DOOR_IDX") { 669 if ($f[0] == "DOOR_IDX") {
671 // $outstr .= ' <tr class="editor">'.PHP_EOL;
672 $outstr .= ' <td class="editname">Door domoticz idx</td>'.PHP_EOL; 670 $outstr .= ' <td class="editname">Door domoticz idx</td>'.PHP_EOL;
673 $outstr .= ' <td class="editfield"><input type="text" name="DoorIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 671 $outstr .= ' <td class="editfield"><input type="text" name="DoorIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
674 $outstr .= ' </tr>'.PHP_EOL; 672 $outstr .= ' </tr>'.PHP_EOL;
675 } 673 }
674
676 if ($f[0] == "PSU_ADDRESS") { 675 if ($f[0] == "PSU_ADDRESS") {
677 $outstr .= ' <tr class="editor">'.PHP_EOL; 676 $outstr .= ' <tr class="editor">'.PHP_EOL;
678 $outstr .= ' <td class="editname">Power Supply Sensor Address</td>'.PHP_EOL; 677 $outstr .= ' <td class="editname">PSU Sensor Address</td>'.PHP_EOL;
679 $outstr .= ' <td class="editfield"><select name="PSUAddress">'.PHP_EOL; 678 $outstr .= ' <td class="editfield"><select name="PSUAddress">'.PHP_EOL;
680 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; 679 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
681 if (startsWith($devices[0], "212")) { 680 if (startsWith($devices[0], "212")) {
682 $j = 1; 681 $j = 1;
683 while (1) { 682 while (1) {
690 } 689 }
691 $j++; 690 $j++;
692 } 691 }
693 } 692 }
694 $outstr .= ' </select></td>'.PHP_EOL; 693 $outstr .= ' </select></td>'.PHP_EOL;
695 // $outstr .= ' </tr>'.PHP_EOL;
696 } 694 }
697 if ($f[0] == "PSU_IDX") { 695 if ($f[0] == "PSU_IDX") {
698 // $outstr .= ' <tr class="editor">'.PHP_EOL;
699 $outstr .= ' <td class="editname">PSU domoticz idx</td>'.PHP_EOL; 696 $outstr .= ' <td class="editname">PSU domoticz idx</td>'.PHP_EOL;
700 $outstr .= ' <td class="editfield"><input type="text" name="PSUIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; 697 $outstr .= ' <td class="editfield"><input type="text" name="PSUIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
701 $outstr .= ' </tr>'.PHP_EOL; 698 $outstr .= ' </tr>'.PHP_EOL;
702 } 699 }
700
703 if ($f[0] == "TEMP_SET_MIN") { 701 if ($f[0] == "TEMP_SET_MIN") {
704 $outstr .= ' <tr class="editor">'.PHP_EOL; 702 $outstr .= ' <tr class="editor">'.PHP_EOL;
705 $outstr .= ' <td class="editname">Min. temp setting</td>'.PHP_EOL; 703 $outstr .= ' <td class="editname">Min. temp setting</td>'.PHP_EOL;
706 $outstr .= ' <td class="editfield"><input type="text" name="TempSetMin" size="5" value="'.$f[1].'"> &deg;C</td>'.PHP_EOL; 704 $outstr .= ' <td class="editfield"><input type="text" name="TempSetMin" size="5" value="'.$f[1].'"> &deg;C</td>'.PHP_EOL;
707 // $outstr .= ' </tr>'.PHP_EOL;
708 } 705 }
709 if ($f[0] == "TEMP_SET_MAX") { 706 if ($f[0] == "TEMP_SET_MAX") {
710 // $outstr .= ' <tr class="editor">'.PHP_EOL;
711 $outstr .= ' <td class="editname">Max. temp setting</td>'.PHP_EOL; 707 $outstr .= ' <td class="editname">Max. temp setting</td>'.PHP_EOL;
712 $outstr .= ' <td class="editfield"><input type="text" name="TempSetMax" size="5" value="'.$f[1].'"> &deg;C</td>'.PHP_EOL; 708 $outstr .= ' <td class="editfield"><input type="text" name="TempSetMax" size="5" value="'.$f[1].'"> &deg;C</td>'.PHP_EOL;
713 $outstr .= ' </tr>'.PHP_EOL; 709 $outstr .= ' </tr>'.PHP_EOL;
714 } 710 }
711
715 $i++; 712 $i++;
716 } 713 }
717 } 714 }
718 $outstr .= ' <tr class="editor">'.PHP_EOL; 715 $outstr .= ' <tr class="editor">'.PHP_EOL;
719 $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL; 716 $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL;
767 $outstr .= ' </div> <!-- errors -->'.PHP_EOL; 764 $outstr .= ' </div> <!-- errors -->'.PHP_EOL;
768 $outstr .= ' <div id="etable">'.PHP_EOL; 765 $outstr .= ' <div id="etable">'.PHP_EOL;
769 $outstr .= ' <table class="setup">'.PHP_EOL; 766 $outstr .= ' <table class="setup">'.PHP_EOL;
770 $outstr .= ' <tr class="trhead">'.PHP_EOL; 767 $outstr .= ' <tr class="trhead">'.PHP_EOL;
771 $outstr .= ' <td class="setup" style="width: 300px;">UUID</td>'.PHP_EOL; 768 $outstr .= ' <td class="setup" style="width: 300px;">UUID</td>'.PHP_EOL;
772 $outstr .= ' <td class="setup" style="width: 300px;">Name</td>'.PHP_EOL; 769 $outstr .= ' <td class="setup" style="width: 300px;">Alias</td>'.PHP_EOL;
773 $outstr .= ' <td class="setup" style="width: 60px;">Mode</td>'.PHP_EOL; 770 $outstr .= ' <td class="setup" style="width: 60px;">Mode</td>'.PHP_EOL;
774 $outstr .= ' <td class="setup" style="width: 40px;">Edit</td>'.PHP_EOL; 771 $outstr .= ' <td class="setup" style="width: 40px;">Edit</td>'.PHP_EOL;
775 $outstr .= ' </tr>'.PHP_EOL; 772 $outstr .= ' </tr>'.PHP_EOL;
776 773
777 if (startsWith($arr[0], "212")) { 774 if (startsWith($arr[0], "212")) {
800 $outstr .= ' <div id="atable">'.PHP_EOL; 797 $outstr .= ' <div id="atable">'.PHP_EOL;
801 $outstr .= ' <form method="POST" action="units.php">'.PHP_EOL; 798 $outstr .= ' <form method="POST" action="units.php">'.PHP_EOL;
802 $outstr .= ' <table class="editor">'.PHP_EOL; 799 $outstr .= ' <table class="editor">'.PHP_EOL;
803 $outstr .= ' <tr class="trhead"><td colspan="3">Add new unit</td></tr>'.PHP_EOL; 800 $outstr .= ' <tr class="trhead"><td colspan="3">Add new unit</td></tr>'.PHP_EOL;
804 $outstr .= ' <tr class="editor">'.PHP_EOL; 801 $outstr .= ' <tr class="editor">'.PHP_EOL;
805 $outstr .= ' <td class="editname">Unit Name</td>'.PHP_EOL; 802 $outstr .= ' <td class="editname">Product Name</td>'.PHP_EOL;
806 $outstr .= ' <td class="editfield"><input type="text" name="Name" size="50" value=""></td>'.PHP_EOL; 803 $outstr .= ' <td class="editfield"><input type="text" name="ProductName" size="50" value=""></td>'.PHP_EOL;
807 $outstr .= ' <td class="editsub"><input type="submit" value="Add" name="key"></td>'.PHP_EOL; 804 $outstr .= ' <td class="editsub"><input type="submit" value="Add" name="key"></td>'.PHP_EOL;
805 $outstr .= '<input type="hidden" value="FAKE000" name="ProductCode">';
808 $outstr .= '<input type="hidden" value="0.0" name="Volume">'; 806 $outstr .= '<input type="hidden" value="0.0" name="Volume">';
809 $outstr .= '<input type="hidden" value="" name="AirAddress">'; 807 $outstr .= '<input type="hidden" value="" name="AirAddress">';
810 $outstr .= '<input type="hidden" value="0" name="AirIdx">'; 808 $outstr .= '<input type="hidden" value="0" name="AirIdx">';
811 $outstr .= '<input type="hidden" value="" name="BeerAddress">'; 809 $outstr .= '<input type="hidden" value="" name="BeerAddress">';
812 $outstr .= '<input type="hidden" value="0" name="BeerIdx">'; 810 $outstr .= '<input type="hidden" value="0" name="BeerIdx">';

mercurial