src/EditProductTab3.cpp

changeset 454
2dfead81c72f
parent 449
00757c056ca6
child 458
ac216a75ca9b
equal deleted inserted replaced
453:fc0c10d79539 454:2dfead81c72f
66 QString w; 66 QString w;
67 QWidget* pWidget; 67 QWidget* pWidget;
68 QHBoxLayout* pLayout; 68 QHBoxLayout* pLayout;
69 QTableWidgetItem *item; 69 QTableWidgetItem *item;
70 70
71 qDebug() << "refreshFermentables" << product->fermentables.size();
72 std::sort(product->fermentables.begin(), product->fermentables.end(), ferment_sort_test); 71 std::sort(product->fermentables.begin(), product->fermentables.end(), ferment_sort_test);
73 72
74 const QStringList labels({tr("Supplier"), tr("Fermentable"), tr("EBC"), tr("Type"), tr("Graintype"), tr("When"), tr("Yield"), 73 const QStringList labels({tr("Supplier"), tr("Fermentable"), tr("EBC"), tr("Type"), tr("Graintype"), tr("When"), tr("Yield"),
75 tr("Amount"), tr("Stock"), tr("Procent"), tr("100%"), tr("Delete"), tr("Edit") }); 74 tr("Amount"), tr("Stock"), tr("Procent"), tr("100%"), tr("Delete"), tr("Edit") });
76 ui->fermentablesTable->setColumnCount(13); 75 ui->fermentablesTable->setColumnCount(13);
343 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_KEGS))) && 342 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_KEGS))) &&
344 product->fermentables.at(i).inventory < product->fermentables.at(i).amount) { 343 product->fermentables.at(i).inventory < product->fermentables.at(i).amount) {
345 product->fermentables_ok = false; 344 product->fermentables_ok = false;
346 } 345 }
347 } 346 }
348 // qDebug() << " adjust to 100" << product->fermentables_use100; 347 #ifdef DEBUG_FERMENTABLES
349 // qDebug() << " supplies" << product->fermentables_ok; 348 qDebug() << " adjust to 100" << product->fermentables_use100;
350 // qDebug() << " colort" << colort << "colorh" << colorh << "colorn" << colorn; 349 qDebug() << " supplies" << product->fermentables_ok;
351 // qDebug() << " psugar" << psugar << "pcara" << pcara << "mvol" << mvol; 350 qDebug() << " colort" << colort << "colorh" << colorh << "colorn" << colorn;
352 // qDebug() << " sugarsf" << sugarsf << "sugarsm" << sugarsm; 351 qDebug() << " psugar" << psugar << "pcara" << pcara << "mvol" << mvol;
352 qDebug() << " sugarsf" << sugarsf << "sugarsm" << sugarsm;
353 #endif
353 354
354 double v = s / sugardensity + mvol; 355 double v = s / sugardensity + mvol;
355 s = 1000 * s / (v * 10); //deg. Plato 356 s = 1000 * s / (v * 10); //deg. Plato
356 product->est_mash_sg = Utils::plato_to_sg(s); 357 product->est_mash_sg = Utils::plato_to_sg(s);
357 ui->brew_mashsgShow->setValue(product->est_mash_sg); 358 ui->brew_mashsgShow->setValue(product->est_mash_sg);
358 359
359 /* Estimate total recipe OG */ 360 /* Estimate total recipe OG */
360 product->est_og = Utils::estimate_sg(sugarsf + addedS, product->batch_size); 361 product->est_og = Utils::estimate_sg(sugarsf + addedS, product->batch_size);
361 // qDebug() << " OG" << ui->est_ogEdit->value() << product->est_og; 362 #ifdef DEBUG_FERMENTABLES
363 qDebug() << " OG" << ui->est_ogEdit->value() << product->est_og;
364 #endif
362 if (product->stage > PROD_STAGE_BREW) { 365 if (product->stage > PROD_STAGE_BREW) {
363 ui->est_ogLabel->setText(tr("Final OG:")); 366 ui->est_ogLabel->setText(tr("Final OG:"));
364 ui->est_ogEdit->setValue(product->og); 367 ui->est_ogEdit->setValue(product->og);
365 ui->est_ogShow->setValue(product->og); 368 ui->est_ogShow->setValue(product->og);
366 } else { 369 } else {
375 ui->brew_aboilsgShow->setValue(product->est_og3); 378 ui->brew_aboilsgShow->setValue(product->est_og3);
376 379
377 /* Estimate SG in kettle before boil */ 380 /* Estimate SG in kettle before boil */
378 product->preboil_sg = Utils::estimate_sg(sugarsm, product->boil_size); 381 product->preboil_sg = Utils::estimate_sg(sugarsm, product->boil_size);
379 ui->brew_preboilsgShow->setValue(product->preboil_sg); 382 ui->brew_preboilsgShow->setValue(product->preboil_sg);
380 // qDebug() << " preboil SG" << product->preboil_sg; 383 #ifdef DEBUG_FERMENTABLES
384 qDebug() << " preboil SG" << product->preboil_sg;
385 #endif
381 386
382 /* 387 /*
383 * Recalculate volumes 388 * Recalculate volumes
384 */ 389 */
385 double aboil_volume = product->batch_size; 390 double aboil_volume = product->batch_size;
451 } else if (product->color_method == 3) { // Hans Halberstadt 456 } else if (product->color_method == 3) { // Hans Halberstadt
452 color = round((4.46 * bv * sr) / product->batch_size * colorh); 457 color = round((4.46 * bv * sr) / product->batch_size * colorh);
453 } else { 458 } else {
454 cw = colort / product->batch_size * 8.34436; 459 cw = colort / product->batch_size * 8.34436;
455 color = Utils::kw_to_ebc(product->color_method, cw); 460 color = Utils::kw_to_ebc(product->color_method, cw);
456 //qDebug() << " oud EBC" << color << "new EBC" << Utils::kw_to_newebc(product->color_method, cw) << "SRM" << Utils::kw_to_srm(product->color_method, cw); 461 #ifdef DEBUG_FERMENTABLES
457 } 462 qDebug() << " oud EBC" << color << "new EBC" << Utils::kw_to_newebc(product->color_method, cw) << "SRM" << Utils::kw_to_srm(product->color_method, cw);
458 //qDebug() << " color" << ui->est_colorEdit->value() << color << product->est_color; 463 #endif
464 }
465 #ifdef DEBUG_FERMENTABLES
466 qDebug() << " color" << ui->est_colorEdit->value() << color << product->est_color;
467 #endif
459 product->est_color = color; 468 product->est_color = color;
460 ui->est_color2Edit->setValue(color); 469 ui->est_color2Edit->setValue(color);
461 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color)); 470 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color));
462 if (product->stage > PROD_STAGE_BREW) { 471 if (product->stage > PROD_STAGE_BREW) {
463 ui->est_colorLabel->setText(tr("Final EBC:")); 472 ui->est_colorLabel->setText(tr("Final EBC:"));
477 ui->perc_mashShow->setValue(round(product->mashs_kg / product->eq_mash_max * 100)); 486 ui->perc_mashShow->setValue(round(product->mashs_kg / product->eq_mash_max * 100));
478 ui->mash_kgEdit->setValue(product->mashs_kg); 487 ui->mash_kgEdit->setValue(product->mashs_kg);
479 ui->perc_sugarsShow->setValue(round(psugar)); 488 ui->perc_sugarsShow->setValue(round(psugar));
480 ui->perc_caraShow->setValue(round(pcara)); 489 ui->perc_caraShow->setValue(round(pcara));
481 if (product->mashs_kg > 0) { 490 if (product->mashs_kg > 0) {
482 // qDebug() << " lintner" << lintner << " mashkg" << product->mashs_kg << "final" << round(lintner / product->mashs_kg); 491 #ifdef DEBUG_FERMENTABLES
492 qDebug() << " lintner" << lintner << " mashkg" << product->mashs_kg << "final" << round(lintner / product->mashs_kg);
493 #endif
483 ui->lintnerShow->setValue(round(lintner / product->mashs_kg)); 494 ui->lintnerShow->setValue(round(lintner / product->mashs_kg));
484 } else { 495 } else {
485 // qDebug() << " lintner N/A"; 496 #ifdef DEBUG_FERMENTABLES
497 qDebug() << " lintner N/A";
498 #endif
486 ui->lintnerShow->setValue(0); 499 ui->lintnerShow->setValue(0);
487 } 500 }
488 501
489 /* 502 /*
490 * Calculate the apparant attenuation. 503 * Calculate the apparant attenuation.
512 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->yeasts.at(i).use == 3))) && // Bottle 525 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->yeasts.at(i).use == 3))) && // Bottle
513 (product->yeasts.at(i).inventory < product->yeasts.at(i).amount)) { 526 (product->yeasts.at(i).inventory < product->yeasts.at(i).amount)) {
514 product->yeasts_ok = false; 527 product->yeasts_ok = false;
515 } 528 }
516 } 529 }
517 // qDebug() << " est SVG" << svg; 530 #ifdef DEBUG_FERMENTABLES
531 qDebug() << " est SVG" << svg;
532 #endif
518 } 533 }
519 if (svg == 0) 534 if (svg == 0)
520 svg = 77.0; 535 svg = 77.0;
521 ui->est_svgEdit->setValue(svg); 536 ui->est_svgEdit->setValue(svg);
522 537
524 product->est_fg = Utils::estimate_fg(psugar, pcara, mashinfuse / product->mashs_kg, mashtime, mashtemp, svg, product->est_og, sta1); 539 product->est_fg = Utils::estimate_fg(psugar, pcara, mashinfuse / product->mashs_kg, mashtime, mashtemp, svg, product->est_og, sta1);
525 else 540 else
526 product->est_fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, product->est_og, sta1); 541 product->est_fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, product->est_og, sta1);
527 qDebug() << " est FG" << ui->est_fgEdit->value() << product->est_fg; 542 qDebug() << " est FG" << ui->est_fgEdit->value() << product->est_fg;
528 product->est_abv = Utils::abvol(product->est_og, product->est_fg); 543 product->est_abv = Utils::abvol(product->est_og, product->est_fg);
529 // qDebug() << " est ABV" << ui->est_abvEdit->value() << product->est_abv; 544 #ifdef DEBUG_FERMENTABLES
545 qDebug() << " est ABV" << ui->est_abvEdit->value() << product->est_abv;
546 #endif
530 547
531 if (product->stage > PROD_STAGE_TERTIARY) { 548 if (product->stage > PROD_STAGE_TERTIARY) {
532 ui->est_fgLabel->setText(tr("Final FG:")); 549 ui->est_fgLabel->setText(tr("Final FG:"));
533 ui->est_fgEdit->setValue(product->fg); 550 ui->est_fgEdit->setValue(product->fg);
534 ui->est_fgShow->setValue(product->fg); 551 ui->est_fgShow->setValue(product->fg);
789 row100 = i; 806 row100 = i;
790 } 807 }
791 double oldperc = product->fermentables.at(product->fermentables_row).percentage; 808 double oldperc = product->fermentables.at(product->fermentables_row).percentage;
792 double diffp = val - oldperc; 809 double diffp = val - oldperc;
793 double diffw = (diffp / 100) * total; 810 double diffw = (diffp / 100) * total;
811 #ifdef DEBUG_FERMENTABLES
794 qDebug() << "row100" << row100 << "total" << total << "diff kg" << diffw << "diff %" << diffp; 812 qDebug() << "row100" << row100 << "total" << total << "diff kg" << diffw << "diff %" << diffp;
813 #endif
795 814
796 product->fermentables[product->fermentables_row].percentage += diffp; 815 product->fermentables[product->fermentables_row].percentage += diffp;
797 product->fermentables[product->fermentables_row].amount += diffw; 816 product->fermentables[product->fermentables_row].amount += diffw;
798 product->fermentables[row100].percentage -= diffp; 817 product->fermentables[row100].percentage -= diffp;
799 product->fermentables[row100].amount -= diffw; 818 product->fermentables[row100].amount -= diffw;

mercurial