src/EditRecipeTab2.cpp

changeset 148
ba25a566b100
parent 142
1caa15a0eefc
child 150
fd568cc1dd0e
--- a/src/EditRecipeTab2.cpp	Tue Apr 19 22:27:18 2022 +0200
+++ b/src/EditRecipeTab2.cpp	Wed Apr 20 12:19:36 2022 +0200
@@ -154,7 +154,6 @@
     double	addedmass = 0;		// Added mass after boil
     double	mvol = 0;		// Mash volume
     double	lintner = 0;		// Total recipe lintner
-    double	mashkg = 0;
     double	sugarsf = 0;		// fermentable sugars mash + boil
     double	sugarsm = 0;		// fermentable sugars in mash
     double	sugardensity = 1.611;	// kg/l in solution
@@ -213,10 +212,12 @@
     	ui->est_abvShow->setValue(0);
     	recipe->est_abv = 0;
     	ui->calEdit->setValue(0);
+	recipe->mashs_kg = 0;
 	return;
     }
     qDebug() << "  adjust to 100" << recipe->fermentables_use100;
 
+    recipe->mashs_kg = 0;
     for (i = 0; i < recipe->fermentables.size(); i++) {
 	if (recipe->fermentables.at(i).f_type == 1 && recipe->fermentables.at(i).f_added < 4)		// Sugars
 	    psugar += recipe->fermentables.at(i).f_percentage;
@@ -230,7 +231,7 @@
 	    }
 	    d = ui->efficiencyEdit->value() / 100 * d;
 	    sugarsm += d;
-	    mashkg += recipe->fermentables.at(i).f_amount;
+	    recipe->mashs_kg += recipe->fermentables.at(i).f_amount;
 	}
 	if (recipe->fermentables.at(i).f_added == 0 || recipe->fermentables.at(i).f_added == 1)		// Mash or boil
 	    sugarsf += d;
@@ -291,11 +292,16 @@
      * We don't have a equipment profile in recipes,
      * so we assume a certain guessed mashtun size.
      */
-    ui->perc_mashShow->setValue(round(mashkg / (ui->boil_sizeEdit->value() / 3) * 100));
+    ui->perc_mashShow->setValue(round(recipe->mashs_kg / (ui->boil_sizeEdit->value() / 3) * 100));
     ui->perc_sugarsShow->setValue(round(psugar));
     ui->perc_caraShow->setValue(round(pcara));
-    qDebug() << "  lintner" << lintner << "  mashkg" << mashkg << "final" << round(lintner / mashkg);
-    ui->lintnerShow->setValue(round(lintner / mashkg));
+    if (recipe->mashs_kg > 0) {
+	qDebug() << "  lintner" << lintner << "  mashkg" << recipe->mashs_kg << "final" << round(lintner / recipe->mashs_kg);
+	ui->lintnerShow->setValue(round(lintner / recipe->mashs_kg));
+    } else {
+	qDebug() << "  lintner N/A";
+	ui->lintnerShow->setValue(0);
+    }
 
     /*
      * Calculate the apparant attenuation.
@@ -316,8 +322,8 @@
     ui->est_svgEdit->setValue(svg);
 
     double fg;
-    if (mashkg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0)
-	fg = Utils::estimate_fg(psugar, pcara, mashinfuse / mashkg, mashtime, mashtemp, svg, og);
+    if (recipe->mashs_kg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0)
+	fg = Utils::estimate_fg(psugar, pcara, mashinfuse / recipe->mashs_kg, mashtime, mashtemp, svg, og);
     else
 	fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, og);
     qDebug() << "  FG" << ui->est_fgEdit->value() << fg;

mercurial