Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.

Thu, 18 Aug 2022 16:11:20 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 16:11:20 +0200
changeset 397
877420a13815
parent 396
c9a1d85c1487
child 398
49cf387e9070

Edit Product, split CO2 package pressure in bottles and kegs. BU:RE code cleanup. calcPack() sets the CO2 values on the first tab. Show final EBC on tab 1 if the stage is after brew. Show final ABV and energy on tab 1 if fermentation is done. Removed wrong bottle priming calculation from calcFermentables() because calcPack() does this.

src/EditProduct.cpp file | annotate | diff | comparison | revisions
src/EditProductTab1.cpp file | annotate | diff | comparison | revisions
src/EditProductTab11.cpp file | annotate | diff | comparison | revisions
src/EditProductTab3.cpp file | annotate | diff | comparison | revisions
src/EditRecipeTab1.cpp file | annotate | diff | comparison | revisions
ui/EditProduct.ui file | annotate | diff | comparison | revisions
ui/EditRecipe.ui file | annotate | diff | comparison | revisions
--- a/src/EditProduct.cpp	Wed Aug 17 15:23:17 2022 +0200
+++ b/src/EditProduct.cpp	Thu Aug 18 16:11:20 2022 +0200
@@ -334,11 +334,16 @@
     ui->est_ibuShow->setRange(product->st_ibu_min, product->st_ibu_max);
     ui->est_ibuShow->setValue(product->est_ibu);
     ui->ibu_methodEdit->setCurrentIndex(product->ibu_method);
-    ui->est_carbEdit->setValue(product->est_carb);
-    ui->est_carbShow->setPrecision(1);
-    ui->est_carbShow->setMarkerTextIsValue(true);
-    ui->est_carbShow->setRange(product->st_carb_min, product->st_carb_max);
-    ui->est_carbShow->setValue(product->est_carb);
+    ui->est_bottle_co2Edit->setValue(product->bottle_carbonation);
+    ui->est_bottle_co2Show->setPrecision(1);
+    ui->est_bottle_co2Show->setMarkerTextIsValue(true);
+    ui->est_bottle_co2Show->setRange(product->st_carb_min, product->st_carb_max);
+    ui->est_bottle_co2Show->setValue(product->bottle_carbonation);
+    ui->est_kegs_co2Edit->setValue(product->keg_carbonation);
+    ui->est_kegs_co2Show->setPrecision(1);
+    ui->est_kegs_co2Show->setMarkerTextIsValue(true);
+    ui->est_kegs_co2Show->setRange(product->st_carb_min, product->st_carb_max);
+    ui->est_kegs_co2Show->setValue(product->keg_carbonation);
     calcStyle();
     ui->est_buguShow->setPrecision(2);
     ui->est_buguShow->setMarkerTextIsValue(true);
--- a/src/EditProductTab1.cpp	Wed Aug 17 15:23:17 2022 +0200
+++ b/src/EditProductTab1.cpp	Thu Aug 18 16:11:20 2022 +0200
@@ -40,12 +40,13 @@
     double re = ((0.1808 * ((Utils::sg_to_plato(product->st_og_min) + Utils::sg_to_plato(product->st_og_max)) / 2)) +
 		 (0.8192 * ((Utils::sg_to_plato(fg_min) + Utils::sg_to_plato(product->st_fg_max)) / 2)));
 
-    /* BU:RE */
+    /*
+     * BU:RE
+     * Divide over average RE gives the best ranges.
+     */
     double bure_min = product->st_ibu_min / re;
     double bure_max = product->st_ibu_max / re;
     ui->est_bufguShow->setRange(bure_min, bure_max);
-
-    qDebug() << "BU:RE" << bure_min << bure_max;
 }
 
 
@@ -116,7 +117,8 @@
     ui->est_fgShow->setRange(query.value(9).toDouble(), query.value(10).toDouble());
     ui->est_ibuShow->setRange(query.value(11).toDouble(), query.value(12).toDouble());
     ui->est_colorShow->setRange(query.value(13).toDouble(), query.value(14).toDouble());
-    ui->est_carbShow->setRange(query.value(15).toDouble(), query.value(16).toDouble());
+    ui->est_bottle_co2Show->setRange(query.value(15).toDouble(), query.value(16).toDouble());
+    ui->est_kegs_co2Show->setRange(query.value(15).toDouble(), query.value(16).toDouble());
     ui->est_abvShow->setRange(query.value(17).toDouble(), query.value(18).toDouble());
 
     calcStyle();
