Sun, 05 Jan 2020 20:00:39 +0100
Fixed ispindel_death. Added ispindel log graph.
bmsd/mysql.c | file | annotate | diff | comparison | revisions | |
www/Makefile | file | annotate | diff | comparison | revisions | |
www/getispindellog.php | file | annotate | diff | comparison | revisions | |
www/js/log_ispindel.js | file | annotate | diff | comparison | revisions | |
www/js/mon_ispindel.js | file | annotate | diff | comparison | revisions | |
www/log_ispindel.php | file | annotate | diff | comparison | revisions |
--- a/bmsd/mysql.c Sun Jan 05 17:04:56 2020 +0100 +++ b/bmsd/mysql.c Sun Jan 05 20:00:39 2020 +0100 @@ -757,11 +757,11 @@ -void ispindel_mysql_death(char *uuid) +void ispindel_mysql_death(char *node) { char *query = malloc(512); - snprintf(query, 511, "UPDATE mon_ispindels SET online='0' WHERE uuid='%s'", uuid); + snprintf(query, 511, "UPDATE mon_ispindels SET online='0' WHERE node='%s'", node); bms_mysql_query(query); free(query); }
--- a/www/Makefile Sun Jan 05 17:04:56 2020 +0100 +++ b/www/Makefile Sun Jan 05 20:00:39 2020 +0100 @@ -9,10 +9,11 @@ export_yeasts.php favicon.ico gen_about.php \ getbrewlog.php getco2meter.php getco2pressurelog.php getfermentablesources.php \ getfermenter.php getfermentlog.php gethopsources.php getmiscsources.php getnode.php \ - getwatersources.php getyeastsources.php getispindel.php import_ingredients.php index.php \ + getwatersources.php getyeastsources.php getispindel.php getispindellog.php \ + import_ingredients.php index.php \ inv_equipments.php inv_fermentables.php inv_hops.php inv_instock.php \ inv_miscs.php inv_suppliers.php inv_waters.php inv_yeasts.php \ - log_brew.php log_co2pressure.php log_fermentation.php \ + log_brew.php log_co2pressure.php log_fermentation.php log_ispindel.php \ mon_brewer.php mon_co2meter.php mon_fermenter.php mon_ispindel.php mon_node.php \ prod_archive_code.php prod_archive_date.php prod_archive_name.php prod_beerxml.php \ prod_checklist.php prod_divide.php prod_duplicate.php prod_edit.php prod_export.php prod_forum.php \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/getispindellog.php Sun Jan 05 20:00:39 2020 +0100 @@ -0,0 +1,45 @@ +<?php + +require_once('config.php'); + +if (isset($_GET["code"])) + $code = $_GET["code"] . ' ' . $_GET["name"]; +else + $code = "TB0091 Kwik"; + +$filename = 'log/ispindel/' . $code . '.log'; + +/* + * 2014-11-15 18:39:12,TEMPERATURE,PLATO,SG,BATTERY,ANGLE,INVERVAL,UUID + * | | | | | + * datetime + | | | | + * temperature ------------+ | | | + * density plato --------------------+ | | + * density sg ----------------------------+ | + * battery ------------------------------------+ + */ +$handle = @fopen($filename, "r"); +if ($handle) { + $lines = 0; + while (($buffer = fgets($handle, 4096)) !== false) { + + $buffer = preg_replace( "/\r|\n/", "", $buffer); + $row = explode(",", $buffer); + $lines++; + + $logs[] = array( + 'date' => $row[0], + 'temperature' => $row[1], + 'plato' => $row[2], + 'sg' => $row[3], + 'battery' => $row[4] + ); + } + if (!feof($handle)) { + echo "Error: unexpected fgets() fail\n"; + } + fclose($handle); +} +header("Content-type: application/json"); +echo json_encode($logs); +//echo $lines . ' lines' . PHP_EOL;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/js/log_ispindel.js Sun Jan 05 20:00:39 2020 +0100 @@ -0,0 +1,128 @@ +/***************************************************************************** + * Copyright (C) 2020 + * + * Michiel Broek <mbroek at mbse dot eu> + * + * This file is part of BMS + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * Brewery Managment System is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ThermFerm; see the file COPYING. If not, write to the Free + * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + *****************************************************************************/ + + +$(document).ready(function() { + + $('#jqxMenu').jqxMenu('destroy'); + $('#jqxLoader').jqxLoader({ + width: 250, + height: 150, + isModal: true, + text: 'Opmaken grafiek ...', + theme: theme + }); + $('#jqxLoader').jqxLoader('open'); + + function getExportServer() { + return 'https://www.jqwidgets.com/export_server/export.php'; + } + + var sourceA = { + datatype: 'json', + datafields: [ + { name: 'date', type: 'date', format: 'yyyy-MM-dd HH:mm' }, + { name: 'temperature', type: 'float' }, + { name: 'plato', type: 'float' }, + { name: 'sg', type: 'float' }, + { name: 'battery', type: 'float' } + ], + url: 'getispindellog.php?code=' + my_code + '&name=' + my_name + }, + dataAdapter = new $.jqx.dataAdapter(sourceA, { + autoBind: true, + async: false, + loadComplete: function() { + $('#jqxLoader').jqxLoader('close'); + }, + loadError: function(jqXHR, status, error) { + } + }), + settings = { + title: my_code + ' "' + my_name + '"', + description: '', + source: dataAdapter, + xAxis: { + dataField: 'date', + type: 'date', + formatFunction: function(value) { + return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear(); + }, + toolTipFormatFunction: function(value) { + var h = value.getHours(), m = value.getMinutes(); + return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() + + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m); + }, + textRotationAngle: 45, + howGridLines: false + }, + colorScheme: 'scheme01', + seriesGroups: [ + { + type: 'spline', + valueAxis: { displayValueAxis: false, description: 'Densiteit SG' }, + series: [{ dataField: 'sg', lineWidth: 3, displayText: 'SG' }] + }, + { + type: 'spline', + valueAxis: { displayValueAxis: false, description: 'Graden C' }, + series: [{ dataField: 'temperature', lineWidth: 1, displayText: 'Temperatuur' }] + } + ] + }; + $('#ispindel_chart').jqxChart(settings); + + $('#print').click(function() { + var content = $('#ispindel_chart')[0].outerHTML, + newWindow = window.open('', '', 'width=865, height=425'), + document = newWindow.document.open(), + pageContent = + '<!DOCTYPE html>' + + '<html>' + + '<head>' + + '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' + + '<meta charset="utf-8" />' + + '<title>' + my_code + ' ' + my_name + ' vergisting</title>' + + '</head>' + + '<body>' + content + '</body></html>'; + document.write(pageContent); + document.close(); + newWindow.print(); + }); + $('#print').jqxButton({ template: 'primary', width: 125, theme: theme }); + + $('#pdfButton').click(function() { + $('#ispindel_chart').jqxChart('saveAsPDF', 'vergisting_' + my_code + '.pdf', getExportServer()); + }); + $('#pdfButton').jqxButton({ template: 'primary', width: 125, theme: theme }); + + $('#pngButton').click(function() { + $('#ispindel_chart').jqxChart('saveAsPNG', 'vergisting_' + my_code + '.png', getExportServer()); + }); + $('#pngButton').jqxButton({ template: 'primary', width: 125, theme: theme }); + + $('#Close').jqxButton({ template: 'success', width: 125, theme: theme }); + $('#Close').click(function() { + window.close(); + }); +}); +
--- a/www/js/mon_ispindel.js Sun Jan 05 17:04:56 2020 +0100 +++ b/www/js/mon_ispindel.js Sun Jan 05 20:00:39 2020 +0100 @@ -247,7 +247,7 @@ // The chart button. $('#VLog').jqxButton({ template: 'primary', width: '150px', theme: theme }); -// $('#FLog').click(function() { -// window.open('log_co2pressure.php?code=' + record.beercode + '&name=' + record.beername); -// }); + $('#VLog').click(function() { + window.open('log_ispindel.php?code=' + record.beercode + '&name=' + record.beername); + }); });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/log_ispindel.php Sun Jan 05 20:00:39 2020 +0100 @@ -0,0 +1,19 @@ +<?php +require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); +page_header('Vergisting grafiek', "log_ispindel"); +?> + + <div id="MainPanel"> + <div id="ContentPanel"></div> + <div id="ispindel_chart" style="width:1130px; height:610px; float:left; margin-left: 10px; margin-top: 10px;"></div> + <div style="margin-top: 10px; margin-left: 10px;"> + <input style="float: left; margin-left: 10px;" id="print" type="button" value="Print grafiek" /> + <input style="float: left; margin-left: 10px; margin-top: 10px;" id="pdfButton" type="button" value="Maak PDF" /> + <input style="float: left; margin-left: 10px; margin-top: 10px;" id="pngButton" type="button" value="Maak PNG" /> + <input style="float: left; margin-left: 10px; margin-top: 10px;" id="Close" type="button" value="Sluiten" /> + </div> + </div> + +<?php +page_footer(); +?>