Monitor motorhome leisure battery and provide simple control of habitation
Dependencies: net lpc1768 crypto clock web fram log
web-this/boiler/web-boiler-script.inc@0:b843d647695c, 2021-01-14 (annotated)
- Committer:
- andrewboyson
- Date:
- Thu Jan 14 16:05:55 2021 +0000
- Revision:
- 0:b843d647695c
Creation (mostly a copy of heating at the moment)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 0:b843d647695c | 1 | "//Boiler script\n" |
andrewboyson | 0:b843d647695c | 2 | "'use strict';\n" |
andrewboyson | 0:b843d647695c | 3 | "\n" |
andrewboyson | 0:b843d647695c | 4 | "let dateTime = '';\n" |
andrewboyson | 0:b843d647695c | 5 | "let tankTemperature = '';\n" |
andrewboyson | 0:b843d647695c | 6 | "let blrOutTemperature = '';\n" |
andrewboyson | 0:b843d647695c | 7 | "let blrRtnTemperature = '';\n" |
andrewboyson | 0:b843d647695c | 8 | "let boilerCall = false;\n" |
andrewboyson | 0:b843d647695c | 9 | "let boilerPump = false;\n" |
andrewboyson | 0:b843d647695c | 10 | "let tankSetPoint = '';\n" |
andrewboyson | 0:b843d647695c | 11 | "let tankHysteresis = '';\n" |
andrewboyson | 0:b843d647695c | 12 | "let blrRunOnDeg = '';\n" |
andrewboyson | 0:b843d647695c | 13 | "let blrRunOnTime = '';\n" |
andrewboyson | 0:b843d647695c | 14 | "\n" |
andrewboyson | 0:b843d647695c | 15 | "function parse()\n" |
andrewboyson | 0:b843d647695c | 16 | "{\n" |
andrewboyson | 0:b843d647695c | 17 | " let lines = Ajax.response.split('\\n');\n" |
andrewboyson | 0:b843d647695c | 18 | " tankTemperature = Ajax.hexToSignedInt16(lines[0]);\n" |
andrewboyson | 0:b843d647695c | 19 | " blrOutTemperature = Ajax.hexToSignedInt16(lines[1]);\n" |
andrewboyson | 0:b843d647695c | 20 | " blrRtnTemperature = Ajax.hexToSignedInt16(lines[2]);\n" |
andrewboyson | 0:b843d647695c | 21 | " boilerCall = Ajax.hexToBit (lines[3], 0);\n" |
andrewboyson | 0:b843d647695c | 22 | " boilerPump = Ajax.hexToBit (lines[3], 1);\n" |
andrewboyson | 0:b843d647695c | 23 | " tankSetPoint = Ajax.hexToSignedInt16(lines[4]);\n" |
andrewboyson | 0:b843d647695c | 24 | " tankHysteresis = Ajax.hexToSignedInt16(lines[5]);\n" |
andrewboyson | 0:b843d647695c | 25 | " blrRunOnDeg = Ajax.hexToSignedInt16(lines[6]);\n" |
andrewboyson | 0:b843d647695c | 26 | " blrRunOnTime = Ajax.hexToSignedInt16(lines[7]);\n" |
andrewboyson | 0:b843d647695c | 27 | "}\n" |
andrewboyson | 0:b843d647695c | 28 | "function display()\n" |
andrewboyson | 0:b843d647695c | 29 | "{\n" |
andrewboyson | 0:b843d647695c | 30 | " let elem;\n" |
andrewboyson | 0:b843d647695c | 31 | " elem = Ajax.getElementOrNull('ajax-tank-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(tankTemperature);\n" |
andrewboyson | 0:b843d647695c | 32 | " elem = Ajax.getElementOrNull('ajax-blr-out-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature);\n" |
andrewboyson | 0:b843d647695c | 33 | " elem = Ajax.getElementOrNull('ajax-blr-rtn-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrRtnTemperature);\n" |
andrewboyson | 0:b843d647695c | 34 | " elem = Ajax.getElementOrNull('ajax-blr-rise-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature - blrRtnTemperature);\n" |
andrewboyson | 0:b843d647695c | 35 | " \n" |
andrewboyson | 0:b843d647695c | 36 | " elem = Ajax.getElementOrNull('ajax-blr-call-toggle'); if (elem) elem.setAttribute('dir', boilerCall ? 'rtl' : 'ltr');\n" |
andrewboyson | 0:b843d647695c | 37 | " elem = Ajax.getElementOrNull('ajax-blr-pump-toggle'); if (elem) elem.setAttribute('dir', boilerPump ? 'rtl' : 'ltr');\n" |
andrewboyson | 0:b843d647695c | 38 | " elem = Ajax.getElementOrNull('ajax-tank-set-point' ); if (elem) elem.value = tankSetPoint;\n" |
andrewboyson | 0:b843d647695c | 39 | " elem = Ajax.getElementOrNull('ajax-tank-hysteresis'); if (elem) elem.value = tankHysteresis;\n" |
andrewboyson | 0:b843d647695c | 40 | " elem = Ajax.getElementOrNull('ajax-blr-run-on-deg' ); if (elem) elem.value = OneWire.DS18B20ToString(blrRunOnDeg);\n" |
andrewboyson | 0:b843d647695c | 41 | " elem = Ajax.getElementOrNull('ajax-blr-run-on-time'); if (elem) elem.value = blrRunOnTime;\n" |
andrewboyson | 0:b843d647695c | 42 | "\n" |
andrewboyson | 0:b843d647695c | 43 | "}\n" |
andrewboyson | 0:b843d647695c | 44 | "\n" |
andrewboyson | 0:b843d647695c | 45 | "Ajax.server = '/boiler-ajax';\n" |
andrewboyson | 0:b843d647695c | 46 | "Ajax.onResponse = function() { parse(); display(); };\n" |
andrewboyson | 0:b843d647695c | 47 | "Ajax.init();\n" |
andrewboyson | 0:b843d647695c | 48 | "" |