@@ -329,8 +331,6 @@
     ui->sp_acidtypeEdit->setDisabled(stage > PROD_STAGE_BREW);
     ui->w2_volEdit->setReadOnly(stage > PROD_STAGE_BREW);
     ui->w2_volEdit->setButtonSymbols((stage > PROD_STAGE_BREW) ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows);
-    //ui->sp_tempEdit->setReadOnly(stage > PROD_STAGE_BREW);
-    //ui->sp_tempEdit->setButtonSymbols((stage > PROD_STAGE_BREW) ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows);
     ui->sp_volEdit->setReadOnly(stage > PROD_STAGE_BREW);
     ui->sp_volEdit->setButtonSymbols((stage > PROD_STAGE_BREW) ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows);
     ui->bs_cacl2Edit->setReadOnly(stage > PROD_STAGE_BREW);
--- a/src/EditProductTab11.cpp	Wed Aug 17 15:23:17 2022 +0200
+++ b/src/EditProductTab11.cpp	Thu Aug 18 16:11:20 2022 +0200
@@ -174,6 +174,8 @@
 	product->bottle_abv = 0;
 	product->bottle_bar = 0;
     }
+    ui->est_bottle_co2Edit->setValue(product->bottle_carbonation);
+    ui->est_bottle_co2Show->setValue(product->bottle_carbonation);
 
     ui->keg_sugarLabel->setEnabled(! product->keg_forced_carb);
     ui->keg_sugarEdit->setEnabled(! product->keg_forced_carb);
@@ -184,7 +186,6 @@
     ui->keg_sug_amountLabel->setEnabled(! product->keg_forced_carb);
     ui->keg_sug_amountShow->setEnabled(! product->keg_forced_carb);
 
-    // keg_amount keg_carbonation keg_priming_sugar keg_priming_amount keg_priming_water keg_carbonation_temp keg_forced_carb keg_pressure
     found1 = false;
     if (product->keg_amount) {
 
@@ -262,6 +263,8 @@
 	    ui->keg_sug_amountShow->setValue(0);
             ui->keg_sug_weightShow->setValue(0);
 	}
+	ui->est_kegs_co2Edit->setValue(product->keg_carbonation);
+	ui->est_kegs_co2Show->setValue(product->keg_carbonation);
     } // if keg_amount
 }
 
--- a/src/EditProductTab3.cpp	Wed Aug 17 15:23:17 2022 +0200
+++ b/src/EditProductTab3.cpp	Thu Aug 18 16:11:20 2022 +0200
@@ -401,11 +401,18 @@
     }
     qDebug() << "  color" << ui->est_colorEdit->value() << color << product->est_color;
     product->est_color = color;
-    ui->est_colorEdit->setValue(color);
-    ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color));
     ui->est_color2Edit->setValue(color);
     ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color));
-    ui->est_colorShow->setValue(color);
+    if (product->stage > PROD_STAGE_BREW) {
+        ui->est_colorLabel->setText(tr("Final EBC"));
+	ui->est_colorEdit->setValue(product->brew_fermenter_color);
+	ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(product->brew_fermenter_color));
+	ui->est_colorShow->setValue(product->brew_fermenter_color);
+    } else {
+	ui->est_colorEdit->setValue(color);
+	ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color));
+	ui->est_colorShow->setValue(color);
+    }
 
     if (round(product->mashs_kg / product->eq_mash_max * 100) > 120)
 	ui->perc_mashShow->setValue(120);
@@ -447,7 +454,7 @@
 		product->yeasts_ok = false;
 	    }
 	}
-	qDebug() << "  SVG" << svg;
+	qDebug() << "  est SVG" << svg;
     }
     if (svg == 0)
 	svg = 77.0;
@@ -457,49 +464,40 @@
 	product->est_fg = Utils::estimate_fg(psugar, pcara, mashinfuse / product->mashs_kg, mashtime, mashtemp, svg, product->est_og);
     else
 	product->est_fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, product->est_og);
-    qDebug() << "  FG" << ui->est_fgEdit->value() << product->est_fg;
+    qDebug() << "  est FG" << ui->est_fgEdit->value() << product->est_fg;
+    product->est_abv = Utils::abvol(product->est_og, product->est_fg);
+    qDebug() << "  est ABV" << ui->est_abvEdit->value() << product->est_abv;
+
     if (product->stage > PROD_STAGE_TERTIARY) {
 	ui->est_fgLabel->setText(tr("Final FG"));
 	ui->est_fgEdit->setValue(product->fg);
 	ui->est_fgShow->setValue(product->fg);
+	ui->est_abvLabel->setText(tr("Final ABV"));
+	double abv = Utils::abvol(product->og, product->fg);
+	ui->est_abvEdit->setValue(abv);
+	ui->est_abvShow->setValue(abv);
     } else {
 	ui->est_fgEdit->setValue(product->est_fg);
 	ui->est_fgShow->setValue(product->est_fg);
+	ui->est_abvEdit->setValue(product->est_abv);
+	ui->est_abvShow->setValue(product->est_abv);
     }
     ui->est_fg3Edit->setValue(product->est_fg);
