# HG changeset patch # User Michiel Broek # Date 1660831880 -7200 # Node ID 877420a138151e0945006d564312a70dbfb60bf2 # Parent c9a1d85c14872c479a71fd59dd4fbe939a368104 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. diff -r c9a1d85c1487 -r 877420a13815 src/EditProduct.cpp --- 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); diff -r c9a1d85c1487 -r 877420a13815 src/EditProductTab1.cpp --- 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); diff -r c9a1d85c1487 -r 877420a13815 src/EditProductTab11.cpp --- 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 } diff -r c9a1d85c1487 -r 877420a13815 src/EditProductTab3.cpp --- 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); - } } diff -r c9a1d85c1487 -r 877420a13815 src/EditRecipeTab1.cpp --- 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(); diff -r c9a1d85c1487 -r 877420a13815 ui/EditProduct.ui --- 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 @@ - Alcohol Volume: + Estimated ABV: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -615,7 +615,7 @@ - + 870 @@ -702,7 +702,7 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 730 @@ -712,13 +712,13 @@ - Carbonation: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - + Bottles CO2: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 950 @@ -738,7 +738,7 @@ - Color EBC: + Estimated EBC: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -818,7 +818,7 @@ 730 - 80 + 110 131 20 @@ -840,7 +840,7 @@ - Bitterness IBU: + Estimated IBU: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -850,7 +850,7 @@ 870 - 80 + 110 71 24 @@ -1006,6 +1006,69 @@ + + + + 870 + 80 + 71 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + false + + + % + + + 1 + + + 0.000000000000000 + + + 80.000000000000000 + + + 0.100000000000000 + + + + + + 950 + 80 + 148 + 24 + + + + + + + 730 + 80 + 131 + 20 + + + + Kegs CO2: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + @@ -2940,7 +3003,7 @@ - Alcohol Volume: + Estimated ABV: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -11571,7 +11634,7 @@ est_abvEdit est_colorEdit color_methodEdit - est_carbEdit + est_bottle_co2Edit est_ibuEdit ibu_methodEdit calEdit diff -r c9a1d85c1487 -r 877420a13815 ui/EditRecipe.ui --- 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 @@ - Alcohol Volume: + Estimated ABV: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -732,7 +732,7 @@ - Color EBC: + Estimated EBC: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -834,7 +834,7 @@ - Bitterness IBU: + Estimated IBU: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter