src/EditProductTab6.cpp

changeset 200
bbab7d37d12f
parent 199
59b0bdbb2f9f
child 201
b8232133a12d
equal deleted inserted replaced
199:59b0bdbb2f9f 200:bbab7d37d12f
179 volume += product->brew_fermenter_extrawater; 179 volume += product->brew_fermenter_extrawater;
180 } else { 180 } else {
181 volume = product->batch_size - product->eq_trub_chiller_loss; 181 volume = product->batch_size - product->eq_trub_chiller_loss;
182 } 182 }
183 183
184 // Also in calcFermentables()
185 //$('#yeast_cells').val(initcells);
186
187 if (product->yeasts.size() == 0) 184 if (product->yeasts.size() == 0)
188 return; // No yeast in product. 185 return; // No yeast in product.
189 186
190 calcViability(); 187 calcViability();
191 188
204 double og = product->yeasts.at(i).y_sg_lo; 201 double og = product->yeasts.at(i).y_sg_lo;
205 double f1 = product->yeasts.at(i).y_gr_hl_lo / 100.0; 202 double f1 = product->yeasts.at(i).y_gr_hl_lo / 100.0;
206 double f2 = round(f1 / 5 * 1000000.0) / 1000000.0; 203 double f2 = round(f1 / 5 * 1000000.0) / 1000000.0;
207 double multiplier = (sg <= og) ? f1 : (f1 + f2 * (sg - og) / 0.008); 204 double multiplier = (sg <= og) ? f1 : (f1 + f2 * (sg - og) / 0.008);
208 qDebug() << " sg:" << sg << "og:" << og << "f1:" << f1 << "f2:" << f2 << "multiplier:" << multiplier; 205 qDebug() << " sg:" << sg << "og:" << og << "f1:" << f1 << "f2:" << f2 << "multiplier:" << multiplier;
209 double yeast_grams = round(volume * multiplier * 100.0) / 100.0; // * (100 / dataRecord.starter_viability), 2); 206 double yeast_grams = round(volume * multiplier * 100.0) / product->starter_viability;
210 double yeast_gr_hl = round((yeast_grams / (volume * 0.01)) * 100.0) / 100.0; 207 double yeast_gr_hl = round((yeast_grams / (volume * 0.01)) * 100.0) / 100.0;
211 ui->need_grEdit->setValue(yeast_grams); 208 double pitch_gr_hl = round(((product->yeasts.at(i).y_amount * 1000.0) / (volume * 0.01)) * 100.0) / 100.0;
212 ui->pitch_grEdit->setValue(yeast_gr_hl); 209 ui->dry_needShow->setValue(yeast_grams);
213 qDebug() << " need" << yeast_grams << "grams, gr/hl:" << yeast_gr_hl; 210 ui->dry_pitchrateShow->setValue(yeast_gr_hl);
211 ui->pitch_grShow->setValue(pitch_gr_hl);
212 ui->pitch_grShow->setStyleSheet((pitch_gr_hl < yeast_gr_hl) ? "background-color: red":"");
213
214 qDebug() << " need" << yeast_grams << "grams, gr/hl:" << yeast_gr_hl << "pitch:" << pitch_gr_hl;
214 return; 215 return;
215 } else { 216 } else {
216 /* 217 /*
217 * Liquid, slant, culture etc. 218 * Liquid, slant, culture etc.
218 * pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ 219 * pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/
504 { 505 {
505 double vpm = 1.00; 506 double vpm = 1.00;
506 double max = 100; 507 double max = 100;
507 508
508 for (int i = 0; i < product->yeasts.size(); i++) { 509 for (int i = 0; i < product->yeasts.size(); i++) {
509 if (product->yeasts.at(i).y_use == 0) { 510 if (product->yeasts.at(i).y_use == YEAST_USE_PRIMARY) {
510 if (product->yeasts.at(i).y_form == 0) { // Liquid 511 if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) {
511 vpm = 0.80; 512 vpm = 0.80;
512 max = 97; 513 max = 97;
513 if (product->yeasts.at(i).y_laboratory == "White Labs") { // PurePitch 514 if (product->yeasts.at(i).y_laboratory == "White Labs") { // PurePitch
514 vpm = 0.95; 515 vpm = 0.95;
515 max = 100; 516 max = 100;
516 } 517 }
517 } else if (product->yeasts.at(i).y_form == 1) { // dry 518 } else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRY) {
518 vpm = 0.998; 519 vpm = 0.998;
519 max = 100; 520 max = 100;
520 } else if (product->yeasts.at(i).y_form == 6) { // dried kveik 521 } else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRIED) { // dried kveik
521 vpm = 0.92; 522 vpm = 0.92;
522 max = 100; 523 max = 100;
523 } else { // Slant, Culture, Frozen, Bottle 524 } else { // Slant, Culture, Frozen, Bottle
524 vpm = 0.99; 525 vpm = 0.99;
525 max = 97; 526 max = 97;
674 675
675 newy.y_name = "Select one"; 676 newy.y_name = "Select one";
676 newy.y_laboratory = ""; 677 newy.y_laboratory = "";
677 newy.y_product_id = ""; 678 newy.y_product_id = "";
678 newy.y_amount = 0; 679 newy.y_amount = 0;
679 newy.y_type = 0; 680 newy.y_type = YEAST_TYPES_ALE;
680 newy.y_form = 0; 681 newy.y_form = YEAST_FORMS_LIQUID;
681 newy.y_min_temperature = 0; 682 newy.y_min_temperature = 0;
682 newy.y_max_temperature = 0; 683 newy.y_max_temperature = 0;
683 newy.y_flocculation = 0; 684 newy.y_flocculation = 0;
684 newy.y_attenuation = 0; 685 newy.y_attenuation = 0;
685 newy.y_cells = 0; 686 newy.y_cells = 0;
686 newy.y_tolerance = 0; 687 newy.y_tolerance = 0;
687 newy.y_inventory = 0; 688 newy.y_inventory = 0;
688 newy.y_use = 0; 689 newy.y_use = YEAST_USE_PRIMARY;
689 newy.y_sta1 = false; 690 newy.y_sta1 = false;
690 newy.y_bacteria = false; 691 newy.y_bacteria = false;
691 newy.y_harvest_top = false; 692 newy.y_harvest_top = false;
692 newy.y_harvest_time = 0; 693 newy.y_harvest_time = 0;
693 newy.y_pitch_temperature = 0; 694 newy.y_pitch_temperature = 0;
728 { 729 {
729 QTableWidgetItem *item; 730 QTableWidgetItem *item;
730 731
731 qDebug() << "yeast_amount_changed()" << product->yeasts_row << val; 732 qDebug() << "yeast_amount_changed()" << product->yeasts_row << val;
732 733
733 if (product->yeasts.at(product->yeasts_row).y_form == 0) { 734 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) {
734 product->yeasts[product->yeasts_row].y_amount = val; 735 product->yeasts[product->yeasts_row].y_amount = val;
735 item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '0')); 736 item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '0'));
736 } else if (product->yeasts.at(product->yeasts_row).y_form == 1) { 737 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) ||
738 (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) {
737 product->yeasts[product->yeasts_row].y_amount = val / 1000.0; 739 product->yeasts[product->yeasts_row].y_amount = val / 1000.0;
738 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0')); 740 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0'));
739 } else { 741 } else {
740 product->yeasts[product->yeasts_row].y_amount = val / 1000.0; 742 product->yeasts[product->yeasts_row].y_amount = val / 1000.0;
741 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0')); 743 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0'));
808 * Update the visible fields 810 * Update the visible fields
809 */ 811 */
810 ynameEdit->setText(product->yeasts.at(product->yeasts_row).y_name); 812 ynameEdit->setText(product->yeasts.at(product->yeasts_row).y_name);
811 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).y_laboratory); 813 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).y_laboratory);
812 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).y_product_id); 814 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).y_product_id);
813 if (product->yeasts.at(product->yeasts_row).y_form == 0) { 815 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) {
814 yamountEdit->setDecimals(0); 816 yamountEdit->setDecimals(0);
815 yamountEdit->setSingleStep(1.0); 817 yamountEdit->setSingleStep(1.0);
816 yamountLabel->setText(tr("Total packs:")); 818 yamountLabel->setText(tr("Total packs:"));
817 } else if (product->yeasts.at(product->yeasts_row).y_form == 1) { 819 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) {
818 yamountEdit->setDecimals(1); 820 yamountEdit->setDecimals(1);
819 yamountEdit->setSingleStep(0.5); 821 yamountEdit->setSingleStep(0.5);
820 yamountLabel->setText(tr("Amount in gr:")); 822 yamountLabel->setText(tr("Amount in gr:"));
821 } else { 823 } else {
822 yamountEdit->setDecimals(1); 824 yamountEdit->setDecimals(1);
937 instockLabel->setText(tr("In stock:")); 939 instockLabel->setText(tr("In stock:"));
938 instockLabel->setGeometry(QRect(525,100, 121, 20)); 940 instockLabel->setGeometry(QRect(525,100, 121, 20));
939 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 941 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
940 yamountLabel = new QLabel(dialog); 942 yamountLabel = new QLabel(dialog);
941 yamountLabel->setObjectName(QString::fromUtf8("amountLabel")); 943 yamountLabel->setObjectName(QString::fromUtf8("amountLabel"));
942 if (product->yeasts.at(product->yeasts_row).y_form == 0) 944 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID)
943 yamountLabel->setText(tr("Total packs:")); 945 yamountLabel->setText(tr("Total packs:"));
944 else if (product->yeasts.at(product->yeasts_row).y_form == 1) 946 else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED))
945 yamountLabel->setText(tr("Amount in gr:")); 947 yamountLabel->setText(tr("Amount in gr:"));
946 else 948 else
947 yamountLabel->setText(tr("Amount in ml:")); 949 yamountLabel->setText(tr("Amount in ml:"));
948 yamountLabel->setGeometry(QRect(10, 130, 141, 20)); 950 yamountLabel->setGeometry(QRect(10, 130, 141, 20));
949 yamountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 951 yamountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
978 yamountEdit = new QDoubleSpinBox(dialog); 980 yamountEdit = new QDoubleSpinBox(dialog);
979 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit")); 981 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit"));
980 yamountEdit->setGeometry(QRect(160, 130, 121, 24)); 982 yamountEdit->setGeometry(QRect(160, 130, 121, 24));
981 yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 983 yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
982 yamountEdit->setAccelerated(true); 984 yamountEdit->setAccelerated(true);
983 if (product->yeasts.at(product->yeasts_row).y_form == 0) { 985 if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) {
984 yamountEdit->setDecimals(0); 986 yamountEdit->setDecimals(0);
985 yamountEdit->setSingleStep(1.0); 987 yamountEdit->setSingleStep(1.0);
986 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount); 988 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount);
987 } else if (product->yeasts.at(product->yeasts_row).y_form == 1) { 989 } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) {
988 yamountEdit->setDecimals(1); 990 yamountEdit->setDecimals(1);
989 yamountEdit->setSingleStep(0.5); 991 yamountEdit->setSingleStep(0.5);
990 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount * 1000.0); 992 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount * 1000.0);
991 } else { 993 } else {
992 yamountEdit->setDecimals(1); 994 yamountEdit->setDecimals(1);

mercurial