src/EditProductTab11.cpp

changeset 443
3c195eb4e7a1
parent 442
d8c110d91b1f
child 447
9b5acb1f5776
equal deleted inserted replaced
442:d8c110d91b1f 443:3c195eb4e7a1
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19
20 double EditProduct::ResCO2(double T)
21 {
22 double F = T * 1.8 + 32;
23 return round((3.0378 - 0.050062 * F + 0.00026555 * F * F) * 1000000.0) / 1000000.0;
24 }
25
26
27 double EditProduct::CarbCO2toS(double CO2, double T, double SFactor)
28 {
29 //var sugar = SFactor * (CO2 - ResCO2(CO2, T)) / 0.286;
30 double sugar = round((SFactor * (CO2 - ResCO2(T)) * 4.014094) * 1000000.0) / 1000000.0;
31 if (sugar < 0)
32 sugar = 0;
33 return sugar; //Round(sugar, 3);
34 }
35 19
36 20
37 double EditProduct::GetPressure(double CO2, double T) 21 double EditProduct::GetPressure(double CO2, double T)
38 { 22 {
39 if (CO2 < 0) 23 if (CO2 < 0)
137 if (! found2) { 121 if (! found2) {
138 ui->bottle_sugarEdit->setCurrentIndex(0); // Make sure not selected 122 ui->bottle_sugarEdit->setCurrentIndex(0); // Make sure not selected
139 product->fermentables.removeAt(i); // Remove false fermentable 123 product->fermentables.removeAt(i); // Remove false fermentable
140 refreshFermentables(); 124 refreshFermentables();
141 } else { 125 } else {
142 product->bottle_priming_amount = CarbCO2toS(product->bottle_carbonation, TSec, SFactor); 126 product->bottle_priming_amount = Utils::CarbCO2toS(product->bottle_carbonation, TSec, SFactor);
143 // qDebug() << " priming CarbCO2toS(" << product->bottle_carbonation << TSec << SFactor << ") =" << product->bottle_priming_amount; 127 //qDebug() << " priming CarbCO2toS(" << product->bottle_carbonation << TSec << SFactor << ") =" << product->bottle_priming_amount;
144 ui->bottle_sug_amountShow->setValue(product->bottle_priming_amount); 128 ui->bottle_sug_amountShow->setValue(product->bottle_priming_amount);
145 double total = round(product->bottle_priming_amount * product->bottle_amount * 100.0) / 100000.0; 129 double total = round(product->bottle_priming_amount * product->bottle_amount * 100.0) / 100000.0;
146 if (total != product->fermentables.at(i).amount) { 130 if (total != product->fermentables.at(i).amount) {
147 qDebug() << " total" << total << product->fermentables.at(i).amount; 131 qDebug() << " total" << total << product->fermentables.at(i).amount;
148 qDebug() << " update priming sugar" << total; 132 qDebug() << " update priming sugar" << total;
155 double pabv = product->final_abv + (product->bottle_priming_amount * (1 / SFactor) * 0.47) / 7.907; 139 double pabv = product->final_abv + (product->bottle_priming_amount * (1 / SFactor) * 0.47) / 7.907;
156 double pvol = product->bottle_amount - (pabv * product->bottle_amount) / 100; 140 double pvol = product->bottle_amount - (pabv * product->bottle_amount) / 100;
157 talc = product->bottle_amount - pvol; 141 talc = product->bottle_amount - pvol;
158 tvol = pvol + product->bottle_priming_water; 142 tvol = pvol + product->bottle_priming_water;
159 product->bottle_abv = talc / (tvol + talc) * 100; 143 product->bottle_abv = talc / (tvol + talc) * 100;
160 product->bottle_bar = Utils::GetPressureBar(product->bottle_priming_amount, product->bottle_carbonation_temp); 144 product->bottle_bar = Utils::GetPressureBar(product->bottle_priming_amount * (1 / SFactor), product->bottle_carbonation_temp);
161 ui->bottle_abvShow->setValue(product->bottle_abv); 145 ui->bottle_abvShow->setValue(product->bottle_abv);
162 ui->bottle_barShow->setValue(product->bottle_bar); 146 ui->bottle_barShow->setValue(product->bottle_bar);
163 } 147 }
164 } 148 }
165 } 149 }
220 if (! found2) { 204 if (! found2) {
221 ui->keg_sugarEdit->setCurrentIndex(0); // Make sure not selected 205 ui->keg_sugarEdit->setCurrentIndex(0); // Make sure not selected
222 product->fermentables.removeAt(i); // Remove false fermentable 206 product->fermentables.removeAt(i); // Remove false fermentable
223 refreshFermentables(); 207 refreshFermentables();
224 } else { 208 } else {
225 product->keg_priming_amount = CarbCO2toS(product->keg_carbonation, TSec, SFactor); 209 product->keg_priming_amount = Utils::CarbCO2toS(product->keg_carbonation, TSec, SFactor);
226 ui->keg_sug_amountShow->setValue(product->keg_priming_amount); 210 ui->keg_sug_amountShow->setValue(product->keg_priming_amount);
227 double total = round(product->keg_priming_amount * product->keg_amount * 100.0) / 100000.0; 211 double total = round(product->keg_priming_amount * product->keg_amount * 100.0) / 100000.0;
228 qDebug() << " total" << total << product->fermentables.at(i).amount; 212 qDebug() << " total" << total << product->fermentables.at(i).amount;
229 if (total != product->fermentables.at(i).amount) { 213 if (total != product->fermentables.at(i).amount) {
230 qDebug() << " update priming sugar" << total; 214 qDebug() << " update priming sugar" << total;

mercurial