src/EditRecipeTab2.cpp

changeset 148
ba25a566b100
parent 142
1caa15a0eefc
child 150
fd568cc1dd0e
equal deleted inserted replaced
147:af1386a6ece7 148:ba25a566b100
152 double vol = 0; // Volume sugars after boil 152 double vol = 0; // Volume sugars after boil
153 double addedS = 0; // Added sugars after boil 153 double addedS = 0; // Added sugars after boil
154 double addedmass = 0; // Added mass after boil 154 double addedmass = 0; // Added mass after boil
155 double mvol = 0; // Mash volume 155 double mvol = 0; // Mash volume
156 double lintner = 0; // Total recipe lintner 156 double lintner = 0; // Total recipe lintner
157 double mashkg = 0;
158 double sugarsf = 0; // fermentable sugars mash + boil 157 double sugarsf = 0; // fermentable sugars mash + boil
159 double sugarsm = 0; // fermentable sugars in mash 158 double sugarsm = 0; // fermentable sugars in mash
160 double sugardensity = 1.611; // kg/l in solution 159 double sugardensity = 1.611; // kg/l in solution
161 double mashtime = 0; // Total mash time 160 double mashtime = 0; // Total mash time
162 double mashtemp = 0; // Average mash temperature 161 double mashtemp = 0; // Average mash temperature
211 ui->est_abvEdit->setValue(0); 210 ui->est_abvEdit->setValue(0);
212 ui->est_abv2Edit->setValue(0); 211 ui->est_abv2Edit->setValue(0);
213 ui->est_abvShow->setValue(0); 212 ui->est_abvShow->setValue(0);
214 recipe->est_abv = 0; 213 recipe->est_abv = 0;
215 ui->calEdit->setValue(0); 214 ui->calEdit->setValue(0);
215 recipe->mashs_kg = 0;
216 return; 216 return;
217 } 217 }
218 qDebug() << " adjust to 100" << recipe->fermentables_use100; 218 qDebug() << " adjust to 100" << recipe->fermentables_use100;
219 219
220 recipe->mashs_kg = 0;
220 for (i = 0; i < recipe->fermentables.size(); i++) { 221 for (i = 0; i < recipe->fermentables.size(); i++) {
221 if (recipe->fermentables.at(i).f_type == 1 && recipe->fermentables.at(i).f_added < 4) // Sugars 222 if (recipe->fermentables.at(i).f_type == 1 && recipe->fermentables.at(i).f_added < 4) // Sugars
222 psugar += recipe->fermentables.at(i).f_percentage; 223 psugar += recipe->fermentables.at(i).f_percentage;
223 if (recipe->fermentables.at(i).f_graintype == 2 && recipe->fermentables.at(i).f_added < 4) // Crystal/Cara 224 if (recipe->fermentables.at(i).f_graintype == 2 && recipe->fermentables.at(i).f_added < 4) // Crystal/Cara
224 pcara += recipe->fermentables.at(i).f_percentage; 225 pcara += recipe->fermentables.at(i).f_percentage;
228 mvol += recipe->fermentables.at(i).f_amount * recipe->fermentables.at(i).f_moisture / 100; 229 mvol += recipe->fermentables.at(i).f_amount * recipe->fermentables.at(i).f_moisture / 100;
229 s += d; 230 s += d;
230 } 231 }
231 d = ui->efficiencyEdit->value() / 100 * d; 232 d = ui->efficiencyEdit->value() / 100 * d;
232 sugarsm += d; 233 sugarsm += d;
233 mashkg += recipe->fermentables.at(i).f_amount; 234 recipe->mashs_kg += recipe->fermentables.at(i).f_amount;
234 } 235 }
235 if (recipe->fermentables.at(i).f_added == 0 || recipe->fermentables.at(i).f_added == 1) // Mash or boil 236 if (recipe->fermentables.at(i).f_added == 0 || recipe->fermentables.at(i).f_added == 1) // Mash or boil
236 sugarsf += d; 237 sugarsf += d;
237 if (recipe->fermentables.at(i).f_added == 2 || recipe->fermentables.at(i).f_added == 3) { // Fermentation or lagering 238 if (recipe->fermentables.at(i).f_added == 2 || recipe->fermentables.at(i).f_added == 3) { // Fermentation or lagering
238 x = (recipe->fermentables.at(i).f_yield / 100) * (1 - recipe->fermentables.at(i).f_moisture / 100); 239 x = (recipe->fermentables.at(i).f_yield / 100) * (1 - recipe->fermentables.at(i).f_moisture / 100);
289 290
290 /* 291 /*
291 * We don't have a equipment profile in recipes, 292 * We don't have a equipment profile in recipes,
292 * so we assume a certain guessed mashtun size. 293 * so we assume a certain guessed mashtun size.
293 */ 294 */
294 ui->perc_mashShow->setValue(round(mashkg / (ui->boil_sizeEdit->value() / 3) * 100)); 295 ui->perc_mashShow->setValue(round(recipe->mashs_kg / (ui->boil_sizeEdit->value() / 3) * 100));
295 ui->perc_sugarsShow->setValue(round(psugar)); 296 ui->perc_sugarsShow->setValue(round(psugar));
296 ui->perc_caraShow->setValue(round(pcara)); 297 ui->perc_caraShow->setValue(round(pcara));
297 qDebug() << " lintner" << lintner << " mashkg" << mashkg << "final" << round(lintner / mashkg); 298 if (recipe->mashs_kg > 0) {
298 ui->lintnerShow->setValue(round(lintner / mashkg)); 299 qDebug() << " lintner" << lintner << " mashkg" << recipe->mashs_kg << "final" << round(lintner / recipe->mashs_kg);
300 ui->lintnerShow->setValue(round(lintner / recipe->mashs_kg));
301 } else {
302 qDebug() << " lintner N/A";
303 ui->lintnerShow->setValue(0);
304 }
299 305
300 /* 306 /*
301 * Calculate the apparant attenuation. 307 * Calculate the apparant attenuation.
302 */ 308 */
303 double svg = 0; 309 double svg = 0;
314 if (svg == 0) 320 if (svg == 0)
315 svg = 77.0; 321 svg = 77.0;
316 ui->est_svgEdit->setValue(svg); 322 ui->est_svgEdit->setValue(svg);
317 323
318 double fg; 324 double fg;
319 if (mashkg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0) 325 if (recipe->mashs_kg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0)
320 fg = Utils::estimate_fg(psugar, pcara, mashinfuse / mashkg, mashtime, mashtemp, svg, og); 326 fg = Utils::estimate_fg(psugar, pcara, mashinfuse / recipe->mashs_kg, mashtime, mashtemp, svg, og);
321 else 327 else
322 fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, og); 328 fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, og);
323 qDebug() << " FG" << ui->est_fgEdit->value() << fg; 329 qDebug() << " FG" << ui->est_fgEdit->value() << fg;
324 recipe->est_fg = fg; 330 recipe->est_fg = fg;
325 ui->est_fgEdit->setValue(fg); 331 ui->est_fgEdit->setValue(fg);

mercurial