# HG changeset patch # User Michiel Broek # Date 1546980859 -3600 # Node ID a810539dc2186ea4b57faa527599b2967911b0ce # Parent 58618d93c0fb69ee4572db106cd0f5934a739320 Added cmd_fermenter.php which interfaces http POST commands to MQTT using mosquitto_pub in a shell. Several chnges to the monitor fermenter screen. diff -r 58618d93c0fb -r a810539dc218 .hgignore --- a/.hgignore Mon Jan 07 22:35:32 2019 +0100 +++ b/.hgignore Tue Jan 08 21:54:19 2019 +0100 @@ -9,6 +9,7 @@ doc/bms.pdf www/version.php www/config.php +www/run/sequence syntax: glob *.o diff -r 58618d93c0fb -r a810539dc218 www/Makefile --- a/www/Makefile Mon Jan 07 22:35:32 2019 +0100 +++ b/www/Makefile Tue Jan 08 21:54:19 2019 +0100 @@ -3,7 +3,7 @@ include ../Makefile.global -SRC = config.php.dist favicon.ico gen_about.php getfermentablesources.php \ +SRC = cmd_fermenter.php config.php.dist favicon.ico gen_about.php getfermentablesources.php \ getfermenter.php getfermentlog.php gethopsources.php getmiscsources.php \ getnode.php getwatersources.php getyeastsources.php index.php \ inv_equipments.php inv_fermentables.php inv_hops.php inv_instock.php \ @@ -31,6 +31,7 @@ install: ${INSTALL} -d -g 314 -o 314 ${PREFIX} ${WWWDIR} ${WWWDIR}/css \ ${WWWDIR}/jqwidgets ${WWWDIR}/js ${WWWDIR}/images/ ${WWWDIR}/includes/ + ${INSTALL} -d -g 314 -o 314 -m 0777 ${WWWDIR}/run ${INSTALL} -g 314 -o 314 ${SRC} ${WWWDIR}/ ${INSTALL} -g 314 -o 314 version.php ${WWWDIR}/ ${INSTALL} -g 314 -o 314 css/* ${WWWDIR}/css/ diff -r 58618d93c0fb -r a810539dc218 www/cmd_fermenter.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/cmd_fermenter.php Tue Jan 08 21:54:19 2019 +0100 @@ -0,0 +1,53 @@ + diff -r 58618d93c0fb -r a810539dc218 www/css/style.css --- a/www/css/style.css Mon Jan 07 22:35:32 2019 +0100 +++ b/www/css/style.css Tue Jan 08 21:54:19 2019 +0100 @@ -127,7 +127,7 @@ * | | * +-------------------------------+ */ -#fermentor_panel_top { +#fermenter_panel_top { width: 280px; height: 200px; float: right; @@ -138,18 +138,14 @@ border-radius: 5px 5px 5px 5px; } -#fermentor_selector { +#fermenter_selector { width: 100px; height: 198px; + margin-top: 3px; float: left; } -input.select { - margin-left: 10px; - margin-top: 13px; -} - -#fermentor_alarmled { +#fermenter_alarmled { width: 50px; height: 30px; float: left; @@ -158,7 +154,7 @@ margin-left: 20px; } -#fermentor_powerled { +#fermenter_powerled { width: 50px; height: 30px; float: left; @@ -167,7 +163,7 @@ margin-left: 42px; } -#fermentor_mode_control { +#fermenter_mode_control { width: 148px; height: 110px; float: left; @@ -175,7 +171,7 @@ background-color: #ddd; } -#fermentor_panel_display { +#fermenter_panel_display { width: 280px; height: 80px; float: right; @@ -187,7 +183,7 @@ margin-bottom: 3px; } -#fermentor_display1 { +#fermenter_display1 { width: 93px; height: 76px; float: left; @@ -195,7 +191,7 @@ margin-top: 7px; } -#fermentor_display2 { +#fermenter_display2 { width: 93px; height: 76px; float: left; @@ -203,7 +199,7 @@ margin-top: 7px; } -#fermentor_display3 { +#fermenter_display3 { width: 93px; height: 76px; float: left; @@ -226,9 +222,9 @@ color: red; } -#fermentor_panel_control { +#fermenter_panel_control { width: 280px; - height: 120px; + height: 140px; float: right; margin: 5px; background-color: #252526; @@ -238,56 +234,31 @@ margin-bottom: 3px; } -#fermentor_led1 { -width: 93px; -height: 30px; -float: left; -text-align: center; -margin-top: 8px; -} - -#fermentor_led2 { -width: 93px; -height: 30px; -float: left; -text-align: center; -margin-top: 8px; +#fermenter_led1, +#fermenter_led2, +#fermenter_led3 { + width: 93px; + height: 30px; + float: left; + text-align: center; + margin-top: 8px; } -#fermentor_led3 { -width: 93px; -height: 30px; -float: left; -text-align: center; -margin-top: 8px; +#fermenter_toggle1 { + float: left; + margin-left: 29px; + margin-top: 20px; } -#fermentor_toggle1 { -width: 93px; -height: 70px; -float: left; -text-align: center; -margin-top: 10px; -} - -#fermentor_toggle2 { -width: 93px; -height: 70px; -float: left; -text-align: center; -margin-top: 10px; -} - -#fermentor_toggle3 { -width: 93px; -height: 70px; -float: left; -text-align: center; -margin-top: 10px; +#fermenter_toggle2, +#fermenter_toggle3 { + float: left; + margin-left: 57px; + margin-top: 20px; } -#fermentor_panel_buttons { +#fermenter_panel_buttons { width: 280px; height: 130px; float: right; @@ -300,19 +271,6 @@ } -#fermenter_tempdigits { - width: 145px; - height: 120px; - float: left; - margin-top: 170; - background-color: #252526; - border: 2px solid; - border-color: #59b4d4; - border-radius: 5px 5px 5px 5px; -} - - - .LEDred_on { margin: 5px auto; width: 18px; diff -r 58618d93c0fb -r a810539dc218 www/includes/global.inc.php --- a/www/includes/global.inc.php Mon Jan 07 22:35:32 2019 +0100 +++ b/www/includes/global.inc.php Tue Jan 08 21:54:19 2019 +0100 @@ -154,6 +154,8 @@ + + diff -r 58618d93c0fb -r a810539dc218 www/js/log_fermentation.js --- a/www/js/log_fermentation.js Mon Jan 07 22:35:32 2019 +0100 +++ b/www/js/log_fermentation.js Tue Jan 08 21:54:19 2019 +0100 @@ -118,10 +118,10 @@ } ] }; - $("#fermentor_chart").jqxChart(settings); + $("#fermenter_chart").jqxChart(settings); $("#print").click(function () { - var content = $("#fermentor_chart")[0].outerHTML; + var content = $("#fermenter_chart")[0].outerHTML; var newWindow = window.open("", "", "width=865, height=425"), document = newWindow.document.open(), pageContent = @@ -141,12 +141,12 @@ $("#pdfButton").click(function () { - $("#fermentor_chart").jqxChart("saveAsPDF", "vergisting_"+my_code+".pdf", getExportServer()); + $("#fermenter_chart").jqxChart("saveAsPDF", "vergisting_"+my_code+".pdf", getExportServer()); }); $("#pdfButton").jqxButton({ template: "info", width: 125, theme: theme }); $("#pngButton").click(function () { - $("#fermentor_chart").jqxChart("saveAsPNG", "vergisting_"+my_code+".png", getExportServer()); + $("#fermenter_chart").jqxChart("saveAsPNG", "vergisting_"+my_code+".png", getExportServer()); }); $("#pngButton").jqxButton({ template: "info", width: 125, theme: theme }); diff -r 58618d93c0fb -r a810539dc218 www/js/mon_fermenter.js --- a/www/js/mon_fermenter.js Mon Jan 07 22:35:32 2019 +0100 +++ b/www/js/mon_fermenter.js Tue Jan 08 21:54:19 2019 +0100 @@ -27,6 +27,8 @@ var bcode = ''; var yl = 12; // Normal yeast temp range var yh = 24; + var bstage = ''; + var bmode = ''; var gaugeoptions = { min: 0, max: 40, width: 375, height: 375, @@ -55,12 +57,45 @@ animationDuration: 1200, caption: { value: 'Chiller', position: 'bottom', offset: [0, 10] } }; + var switchoptions = { + height: 68, + width: 35, + theme: theme, + thumbSize:'50%', + orientation: 'vertical' + }; + srcMode = [ "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" ]; + srcStage = [ "PRIMARY", "SECONDARY", "TERTIARY", "CARBONATION" ]; $("#gaugeContainer_air").jqxGauge( gaugeoptions ); $("#gaugeContainer_air").jqxGauge( { caption: { value: 'Air', position: 'bottom', offset: [0, 10] }} ); $("#gaugeContainer_beer").jqxGauge( gaugeoptions ); $("#gaugeContainer_beer").jqxGauge( { caption: { value: 'Beer', position: 'bottom', offset: [0, 10] }} ); $("#gaugeContainer_chiller").jqxGauge( gaugeSmalloptions ); + $("#fermenter_toggle1").jqxSwitchButton( switchoptions ); + $("#fermenter_toggle2").jqxSwitchButton( switchoptions ); + $("#fermenter_toggle3").jqxSwitchButton( switchoptions ); + + $("#info_mode").jqxDropDownList({ theme: theme, source: srcMode, width: 100, height: 23, dropDownHeight: 156 }); + $("#info_stage").jqxDropDownList({ theme: theme, source: srcStage, width: 150, height: 23, dropDownHeight: 125 }); + + function sendBase(stage, mode) { + + console.log("sendBase("+stage+", "+mode+")"); + var data = 'node=rpi01&alias=unit0&payload={"stage":"' + stage; + data += '","mode":"' + mode + '","setpoint":{"low":17.8,"high":18.2}}'; + $.ajax({ + url: "cmd_fermenter.php", + data: data, + type: "POST", + success: function(data) { + //do something after something is recieved from php + }, + error: function(jqXHR, textStatus, errorThrown) { + console.log("sendBase() error"); + } + }); + } var url = "getfermenter.php?uuid='" + my_uuid + "'"; var source = { @@ -110,27 +145,25 @@ loadComplete: function (records) { var record = dataAdapter.records[0]; var oline = (record.online) ? "On-line" : "Off-line"; - var html = ""; - html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - html += "" - html += ""; - $("#fermenter_info").html(html); + $("#info_uuid").html(record.uuid); + $("#info_system").html(record.node + "/" + record.alias + " " + oline); + $("#info_beer").html(record.beercode + " - " + record.beername); bcode = record.beercode; bname = record.beername; + bstage = record.stage; + bmode = record.mode; + $("#info_mode").jqxDropDownList('selectItem', record.mode); + $("#info_stage").jqxDropDownList('selectItem', record.stage); if (record.online && (record.mode != "OFF")) { - $("#fermentor_powerled").html('
Power'); + $("#fermenter_powerled").html('
Power'); } else { - $("#fermentor_powerled").html('
Power'); + $("#fermenter_powerled").html('
Power'); } if (record.online && (record.alarm != "0")) { - $("#fermentor_alarmled").html('
Alarm'); + $("#fermenter_alarmled").html('
Alarm'); } else { - $("#fermentor_alarmled").html('
Alarm'); + $("#fermenter_alarmled").html('
Alarm'); } $("#target_lo").html(record.setpoint_low.toFixed(1)); @@ -139,21 +172,32 @@ $("#load_beer").html(record.beer_temperature.toFixed(3)); if (record.online && (record.heater_state != "0")) { - $("#fermentor_led1").html('
Heat'); + $("#fermenter_led1").html('
Heat'); } else { - $("#fermentor_led1").html('
Heat'); + $("#fermenter_led1").html('
Heat'); } if (record.online && (record.cooler_state != "0")) { - $("#fermentor_led2").html('
Cool'); + $("#fermenter_led2").html('
Cool'); } else { - $("#fermentor_led2").html('
Cool'); + $("#fermenter_led2").html('
Cool'); } if (record.online && (record.fan_state != "0")) { - $("#fermentor_led3").html('
Fan'); + $("#fermenter_led3").html('
Fan'); } else { - $("#fermentor_led3").html('
Fan'); + $("#fermenter_led3").html('
Fan'); } - + if (record.online && (record.mode == "NONE")) { + $("#fermenter_toggle1").jqxSwitchButton( 'enable' ); + $("#fermenter_toggle2").jqxSwitchButton( 'enable' ); + $("#fermenter_toggle3").jqxSwitchButton( 'enable' ); + } else { + $("#fermenter_toggle1").jqxSwitchButton( 'disable' ); + $("#fermenter_toggle2").jqxSwitchButton( 'disable' ); + $("#fermenter_toggle3").jqxSwitchButton( 'disable' ); + $("#fermenter_toggle1").val( (record.heater_state != "0") ); + $("#fermenter_toggle2").val( (record.cooler_state != "0") ); + $("#fermenter_toggle3").val( (record.fan_state != "0") ); + } $('#gaugeContainer_air').jqxGauge({ value: record.air_temperature }); if (record.online && (record.air_state == "OK")) { @@ -182,6 +226,14 @@ dataAdapter.dataBind(); }, 10000); + $('#info_mode').on('change', function (event) { + sendBase(bstage, args.item.value); + }); + $('#info_stage').on('change', function (event) { + sendBase(args.item.value, bmode); + }); + + // The chart button. $("#FLog").jqxButton({ template: "info", width: '150px', theme: theme }); $("#FLog").click(function () { diff -r 58618d93c0fb -r a810539dc218 www/log_fermentation.php --- a/www/log_fermentation.php Mon Jan 07 22:35:32 2019 +0100 +++ b/www/log_fermentation.php Tue Jan 08 21:54:19 2019 +0100 @@ -5,7 +5,7 @@
-
+
diff -r 58618d93c0fb -r a810539dc218 www/mon_fermenter.php --- a/www/mon_fermenter.php Mon Jan 07 22:35:32 2019 +0100 +++ b/www/mon_fermenter.php Tue Jan 08 21:54:19 2019 +0100 @@ -7,7 +7,16 @@
-
+
+
Klimaatkast overzicht
Uuid" + record.uuid + "
Systeem" + record.node + "/" + record.alias + " " + oline + "
Bier" + record.beercode + " - " + record.beername + "
Werking" + record.mode + "
Fase" + record.stage + "
+ + + + + + +
Klimaatkast overzicht
Uuid
Systeem
Bier
Werking
Fase
+
@@ -17,39 +26,38 @@
-
-
- +
+
-
-
+
+
-
-
+
+
Sp
-
+
Air
-
+
Beer
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+