Calculate the svg using Brew by the Numbers, Micahel L. Hall.

Sat, 18 Apr 2020 11:12:28 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 18 Apr 2020 11:12:28 +0200
changeset 655
f4e00869f39f
parent 654
0aef416dbceb
child 656
a4a9f6ded485

Calculate the svg using Brew by the Numbers, Micahel L. Hall.

www/includes/formulas.php file | annotate | diff | comparison | revisions
www/js/global.js file | annotate | diff | comparison | revisions
www/js/mon_ispindel.js file | annotate | diff | comparison | revisions
www/js/prod_edit.js file | annotate | diff | comparison | revisions
www/prod_print.php file | annotate | diff | comparison | revisions
www/prod_r_yeast.php file | annotate | diff | comparison | revisions
--- a/www/includes/formulas.php	Fri Apr 17 11:29:37 2020 +0200
+++ b/www/includes/formulas.php	Sat Apr 18 11:12:28 2020 +0200
@@ -132,6 +132,14 @@
 
 
 
+function calc_svg($og, $fg) {
+	$oe = sg_to_plato($og);
+	$ae = sg_to_plato($fg);
+	return ($oe - $ae) / $oe * 100;
+}
+
+
+
 /*
  * sugars is the total extract weight of sugars.
  */
--- a/www/js/global.js	Fri Apr 17 11:29:37 2020 +0200
+++ b/www/js/global.js	Sat Apr 18 11:12:28 2020 +0200
@@ -1062,6 +1062,14 @@
 
 
 
+function calc_svg(og, fg) {
+ var oe = sg_to_plato(og);
+ var ae = sg_to_plato(fg);
+ return (oe - ae) / oe * 100;
+}
+
+
+
 function brix_to_sg(brix) {
  if (my_brix_correction > 0)
   return plato_to_sg(brix / my_brix_correction);
--- a/www/js/mon_ispindel.js	Fri Apr 17 11:29:37 2020 +0200
+++ b/www/js/mon_ispindel.js	Sat Apr 18 11:12:28 2020 +0200
@@ -147,7 +147,7 @@
 
    if (record.og_gravity) {
     var og = plato_to_sg(record.og_gravity);
-    var svg = 100 * (og - sg) / (og - 1);
+    var svg = calc_svg(og, sg);
 
     $('#vg_og1').html(og.toFixed(4));
     $('#vg_og2').html(record.og_gravity.toFixed(1) + '&deg;P');
--- a/www/js/prod_edit.js	Fri Apr 17 11:29:37 2020 +0200
+++ b/www/js/prod_edit.js	Sat Apr 18 11:12:28 2020 +0200
@@ -1960,7 +1960,7 @@
 
   // Calculate the final svg if available use the real value.
   if ((dataRecord.stage >= 6) && (dataRecord.fg > 0.990) && (dataRecord.fg < dataRecord.brew_fermenter_sg)) {
-   svg = 100 * (dataRecord.brew_fermenter_sg - dataRecord.fg) / (dataRecord.brew_fermenter_sg - 1);
+   svg = calc_svg(dataRecord.brew_fermenter_sg, dataRecord.fg);
    org = dataRecord.brew_fermenter_sg;
    fig = dataRecord.fg;
   }
@@ -3390,13 +3390,13 @@
   if (dataRecord.brew_fermenter_sg < 1.020)
    return;
   if ((dataRecord.primary_end_sg > 0.990) && (dataRecord.primary_end_sg < dataRecord.brew_fermenter_sg)) {
-   primary_svg = Round(100 * (dataRecord.brew_fermenter_sg - dataRecord.primary_end_sg) / (dataRecord.brew_fermenter_sg - 1), 1);
+   primary_svg = Round(calc_svg(dataRecord.brew_fermenter_sg, dataRecord.primary_end_sg), 1);
    $('#primary_svg').val(primary_svg);
    if ((dataRecord.secondary_end_sg > 0.990) && (dataRecord.secondary_end_sg < dataRecord.brew_fermenter_sg)) {
-    secondary_svg = Round(100 * (dataRecord.brew_fermenter_sg - dataRecord.secondary_end_sg) / (dataRecord.brew_fermenter_sg - 1), 1);
+    secondary_svg = Round(calc_svg(dataRecord.brew_fermenter_sg, dataRecord.secondary_end_sg), 1);
     $('#secondary_svg').val(secondary_svg);
     if ((dataRecord.fg > 0.990) && (dataRecord.fg < dataRecord.brew_fermenter_sg)) {
-     final_svg = Round(100 * (dataRecord.brew_fermenter_sg - dataRecord.fg) / (dataRecord.brew_fermenter_sg - 1), 1);
+     final_svg = Round(calc_svg(dataRecord.brew_fermenter_sg, dataRecord.fg), 1);
      $('#final_svg').val(final_svg);
      ABV = Round(abvol(dataRecord.brew_fermenter_sg, dataRecord.fg), 2);
      $('#final_abv').val(ABV);
--- a/www/prod_print.php	Fri Apr 17 11:29:37 2020 +0200
+++ b/www/prod_print.php	Sat Apr 18 11:12:28 2020 +0200
@@ -896,7 +896,7 @@
                 $this->Cell(45,5,'Lageren einde',0,0,'L',true);
                 $this->Cell(45,5,$row['package_date'],0,0,'L',true);
 		$this->Cell($vul,5,'',0,0,'L',false);
-		$svg = 100 * (floatval($row['brew_fermenter_sg']) - floatval($row['fg'])) / (floatval($row['brew_fermenter_sg']) - 1);
+		$svg = calc_svg(floatval($row['brew_fermenter_sg']), floatval($row['fg']));
 		$this->Cell(45,5,'Schijnbare vergistingsgraad',0,0,'L',true);
                 $this->Cell(45,5,sprintf("%.1f",$svg).'%',0,0,'L',true);
                 $this->Ln();
--- a/www/prod_r_yeast.php	Fri Apr 17 11:29:37 2020 +0200
+++ b/www/prod_r_yeast.php	Sat Apr 18 11:12:28 2020 +0200
@@ -101,7 +101,7 @@
 
 			$og = floatval($row['brew_fermenter_sg']);
 			$fg = floatval($row['fg']);
-			$svg = 100 * ($og - $fg) / ($og - 1);
+			$svg = calc_svg($og, $fg);
 
 			$name = iconv('UTF-8','windows-1252',$row['name']);
 			$this->SetX($this->TableX);

mercurial