src/EditRecipeTab7.cpp

Thu, 18 Aug 2022 20:34:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 20:34:15 +0200
changeset 401
583148eb6e01
parent 395
7212b980a527
permissions
-rw-r--r--

Init est_carb field for new products.

129
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditRecipe.cpp is part of bmsapp.
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * tab 6, water.
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the hope that it will be useful,
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
131
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
21 void EditRecipe::refreshWaters()
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
22 {
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
23
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
24 // calc_acid
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
25 ui->mw_phEdit->setValue(recipe->mash_ph);
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
26 // mash_name
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
27 //ui->mw_acidpercEdit->setValue(recipe->
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
28
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
29 }
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
30
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
31
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
32 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
33 * Z alkalinity is the amount of acid (in mEq/l) needed to bring water to the target pH (Z pH)
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
34 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
35 double EditRecipe::ZAlkalinity(double pHZ)
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
36 {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
37 double C43 = Utils::Charge(4.3);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
38 double Cw = Utils::Charge(recipe->wg_ph);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
39 double Cz = Utils::Charge(pHZ);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
40 double DeltaCNaught = -C43 + Cw;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
41 double CT = recipe->wg_total_alkalinity / 50 / DeltaCNaught;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
42 double DeltaCZ = -Cz + Cw;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
43 return CT * DeltaCZ;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
44 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
45
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
46
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
47 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
48 * Z Residual alkalinity is the amount of acid (in mEq/l) needed
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
49 * to bring the water in the mash to the target pH (Z pH).
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
50 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
51 double EditRecipe::ZRA(double pHZ)
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
52 {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
53 double Calc = recipe->wg_calcium / (MMCa / 2);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
54 double Magn = recipe->wg_magnesium / (MMMg / 2);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
55 double Z = ZAlkalinity(pHZ);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
56 return Z - (Calc / 3.5 + Magn / 7);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
57 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
58
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
59
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
60 double EditRecipe::BufferCapacity(Fermentables F)
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
61 {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
62 double C1 = 0;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
63
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
64 if ((F.di_ph != 5.7) && ((F.acid_to_ph_57 < - 0.1) || (F.acid_to_ph_57 > 0.1))) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
65 C1 = F.acid_to_ph_57 / (F.di_ph - 5.7);
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
66 } else {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
67 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
68 * If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid.
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
69 */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
70 switch (F.graintype) {
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
71 case FERMENTABLE_GRAINTYPE_BASE:
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
72 case FERMENTABLE_GRAINTYPE_KILNED:
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
73 case FERMENTABLE_GRAINTYPE_SPECIAL: C1 = 0.014 * F.color - 34.192;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
74 break;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
75 case FERMENTABLE_GRAINTYPE_CRYSTAL: C1 = -0.0597 * F.color - 32.457;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
76 break;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
77 case FERMENTABLE_GRAINTYPE_ROAST: C1 = 0.0107 * F.color - 54.768;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
78 break;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
79 case FERMENTABLE_GRAINTYPE_SOUR_MALT: C1 = -149;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
80 break;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
81 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
82 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
83 return C1;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
84 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
85
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
86
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
87 double EditRecipe::AcidRequired(double ZpH, Fermentables F)
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
88 {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
89 double C1 = BufferCapacity(F);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
90 double x = F.di_ph;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
91 return C1 * (ZpH - x);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
92 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
93
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
94
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
95 double EditRecipe::ProtonDeficit(double pHZ)
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
96 {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
97 double C1, x;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
98 int i, error_count = 0;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
99 double Result = ZRA(pHZ) * recipe->wg_amount;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
100 Fermentables F;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
101
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
102 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
103 * proton deficit for the grist
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
104 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
105 if (recipe->fermentables.size()) {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
106 for (i = 0; i < recipe->fermentables.size(); i++) {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
107 F = recipe->fermentables.at(i);
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
108 if (F.added == FERMENTABLE_ADDED_MASH && F.graintype != FERMENTABLE_GRAINTYPE_NO_MALT) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
109 x = AcidRequired(pHZ, F) * F.amount;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
110 Result += x;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
111 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
112 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
113 } else {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
114 error_count++;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
115 if (error_count < 5)
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
116 qDebug() << " ProtonDeficit" << pHZ << "invalid grist, return" << Result;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
117 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
118 return Result;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
119 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
120
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
121
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
122 double EditRecipe::MashpH()
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
123 {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
124 int n = 0;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
125 double pH = 5.4;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
126 double deltapH = 0.001;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
127 double deltapd = 0.1;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
128 double pd = ProtonDeficit(pH);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
129
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
130 while (((pd < -deltapd) || (pd > deltapd)) && (n < 2000)) {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
131 n++;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
132 if (pd < -deltapd)
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
133 pH -= deltapH;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
134 else if (pd > deltapd)
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
135 pH += deltapH;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
136 pd = ProtonDeficit(pH);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
137 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
138 pH = round(pH * 1000000) / 1000000.0;
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
139 qDebug() << " MashpH() n:" << n << "pH:" << pH;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
140 return pH;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
141 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
142
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
143
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
144 void EditRecipe::setButtons(bool locked)
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
145 {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
146 if (locked) {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
147 /*
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
148 * If recipe is locked, disable the buttons and that's it.
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
149 */
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
150 ui->w1_spButton->setDisabled(true);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
151 ui->w2_spButton->setDisabled(true);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
152 ui->wg_spButton->setDisabled(true);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
153 return;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
154 }
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
155 ui->w1_spButton->setDisabled(false);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
156
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
157 const QSignalBlocker blocker1(ui->w1_spButton);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
158 const QSignalBlocker blocker2(ui->w2_spButton);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
159 const QSignalBlocker blocker3(ui->wg_spButton);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
160
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
161 if (recipe->w2_name != "") {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
162 ui->w2_spButton->setDisabled(false);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
163 if (recipe->w2_amount > 0.1 && recipe->w2_ph > 5) {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
164 /*
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
165 * Water 2 is valid and used for mash, mixed is available.
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
166 */
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
167 ui->wg_spButton->setDisabled(false);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
168 } else {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
169 /*
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
170 * No mixed water for mash. We can still sparge with source 2.
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
171 */
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
172 ui->wg_spButton->setDisabled(true);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
173 if (recipe->sparge_source == 2) {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
174 /*
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
175 * If mixed was selected, switch to source 2.
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
176 */
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
177 recipe->sparge_source = 1;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
178 ui->w2_spButton->setChecked(true);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
179 }
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
180 }
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
181 } else {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
182 ui->w2_spButton->setDisabled(true);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
183 ui->wg_spButton->setDisabled(true);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
184 recipe->sparge_source = 0; // Fallback to source 1
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
185 ui->w1_spButton->setChecked(true);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
186 }
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
187 }
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
188
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
189
395
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
190 void EditRecipe::calcBU()
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
191 {
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
192 double BUGU = GetBUGU();
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
193 ui->buguEdit->setValue(BUGU);
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
194 ui->est_buguEdit->setValue(BUGU);
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
195 ui->est_buguShow->setValue(BUGU);
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
196 if (BUGU < 0.32)
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
197 ui->buguResult->setText(tr("Very malty and sweet"));
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
198 else if (BUGU < 0.43)
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
199 ui->buguResult->setText(tr("Malty, sweet"));
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
200 else if (BUGU < 0.52)
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
201 ui->buguResult->setText(tr("Balanced"));
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
202 else if (BUGU < 0.63)
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
203 ui->buguResult->setText(tr("Hoppy, bitter"));
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
204 else
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
205 ui->buguResult->setText(tr("Very hoppy, very bitter"));
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
206
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
207 double og = recipe->est_og;
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
208 double fg = recipe->est_fg;
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
209 double ibu = recipe->est_ibu;
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
210
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
211 if (fg < 1.002) /* Can't be too low for this */
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
212 fg = 1.002;
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
213
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
214 double bure = ibu / ((0.1808 * Utils::sg_to_plato(og)) + (0.8192 * Utils::sg_to_plato(fg)));
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
215 qDebug() << "BU:RE" << bure << recipe->est_fg << recipe->est_ibu;
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
216 ui->est_bufguEdit->setValue(bure);
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
217 ui->est_bufguShow->setValue(bure);
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
218
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
219 }
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
220
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
221
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
222 void EditRecipe::calcWater()
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
223 {
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
224 double liters = 0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
225 double calcium = 0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
226 double magnesium = 0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
227 double sodium = 0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
228 double total_alkalinity = 0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
229 double bicarbonate = 0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
230 double chloride = 0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
231 double sulfate = 0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
232 double ph = 0;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
233 double TpH = 0;
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
234 double frac, RA;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
235 double protonDeficit = 0;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
236 double Acid = 0, Acidmg = 0;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
237 int AT;
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
238
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
239 qDebug() << "calcWater()";
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
240
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
241 ui->w1_hardnessEdit->setValue(Utils::Hardness(recipe->w1_calcium, recipe->w1_magnesium));
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
242 ui->w1_raEdit->setValue(Utils::ResidualAlkalinity(recipe->w1_total_alkalinity, recipe->w1_calcium, recipe->w1_magnesium));
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
243
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
244 /*
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
245 * If there is a dilute water source, mix the waters.
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
246 */
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
247 if (recipe->w2_name != "") {
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
248 liters = recipe->w1_amount + recipe->w2_amount;
134
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
249 calcium = Utils::mix(recipe->w1_amount, recipe->w2_amount, recipe->w1_calcium, recipe->w2_calcium);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
250 magnesium = Utils::mix(recipe->w1_amount, recipe->w2_amount, recipe->w1_magnesium, recipe->w2_magnesium);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
251 sodium = Utils::mix(recipe->w1_amount, recipe->w2_amount, recipe->w1_sodium, recipe->w2_sodium);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
252 chloride = Utils::mix(recipe->w1_amount, recipe->w2_amount, recipe->w1_chloride, recipe->w2_chloride);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
253 sulfate = Utils::mix(recipe->w1_amount, recipe->w2_amount, recipe->w1_sulfate, recipe->w2_sulfate);
5099df8ba6c6 Moved the mix function to Utils. Added some calculations to Utils. Added defines to global.h.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
254 total_alkalinity = Utils::mix(recipe->w1_amount, recipe->w2_amount, recipe->w1_total_alkalinity, recipe->w2_total_alkalinity);
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
255 ph = -log10(((pow(10, -recipe->w1_ph) * recipe->w1_amount) + (pow(10, -recipe->w2_ph) * recipe->w2_amount)) / liters);
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
256 ui->w2_hardnessEdit->setValue(Utils::Hardness(recipe->w2_calcium, recipe->w2_magnesium));
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
257 ui->w2_raEdit->setValue(Utils::ResidualAlkalinity(recipe->w2_total_alkalinity, recipe->w2_calcium, recipe->w2_magnesium));
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
258 } else {
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
259 liters = recipe->w1_amount;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
260 calcium = recipe->w1_calcium;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
261 magnesium = recipe->w1_magnesium;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
262 sodium = recipe->w1_sodium;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
263 chloride = recipe->w1_chloride;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
264 sulfate = recipe->w1_sulfate;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
265 total_alkalinity = recipe->w1_total_alkalinity;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
266 ph = recipe->w1_ph;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
267 }
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
268
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
269 recipe->wg_amount = liters;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
270 recipe->wg_calcium = round(calcium * 10.0) / 10.0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
271 recipe->wg_magnesium = round(magnesium * 10.0) / 10.0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
272 recipe->wg_sodium = round(sodium * 10.0) / 10.0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
273 recipe->wg_chloride = round(chloride * 10.0) / 10.0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
274 recipe->wg_sulfate = round(sulfate * 10.0) / 10.0;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
275 recipe->wg_total_alkalinity = round(total_alkalinity * 10.0) / 10.0;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
276 recipe->wg_ph = ph;
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
277
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
278 bicarbonate = Utils::Bicarbonate(total_alkalinity, ph);
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
279 ui->wg_volEdit->setValue(liters);
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
280 ui->wg_caEdit->setValue(calcium);
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
281 ui->wg_mgEdit->setValue(magnesium);
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
282 ui->wg_hco3Edit->setValue(bicarbonate);
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
283 ui->wg_caco3Edit->setValue(total_alkalinity);
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
284 ui->wg_naEdit->setValue(sodium);
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
285 ui->wg_clEdit->setValue(chloride);
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
286 ui->wg_so4Edit->setValue(sulfate);
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
287 ui->wg_phEdit->setValue(ph);
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
288 ui->wg_hardnessEdit->setValue(Utils::Hardness(calcium, magnesium));
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
289 ui->wg_raEdit->setValue(Utils::ResidualAlkalinity(total_alkalinity, calcium, magnesium));
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
290
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
291 /* Save mixed water ions for later */
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
292 double wg_calcium = calcium;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
293 double wg_sodium = sodium;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
294 double wg_total_alkalinity = total_alkalinity;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
295 double wg_chloride = chloride;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
296 double wg_sulfate = sulfate;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
297 double wg_bicarbonate = bicarbonate;
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
298
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
299 double mash_ph = MashpH();
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
300 qDebug() << " Distilled water mash pH:" << mash_ph;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
301
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
302 /* Calculate Salt additions */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
303 if (liters > 0) {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
304 calcium += ( ui->bs_cacl2Edit->value() * MMCa / MMCaCl2 * 1000 + ui->bs_caso4Edit->value() * MMCa / MMCaSO4 * 1000 +
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
305 ui->bs_caco3Edit->value() * MMCa / MMCaCO3 * 1000) / liters;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
306 magnesium += (ui->bs_mgso4Edit->value() * MMMg / MMMgSO4 * 1000 + ui->bs_mgcl2Edit->value() * MMMg / MMMgCl2 * 1000) / liters;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
307 sodium += (ui->bs_naclEdit->value() * MMNa / MMNaCl * 1000 + ui->bs_nahco3Edit->value() * MMNa / MMNaHCO3 * 1000) / liters;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
308 sulfate += (ui->bs_caso4Edit->value() * MMSO4 / MMCaSO4 * 1000 + ui->bs_mgso4Edit->value() * MMSO4 / MMMgSO4 * 1000) / liters;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
309 chloride += (2 * ui->bs_cacl2Edit->value() * MMCl / MMCaCl2 * 1000 + ui->bs_naclEdit->value() * MMCl / MMNaCl * 1000 +
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
310 ui->bs_mgcl2Edit->value() * MMCl / MMMgCl2 * 1000) / liters;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
311 bicarbonate += (ui->bs_nahco3Edit->value() * MMHCO3 / MMNaHCO3 * 1000 + ui->bs_caco3Edit->value() / 3 * MMHCO3 / MMCaCO3 * 1000) / liters;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
312 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
313
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
314 const QSignalBlocker blocker1(ui->mw_acidPick);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
315 const QSignalBlocker blocker2(ui->mw_acidpercEdit);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
316 const QSignalBlocker blocker3(ui->mw_acidvolEdit);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
317 const QSignalBlocker blocker4(ui->wb_phEdit);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
318 const QSignalBlocker blocker5(ui->mw_phEdit);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
319
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
320 if (recipe->wa_acid_name < 0 || recipe->wa_acid_name >= my_acids.size()) {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
321 recipe->wa_acid_name = 0;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
322 recipe->wa_acid_perc = my_acids.at(0).AcidPrc;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
323 ui->mw_acidPick->setCurrentIndex(0);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
324 ui->mw_acidpercEdit->setValue(my_acids.at(0).AcidPrc);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
325 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
326 AT = recipe->wa_acid_name;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
327
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
328 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
329 * Note that the next calculations do not correct the pH change by the added salts.
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
330 * This pH change is at most 0.1 pH and is a minor difference in Acid amount.
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
331 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
332 if (recipe->calc_acid) {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
333 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
334 * Auto calculate the needed acid.
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
335 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
336 TpH = recipe->mash_ph;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
337 protonDeficit = ProtonDeficit(TpH);
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
338 qDebug() << " calc_acid tgt:" << TpH << "protonDeficit:" << protonDeficit;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
339 if (protonDeficit > 0) {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
340 frac = Utils::CalcFrac(TpH, my_acids[AT].pK1, my_acids[AT].pK2, my_acids[AT].pK3);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
341 Acid = protonDeficit / frac;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
342 Acid *= my_acids[AT].MolWt; // mg.
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
343 Acidmg = Acid;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
344 Acid = Acid / my_acids[AT].AcidSG;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
345 Acid = round((Acid / (recipe->wa_acid_perc / 100.0)) * 100.0) / 100.0;
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
346 qDebug() << " Mash auto Acid final old ml:" << Acid;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
347 Acid = Acidmg;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
348
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
349 double RealSG = round(((my_acids[AT].AcidSG - 1000) * (recipe->wa_acid_perc / 100)) + 1000);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
350 Acid /= RealSG;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
351 Acid /= my_acids[AT].AcidPrc / 100;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
352 Acid = round(Acid * 100.0) / 100.0;
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
353 qDebug() << " Mash auto Acid final ml:" << Acid;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
354
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
355 QString w = my_acids[AT].name_en + ' ' + my_acids[AT].name_nl;
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
356 brewing_salt_sub(w, Acid, MISC_USES_MASH);
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
357 ui->mw_acidvolEdit->setValue(Acid);
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
358
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
359 bicarbonate = bicarbonate - protonDeficit * frac / liters;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
360 total_alkalinity = bicarbonate * 50 / 61;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
361 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
362 ph = TpH;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
363 ui->wb_phEdit->setValue(ph);
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
364 recipe->mash_ph = ph;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
365 } else { // Manual
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
366 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
367 * Manual adjust acid, calculate resulting pH.
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
368 */
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
369 double pHa = ph; // Mixed water pH.
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
370 double RealSG = round(((my_acids[AT].AcidSG - 1000) * (recipe->wa_acid_perc / 100)) + 1000);
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
371 // Then calculate the new pH with added acids and malts
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
372 qDebug() << " Mash pH:" << pHa;
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
373 Acid = RealSG;
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
374 Acid *= ui->mw_acidvolEdit->value();
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
375 Acid *= my_acids[AT].AcidPrc / 100;
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
376 Acid /= my_acids[AT].MolWt; // mg;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
377 Acidmg = Acid;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
378
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
379 //find the pH where the protondeficit = protondeficit by the acid
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
380 frac = Utils::CalcFrac(pHa, my_acids[AT].pK1, my_acids[AT].pK2, my_acids[AT].pK3);
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
381 protonDeficit = Acid * frac;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
382 //qDebug() << " protonDeficit Acid:" << protonDeficit << "frac:" << frac << "pH:" << pHa;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
383
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
384 double deltapH = 0.001;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
385 double deltapd = 0.1;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
386 double pd = round(ProtonDeficit(pHa) * 1000000.0) / 1000000.0;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
387 int n = 0;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
388 while (((pd < (protonDeficit - deltapd)) || (pd > (protonDeficit + deltapd))) && (n < 4000)) {
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
389 n++;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
390 if (pd < (protonDeficit - deltapd))
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
391 pHa -= deltapH;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
392 else if (pd > (protonDeficit + deltapd))
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
393 pHa += deltapH;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
394 frac = Utils::CalcFrac(pHa, my_acids[AT].pK1, my_acids[AT].pK2, my_acids[AT].pK3);
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
395 protonDeficit = Acid * frac;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
396 pd = ProtonDeficit(pHa);
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
397 }
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
398 //qDebug() << " n:" << n << "pd:" << pd << "protonDeficit:" << protonDeficit << "frac:" << frac << "pHa:" << pHa;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
399
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
400 bicarbonate = wg_bicarbonate - protonDeficit * frac / liters;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
401 total_alkalinity = bicarbonate * 50 / 61;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
402 ph = pHa;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
403 ui->wb_phEdit->setValue(ph);
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
404 ui->mw_phEdit->setValue(ph);
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
405 recipe->mash_ph = ph;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
406 }
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
407
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
408 if ((AT == 3) && (liters > 0)) { // Sulfuctic / Zwavelzuur
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
409 RA = ui->bs_caso4Edit->value() * MMSO4 / MMCaSO4 + ui->bs_mgso4Edit->value() * MMSO4 / MMMgSO4 + Acidmg / 1000 * MMSO4 / (MMSO4 + 2);
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
410 RA = 1000 * RA / liters;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
411 sulfate = wg_sulfate + RA; // Not add to sulfate??
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
412 } else if ((AT == 1) && (liters > 0)) { // Hydrochloric, Zoutzuur
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
413 RA = ui->bs_cacl2Edit->value() * MMCl / MMCaCl2 + ui->bs_naclEdit->value() * MMCl / MMNaCl + Acidmg / 1000 * MMCl / (MMCl + 1);
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
414 RA = 1000 * RA / liters;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
415 chloride = wg_chloride + RA;
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
416 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
417
395
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 365
diff changeset
418 calcBU();
137
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
419
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
420 double OptSO4Clratio = GetOptSO4Clratio();
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
421 ui->so4clEdit->setValue(OptSO4Clratio);
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
422 ui->cur_so4clResult->setRange(0.7 * OptSO4Clratio, 1.3 * OptSO4Clratio);
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
423 if (OptSO4Clratio < 0.4)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
424 ui->so4clResult->setText(tr("Too malty"));
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
425 else if (OptSO4Clratio < 0.6)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
426 ui->so4clResult->setText(tr("Very malty"));
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
427 else if (OptSO4Clratio < 0.8)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
428 ui->so4clResult->setText(tr("Malty"));
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
429 else if (OptSO4Clratio < 1.5)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
430 ui->so4clResult->setText(tr("Balanced"));
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
431 else if (OptSO4Clratio < 2.0)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
432 ui->so4clResult->setText(tr("Little bitter"));
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
433 else if (OptSO4Clratio < 4.0)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
434 ui->so4clResult->setText(tr("Bitter"));
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
435 else if (OptSO4Clratio < 9.0)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
436 ui->so4clResult->setText(tr("Very bitter"));
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
437 else
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
438 ui->so4clResult->setText(tr("Too bitter"));
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
439 if (chloride > 0)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
440 RA = sulfate / chloride;
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
441 else
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
442 RA = 10;
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
443 ui->cur_so4clEdit->setValue(RA);
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
444 ui->cur_so4clResult->setValue(RA);
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
445
161
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
446 recipe->wb_calcium = calcium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
447 recipe->wb_magnesium = magnesium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
448 recipe->wb_total_alkalinity = total_alkalinity;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
449 recipe->wb_sodium = sodium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
450 recipe->wb_chloride = chloride;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
451 recipe->wb_sulfate = sulfate;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
452 recipe->wb_ph = ph;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
453
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
454 ui->wb_caEdit->setValue(calcium);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
455 ui->wb_mgEdit->setValue(magnesium);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
456 ui->wb_hco3Edit->setValue(bicarbonate);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
457 ui->wb_caco3Edit->setValue(total_alkalinity);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
458 ui->wb_naEdit->setValue(sodium);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
459 ui->wb_clEdit->setValue(chloride);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
460 ui->wb_so4Edit->setValue(sulfate);
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
461 ui->wb_hardnessEdit->setValue(Utils::Hardness(calcium, magnesium));
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
462 ui->wb_raEdit->setValue(Utils::ResidualAlkalinity(total_alkalinity, calcium, magnesium));
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
463
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
464 ui->wb_caEdit->setStyleSheet((calcium < 40 || calcium > 150) ? "background-color: red":"background-color: green");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
465 ui->wb_mgEdit->setStyleSheet((magnesium < 5 || magnesium > 40) ? "background-color: red":"background-color: green");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
466 ui->wb_naEdit->setStyleSheet((sodium > 150) ? "background-color: red":"background-color: green");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
467 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
468 * Both chloride and sulfate should be above 50 according to
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
469 * John Palmer. So the Cl/SO4 ratio calculation will work.
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
470 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
471 ui->wb_clEdit->setStyleSheet((chloride <= 50 || chloride > 150) ? "background-color: red":"background-color: green");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
472 ui->wb_so4Edit->setStyleSheet((sulfate <= 50 || sulfate > 400) ? "background-color: red":"background-color: green");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
473 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
474 * (cloride + sulfate) > 500 is too high
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
475 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
476 if ((chloride + sulfate) > 500) {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
477 ui->wb_clEdit->setStyleSheet("background-color: red");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
478 ui->wb_so4Edit->setStyleSheet("background-color: red");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
479 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
480 ui->wb_phEdit->setStyleSheet((ph < 5.2 || ph > 5.6) ? "background-color: red":"background-color: green");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
481 ui->wb_hco3Edit->setStyleSheet((bicarbonate > 250) ? "background-color: red":"background-color: green");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
482 ui->wb_caco3Edit->setStyleSheet((bicarbonate > 250) ? "background-color: red":"background-color: green");
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
483
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
484 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
485 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
486
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
487
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
488 /*
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
489 * Based on the work of ajDeLange.
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
490 */
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
491 void EditRecipe::calcSparge()
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
492 {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
493 double TargetpH = recipe->sparge_ph;
365
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
494 double Source_pH = 7.0;
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
495
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
496 qDebug() << "calcSparge()";
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
497 setButtons(recipe->locked);
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
498
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
499 if (recipe->sparge_source == 1 && recipe->w2_ph > 0.0) {
365
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
500 recipe->ws_calcium = recipe->w2_calcium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
501 recipe->ws_magnesium = recipe->w2_magnesium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
502 recipe->ws_total_alkalinity = recipe->w2_total_alkalinity;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
503 recipe->ws_sodium = recipe->w2_sodium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
504 recipe->ws_chloride = recipe->w2_chloride;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
505 recipe->ws_sulfate = recipe->w2_sulfate;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
506 Source_pH = recipe->w2_ph;
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
507 } else if (recipe->sparge_source == 2 && recipe->w2_ph > 0.0) {
365
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
508 recipe->ws_calcium = recipe->wg_calcium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
509 recipe->ws_magnesium = recipe->wg_magnesium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
510 recipe->ws_total_alkalinity = recipe->wg_total_alkalinity;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
511 recipe->ws_sodium = recipe->wg_sodium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
512 recipe->ws_chloride = recipe->wg_chloride;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
513 recipe->ws_sulfate = recipe->wg_sulfate;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
514 Source_pH = recipe->wg_ph;
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
515 } else {
365
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
516 recipe->ws_calcium = recipe->w1_calcium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
517 recipe->ws_magnesium = recipe->w1_magnesium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
518 recipe->ws_total_alkalinity = recipe->w1_total_alkalinity;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
519 recipe->ws_sodium = recipe->w1_sodium;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
520 recipe->ws_chloride = recipe->w1_chloride;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
521 recipe->ws_sulfate = recipe->w1_sulfate;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
522 Source_pH = recipe->w1_ph;
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
523 }
365
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
524
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
525 /* Calculate Salt additions */
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
526 if (recipe->sparge_volume > 0) {
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
527 recipe->ws_calcium += ( ui->ss_cacl2Edit->value() * MMCa / MMCaCl2 * 1000 + ui->ss_caso4Edit->value() * MMCa / MMCaSO4 * 1000) / recipe->sparge_volume;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
528 recipe->ws_magnesium += (ui->ss_mgso4Edit->value() * MMMg / MMMgSO4 * 1000 + ui->ss_mgcl2Edit->value() * MMMg / MMMgCl2 * 1000) / recipe->sparge_volume;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
529 recipe->ws_sodium += (ui->ss_naclEdit->value() * MMNa / MMNaCl * 1000) / recipe->sparge_volume;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
530 recipe->ws_sulfate += (ui->ss_caso4Edit->value() * MMSO4 / MMCaSO4 * 1000 + ui->ss_mgso4Edit->value() * MMSO4 / MMMgSO4 * 1000) / recipe->sparge_volume;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
531 recipe->ws_chloride += (2 * ui->ss_cacl2Edit->value() * MMCl / MMCaCl2 * 1000 + ui->ss_naclEdit->value() * MMCl / MMNaCl * 1000 +
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
532 ui->ss_mgcl2Edit->value() * MMCl / MMMgCl2 * 1000) / recipe->sparge_volume;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
533 }
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
534
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
535 /* Show the spargewater with salt additions. */
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
536 ui->sp_caEdit->setValue(recipe->ws_calcium);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
537 ui->sp_mgEdit->setValue(recipe->ws_magnesium);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
538 ui->sp_hco3Edit->setValue(Utils::Bicarbonate(recipe->ws_total_alkalinity, Source_pH));
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
539 ui->sp_caco3Edit->setValue(recipe->ws_total_alkalinity);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
540 ui->sp_naEdit->setValue(recipe->ws_sodium);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
541 ui->sp_clEdit->setValue(recipe->ws_chloride);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
542 ui->sp_so4Edit->setValue(recipe->ws_sulfate);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
543 ui->sp_phShow->setValue(recipe->sparge_ph);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
544 ui->sp_hardnessEdit->setValue(Utils::Hardness(recipe->ws_calcium, recipe->ws_magnesium));
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
545 ui->sp_raEdit->setValue(Utils::ResidualAlkalinity(recipe->ws_total_alkalinity, recipe->ws_calcium, recipe->ws_magnesium));
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
546
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
547 int AT = recipe->sparge_acid_type;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
548 if (AT < 0 || AT >= my_acids.size()) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
549 AT = 0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
550 recipe->sparge_acid_type = 0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
551 ui->sp_acidtypeEdit->setCurrentIndex(0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
552 recipe->sparge_acid_perc = my_acids[0].AcidPrc;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
553 ui->sp_acidpercEdit->setValue(recipe->sparge_acid_perc);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
554 }
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
555
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
556 /*
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
557 * Auto calculate the required acid
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
558 */
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
559 if (recipe->calc_acid) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
560 // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
561 double r1 = pow(10, Source_pH - 6.35);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
562 double r2 = pow(10, Source_pH - 10.33);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
563 double d = 1 + r1 + r1 * r2;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
564 double f1 = 1 / d;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
565 double f3 = r1 * r2 / d;
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
566
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
567 // Step 2. Compute the mole fractions at pH = 4.3 (the pH which defines alkalinity)
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
568 double r143 = pow(10, 4.3 - 6.35);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
569 double r243 = pow(10, 4.3 - 10.33);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
570 double d43 = 1 + r143 + r143 * r243;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
571 double f143 = 1 / d43;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
572 double f343 = r143 * r243 / d43;
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
573
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
574 // Step 4. Solve
365
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
575 double Ct = recipe->ws_total_alkalinity / 50 / ((f143 - f1) + (f3 - f343));
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
576
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
577 // Step 5. Compute mole fractions at desired pH
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
578 double r1g = pow(10, TargetpH - 6.35);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
579 double r2g = pow(10, TargetpH - 10.33);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
580 double dg = 1 + r1g + r1g * r2g;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
581 double f1g = 1 / dg;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
582 double f3g = r1g * r2g / dg;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
583
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
584 // Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L)
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
585 double Acid = Ct * ((f1g - f1) + (f3 - f3g)) + pow(10, -TargetpH) - pow(10, -Source_pH); //mEq/l
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
586 Acid += 0.01; // Add acid that would be required for distilled water.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
587
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
588 // Step 8. Get the acid data.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
589 double fract = Utils::CalcFrac(TargetpH, my_acids[AT].pK1, my_acids[AT].pK2, my_acids[AT].pK3);
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
590
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
591 // Step 9. Now divide the mEq required by the "fraction". This is the required number of moles of acid.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
592 Acid /= fract;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
593
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
594 // Step 10. Multiply by molecular weight of the acid
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
595 Acid *= my_acids[AT].MolWt; //mg
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
596
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
597 // Step 11. Divide by Specific Gravity and Percentage to get the final ml.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
598 double RealSG = round(((my_acids[AT].AcidSG - 1000) * (recipe->sparge_acid_perc / 100)) + 1000);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
599 Acid = Acid / RealSG; //ml
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
600 Acid *= recipe->sparge_volume; //ml acid total at 100%
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
601 Acid /= my_acids[AT].AcidPrc / 100; //ml acid at supplied strength
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
602 Acid = round(Acid * 100.0) / 100.0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
603 recipe->sparge_acid_amount = Acid / 1000;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
604 QString w = my_acids[AT].name_en + ' ' + my_acids[AT].name_nl;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
605 brewing_salt_sub(w, Acid, MISC_USES_SPARGE); // Put it in the miscs table.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
606 ui->sp_acidvolEdit->setValue(Acid);
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
607 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
608
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
609 // Finally calculate the estimate preboil pH
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
610 recipe->preboil_ph = -log10(((pow(10, -recipe->mash_ph) * recipe->wg_amount) + (pow(10, -recipe->sparge_ph) * recipe->sparge_volume)) /
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
611 (recipe->wg_amount + recipe->sparge_volume));
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
612 ui->preboil_phEdit->setValue(recipe->preboil_ph);
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
613 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
614
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
615
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
616 void EditRecipe::sp_group_changed(int val)
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
617 {
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
618 if (val != recipe->sparge_source) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
619 qDebug() << "sp_group_changed" << val;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
620 recipe->sparge_source = val;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
621 calcSparge();
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
622 is_changed();
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
623 }
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
624 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
625
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
626
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
627 void EditRecipe::sp_type_changed(int val)
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
628 {
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
629 if (val == recipe->sparge_acid_type)
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
630 return;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
631
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
632 qDebug() << "sp_type_changed" << val << "old" << recipe->sparge_acid_type;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
633 /*
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
634 * First remove current acid.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
635 */
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
636 QString w = my_acids[recipe->sparge_acid_type].name_en + ' ' + my_acids[recipe->sparge_acid_type].name_nl;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
637 brewing_salt_sub(w, 0, MISC_USES_SPARGE);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
638
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
639 recipe->sparge_acid_type = val;
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
640 w = my_acids[recipe->sparge_acid_type].name_en + ' ' + my_acids[recipe->sparge_acid_type].name_nl;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
641
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
642 recipe->sparge_acid_perc = my_acids[val].AcidPrc;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
643 ui->sp_acidpercEdit->setValue(recipe->sparge_acid_perc);
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
644 brewing_salt_sub(w, ui->sp_acidvolEdit->value(), MISC_USES_SPARGE); // For now, set old amount.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
645
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
646 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
647 is_changed();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
648 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
649
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
650
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
651 void EditRecipe::sp_ph_changed(double val)
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
652 {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
653 recipe->sparge_ph = val;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
654 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
655 is_changed();
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
656 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
657
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
658
365
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
659 void EditRecipe::sp_vol_changed(double val)
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
660 {
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
661 if (! recipe->calc_acid) {
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
662 recipe->sparge_acid_amount *= val / recipe->sparge_volume;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
663 const QSignalBlocker blocker1(ui->sp_acidvolEdit);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
664 ui->sp_acidvolEdit->setValue(recipe->sparge_acid_amount * 1000.0);
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
665 }
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
666
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
667 recipe->sparge_volume = val;
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
668 calcSparge();
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
669 is_changed();
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
670 }
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
671
4bc746c65650 Added sparge water salt additions. Adjust sparge acid amount if manual calculations and the water volume is changed.
Michiel Broek <mbroek@mbse.eu>
parents: 361
diff changeset
672
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
673 void EditRecipe::sp_acid_changed(double val)
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
674 {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
675 if (recipe->calc_acid)
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
676 return;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
677
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
678 qDebug() << "sp_acid_changed" << val << recipe->sparge_acid_amount * 1000.0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
679
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
680 double TargetpH = recipe->sparge_ph;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
681 double Source_pH = recipe->w1_ph;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
682 double Source_alkalinity = recipe->w1_total_alkalinity;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
683
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
684 if (recipe->sparge_source == 1) { // Source 2
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
685 if (recipe->w2_ph > 0.0 && recipe->w2_amount > 0) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
686 Source_pH = recipe->w2_ph;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
687 Source_alkalinity = recipe->w2_total_alkalinity;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
688 }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
689 } else if (recipe->sparge_source == 2) { // Mixed
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
690 if (recipe->w2_ph > 0.0 && recipe->w2_amount > 0) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
691 Source_pH = recipe->wg_ph;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
692 Source_alkalinity = recipe->wg_total_alkalinity;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
693 }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
694 }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
695
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
696 int AT = recipe->sparge_acid_type;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
697 if (AT < 0 || AT >= my_acids.size()) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
698 AT = 0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
699 recipe->sparge_acid_type = 0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
700 ui->sp_acidtypeEdit->setCurrentIndex(0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
701 recipe->sparge_acid_perc = my_acids[0].AcidPrc;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
702 ui->sp_acidpercEdit->setValue(recipe->sparge_acid_perc);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
703 }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
704
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
705 bool go_up = (val < (recipe->sparge_acid_amount * 1000.0));
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
706 bool loop = true;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
707
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
708 while (loop) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
709
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
710 if (go_up)
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
711 TargetpH += 0.001;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
712 else
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
713 TargetpH -= 0.001;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
714 //qDebug() << " TargetpH" << TargetpH << "up" << go_up;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
715
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
716 // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
717 double r1 = pow(10, Source_pH - 6.35);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
718 double r2 = pow(10, Source_pH - 10.33);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
719 double d = 1 + r1 + r1 * r2;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
720 double f1 = 1 / d;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
721 double f3 = r1 * r2 / d;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
722
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
723 // Step 2. Compute the mole fractions at pH = 4.3 (the pH which defines alkalinity)
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
724 double r143 = pow(10, 4.3 - 6.35);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
725 double r243 = pow(10, 4.3 - 10.33);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
726 double d43 = 1 + r143 + r143 * r243;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
727 double f143 = 1 / d43;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
728 double f343 = r143 * r243 / d43;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
729
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
730 // Step 4. Solve
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
731 double Ct = Source_alkalinity / 50 / ((f143 - f1) + (f3 - f343));
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
732
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
733 // Step 5. Compute mole fractions at desired pH
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
734 double r1g = pow(10, TargetpH - 6.35);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
735 double r2g = pow(10, TargetpH - 10.33);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
736 double dg = 1 + r1g + r1g * r2g;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
737 double f1g = 1 / dg;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
738 double f3g = r1g * r2g / dg;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
739
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
740 // Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L)
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
741 double Acid = Ct * ((f1g - f1) + (f3 - f3g)) + pow(10, -TargetpH) - pow(10, -Source_pH); //mEq/l
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
742 Acid += 0.01; // Add acid that would be required for distilled water.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
743
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
744 // Step 7. There is no step 7.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
745
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
746 // Step 8. Get the acid data.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
747 double fract = Utils::CalcFrac(TargetpH, my_acids[AT].pK1, my_acids[AT].pK2, my_acids[AT].pK3);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
748
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
749 // Step 9. Now divide the mEq required by the "fraction". This is the required number of moles of acid.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
750 Acid /= fract;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
751
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
752 // Step 10. Multiply by molecular weight of the acid
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
753 Acid *= my_acids[AT].MolWt; //mg
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
754
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
755 // Step 11. Divide by Specific Gravity and Percentage to get the final ml.
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
756 double RealSG = round(((my_acids[AT].AcidSG - 1000) * (recipe->sparge_acid_perc / 100)) + 1000);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
757 Acid = Acid / RealSG; //ml
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
758 Acid *= recipe->sparge_volume; //ml acid total at 100%
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
759 Acid /= my_acids[AT].AcidPrc / 100; //ml acid at supplied strength
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
760 Acid = round(Acid * 100.0) / 100.0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
761 recipe->sparge_acid_amount = Acid / 1000;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
762 //qDebug() << " acid" << recipe->sparge_acid_amount;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
763
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
764 if (go_up && (val > (recipe->sparge_acid_amount * 1000.0)))
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
765 loop = false;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
766 else if (! go_up && (val < (recipe->sparge_acid_amount * 1000.0)))
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
767 loop = false;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
768
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
769 //qDebug() << " test" << loop << go_up << val << recipe->sparge_acid_amount * 1000.0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
770 }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
771
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
772 const QSignalBlocker blocker1(ui->sp_phEdit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
773 recipe->sparge_ph = round(TargetpH * 100) / 100;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
774 ui->sp_phEdit->setValue(recipe->sparge_ph);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
775 ui->sp_phShow->setValue(recipe->sparge_ph);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
776
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
777 QString w = my_acids[AT].name_en + ' ' + my_acids[AT].name_nl;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
778 set_brewing_salt(w, val, MISC_USES_SPARGE);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
779 //qDebug() << " new" << recipe->sparge_ph << val;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
780 }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
781
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
782
137
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
783 double EditRecipe::GetBUGU()
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
784 {
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
785 double gu = (recipe->est_og - 1) * 1000;
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
786 if (gu > 0)
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
787 return recipe->est_ibu / gu;
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
788 return 0.5;
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
789 }
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
790
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
791
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
792 double EditRecipe::GetOptSO4Clratio()
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
793 {
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
794 if (ui->wt_so4Edit->value() > 0 && ui->wt_clEdit->value()) {
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
795 /* If target water is selected .. */
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
796 return (ui->wt_so4Edit->value() / ui->wt_clEdit->value());
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
797 }
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
798 double BUGU = GetBUGU();
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
799 return (-1.2 * BUGU + 1.4);
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
800 }
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
801
ffe8b2e9517b Added indicators for BUGU and SO4:Cl ratio. Force rounded values for changing brewing salts.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
802
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
803 void EditRecipe::mw_calc_acid_clicked()
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
804 {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
805 recipe->calc_acid = ! recipe->calc_acid;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
806 ui->mw_autoEdit->setChecked(recipe->calc_acid);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
807 ui->mw_phEdit->setReadOnly(! recipe->calc_acid);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
808 ui->mw_phEdit->setButtonSymbols(recipe->calc_acid ? QAbstractSpinBox::UpDownArrows : QAbstractSpinBox::NoButtons);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
809 ui->mw_acidvolEdit->setReadOnly(recipe->calc_acid);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
810 ui->mw_acidvolEdit->setButtonSymbols(recipe->calc_acid ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows);
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
811 ui->sp_phEdit->setReadOnly(! recipe->calc_acid);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
812 ui->sp_phEdit->setButtonSymbols(recipe->calc_acid ? QAbstractSpinBox::UpDownArrows : QAbstractSpinBox::NoButtons);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
813 ui->sp_acidvolEdit->setReadOnly(recipe->calc_acid);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
814 ui->sp_acidvolEdit->setButtonSymbols(recipe->calc_acid ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows);
135
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
815 is_changed();
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
816 calcWater();
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
817 }
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
818
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
819
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
820 void EditRecipe::mw_ph_changed(double val)
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
821 {
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
822 if (! recipe->calc_acid)
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
823 return;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
824
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
825 if (recipe->mash_ph != val) {
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
826 qDebug() << "mw_ph_changed" << val << recipe->mash_ph;
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
827 recipe->mash_ph = val;
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
828 is_changed();
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
829 calcWater();
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
830 }
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
831 }
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
832
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
833
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
834 void EditRecipe::mw_acid_changed(double val)
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
835 {
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
836 if (recipe->calc_acid)
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
837 return;
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
838
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
839 qDebug() << "on_mw_acid_changed" << val;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
840 QString w = my_acids[recipe->wa_acid_name].name_en + ' ' + my_acids[recipe->wa_acid_name].name_nl;
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
841 set_brewing_salt(w, val, MISC_USES_MASH);
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
842 }
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
843
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
844
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
845 void EditRecipe::mw_type_changed(int val)
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
846 {
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
847 if (val == recipe->wa_acid_name)
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
848 return;
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
849
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
850 qDebug() << "on_mw_type_changed" << val << "old" << recipe->wa_acid_name;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
851 /*
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
852 * First remove current acid.
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
853 */
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
854 QString w = my_acids[recipe->wa_acid_name].name_en + ' ' + my_acids[recipe->wa_acid_name].name_nl;
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
855 brewing_salt_sub(w, 0, MISC_USES_MASH);
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
856
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
857 recipe->wa_acid_name = val;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
858 w = my_acids[recipe->wa_acid_name].name_en + ' ' + my_acids[recipe->wa_acid_name].name_nl;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
859
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
860 recipe->wa_acid_perc = my_acids.at(val).AcidPrc;
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
861 ui->mw_acidpercEdit->setValue(my_acids.at(val).AcidPrc);
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
862 brewing_salt_sub(w, ui->mw_acidvolEdit->value(), MISC_USES_MASH); // For now, set old amount.
136
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
863
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
864 is_changed();
17030224d919 Remove some water search debug messages. Added signals and slots for mash water pH and volume changes. Added manual pH adjust.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
865 calcWater();
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
866 }
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
867
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
868
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
869 void EditRecipe::w2_volume_changed(double val)
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
870 {
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
871 qDebug() << "w2_vol_changed" << val;
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
872
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
873 if (recipe->w2_total_alkalinity && recipe->w2_sulfate) {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
874 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
875 * Seems a valid water, but don't go over the total.
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
876 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
877 if (val < (recipe->w1_amount + recipe->w2_amount)) {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
878 recipe->w1_amount -= val - recipe->w2_amount;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
879 recipe->w2_amount = val;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
880 ui->w1_volEdit->setValue(recipe->w1_amount);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
881 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
882 } else {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
883 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
884 * Invalid water, block changes.
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
885 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
886 recipe->w2_amount = 0;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
887 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
888 ui->w2_volEdit->setValue(recipe->w2_amount);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
889
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
890 calcWater();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
891 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
892 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
893
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
894
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
895 void EditRecipe::w1_name_changed(int val)
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
896 {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
897 QSqlQuery query;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
898
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
899 qDebug() << "w1_name_changed" << val;
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
900 const QSignalBlocker blocker1(ui->w1_nameEdit);
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
901 if (val == 0) {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
902 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
903 * If no water is selected, take the default water.
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
904 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
905 val = my_default_water;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
906 ui->w1_nameEdit->setCurrentIndex(val);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
907 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
908
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
909 query.prepare("SELECT * FROM inventory_waters ORDER BY record");
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
910 query.exec();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
911 query.first();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
912 for (int i = 0; i < (val - 1); i++) {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
913 query.next();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
914 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
915 qDebug() << "set water" << query.value(1).toString();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
916
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
917 recipe->w1_name = query.value("name").toString();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
918 recipe->w1_calcium = query.value("calcium").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
919 recipe->w1_magnesium = query.value("magnesium").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
920 recipe->w1_total_alkalinity = query.value("total_alkalinity").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
921 recipe->w1_sodium = query.value("sodium").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
922 recipe->w1_chloride = query.value("chloride").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
923 recipe->w1_sulfate = query.value("sulfate").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
924 recipe->w1_ph = query.value("ph").toDouble();
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
925
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
926 ui->w1_caEdit->setValue(recipe->w1_calcium);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
927 ui->w1_mgEdit->setValue(recipe->w1_magnesium);
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
928 ui->w1_hco3Edit->setValue(Utils::Bicarbonate(recipe->w1_total_alkalinity, recipe->w1_ph));
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
929 ui->w1_caco3Edit->setValue(recipe->w1_total_alkalinity);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
930 ui->w1_naEdit->setValue(recipe->w1_sodium);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
931 ui->w1_clEdit->setValue(recipe->w1_chloride);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
932 ui->w1_so4Edit->setValue(recipe->w1_sulfate);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
933 ui->w1_phEdit->setValue(recipe->w1_ph);
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
934 ui->w1_hardnessEdit->setValue(Utils::Hardness(recipe->w1_calcium, recipe->w1_magnesium));
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
935 ui->w1_raEdit->setValue(Utils::ResidualAlkalinity(recipe->w1_total_alkalinity, recipe->w1_calcium, recipe->w1_magnesium));
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
936
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
937 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
938 calcWater();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
939 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
940
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
941
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
942 void EditRecipe::w2_name_changed(int val)
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
943 {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
944 QSqlQuery query;
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
945 double hardness, ra_ppm;
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
946
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
947 qDebug() << "w2_name_changed" << val;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
948
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
949 if (val == 0) { // Clear water 2.
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
950 recipe->w2_name = "";
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
951 recipe->w2_calcium = 0;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
952 recipe->w2_magnesium = 0;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
953 recipe->w2_total_alkalinity = 0;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
954 recipe->w2_sodium = 0;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
955 recipe->w2_chloride = 0;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
956 recipe->w2_sulfate = 0;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
957 recipe->w2_ph = 0;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
958 recipe->w1_amount += recipe->w2_amount;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
959 recipe->w2_amount = 0;
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
960 hardness = ra_ppm = 0;
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
961 } else {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
962 query.prepare("SELECT * FROM inventory_waters ORDER BY record");
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
963 query.exec();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
964 query.first();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
965 for (int i = 0; i < (val - 1); i++) {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
966 query.next();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
967 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
968 qDebug() << "set water" << query.value(1).toString();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
969
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
970 recipe->w2_name = query.value("name").toString();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
971 recipe->w2_calcium = query.value("calcium").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
972 recipe->w2_magnesium = query.value("magnesium").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
973 recipe->w2_total_alkalinity = query.value("total_alkalinity").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
974 recipe->w2_sodium = query.value("sodium").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
975 recipe->w2_chloride = query.value("chloride").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
976 recipe->w2_sulfate = query.value("sulfate").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
977 recipe->w2_ph = query.value("ph").toDouble();
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
978 hardness = Utils::Hardness(recipe->w2_calcium, recipe->w2_magnesium);
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
979 ra_ppm = Utils::ResidualAlkalinity(recipe->w2_total_alkalinity, recipe->w2_calcium, recipe->w2_magnesium);
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
980 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
981 ui->w1_volEdit->setValue(recipe->w1_amount);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
982 ui->w2_volEdit->setValue(recipe->w2_amount);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
983 ui->w2_caEdit->setValue(recipe->w2_calcium);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
984 ui->w2_mgEdit->setValue(recipe->w2_magnesium);
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
985 ui->w2_hco3Edit->setValue(Utils::Bicarbonate(recipe->w2_total_alkalinity, recipe->w2_ph));
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
986 ui->w2_caco3Edit->setValue(recipe->w2_total_alkalinity);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
987 ui->w2_naEdit->setValue(recipe->w2_sodium);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
988 ui->w2_clEdit->setValue(recipe->w2_chloride);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
989 ui->w2_so4Edit->setValue(recipe->w2_sulfate);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
990 ui->w2_phEdit->setValue(recipe->w2_ph);
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
991 ui->w2_hardnessEdit->setValue(hardness);
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
992 ui->w2_raEdit->setValue(ra_ppm);
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
993
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
994 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
995 calcWater();
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
996 }
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
997
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
998
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
999 void EditRecipe::wt_target_changed(int val)
138
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1000 {
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1001 QSqlQuery query;
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1002
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1003 if (val == 0) {
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1004 /* Clear values */
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1005 ui->wt_caEdit->setValue(0);
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1006 ui->wt_mgEdit->setValue(0);
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1007 ui->wt_hco3Edit->setValue(0);
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1008 ui->wt_caco3Edit->setValue(0);
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1009 ui->wt_naEdit->setValue(0);
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1010 ui->wt_clEdit->setValue(0);
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1011 ui->wt_so4Edit->setValue(0);
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1012 ui->wt_hardnessEdit->setValue(0);
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1013 ui->wt_raEdit->setValue(0);
138
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1014 } else {
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1015 query.prepare("SELECT * FROM profile_water ORDER BY name");
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1016 query.exec();
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1017 query.first();
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1018 for (int i = 0; i < (val - 1); i++) {
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1019 query.next();
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1020 }
350
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1021 ui->wt_caEdit->setValue(query.value("calcium").toDouble());
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1022 ui->wt_mgEdit->setValue(query.value("magnesium").toDouble());
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1023 ui->wt_hco3Edit->setValue(query.value("bicarbonate").toDouble());
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1024 ui->wt_caco3Edit->setValue(query.value("total_alkalinity").toDouble());
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1025 ui->wt_naEdit->setValue(query.value("sodium").toDouble());
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1026 ui->wt_clEdit->setValue(query.value("chloride").toDouble());
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1027 ui->wt_so4Edit->setValue(query.value("sulfate").toDouble());
37b3c690b02c Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
1028 ui->wt_hardnessEdit->setValue(Utils::Hardness(query.value("calcium").toDouble(), query.value("magnesium").toDouble()));
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
1029 ui->wt_raEdit->setValue(Utils::ResidualAlkalinity(query.value("total_alkalinity").toDouble(), query.value("calcium").toDouble(), query.value("magnesium").toDouble()));
138
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1030 }
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1031 calcWater();
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1032 }
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1033
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1034
150
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1035 void EditRecipe::adjustWaters(double factor)
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1036 {
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1037 int i;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1038 double amount;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1039
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1040 if (recipe->mashs.size() == 0)
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1041 return;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1042
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1043 double mash_infuse = 0;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1044 for (i = 0; i < recipe->mashs.size(); i++) {
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1045 if (recipe->mashs.at(i).step_type == 0) { // Infusion
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1046 amount = round(recipe->mashs.at(i).step_infuse_amount * factor * 1000000.0) / 1000000.0;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1047 recipe->mashs[i].step_infuse_amount = amount;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1048 mash_infuse += amount;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1049 recipe->mashs[i].step_volume = mash_infuse;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1050 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1051 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1052
152
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1053 const QSignalBlocker blocker1(ui->w1_volEdit);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1054 const QSignalBlocker blocker2(ui->w2_volEdit);
58e4ce7dd217 Fixed vanishing mash profiles from some recipes. All ingnoreChanges flags removed and replaced by blocking signals. Update prompts and yeast amounts depending on the yeast form. Save water profile names fixed.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1055
150
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1056 if (recipe->w2_amount == 0) {
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1057 recipe->w1_amount = mash_infuse;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1058 ui->w1_volEdit->setValue(mash_infuse);
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1059 } else {
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1060 double w1 = (recipe->w1_amount / (recipe->w1_amount + recipe->w2_amount)) * mash_infuse;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1061 double w2 = (recipe->w2_amount / (recipe->w1_amount + recipe->w2_amount)) * mash_infuse;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1062 recipe->w1_amount = w1;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1063 recipe->w2_amount = w2;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1064 ui->w1_volEdit->setValue(recipe->w1_amount);
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1065 ui->w2_volEdit->setValue(recipe->w2_amount);
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1066 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1067 recipe->wg_amount = mash_infuse;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1068 ui->wg_volEdit->setValue(mash_infuse);
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1069 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1070
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1071
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1072 void EditRecipe::wb_cacl2_changed(double val) { set_brewing_salt("CaCl2", val, MISC_USES_MASH); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1073 void EditRecipe::wb_caso4_changed(double val) { set_brewing_salt("CaSO4", val, MISC_USES_MASH); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1074 void EditRecipe::wb_mgso4_changed(double val) { set_brewing_salt("MgSO4", val, MISC_USES_MASH); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1075 void EditRecipe::wb_nacl_changed(double val) { set_brewing_salt("NaCl", val, MISC_USES_MASH); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1076 void EditRecipe::wb_mgcl2_changed(double val) { set_brewing_salt("MgCl2", val, MISC_USES_MASH); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1077 void EditRecipe::wb_nahco3_changed(double val) { set_brewing_salt("NaHCO3", val, MISC_USES_MASH); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1078 void EditRecipe::wb_caco3_changed(double val) { set_brewing_salt("CaCO3", val, MISC_USES_MASH); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1079 void EditRecipe::sp_cacl2_changed(double val) { set_brewing_salt("CaCl2", val, MISC_USES_SPARGE); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1080 void EditRecipe::sp_caso4_changed(double val) { set_brewing_salt("CaSO4", val, MISC_USES_SPARGE); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1081 void EditRecipe::sp_mgso4_changed(double val) { set_brewing_salt("MgSO4", val, MISC_USES_SPARGE); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1082 void EditRecipe::sp_nacl_changed(double val) { set_brewing_salt("NaCl", val, MISC_USES_SPARGE); }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 358
diff changeset
1083 void EditRecipe::sp_mgcl2_changed(double val) { set_brewing_salt("MgCl2", val, MISC_USES_SPARGE); }
133
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
1084
08635b028dcf Load waters during recipe startup. Started calcWater() function. Load profile_setup record global. The print function uses the globals now too instead of loading from the database.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
1085

mercurial