-
-    product->est_abv = Utils::abvol(product->est_og, product->est_fg);
-    qDebug() << "  ABV" << ui->est_abvEdit->value() << product->est_abv;
-    ui->est_abvEdit->setValue(product->est_abv);
     ui->est_abv2Edit->setValue(product->est_abv);
-    ui->est_abvShow->setValue(product->est_abv);
 
     /*
      * Calculate kilocalories/liter. Formula from brouwhulp.
      * Take the alcohol and sugar parts and then combine.
      */
-    double alc = 1881.22 * product->est_fg * (product->est_og - product->est_fg) / (1.775 - product->est_og);
-    double sug = 3550 * product->est_fg * (0.1808 * product->est_og + 0.8192 * product->est_fg - 1.0004);
+    double alc, sug;
+    if (product->stage > PROD_STAGE_TERTIARY) {
+	alc = 1881.22 * product->fg * (product->og - product->fg) / (1.775 - product->og);
+	sug = 3550 * product->fg * (0.1808 * product->og + 0.8192 * product->fg - 1.0004);
+    } else {
+	alc = 1881.22 * product->est_fg * (product->est_og - product->est_fg) / (1.775 - product->est_og);
+	sug = 3550 * product->est_fg * (0.1808 * product->est_og + 0.8192 * product->est_fg - 1.0004);
+    }
     ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296)));
-
-    // Bottle priming
-    double priming_total = 0;
-    for (i = 0; i < product->fermentables.size(); i++) {
-	if (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE) {
-	    priming_total += ((product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100)) *
-		    		product->fermentables.at(i).amount;
-	    qDebug() << "  priming" << product->fermentables.at(i).amount << "total" << priming_total;
-	}
-    }
-    double grl = priming_total * 1000.0 * (1 / product->batch_size);
-    double volco2 = grl * 0.510;
-    qDebug() << "  priming gr/l" << grl << "volco2" << volco2;
-
-    if (volco2 > 0) {
-	product->est_carb = volco2;
-	ui->est_carbEdit->setValue(product->est_carb);
-	ui->est_carbShow->setValue(product->est_carb);
-    }
 }
 
 
--- a/src/EditRecipeTab1.cpp	Wed Aug 17 15:23:17 2022 +0200
+++ b/src/EditRecipeTab1.cpp	Thu Aug 18 16:11:20 2022 +0200
@@ -40,12 +40,13 @@
     double re = ((0.1808 * ((Utils::sg_to_plato(recipe->st_og_min) + Utils::sg_to_plato(recipe->st_og_max)) / 2)) +
                 (0.8192 * ((Utils::sg_to_plato(fg_min) + Utils::sg_to_plato(recipe->st_fg_max)) / 2)));
 
-    /* BU:RE */
+    /*
+     * BU:RE
+     * Divide over average RE gives the best ranges.
+     */
     double bure_min = recipe->st_ibu_min / re;
     double bure_max = recipe->st_ibu_max / re;
     ui->est_bufguShow->setRange(bure_min, bure_max);
-
-    qDebug() << "BU:RE" << bure_min << bure_max;
 }
 
 
@@ -189,7 +190,6 @@
     adjustYeasts(factor);
     calcIBUs();
     calcWater();
-    //calcSparge();
     calcMash();
     is_changed();
     emit refreshAll();
--- a/ui/EditProduct.ui	Wed Aug 17 15:23:17 2022 +0200
+++ b/ui/EditProduct.ui	Thu Aug 18 16:11:20 2022 +0200
@@ -527,7 +527,7 @@
           </rect>
          </property>
          <property name="text">
-          <string>Alcohol Volume:</string>
+          <string>Estimated ABV:</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -615,7 +615,7 @@
           </rect>
          </property>
         </widget>
-        <widget class="QDoubleSpinBox" name="est_carbEdit">
+        <widget class="QDoubleSpinBox" name="est_bottle_co2Edit">
          <property name="geometry">
           <rect>
            <x>870</x>
@@ -702,7 +702,7 @@
           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
          </property>
         </widget>
-        <widget class="QLabel" name="est_carbLabel">
+        <widget class="QLabel" name="est_bottle_co2Label">
          <property name="geometry">
           <rect>
            <x>730</x>
@@ -712,13 +712,13 @@
           </rect>
          </property>
          <property name="text">
-          <string>Carbonation:</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-         </property>
-        </widget>
-        <widget class="RangedSlider" name="est_carbShow">
+          <string>Bottles CO2:</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+         </property>
+        </widget>
+        <widget class="RangedSlider" name="est_bottle_co2Show">
          <property name="geometry">
           <rect>
            <x>950</x>
@@ -738,7 +738,7 @@
           </rect>
          </property>
          <property name="text">
-          <string>Color EBC:</string>
+          <string>Estimated EBC:</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -818,7 +818,7 @@
          <property name="geometry">
           <rect>
            <x>730</x>
-           <y>80</y>
+           <y>110</y>
            <width>131</width>
            <height>20</height>
           </rect>
@@ -840,7 +840,7 @@
           </rect>
          </property>
          <property name="text">
-          <string>Bitterness IBU:</string>
+          <string>Estimated IBU:</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -850,7 +850,7 @@
          <property name="geometry">
           <rect>
            <x>870</x>
-           <y>80</y>
+           <y>110</y>
            <width>71</width>
            <height>24</height>
           </rect>
@@ -1006,6 +1006,69 @@
           </rect>
          </property>
         </widget>
+        <widget class="QDoubleSpinBox" name="est_kegs_co2Edit">
+         <property name="geometry">
+          <rect>
+           <x>870</x>
+           <y>80</y>
+           <width>71</width>
+           <height>24</height>
+          </rect>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+         </property>
+         <property name="readOnly">
+          <bool>true</bool>
+         </property>
+         <property name="buttonSymbols">
+          <enum>QAbstractSpinBox::NoButtons</enum>
+         </property>
+         <property name="accelerated">
+          <bool>false</bool>
+         </property>
+         <property name="suffix">
+          <string> %</string>
+         </property>
+         <property name="decimals">
+          <number>1</number>
+         </property>
+         <property name="minimum">
+          <double>0.000000000000000</double>
+         </property>
+         <property name="maximum">
+          <double>80.000000000000000</double>
+         </property>
+         <property name="singleStep">
+          <double>0.100000000000000</double>
+         </property>
+        </widget>
+        <widget class="RangedSlider" name="est_kegs_co2Show">
+         <property name="geometry">
+          <rect>
+           <x>950</x>
+           <y>80</y>
+           <width>148</width>
+           <height>24</height>
+          </rect>
+         </property>
+        </widget>
+        <widget class="QLabel" name="est_kegs_co2Label">
+         <property name="geometry">
+          <rect>
+           <x>730</x>
+           <y>80</y>
+           <width>131</width>
+           <height>20</height>
+          </rect>
+         </property>
+         <property name="text">
+          <string>Kegs CO2:</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+         </property>
+        </widget>
        </widget>
        <widget class="QGroupBox" name="styleBox">
         <property name="geometry">
@@ -2940,7 +3003,7 @@
          </rect>
         </property>
         <property name="text">
-         <string>Alcohol Volume:</string>
+         <string>Estimated ABV:</string>
         </property>
         <property name="alignment">
          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -11571,7 +11634,7 @@
   <tabstop>est_abvEdit</tabstop>
   <tabstop>est_colorEdit</tabstop>
   <tabstop>color_methodEdit</tabstop>
-  <tabstop>est_carbEdit</tabstop>
+  <tabstop>est_bottle_co2Edit</tabstop>
   <tabstop>est_ibuEdit</tabstop>
   <tabstop>ibu_methodEdit</tabstop>
   <tabstop>calEdit</tabstop>
--- a/ui/EditRecipe.ui	Wed Aug 17 15:23:17 2022 +0200
+++ b/ui/EditRecipe.ui	Thu Aug 18 16:11:20 2022 +0200
@@ -521,7 +521,7 @@
           </rect>
          </property>
          <property name="text">
-          <string>Alcohol Volume:</string>
+          <string>Estimated ABV:</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -732,7 +732,7 @@
           </rect>
          </property>
          <property name="text">
-          <string>Color EBC:</string>
+          <string>Estimated EBC:</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -834,7 +834,7 @@
           </rect>
          </property>
          <property name="text">
-          <string>Bitterness IBU:</string>
+          <string>Estimated IBU:</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>

mercurial