92 result = 1; |
92 result = 1; |
93 } else if (use == 3) { // Aroma |
93 } else if (use == 3) { // Aroma |
94 result = 1.2; |
94 result = 1.2; |
95 } |
95 } |
96 return (result * amount * 1000) / vol; |
96 return (result * amount * 1000) / vol; |
97 } |
|
98 |
|
99 |
|
100 function calcPercentages() { |
|
101 |
|
102 console.log('calcPercentages()'); |
|
103 var tw, rowdata, percentage, i, rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
|
104 if (rowscount > 1) { |
|
105 tw = 0; |
|
106 for (i = 0; i < rowscount; i++) { |
|
107 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
|
108 if (rowdata.f_added < 4) |
|
109 tw += Round(rowdata.f_amount, 3); |
|
110 } |
|
111 tw = Round(tw, 3); |
|
112 |
|
113 for (i = 0; i < rowscount; i++) { |
|
114 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
|
115 if (rowdata.f_added < 4) { |
|
116 percentage = Round(rowdata.f_amount / tw * 100, 1); |
|
117 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', percentage); |
|
118 } else { |
|
119 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', 0); |
|
120 } |
|
121 } |
|
122 } else { |
|
123 $('#fermentableGrid').jqxGrid('setcellvalue', 0, 'f_percentage', 100); |
|
124 } |
|
125 } |
97 } |
126 |
98 |
127 |
99 |
128 function calcFermentables() { |
100 function calcFermentables() { |
129 console.log('calcFermentables()'); |
101 console.log('calcFermentables()'); |
336 mashtime += row.step_time + row.ramp_time; |
308 mashtime += row.step_time + row.ramp_time; |
337 row.step_wg_ratio = Round(infused / mashkg, 6); |
309 row.step_wg_ratio = Round(infused / mashkg, 6); |
338 $('#mashGrid').jqxGrid('updaterow', i, row); |
310 $('#mashGrid').jqxGrid('updaterow', i, row); |
339 } |
311 } |
340 } |
312 } |
341 } |
|
342 |
|
343 |
|
344 function calcIBUs() { |
|
345 var total_ibus = 0, |
|
346 rows = {}, |
|
347 i, row; |
|
348 |
|
349 hop_aroma = hop_flavour = 0; |
|
350 if (!(rows = $('#hopGrid').jqxGrid('getrows'))) { |
|
351 return; |
|
352 } |
|
353 for (i = 0; i < rows.length; i++) { |
|
354 row = rows[i]; |
|
355 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size), |
|
356 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method, 0, parseFloat(row.h_time), 0); |
|
357 hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), row.h_useat, parseFloat(row.h_amount)); |
|
358 hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), row.h_useat, parseFloat(row.h_amount)); |
|
359 } |
|
360 total_ibus = Round(total_ibus, 1); |
|
361 hop_flavour = Round(hop_flavour * 100 / 5, 1); |
|
362 hop_aroma = Round(hop_aroma * 100 / 6, 1); |
|
363 if (hop_flavour > 100) |
|
364 hop_flavour = 100; |
|
365 if (hop_aroma > 100) |
|
366 hop_aroma = 100; |
|
367 console.log('calcIBUs(): ' + total_ibus + ' flavour: ' + hop_flavour + ' aroma: ' + hop_aroma); |
|
368 dataRecord.est_ibu = total_ibus; |
|
369 $('#est_ibu').val(total_ibus); |
|
370 $('#est_ibu2').val(total_ibus); |
|
371 $('#hop_flavour').jqxProgressBar('val', hop_flavour); |
|
372 $('#hop_aroma').jqxProgressBar('val', hop_aroma); |
|
373 } |
|
374 |
|
375 |
|
376 function adjustYeasts(factor) { |
|
377 |
|
378 var i, row, amount, rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; |
|
379 if (rowscount == 0) |
|
380 return; |
|
381 |
|
382 for (i = 0; i < rowscount; i++) { |
|
383 row = $('#yeastGrid').jqxGrid('getrowdata', i); |
|
384 if (row.y_form == 1) { // Only adjust dry yeast |
|
385 amount = row.y_amount * factor; |
|
386 $('#yeastGrid').jqxGrid('setcellvalue', i, 'y_amount', amount); |
|
387 } |
|
388 } |
|
389 } |
|
390 |
|
391 |
|
392 function adjustWaters(factor) { |
|
393 |
|
394 var i, row, amount, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
|
395 if (rowscount == 0) |
|
396 return; |
|
397 mash_infuse = 0; |
|
398 for (i = 0; i < rowscount; i++) { |
|
399 row = $('#mashGrid').jqxGrid('getrowdata', i); |
|
400 if (row.step_type == 0) { // Infusion |
|
401 amount = Round(row.step_infuse_amount * factor, 1); |
|
402 $('#mashGrid').jqxGrid('setcellvalue', i, 'step_infuse_amount', amount); |
|
403 mash_infuse += amount; |
|
404 } |
|
405 } |
|
406 if (dataRecord.w2_amount == 0) { |
|
407 dataRecord.w1_amount = mash_infuse; |
|
408 $('#w1_amount').val(mash_infuse); |
|
409 } else { |
|
410 dataRecord.w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
411 dataRecord.w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
412 $('#w1_amount').val(dataRecord.w1_amount); |
|
413 $('#w2_amount').val(dataRecord.w2_amount); |
|
414 } |
|
415 $('#wg_amount').val(mash_infuse); |
|
416 } |
313 } |
417 |
314 |
418 |
315 |
419 function GetBUGU() { |
316 function GetBUGU() { |
420 var gu = (dataRecord.est_og - 1) * 1000; |
317 var gu = (dataRecord.est_og - 1) * 1000; |