Better fg estimation in product print.

Thu, 14 Feb 2019 14:42:52 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 14 Feb 2019 14:42:52 +0100
changeset 275
fb1e88f1c643
parent 274
65ca75fc4af8
child 276
08c824a5ffd8

Better fg estimation in product print.

www/prod_print.php file | annotate | diff | comparison | revisions
--- a/www/prod_print.php	Wed Feb 13 21:10:38 2019 +0100
+++ b/www/prod_print.php	Thu Feb 14 14:42:52 2019 +0100
@@ -30,6 +30,7 @@
 $colorw = 0;
 $total_ibus = 0;
 $preboil_sg = 0;
+$mashkg = 0;
 date_default_timezone_set('Europe/Amsterdam');
 $prdate = date(DATE_RFC2822);
 
@@ -109,6 +110,7 @@
 		global $pCara;
 		global $colorw;
 		global $preboil_sg;
+		global $mashkg;
 		$added = array( 'Maischen', 'Koken', 'Vergisten', 'Nagisten/lageren', 'Bottelen' );
 		$vul = $this->w - $this->rMargin - $this->lMargin - 132;
 		$this->AddCol($vul,'Grondstof','L');
@@ -128,6 +130,7 @@
 
 		$sugarsf = 0;
 		$sugarsm = 0;
+		$mashkg = 0;
 		$this->SetFont('Helvetica','',9);
 		$this->SetFillColor(250, 195, 65);
 		$arr = json_decode($row['json_fermentables'], true);
@@ -154,6 +157,7 @@
 			if ($item['f_added']  == 0) {
 				$d = floatval($row['efficiency']) / 100 * $d;
 				$sugarsm += $d;
+				$mashkg += $amount;
 			}
 			$sugarsf += $d;
 			$colorw += ($amount * ebc_to_srm($color) / $row['batch_size']) * 8.34436;
@@ -389,6 +393,7 @@
 		global $cost_hops;
 		global $cost_miscs;
 		global $cost_yeasts;
+		global $mashkg;
 		/* 2 Columns */
 		$vul = $this->w - $this->rMargin - $this->lMargin - 170;
 		$cMargin=$this->cMargin;
@@ -403,7 +408,25 @@
 		$this->SetFont('Helvetica','',9);
 		$this->SetFillColor(210,245,255);
 
-		$row['est_fg'] = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $row['est_og']);
+		$mashtime = 0;
+		$mashtemp = 0;
+		$mash_infuse = 0;
+		$arr = json_decode($row['json_mashs'], true);
+		foreach($arr as $item) {
+			if ($item['step_type'] == 0) { // infusion
+				$mash_infuse += floatval($item['step_infuse_amount']);
+			}
+			if ($item['step_temp'] < 75) { // ignore mashout temps
+				$mashtime += floatval($item['step_time']);
+				$mashtemp += floatval($item['step_time']) * floatval($item['step_temp']);
+			}
+		}
+		$mashtemp = $mashtemp / $mashtime;
+		if (($mashkg > 0) && ($mash_infuse > 0) && ($mashtime > 0) && ($mashtemp > 0)) {
+			$row['est_fg'] = estimate_fg($pSugar, $pCara, $mash_infuse / $mashkg, $mashtime, $mashtemp, $svg, $row['est_og']);
+		} else {
+			$row['est_fg'] = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $row['est_og']);
+		}
 
 		$this->SetX($this->TableX);
 		$this->Cell(35,5,'Start SG',0,0,'L',true);

mercurial