src/EditRecipeTab7.cpp

Tue, 12 Jul 2022 15:34:17 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 12 Jul 2022 15:34:17 +0200
changeset 350
37b3c690b02c
parent 283
242a68fa7186
child 358
d89bc21e2f07
permissions
-rw-r--r--

Added calculation preboild pH in recipes. Added water hardness and residual alkalinity calculations in the water tab.

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) {
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
71 case 0: // Base, Special, Kilned
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
72 case 3:
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
73 case 5: C1 = 0.014 * F.color - 34.192;
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
74 break;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
75 case 2: C1 = -0.0597 * F.color - 32.457; // Crystal
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
76 break;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
77 case 1: C1 = 0.0107 * F.color - 54.768; // Roast
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
78 break;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
79 case 4: C1 = -149; // Sour malt
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
80 break;
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The 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);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 162
diff changeset
108 if (F.added == 0 && F.graintype != 6) { // Added == Mash && graintype != No Malt
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
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
144 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
145 {
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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160
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
161 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
162
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
163 ui->w1_hardnessEdit->setValue(Utils::Hardness(recipe->w1_calcium, recipe->w1_magnesium));
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
164 ui->w1_raEdit->setValue(Utils::RA_ppm(recipe->w1_total_alkalinity, recipe->w1_calcium, recipe->w1_magnesium));
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
165
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
166 /*
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
167 * 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
168 */
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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 ui->w2_hardnessEdit->setValue(Utils::Hardness(recipe->w2_calcium, recipe->w2_magnesium));
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
179 ui->w2_raEdit->setValue(Utils::RA_ppm(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
180 } 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 }
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
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 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
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199
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 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
201 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
202 ui->wg_mgEdit->setValue(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
203 ui->wg_hco3Edit->setValue(total_alkalinity * 1.22);
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
204 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
205 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
206 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
207 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
208 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
209 ui->wg_hardnessEdit->setValue(Utils::Hardness(calcium, magnesium));
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
210 ui->wg_raEdit->setValue(Utils::RA_ppm(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
211 bicarbonate = total_alkalinity * 1.22;
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 /* 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
214 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
215 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
216 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
217 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
218 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
219 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
220
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
221 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
222 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
223
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
224 /* 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
235
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
236 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
237 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
238 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
239 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
240 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
241
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
242 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
243 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
244 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
245 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
246 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
247 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
248 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
249
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
250 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
251 * 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
252 * 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
253 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
254 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
255 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
256 * 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
257 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 Acid = round((Acid / (recipe->wa_acid_perc / 100.0)) * 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
268 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
269
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
270 QString w = my_acids[AT].name_en + ' ' + my_acids[AT].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
271 brewing_salt_sub(w, 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
272 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
273
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
274 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
275 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
276 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The 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 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
278 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
279 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
280 } 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
281 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
282 * 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
283 */
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
284 double pHa = ph; // Mixed water 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
285 // 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
286 qDebug() << " Mash 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
287 Acid = my_acids[AT].AcidSG * (recipe->wa_acid_perc / 100.0); // ml
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
288 Acid *= ui->mw_acidvolEdit->value();
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
289 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
290 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
291
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
292 //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
293 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
294 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
295 //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
296
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
297 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
298 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
299 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
300 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
301 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
302 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
303 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
304 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
305 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
306 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
307 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
308 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
309 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
310 }
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
311 //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
312
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
313 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
314 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
315 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
316 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
317 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
318 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
319 }
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
320
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 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
322 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
323 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
324 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
325 } 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
326 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
327 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
328 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
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
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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
343
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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367 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
368 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
369
161
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
370 recipe->wb_calcium = calcium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
371 recipe->wb_magnesium = magnesium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
372 recipe->wb_total_alkalinity = total_alkalinity;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
373 recipe->wb_sodium = sodium;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
374 recipe->wb_chloride = chloride;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
375 recipe->wb_sulfate = sulfate;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
376 recipe->wb_ph = ph;
b36d249512cc Fix missing values for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 152
diff changeset
377
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
378 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
379 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
380 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
381 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
382 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
383 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
384 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
385 ui->wb_hardnessEdit->setValue(Utils::Hardness(calcium, magnesium));
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
386 ui->wb_raEdit->setValue(Utils::RA_ppm(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
387
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
388 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
389 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
390 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
391 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
392 * 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
393 * 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
394 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
395 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
396 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
397 /*
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
398 * (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
399 */
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
400 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
401 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
402 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
403 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
404 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
405 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
406 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
407
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
408 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
409 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
410
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
411
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
412 /*
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
413 * Based on the work of ajDeLange.
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
414 */
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
415 void EditRecipe::calcSparge()
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
416 {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
417 double TargetpH = recipe->sparge_ph;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
418 double Source_pH = recipe->w1_ph;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
419 double Source_alkalinity = recipe->w1_total_alkalinity;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
420
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
421 qDebug() << "calcSparge()";
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
422
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
423 const QSignalBlocker blocker1(ui->sp_sourceEdit);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
424
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
425 // Select watersource or fallback to the first source.
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
426 if (recipe->sparge_source == 1) { // Source 2
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
427 if (recipe->w2_ph > 0.0 && recipe->w2_amount > 0) {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
428 Source_pH = recipe->w2_ph;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
429 Source_alkalinity = recipe->w2_total_alkalinity;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
430 } else {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
431 recipe->sparge_source = 0; // Source 1
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
432 ui->sp_sourceEdit->setCurrentIndex(0);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
433 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
434 } else if (recipe->sparge_source == 2) { // Mixed
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
435 if (recipe->w2_ph > 0.0 && recipe->w2_amount > 0) {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
436 Source_pH = recipe->wg_ph;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
437 Source_alkalinity = recipe->wg_total_alkalinity;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
438 } else {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
439 recipe->sparge_source = 0; // Source 1
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
440 ui->sp_sourceEdit->setCurrentIndex(0);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
441 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
442 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
443
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
444 // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
445 double r1 = pow(10, Source_pH - 6.35);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
446 double r2 = pow(10, Source_pH - 10.33);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
447 double d = 1 + r1 + r1 * r2;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
448 double f1 = 1 / d;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
449 double f3 = r1 * r2 / d;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
450
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
451 // Step 2. Compute the mole fractions at pH = 4.3 (the pH which defines alkalinity)
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
452 double r143 = pow(10, 4.3 - 6.35);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
453 double r243 = pow(10, 4.3 - 10.33);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
454 double d43 = 1 + r143 + r143 * r243;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
455 double f143 = 1 / d43;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
456 double f343 = r143 * r243 / d43;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
457
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
458 // Step 4. Solve
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
459 //double Ct = (Source_alkalinity - 1000 * (pow(10, -4.3) - pow(10, -Source_pH))) / ((f143 - f1) + (f3 - f343));
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
460 double Ct = Source_alkalinity / 50 / ((f143 - f1) + (f3 - f343));
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
461
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
462 // Step 5. Compute mole fractions at desired pH
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
463 double r1g = pow(10, TargetpH - 6.35);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
464 double r2g = pow(10, TargetpH - 10.33);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
465 double dg = 1 + r1g + r1g * r2g;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
466 double f1g = 1 / dg;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
467 double f3g = r1g * r2g / dg;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
468
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
469 // Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L)
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
470 double Acid = Ct * ((f1g - f1) + (f3 - f3g)) + pow(10, -TargetpH) - pow(10, -Source_pH); //mEq/l
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
471 Acid += 0.01; // Add acid that would be required for distilled water.
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
472
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
473 //Step 8. Get the acid data.
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
474 int AT = recipe->sparge_acid_type;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
475 if (AT < 0 || AT >= my_acids.size()) {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
476 AT = 0;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
477 recipe->sparge_acid_type = 0;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
478 ui->sp_acidtypeEdit->setCurrentIndex(0);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
479 recipe->sparge_acid_perc = my_acids[0].AcidPrc;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
480 ui->sp_acidpercEdit->setValue(recipe->sparge_acid_perc);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
481 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
482 double fract = Utils::CalcFrac(TargetpH, my_acids[AT].pK1, my_acids[AT].pK2, my_acids[AT].pK3);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
483
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
484 // Step 9. Now divide the mEq required by the "fraction". This is the required number of moles of acid.
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
485 Acid /= fract;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
486
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
487 // Step 10. Multiply by molecular weight of the acid
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
488 Acid *= my_acids[AT].MolWt; //mg
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
489
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
490 // Step 11. Divide by Specific Gravity and Percentage to get the final ml.
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
491 Acid = Acid / my_acids[AT].AcidSG / (recipe->sparge_acid_perc / 100); //ml
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
492 Acid *= recipe->sparge_volume; //ml acid total
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
493 Acid = round(Acid * 100.0) / 100.0;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
494 recipe->sparge_acid_amount = Acid / 1000;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
495 ui->sp_acidvolEdit->setValue(Acid);
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
496
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
497 // 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
498 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
499 (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
500 ui->preboil_phEdit->setValue(recipe->preboil_ph);
162
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
501 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
502
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
503
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
504 void EditRecipe::sp_source_changed(int val)
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
505 {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
506 recipe->sparge_source = val;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
507 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
508 is_changed();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
509 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
510
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
511
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
512 void EditRecipe::sp_type_changed(int val)
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
513 {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
514 recipe->sparge_acid_type = val;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
515 recipe->sparge_acid_perc = my_acids[val].AcidPrc;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
516 ui->sp_acidpercEdit->setValue(recipe->sparge_acid_perc);
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
517 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
518 is_changed();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
519 }
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
520
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
521
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
522 void EditRecipe::sp_ph_changed(double val)
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
523 {
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
524 recipe->sparge_ph = val;
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
525 calcSparge();
19156b8b339f Added calcSparge.
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
526 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
527 }
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
528
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
529
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
530 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
531 {
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
532 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
533 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
534 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
535 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
536 }
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
537
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
538
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
539 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
540 {
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
541 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
542 /* 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
543 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
544 }
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
545 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
546 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
547 }
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
548
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
549
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
550 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
551 {
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
552 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
553 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
554 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
555 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
556 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
557 ui->mw_acidvolEdit->setButtonSymbols(recipe->calc_acid ? QAbstractSpinBox::NoButtons : QAbstractSpinBox::UpDownArrows);
e68b27ad8a40 Added dutch translations to the internal acids array. Added slot for calc_acid checkbox. Added more water calculations. The miscs amount fields now have two decimal digits. Show treated waters and good/bad indicators.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
558 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
559 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
560 }
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
561
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
562
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
563 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
564 {
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
565 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
566 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
567
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
568 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
569 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
570 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
571 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
572 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
573 }
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
574 }
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
575
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
576
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
577 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
578 {
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
579 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
580 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
581
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
582 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
583 QString 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
584 set_brewing_salt(w, 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
585 }
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
586
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
587
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
588 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
589 {
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
590 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
591 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
592
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
593 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
594 /*
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
595 * 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
596 */
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
597 QString 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
598 brewing_salt_sub(w, 0);
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
599
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
600 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
601 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
602
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
603 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
604 ui->mw_acidpercEdit->setValue(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
605 brewing_salt_sub(w, ui->mw_acidvolEdit->value()); // For now, set old amount.
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
606
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
607 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
608 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
609 }
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
610
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
611
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
612 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
613 {
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
614 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
615
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
616 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
617 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
618 * 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
619 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
620 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
621 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
622 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
623 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
624 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
625 } else {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
626 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
627 * 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
628 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
629 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
630 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
631 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
632
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
633 calcWater();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
634 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
635 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
636
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
637
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
638 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
639 {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
640 QSqlQuery query;
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
641
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
642 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
643 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
644 if (val == 0) {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
645 /*
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
646 * 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
647 */
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
648 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
649 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
650 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
651
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
652 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
653 query.exec();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
654 query.first();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
655 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
656 query.next();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
657 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
658 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
659
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
660 recipe->w1_name = query.value(1).toString();
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
661 recipe->w1_calcium = query.value(3).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
662 recipe->w1_magnesium = query.value(8).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
663 recipe->w1_total_alkalinity = query.value(11).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
664 recipe->w1_sodium = query.value(7).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
665 recipe->w1_chloride = query.value(6).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
666 recipe->w1_sulfate = query.value(5).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
667 recipe->w1_ph = query.value(9).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
668
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
669 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
670 ui->w1_mgEdit->setValue(recipe->w1_magnesium);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
671 ui->w1_hco3Edit->setValue(recipe->w1_total_alkalinity * 1.22);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
672 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
673 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
674 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
675 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
676 ui->w1_phEdit->setValue(recipe->w1_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
677 ui->w1_hardnessEdit->setValue(Utils::Hardness(product->w1_calcium, product->w1_magnesium));
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
678 ui->w1_raEdit->setValue(Utils::RA_ppm(product->w1_total_alkalinity, product->w1_calcium, product->w1_magnesium));
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
679
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
680 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
681 calcWater();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
682 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
683
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
684
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
685 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
686 {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
687 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
688 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
689
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
690 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
691
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
692 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
693 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
694 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
695 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
696 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
697 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
698 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
699 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
700 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
701 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
702 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
703 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
704 } else {
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
705 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
706 query.exec();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
707 query.first();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
708 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
709 query.next();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
710 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
711 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
712
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
713 recipe->w2_name = query.value(1).toString();
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
714 recipe->w2_calcium = query.value(3).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
715 recipe->w2_magnesium = query.value(8).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
716 recipe->w2_total_alkalinity = query.value(11).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
717 recipe->w2_sodium = query.value(7).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
718 recipe->w2_chloride = query.value(6).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
719 recipe->w2_sulfate = query.value(5).toDouble();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
720 recipe->w2_ph = query.value(9).toDouble();
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
721 hardness = Utils::Hardness(product->w2_calcium, product->w2_magnesium);
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
722 ra_ppm = Utils::RA_ppm(product->w2_total_alkalinity, product->w2_calcium, product->w2_magnesium);
149
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
723 }
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
724 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
725 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
726 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
727 ui->w2_mgEdit->setValue(recipe->w2_magnesium);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
728 ui->w2_hco3Edit->setValue(recipe->w2_total_alkalinity * 1.22);
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
729 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
730 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
731 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
732 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
733 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
734 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
735 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
736
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
737 is_changed();
d73719fa2ebb Implemented choose main and dillution waters. Implement change dillution water volume.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
738 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
739 }
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
740
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
741
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
742 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
743 {
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
744 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
745
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
746 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
747 /* 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
748 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
749 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
750 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
751 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
752 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
753 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
754 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
755 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
756 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
757 } 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
758 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
759 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
760 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
761 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
762 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
763 }
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
764 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
765 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
766 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
767 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
768 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
769 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
770 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
771 ui->wt_hardnessEdit->setValue(Utils::Hardness(query.value("calcium").toDouble(), 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
772 ui->wt_raEdit->setValue(Utils::RA_ppm(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
773 }
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
774 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
775 }
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
776
1189d072f346 Add select target water profile. The mash part of the water tab is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
777
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
778 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
779 {
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
780 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
781 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
782
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
783 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
784 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
785
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
786 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
787 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
788 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
789 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
790 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
791 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
792 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
793 }
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
794 }
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
795
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
796 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
797 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
798
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
799 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
800 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
801 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
802 } 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
803 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
804 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
805 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
806 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
807 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
808 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
809 }
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
810 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
811 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
812 }
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
813
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
814
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
815 void EditRecipe::wb_cacl2_changed(double val) { set_brewing_salt("CaCl2", 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
816 void EditRecipe::wb_caso4_changed(double val) { set_brewing_salt("CaSO4", 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
817 void EditRecipe::wb_mgso4_changed(double val) { set_brewing_salt("MgSO4", 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
818 void EditRecipe::wb_nacl_changed(double val) { set_brewing_salt("NaCl", 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
819 void EditRecipe::wb_mgcl2_changed(double val) { set_brewing_salt("MgCl2", 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
820 void EditRecipe::wb_nahco3_changed(double val) { set_brewing_salt("NaHCO3", 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
821 void EditRecipe::wb_caco3_changed(double val) { set_brewing_salt("CaCO3", 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
822
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
823

mercurial