src/EditRecipeTab7.cpp

Tue, 19 Jul 2022 11:17:39 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 19 Jul 2022 11:17:39 +0200
changeset 361
ec8de79f6ff6
parent 359
dfbb012c631c
child 365
4bc746c65650
permissions
-rw-r--r--

Improved selection logic for the sparge water.

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
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
190 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
191 {
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
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206
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
207 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
208
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
209 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
210 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
211
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
212 /*
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
213 * 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
214 */
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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 } 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 }
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
236
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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258
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 /* 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
260 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
261 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
262 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
263 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
264 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
265 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
266
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
267 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
268 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
269
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
270 /* 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
271 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
272 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
273 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
274 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
275 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
276 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
277 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
278 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
279 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
280 }
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
281
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
282 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
283 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
284 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
285 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
286 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
287
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
288 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
289 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
290 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
291 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
292 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
293 }
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
294 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
295
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
296 /*
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
297 * 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
298 * 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
299 */
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
300 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
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 * 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
303 */
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 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
305 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
306 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
307 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
308 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
309 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
310 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
311 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
312 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
313 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
314 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
315 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
316
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
317 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
318 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
319 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
320 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
321 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
322
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
323 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
324 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
325 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
326
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
327 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
328 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
329 }
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 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
331 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
332 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
333 } 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
334 /*
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 * 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
336 */
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
337 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
338 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
339 // 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
340 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
341 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
342 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
343 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
344 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
345 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
346
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
347 //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
348 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
349 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
350 //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
351
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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365 }
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
366 //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
367
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
368 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
369 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
370 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
371 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
372 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
373 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
374 }
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
375
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 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
377 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
378 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
379 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
380 } 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
381 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
382 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
383 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
384 }
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
385
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
386 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
387 ui->buguEdit->setValue(BUGU);
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
388 if (BUGU < 0.32)
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
389 ui->buguResult->setText(tr("Very malty and sweet"));
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
390 else if (BUGU < 0.43)
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
391 ui->buguResult->setText(tr("Malty, sweet"));
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
392 else if (BUGU < 0.52)
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
393 ui->buguResult->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
394 else if (BUGU < 0.63)
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
395 ui->buguResult->setText(tr("Hoppy, 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
396 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
397 ui->buguResult->setText(tr("Very hoppy, 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
398
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
399 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
400 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
401 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
402 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
403 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
404 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
405 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
406 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
407 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
408 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
409 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
410 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
411 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
412 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
413 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
414 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
415 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
416 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
417 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
418 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
419 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
420 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
421 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
422 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
423 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
424
161
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
425 recipe->wb_calcium = calcium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
426 recipe->wb_magnesium = magnesium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
427 recipe->wb_total_alkalinity = total_alkalinity;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
428 recipe->wb_sodium = sodium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
429 recipe->wb_chloride = chloride;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
430 recipe->wb_sulfate = sulfate;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
431 recipe->wb_ph = ph;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
432
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
433 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
434 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
435 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
436 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
437 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
438 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
439 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
440 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
441 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
442
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
443 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
444 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
445 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
446 /*
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
447 * 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
448 * 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
449 */
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
450 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
451 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
452 /*
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
453 * (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
454 */
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 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
456 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
457 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
458 }
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_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
460 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
461 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
462
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
463 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
464 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
465
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
466
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
467 /*
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
468 * Based on the work of ajDeLange.
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
469 */
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
470 void EditRecipe::calcSparge()
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
471 {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
472 double TargetpH = recipe->sparge_ph;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
473 double Source_pH = recipe->w1_ph;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
474 double Source_alkalinity = recipe->w1_total_alkalinity;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
475
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
476 qDebug() << "calcSparge()";
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
477 setButtons(recipe->locked);
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
478
361
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
479 if (recipe->sparge_source == 1 && recipe->w2_ph > 0.0) {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
480 Source_pH = recipe->w2_ph;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
481 Source_alkalinity = recipe->w2_total_alkalinity;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
482 ui->sp_caEdit->setValue(recipe->w2_calcium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
483 ui->sp_mgEdit->setValue(recipe->w2_magnesium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
484 ui->sp_hco3Edit->setValue(Utils::Bicarbonate(recipe->w2_total_alkalinity, recipe->w2_ph));
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
485 ui->sp_caco3Edit->setValue(recipe->w2_total_alkalinity);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
486 ui->sp_naEdit->setValue(recipe->w2_sodium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
487 ui->sp_clEdit->setValue(recipe->w2_chloride);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
488 ui->sp_so4Edit->setValue(recipe->w2_sulfate);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
489 ui->sp_phShow->setValue(recipe->w2_ph);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
490 ui->sp_hardnessEdit->setValue(Utils::Hardness(recipe->w2_calcium, recipe->w2_magnesium));
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
491 ui->sp_raEdit->setValue(Utils::ResidualAlkalinity(recipe->w2_total_alkalinity, recipe->w2_calcium, recipe->w2_magnesium));
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
492 } else if (recipe->sparge_source == 2 && recipe->w2_ph > 0.0) {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
493 Source_pH = recipe->wg_ph;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
494 Source_alkalinity = recipe->wg_total_alkalinity;
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
495 ui->sp_caEdit->setValue(recipe->wg_calcium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
496 ui->sp_mgEdit->setValue(recipe->wg_magnesium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
497 ui->sp_hco3Edit->setValue(Utils::Bicarbonate(recipe->wg_total_alkalinity, recipe->wg_ph));
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
498 ui->sp_caco3Edit->setValue(recipe->wg_total_alkalinity);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
499 ui->sp_naEdit->setValue(recipe->wg_sodium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
500 ui->sp_clEdit->setValue(recipe->wg_chloride);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
501 ui->sp_so4Edit->setValue(recipe->wg_sulfate);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
502 ui->sp_phShow->setValue(recipe->wg_ph);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
503 ui->sp_hardnessEdit->setValue(Utils::Hardness(recipe->wg_calcium, recipe->wg_magnesium));
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
504 ui->sp_raEdit->setValue(Utils::ResidualAlkalinity(recipe->wg_total_alkalinity, recipe->wg_calcium, recipe->wg_magnesium));
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
505 } else {
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
506 ui->sp_caEdit->setValue(recipe->w1_calcium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
507 ui->sp_mgEdit->setValue(recipe->w1_magnesium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
508 ui->sp_hco3Edit->setValue(Utils::Bicarbonate(recipe->w1_total_alkalinity, recipe->w1_ph));
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
509 ui->sp_caco3Edit->setValue(recipe->w1_total_alkalinity);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
510 ui->sp_naEdit->setValue(recipe->w1_sodium);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
511 ui->sp_clEdit->setValue(recipe->w1_chloride);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
512 ui->sp_so4Edit->setValue(recipe->w1_sulfate);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
513 ui->sp_phShow->setValue(recipe->w1_ph);
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
514 ui->sp_hardnessEdit->setValue(Utils::Hardness(recipe->w1_calcium, recipe->w1_magnesium));
ec8de79f6ff6 Improved selection logic for the sparge water.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
515 ui->sp_raEdit->setValue(Utils::ResidualAlkalinity(recipe->w1_total_alkalinity, recipe->w1_calcium, recipe->w1_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
516 }
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
517 // The spargewater is set.
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
518
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
519 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
520 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
521 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
522 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
523 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
524 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
525 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
526 }
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
527
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
528 /*
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
529 * 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
530 */
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
531 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
532 // 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
533 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
534 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
535 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
536 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
537 double f3 = r1 * r2 / d;
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
538
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
539 // 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
540 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
541 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
542 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
543 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
544 double f343 = r143 * r243 / d43;
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
545
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 // 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
547 double Ct = Source_alkalinity / 50 / ((f143 - f1) + (f3 - f343));
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
548
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
549 // 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
550 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
551 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
552 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
553 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
554 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
555
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 // 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
557 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
558 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
559
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 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
561 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
562
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
563 // 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
564 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
565
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
566 // 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
567 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
568
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 // 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
570 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
571 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
572 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
573 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
574 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
575 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
576 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
577 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
578 ui->sp_acidvolEdit->setValue(Acid);
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
579 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
580
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
581 ui->sp_phShow->setValue(recipe->sparge_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
582 // 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
583 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
584 (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
585 ui->preboil_phEdit->setValue(recipe->preboil_ph);
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
586 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
587
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
588
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
589 void EditRecipe::sp_group_changed(int val)
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 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
592 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
593 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
594 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
595 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
596 }
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
597 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
598
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
599
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
600 void EditRecipe::sp_type_changed(int val)
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
601 {
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
602 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
603 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
604
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 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
606 /*
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
607 * 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
608 */
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
609 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
610 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
611
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
612 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
613 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
614
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
615 recipe->sparge_acid_perc = my_acids[val].AcidPrc;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
616 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
617 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
618
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
619 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
620 is_changed();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
621 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
622
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
623
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
624 void EditRecipe::sp_ph_changed(double val)
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 recipe->sparge_ph = val;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
627 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
628 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
629 }
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
630
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
631
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
632 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
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 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
635 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
636
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 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
638
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
639 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
640 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
641 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
642
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
643 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
644 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
645 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
646 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
647 }
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
648 } 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
649 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
650 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
651 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
652 }
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
653 }
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
654
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
655 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
656 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
657 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
658 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
659 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
660 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
661 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
662 }
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
663
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
664 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
665 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
666
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
667 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
668
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
669 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
670 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
671 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
672 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
673 //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
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 // 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
676 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
677 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
678 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
679 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
680 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
681
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 // 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
683 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
684 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
685 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
686 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
687 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
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 // 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
690 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
691
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 // 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
693 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
694 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
695 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
696 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
697 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
698
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 // 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
700 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
701 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
702
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 // 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
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 // 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
706 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
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 // 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
709 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
710
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 // 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
712 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
713
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 // 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
715 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
716 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
717 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
718 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
719 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
720 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
721 //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
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 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
724 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
725 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
726 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
727
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 //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
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
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 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
732 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
733 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
734 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
735
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 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
737 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
738 //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
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
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
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
742 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
743 {
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
744 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
745 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
746 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
747 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
748 }
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
749
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
750
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
751 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
752 {
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
753 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
754 /* 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
755 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
756 }
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
757 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
758 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
759 }
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
760
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
761
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
762 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
763 {
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
764 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
765 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
766 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
767 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
768 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
769 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
770 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
771 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
772 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
773 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
774 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
775 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
776 }
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
777
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
778
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
779 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
780 {
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
781 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
782 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
783
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
784 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
785 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
786 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
787 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
788 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
789 }
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
790 }
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
791
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
792
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
793 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
794 {
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
795 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
796 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
797
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
798 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
799 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
800 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
801 }
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
802
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
803
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
804 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
805 {
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
806 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
807 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
808
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
809 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
810 /*
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
811 * 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
812 */
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
813 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
814 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
815
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
816 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
817 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
818
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
819 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
820 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
821 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
822
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 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
824 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
825 }
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
826
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
827
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
828 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
829 {
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
830 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
831
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
832 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
833 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
834 * 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
835 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
836 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
837 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
838 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
839 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
840 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
841 } else {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
842 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
843 * 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
844 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
845 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
846 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
847 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
848
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
849 calcWater();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
850 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
851 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
852
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
853
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
854 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
855 {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
856 QSqlQuery query;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
857
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
858 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
859 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
860 if (val == 0) {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
861 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
862 * 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
863 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
864 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
865 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
866 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
867
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
868 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
869 query.exec();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
870 query.first();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
871 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
872 query.next();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
873 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
874 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
875
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
876 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
877 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
878 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
879 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
880 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
881 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
882 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
883 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
884
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
885 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
886 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
887 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
888 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
889 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
890 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
891 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
892 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
893 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
894 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
895
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
896 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
897 calcWater();
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
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
900
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
901 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
902 {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
903 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
904 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
905
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
906 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
907
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
908 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
909 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
910 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
911 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
912 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
913 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
914 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
915 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
916 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
917 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
918 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
919 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
920 } else {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
921 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
922 query.exec();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
923 query.first();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
924 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
925 query.next();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
926 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
927 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
928
358
d89bc21e2f07 Adapted to new Utils functions. Used named versions for MySQL water read.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
929 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
930 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
931 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
932 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
933 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
934 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
935 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
936 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
937 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
938 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
939 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
940 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
941 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
942 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
943 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
944 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
945 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
946 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
947 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
948 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
949 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
950 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
951 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
952
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
953 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
954 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
955 }
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
956
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
957
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
958 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
959 {
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
960 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
961
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
962 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
963 /* 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
964 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
965 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
966 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
967 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
968 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
969 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
970 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
971 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
972 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
973 } 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
974 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
975 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
976 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
977 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
978 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
979 }
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
980 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
981 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
982 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
983 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
984 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
985 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
986 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
987 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
988 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
989 }
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
990 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
991 }
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
992
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
993
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
994 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
995 {
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
996 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
997 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
998
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
999 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
1000 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
1001
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
1002 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
1003 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
1004 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
1005 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
1006 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
1007 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
1008 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
1009 }
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
1010 }
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
1011
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
1012 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
1013 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
1014
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
1015 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
1016 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
1017 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
1018 } 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
1019 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
1020 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
1021 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
1022 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
1023 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
1024 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
1025 }
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
1026 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
1027 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
1028 }
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
1029
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
1030
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
1031 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
1032 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
1033 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
1034 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
1035 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
1036 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
1037 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
1038 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
1039 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
1040 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
1041 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
1042 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
1043
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
1044

mercurial