src/EditProductTab8.cpp

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

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

Init est_carb field for new products.

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

mercurial