# HG changeset patch # User Michiel Broek # Date 1668787022 -3600 # Node ID 3c195eb4e7a1ddab95acc9de342ce1b7a255a101 # Parent d8c110d91b1f62cc67cabde4791de64f6c190488 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages. diff -r d8c110d91b1f -r 3c195eb4e7a1 src/DetailCO2meter.cpp --- a/src/DetailCO2meter.cpp Fri Nov 18 12:17:32 2022 +0100 +++ b/src/DetailCO2meter.cpp Fri Nov 18 16:57:02 2022 +0100 @@ -18,6 +18,7 @@ #include "ChartCarbonate.h" #include "../ui/ui_DetailCO2meter.h" #include "global.h" +#include "Utils.h" #include "MainWindow.h" @@ -62,7 +63,8 @@ void DetailCO2meter::refreshTable() { - QSqlQuery query; + QSqlQuery query, query2; + QString sql = ""; qDebug() << "refreshTable co2meter rec:" << this->recno; @@ -80,6 +82,34 @@ _beercode = query.value("beercode").toString(); _beername = query.value("beername").toString(); + sql = "SELECT " + "st_carb_min,st_carb_max,secondary_temp,primary_end_temp,bottle_carbonation_temp" + " FROM products WHERE code=:code AND name=:name"; + query2.prepare(sql); + query2.bindValue(":code", _beercode); + query2.bindValue(":name", _beername); + query2.exec(); + if (query2.next()) { + /* Get highest fermentation temperature. */ + double TSec = query2.value("secondary_temp").toDouble(); + if (TSec < 1) + TSec = query2.value("primary_end_temp").toDouble(); + if (TSec < 1) + TSec = 18; + + double carbtemp = query2.value("bottle_carbonation_temp").toDouble(); + double barmin = Utils::GetPressureBar(Utils::CarbCO2toS(query2.value("st_carb_min").toDouble(), TSec, 1), carbtemp); + double barmax = Utils::GetPressureBar(Utils::CarbCO2toS(query2.value("st_carb_max").toDouble(), TSec, 1), carbtemp); + ui->minVol->setValue(query2.value("st_carb_min").toDouble()); + ui->maxVol->setValue(query2.value("st_carb_max").toDouble()); + ui->minBar->setValue(barmin); + ui->maxBar->setValue(barmax); + qDebug() << " beerdata" << TSec << carbtemp << barmin << barmax; + + ui->barMeter->setNominal(barmin); + ui->barMeter->setCritical(barmax); + } + ui->uuidEdit->setText(_uuid); ui->systemEdit->setText(_node+"/"+_alias); ui->codePick->setItemText(0, _alias.toUpper()+" - "+_alias); @@ -123,7 +153,6 @@ DetailCO2meter::~DetailCO2meter() { - qDebug() << "DetailCO2meter done"; delete ui; emit entry_changed(); } diff -r d8c110d91b1f -r 3c195eb4e7a1 src/EditProduct.h --- a/src/EditProduct.h Fri Nov 18 12:17:32 2022 +0100 +++ b/src/EditProduct.h Fri Nov 18 16:57:02 2022 +0100 @@ -332,8 +332,6 @@ void calcEfficiencyAfterBoil(); void brew_volume_calc(double volume, double kettle_volume, double kettle_height, double est_volume, bool aboil); double get_fg(double gravity); - double ResCO2(double T); - double CarbCO2toS(double CO2, double T, double SFactor); double GetPressure(double CO2, double T); double CarbCO2ToPressure(double CO2, double T); void calcPack(); diff -r d8c110d91b1f -r 3c195eb4e7a1 src/EditProductTab11.cpp --- a/src/EditProductTab11.cpp Fri Nov 18 12:17:32 2022 +0100 +++ b/src/EditProductTab11.cpp Fri Nov 18 16:57:02 2022 +0100 @@ -17,22 +17,6 @@ * along with this program. If not, see . */ -double EditProduct::ResCO2(double T) -{ - double F = T * 1.8 + 32; - return round((3.0378 - 0.050062 * F + 0.00026555 * F * F) * 1000000.0) / 1000000.0; -} - - -double EditProduct::CarbCO2toS(double CO2, double T, double SFactor) -{ - //var sugar = SFactor * (CO2 - ResCO2(CO2, T)) / 0.286; - double sugar = round((SFactor * (CO2 - ResCO2(T)) * 4.014094) * 1000000.0) / 1000000.0; - if (sugar < 0) - sugar = 0; - return sugar; //Round(sugar, 3); -} - double EditProduct::GetPressure(double CO2, double T) { @@ -139,8 +123,8 @@ product->fermentables.removeAt(i); // Remove false fermentable refreshFermentables(); } else { - product->bottle_priming_amount = CarbCO2toS(product->bottle_carbonation, TSec, SFactor); -// qDebug() << " priming CarbCO2toS(" << product->bottle_carbonation << TSec << SFactor << ") =" << product->bottle_priming_amount; + product->bottle_priming_amount = Utils::CarbCO2toS(product->bottle_carbonation, TSec, SFactor); + //qDebug() << " priming CarbCO2toS(" << product->bottle_carbonation << TSec << SFactor << ") =" << product->bottle_priming_amount; ui->bottle_sug_amountShow->setValue(product->bottle_priming_amount); double total = round(product->bottle_priming_amount * product->bottle_amount * 100.0) / 100000.0; if (total != product->fermentables.at(i).amount) { @@ -157,7 +141,7 @@ talc = product->bottle_amount - pvol; tvol = pvol + product->bottle_priming_water; product->bottle_abv = talc / (tvol + talc) * 100; - product->bottle_bar = Utils::GetPressureBar(product->bottle_priming_amount, product->bottle_carbonation_temp); + product->bottle_bar = Utils::GetPressureBar(product->bottle_priming_amount * (1 / SFactor), product->bottle_carbonation_temp); ui->bottle_abvShow->setValue(product->bottle_abv); ui->bottle_barShow->setValue(product->bottle_bar); } @@ -222,7 +206,7 @@ product->fermentables.removeAt(i); // Remove false fermentable refreshFermentables(); } else { - product->keg_priming_amount = CarbCO2toS(product->keg_carbonation, TSec, SFactor); + product->keg_priming_amount = Utils::CarbCO2toS(product->keg_carbonation, TSec, SFactor); ui->keg_sug_amountShow->setValue(product->keg_priming_amount); double total = round(product->keg_priming_amount * product->keg_amount * 100.0) / 100000.0; qDebug() << " total" << total << product->fermentables.at(i).amount; diff -r d8c110d91b1f -r 3c195eb4e7a1 src/MonCO2meters.cpp --- a/src/MonCO2meters.cpp Fri Nov 18 12:17:32 2022 +0100 +++ b/src/MonCO2meters.cpp Fri Nov 18 16:57:02 2022 +0100 @@ -71,7 +71,7 @@ { QTableWidgetItem *item; - qDebug() << "MonCO2meters reload"; + //qDebug() << "MonCO2meters reload"; QSqlQuery query("SELECT record,node,alias,online,mode,beercode,beername,temperature,pressure_bar FROM mon_co2meters ORDER BY node,alias"); const QStringList labels({tr("Node"), tr("Unit"), tr("Status"), tr("Mode"), tr("Beer"), tr("Temperature"), tr("Pressure"), tr("Details")}); @@ -144,7 +144,7 @@ void MonCO2meters::refreshCO2meters(QString data) { - qDebug() << "refreshCO2meters" << data; + //qDebug() << "refreshCO2meters" << data; emit refreshTable(); emit updateCO2meter(data); } diff -r d8c110d91b1f -r 3c195eb4e7a1 src/Utils.cpp --- a/src/Utils.cpp Fri Nov 18 12:17:32 2022 +0100 +++ b/src/Utils.cpp Fri Nov 18 16:57:02 2022 +0100 @@ -771,6 +771,22 @@ } +double Utils::ResCO2(double T) +{ + double F = T * 1.8 + 32; + return round((3.0378 - 0.050062 * F + 0.00026555 * F * F) * 1000000.0) / 1000000.0; +} + + +double Utils::CarbCO2toS(double CO2, double T, double SFactor) +{ + double sugar = round((SFactor * (CO2 - ResCO2(T)) * 4.014094) * 1000000.0) / 1000000.0; + if (sugar < 0) + sugar = 0; + return sugar; +} + + double Utils::GetPressureBar(double gl, double T) { if (gl <= 0) diff -r d8c110d91b1f -r 3c195eb4e7a1 src/Utils.h --- a/src/Utils.h Fri Nov 18 12:17:32 2022 +0100 +++ b/src/Utils.h Fri Nov 18 16:57:02 2022 +0100 @@ -197,6 +197,22 @@ double CalcFrac(double TpH, double pK1, double pK2, double pK3); /** + * @brief Calculate residual volumes CO2 in the fermenter. + * @param T The highest fermentation temperature in celsius. + * @return The volumes CO2. + */ + double ResCO2(double T); + + /** + * @brief Calculate the grams/liter sugar. + * @param CO2 The desired volumes CO2. + * @param T The highest fermentation temperature in celsius. + * @param SFactor The sugar factor, 1.0 for table sugar. + * @return The grams/liter of the chosen priming sugar. + */ + double CarbCO2toS(double CO2, double T, double SFactor); + + /** * @brief Calculate pressure in Bar after refermentation. * @param gl Sugar in gram/liter * @param T Temperature in celsius diff -r d8c110d91b1f -r 3c195eb4e7a1 translations/bmsapp_en.ts --- a/translations/bmsapp_en.ts Fri Nov 18 12:17:32 2022 +0100 +++ b/translations/bmsapp_en.ts Fri Nov 18 16:57:02 2022 +0100 @@ -354,27 +354,52 @@ - + + Maximum + + + + + Minimum + + + + + Vol CO2: + + + + + Bar: + + + + + Style limits + + + + Quit - + Log - + BMSapp - Details Carbonation - + Online - + Offline @@ -411,9 +436,9 @@ - - - + + + Color Led component @@ -422,9 +447,9 @@ - - - + + + Led indicator @@ -480,79 +505,84 @@ - - Chiller + + Current status: - Air + Chiller + Air + + + + Beer - + Shows the chiller temperature - + Shows the beer temperature - + Shows the air temperature - + °C low - + °C high - - Heat - - - - Cool + Heat - Fan + Cool - - + Fan + + + + + + ... - + Quit - + Log - + Camera @@ -4774,12 +4804,12 @@ - + Confirm package - + Confirm that the beer is packaged and all data is correct diff -r d8c110d91b1f -r 3c195eb4e7a1 translations/bmsapp_nl.ts --- a/translations/bmsapp_nl.ts Fri Nov 18 12:17:32 2022 +0100 +++ b/translations/bmsapp_nl.ts Fri Nov 18 16:57:02 2022 +0100 @@ -403,6 +403,31 @@ Toont de temperatuur + + Maximum + Maximum + + + + Minimum + Minimum + + + + Style limits + Stijl limieten + + + + Vol CO2: + Vol CO2: + + + + Bar: + Druk bar: + + Shows the beer temperature Toont de bier temperatuur @@ -411,27 +436,27 @@ Toont de lucht temperatuur - + Quit Terug - + Log Log - + BMSapp - Details Carbonation BMSapp - Details carbonatie - + Online Online - + Offline Offline @@ -468,9 +493,9 @@ - - - + + + Color Led component @@ -479,9 +504,9 @@ - - - + + + Led indicator @@ -537,79 +562,84 @@ Kies profiel: - - Chiller - Koeler + + Current status: + Huidige status: - Air - Lucht + Chiller + Koeler + Air + Lucht + + + Beer Bier - + Shows the chiller temperature Toont de koeler temperatuur - + Shows the beer temperature Toont de bier temperatuur - + Shows the air temperature Toont de lucht temperatuur - + °C low °C laag - + °C high °C hoog - - Heat - Verwarm - - - Cool - Koel + Heat + Verwarm - Fan - Ventilator + Cool + Koel - - + Fan + Ventilator + + + + + ... ... - + Quit Terug - + Log Log - + Camera Camera @@ -5440,12 +5470,12 @@ Batterij volt - + Confirm package Bevestig verpakken - + Confirm that the beer is packaged and all data is correct Bevestig dat het bier verpakt is en de gegevens kloppen diff -r d8c110d91b1f -r 3c195eb4e7a1 ui/DetailCO2meter.ui --- a/ui/DetailCO2meter.ui Fri Nov 18 12:17:32 2022 +0100 +++ b/ui/DetailCO2meter.ui Fri Nov 18 16:57:02 2022 +0100 @@ -148,7 +148,7 @@ 10 - 150 + 120 141 20 @@ -164,7 +164,7 @@ 10 - 180 + 150 141 20 @@ -234,9 +234,9 @@ - 160 - 120 - 111 + 560 + 90 + 141 23 @@ -248,7 +248,7 @@ 160 - 150 + 120 381 23 @@ -261,7 +261,7 @@ 560 - 150 + 120 141 23 @@ -276,8 +276,8 @@ - 10 - 120 + 410 + 90 141 20 @@ -293,7 +293,7 @@ 160 - 180 + 150 111 23 @@ -403,25 +403,226 @@ - - - - 740 - 130 - 261 - 101 - - - - + 740 240 261 - 121 + 161 + + + + 100 + 90 + 71 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + false + + + 2 + + + 45.000000000000000 + + + 1.000000000000000 + + + + + + 10 + 90 + 81 + 20 + + + + Bar: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 180 + 60 + 71 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + false + + + 2 + + + 45.000000000000000 + + + 1.000000000000000 + + + + + + 10 + 60 + 81 + 20 + + + + Vol CO2: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 180 + 120 + 71 + 20 + + + + Maximum + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 100 + 60 + 71 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + false + + + 2 + + + 45.000000000000000 + + + 1.000000000000000 + + + + + + 180 + 90 + 71 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + false + + + 2 + + + 45.000000000000000 + + + 1.000000000000000 + + + + + + 100 + 120 + 71 + 20 + + + + Minimum + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 20 + 241 + 25 + + + + + 12 + 75 + true + + + + Style limits + + + Qt::AlignCenter + + diff -r d8c110d91b1f -r 3c195eb4e7a1 ui/DetailFermenter.ui --- a/ui/DetailFermenter.ui Fri Nov 18 12:17:32 2022 +0100 +++ b/ui/DetailFermenter.ui Fri Nov 18 16:57:02 2022 +0100 @@ -474,6 +474,22 @@ Choose profile: + + + + 410 + 70 + 141 + 20 + + + + Current status: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + +