Record iSpindel original plato by updating to the highest measured value. Reset this value when a new beer is set. Added current status to the monitor screen.

Sun, 08 Mar 2020 17:11:18 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 08 Mar 2020 17:11:18 +0100
changeset 628
a42166cbb19a
parent 627
f1a7c14d5601
child 629
92afe6b59610

Record iSpindel original plato by updating to the highest measured value. Reset this value when a new beer is set. Added current status to the monitor screen.

bmsd/mysql.c file | annotate | diff | comparison | revisions
www/cmd_ispindel.php file | annotate | diff | comparison | revisions
www/js/mon_ispindel.js file | annotate | diff | comparison | revisions
www/mon_ispindel.php file | annotate | diff | comparison | revisions
--- a/bmsd/mysql.c	Sat Mar 07 21:05:49 2020 +0100
+++ b/bmsd/mysql.c	Sun Mar 08 17:11:18 2020 +0100
@@ -729,7 +729,7 @@
 
     snprintf(query, 2559,
         "INSERT INTO mon_ispindels SET uuid='%s', alias='%s', node='%s', online='%d', mode='%s', alarm='%d', " \
-        "angle='%.5f', temperature='%.4f', battery='%.6f', gravity='%.5f', up_interval='%d'",
+        "angle='%.5f', temperature='%.4f', battery='%.6f', gravity='%.5f', up_interval='%d', og_gravity='0.0'",
         ispindel->uuid, ispindel->alias, ispindel->node, ispindel->online ? 1:0, ispindel->mode, ispindel->alarm,
         ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval);
 
@@ -747,9 +747,9 @@
 
     snprintf(query, 2559,
         "UPDATE mon_ispindels SET online='%d', mode='%s', alarm='%d', " \
-	"angle='%.5f', temperature='%.4f', battery='%.6f', gravity='%.5f', up_interval='%d' WHERE uuid='%s'",
+	"angle='%.5f', temperature='%.4f', battery='%.6f', gravity='%.5f', up_interval='%d', og_gravity=GREATEST(og_gravity, '%.5f') WHERE uuid='%s'",
         ispindel->online ? 1:0, ispindel->mode, ispindel->alarm,
-	ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval, ispindel->uuid);
+	ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval, ispindel->gravity, ispindel->uuid);
 
     bms_mysql_query(query);
     free(query);
--- a/www/cmd_ispindel.php	Sat Mar 07 21:05:49 2020 +0100
+++ b/www/cmd_ispindel.php	Sun Mar 08 17:11:18 2020 +0100
@@ -14,7 +14,7 @@
 	$sql .=    "beername='" . mysqli_real_escape_string($connect, $_POST['beername']);
 	$sql .= "', beercode='" . mysqli_real_escape_string($connect, $_POST['beercode']);
 	$sql .= "', beeruuid='" . mysqli_real_escape_string($connect, $_POST['beeruuid']);
-	$sql .= "' WHERE uuid='" . $_POST['uuid'] . "';";
+	$sql .= "', og_gravity=0 WHERE uuid='" . $_POST['uuid'] . "';";
 } else if (isset($_POST['mode'])) {
 	$sql  = "UPDATE `mon_ispindels` SET mode='" .$_POST['mode'] . "' WHERE uuid='" . $_POST['uuid'] . "';";
 } else {
--- a/www/js/mon_ispindel.js	Sat Mar 07 21:05:49 2020 +0100
+++ b/www/js/mon_ispindel.js	Sun Mar 08 17:11:18 2020 +0100
@@ -100,7 +100,8 @@
    { name: 'battery', type: 'float' },
    { name: 'gravity', type: 'float' },
    { name: 'up_interval', type: 'int' },
-   { name: 'mode', type: 'string' }
+   { name: 'mode', type: 'string' },
+   { name: 'og_gravity', type: 'float' }
   ],
   id: 'record',
   url: url
@@ -137,10 +138,21 @@
    $('#gaugeContainer_temperature').jqxGauge({ caption: { value: record.temperature.toFixed(3) + '°C' }});
    $('#gaugeContainer_temperature').jqxGauge({ value: record.temperature });
 
+   var og = plato_to_sg(record.og_gravity);
+   var sg = plato_to_sg(record.gravity);
+   var svg = 100 * (og - sg) / (og - 1);
+
    $('#info_battery').val(record.battery);
    $('#info_tilt').val(record.angle);
    $('#info_plato').val(record.gravity);
-   $('#info_sg').val(plato_to_sg(record.gravity));
+   $('#info_sg').val(sg);
+
+   $('#vg_og1').html(og.toFixed(4));
+   $('#vg_og2').html(record.og_gravity.toFixed(1) + '&deg;P');
+   $('#vg_sg1').html(sg.toFixed(4));
+   $('#vg_sg2').html(record.gravity.toFixed(1) + '&deg;P');
+   $('#vg_svg').html(svg.toFixed(1) + '%')
+   $('#vg_abv').html(abvol(og, sg).toFixed(2) + '%');
 
    var gravity = plato_to_sg(record.gravity) * 1000;
    $('#gaugeContainer_gravity').jqxLinearGauge({ value: gravity });
--- a/www/mon_ispindel.php	Sat Mar 07 21:05:49 2020 +0100
+++ b/www/mon_ispindel.php	Sun Mar 08 17:11:18 2020 +0100
@@ -60,10 +60,31 @@
      </div> <!-- ispindel_panel_top -->
 
      <div id="ispindel_panel_display">
-      <div id="ispindel_display">
-      </div>
-      <div id="ispindel_display">
-      </div>
+      <table style='width: 100%; padding: 10px;'>
+       <col width="30%">
+       <col width="35%">
+       <col width="35%">
+       <tr><th colspan=3>Voortgang</th></tr>
+       <tr><th colspan=3>&nbsp;</th></tr>
+       <tr style="height: 25px;">
+        <td>OG</td>
+        <td><div id="vg_og1"></div></td>
+        <td><div id="vg_og2"></div></td>
+       </tr>
+       <tr style="height: 25px;">
+        <td>SG</td>
+        <td><div id="vg_sg1"></div></td>
+        <td><div id="vg_sg2"></div></td>
+       </tr>
+       <tr style="height: 25px;">
+        <td>SVG</td>
+        <td colspan='2'><div id="vg_svg"></div></td>
+       </tr>
+       <tr style="height: 25px;">
+        <td>ABV</td>
+        <td colspan='2'><div id="vg_abv"></div></td>
+       </tr>
+      </table>
      </div> <!-- ispindel_panel_display -->
 
      <div id="ispindel_panel_control">

mercurial