src/EditProductTab6.cpp

changeset 487
04c67c9f903c
parent 486
f1cc6a30623d
equal deleted inserted replaced
486:f1cc6a30623d 487:04c67c9f903c
596 double vpm = 1.00; 596 double vpm = 1.00;
597 double max = 100; 597 double max = 100;
598 598
599 for (int i = 0; i < product->yeasts.size(); i++) { 599 for (int i = 0; i < product->yeasts.size(); i++) {
600 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY) { 600 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY) {
601 qDebug() << "calcViability()" << i << product->yeasts.at(i).yp_uuid << product->yeasts.at(i).yp_package;
602 if (! product->yeasts.at(i).yp_uuid.isNull() && (product->yeasts.at(i).yp_uuid.length() == 36)) { 601 if (! product->yeasts.at(i).yp_uuid.isNull() && (product->yeasts.at(i).yp_uuid.length() == 36)) {
603 qDebug() << " valid package vpm:" << product->yeasts.at(i).yp_viability << product->yeasts.at(i).yp_max;
604 vpm = product->yeasts.at(i).yp_viability; 602 vpm = product->yeasts.at(i).yp_viability;
605 max = product->yeasts.at(i).yp_max; 603 max = product->yeasts.at(i).yp_max;
606 } else if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID) { // Fallback to hardcoded values. 604 } else if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID) { // Fallback to hardcoded values.
607 vpm = 0.80; 605 vpm = 0.80;
608 max = 97; 606 max = 97;
609 if (product->yeasts.at(i).laboratory == "White Labs") { // PurePitch 607 if (product->yeasts.at(i).laboratory == "White Labs") { // PurePitch
610 /*
611 * Purepitch 6th month viability point 80,8%.
612 * Purepitch Next Generation 6th month viability point 94,9%.
613 */
614 vpm = 0.9648; // Purepitch 608 vpm = 0.9648; // Purepitch
615 //vpm = 0.9914; // Purepitch Next Generation
616 max = 100; 609 max = 100;
617 } 610 }
618 } else if (product->yeasts.at(i).form == YEAST_FORMS_DRY) { 611 } else if (product->yeasts.at(i).form == YEAST_FORMS_DRY) {
619 vpm = 0.998; 612 vpm = 0.998;
620 max = 100; 613 max = 100;
648 if (base > max) 641 if (base > max)
649 base = max; 642 base = max;
650 product->starter_viability = round(base * 10) / 10; 643 product->starter_viability = round(base * 10) / 10;
651 ui->conditionShow->setValue(product->starter_viability); 644 ui->conditionShow->setValue(product->starter_viability);
652 #ifdef DEBUG_YEAST 645 #ifdef DEBUG_YEAST
653 qDebug() << "age" << timeDiff << "degrade" << degrade << "viability" << product->starter_viability; 646 qDebug() << " Age" << timeDiff << "degrade" << degrade << "viability" << product->starter_viability;
654 #endif 647 #endif
655 } 648 }
656 649
657 650
658 void EditProduct::yeast_prod_date_changed(QDate val) 651 void EditProduct::yeast_prod_date_changed(QDate val)
978 this->ypackageEdit->clear(); 971 this->ypackageEdit->clear();
979 this->ypackageEdit->addItem(""); // Start with empty value 972 this->ypackageEdit->addItem(""); // Start with empty value
980 query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package"); 973 query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package");
981 query.bindValue(":laboratory", laboratory); 974 query.bindValue(":laboratory", laboratory);
982 query.bindValue(":form", form); 975 query.bindValue(":form", form);
983 qDebug() << " search" << laboratory << form; 976 // qDebug() << " search" << laboratory << form;
984 query.exec(); 977 query.exec();
985 while (query.next()) { 978 while (query.next()) {
986 this->ypackageEdit->addItem(query.value("laboratory").toString()+" - "+query.value("package").toString()); 979 this->ypackageEdit->addItem(query.value("laboratory").toString()+" - "+query.value("package").toString());
987 qDebug() << " add package" << query.value("laboratory").toString() << query.value("package").toString(); 980 // qDebug() << " add package" << query.value("laboratory").toString() << query.value("package").toString();
988 } 981 }
989 } 982 }
990 983
991 984
992 void EditProduct::yeast_package_changed(int val) 985 void EditProduct::yeast_package_changed(int val)
1002 * Scan the packages for result number 'val' 995 * Scan the packages for result number 'val'
1003 */ 996 */
1004 query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package"); 997 query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package");
1005 query.bindValue(":laboratory", product->yeasts.at(product->yeasts_row).laboratory); 998 query.bindValue(":laboratory", product->yeasts.at(product->yeasts_row).laboratory);
1006 query.bindValue(":form", product->yeasts.at(product->yeasts_row).form); 999 query.bindValue(":form", product->yeasts.at(product->yeasts_row).form);
1007 qDebug() << " search" << product->yeasts.at(product->yeasts_row).laboratory << product->yeasts.at(product->yeasts_row).form; 1000 // qDebug() << " search" << product->yeasts.at(product->yeasts_row).laboratory << product->yeasts.at(product->yeasts_row).form;
1008 query.exec(); 1001 query.exec();
1009 while (query.next()) { 1002 while (query.next()) {
1010 index++; 1003 index++;
1011 if (index == val) { 1004 if (index == val) {
1012 qDebug() << " result" << index << query.value("package").toString(); 1005 // qDebug() << " result" << index << query.value("package").toString();
1013 product->yeasts[product->yeasts_row].yp_uuid = query.value("uuid").toString(); 1006 product->yeasts[product->yeasts_row].yp_uuid = query.value("uuid").toString();
1014 product->yeasts[product->yeasts_row].yp_package = query.value("package").toString(); 1007 product->yeasts[product->yeasts_row].yp_package = query.value("package").toString();
1015 product->yeasts[product->yeasts_row].yp_cells = query.value("cells").toDouble(); 1008 product->yeasts[product->yeasts_row].yp_cells = query.value("cells").toDouble();
1016 product->yeasts[product->yeasts_row].yp_viability = query.value("viability").toDouble(); 1009 product->yeasts[product->yeasts_row].yp_viability = query.value("viability").toDouble();
1017 product->yeasts[product->yeasts_row].yp_max = query.value("max").toInt(); 1010 product->yeasts[product->yeasts_row].yp_max = query.value("max").toInt();
1029 product->yeasts[product->yeasts_row].yp_cells = product->yeasts[product->yeasts_row].cells; 1022 product->yeasts[product->yeasts_row].yp_cells = product->yeasts[product->yeasts_row].cells;
1030 product->yeasts[product->yeasts_row].yp_viability = 0.99; 1023 product->yeasts[product->yeasts_row].yp_viability = 0.99;
1031 product->yeasts[product->yeasts_row].yp_max = 100; 1024 product->yeasts[product->yeasts_row].yp_max = 100;
1032 product->yeasts[product->yeasts_row].yp_size = 0.01; 1025 product->yeasts[product->yeasts_row].yp_size = 0.01;
1033 is_changed(); 1026 is_changed();
1034 qDebug() << " cleared old yp_xxx data"; 1027 // qDebug() << " cleared old yp_xxx data";
1035 } 1028 }
1036 qDebug() << " result not found"; 1029 // qDebug() << " result not found";
1037 } 1030 }
1038 1031
1039 1032
1040 void EditProduct::yeast_select_changed(int val) 1033 void EditProduct::yeast_select_changed(int val)
1041 { 1034 {

mercurial