763 |
763 |
764 // Inline fermentables editor |
764 // Inline fermentables editor |
765 var editFermentable = function(data) { |
765 var editFermentable = function(data) { |
766 var fermentableSource = { |
766 var fermentableSource = { |
767 localdata: data.fermentables, |
767 localdata: data.fermentables, |
768 datatype: 'local', |
|
769 cache: false, |
|
770 async: true, |
|
771 datafields: [ |
768 datafields: [ |
772 { name: 'f_name', type: 'string' }, |
769 { name: 'f_name', type: 'string' }, |
773 { name: 'f_origin', type: 'string' }, |
770 { name: 'f_origin', type: 'string' }, |
774 { name: 'f_supplier', type: 'string' }, |
771 { name: 'f_supplier', type: 'string' }, |
775 { name: 'f_amount', type: 'float' }, |
772 { name: 'f_amount', type: 'float' }, |
942 { text: 'Maxinbatch', datafield: 'f_max_in_batch', hidden: true }, |
939 { text: 'Maxinbatch', datafield: 'f_max_in_batch', hidden: true }, |
943 { text: 'Opbrengst', datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
940 { text: 'Opbrengst', datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
944 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, |
941 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, |
945 { text: 'Voorraad Kg', datafield: 'f_inventory', width: 120, align: 'right', |
942 { text: 'Voorraad Kg', datafield: 'f_inventory', width: 120, align: 'right', |
946 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
943 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
947 var color = '#ffffff'; |
944 var color = (value < rowdata.f_amount) ? '#ff4040':'#ffffff'; |
948 if (block_fermentable(dataRecord.inventory_reduced, rowdata.f_added) == false) { |
945 if (block_fermentable(dataRecord.inventory_reduced, rowdata.f_added) == false) { |
949 if (value < rowdata.f_amount) |
|
950 color = '#ff4040'; |
|
951 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + fermentableAdapter.formatNumber(value, 'f3') + '</span>'; |
946 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + fermentableAdapter.formatNumber(value, 'f3') + '</span>'; |
952 } else { |
947 } else { |
953 return '<span></span>'; |
948 return '<span></span>'; |
954 } |
949 } |
955 } |
950 } |
956 }, |
951 }, |
957 { text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right', |
952 { text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right', |
958 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
953 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
959 if (rowdata.f_added >= 4) |
954 if (rowdata.f_added >= 4) |
960 return '<span></span>'; |
955 return '<span></span>'; |
961 var color = '#ffffff'; |
956 var color = (value > rowdata.f_max_in_batch) ? '#ff4040':'#ffffff'; |
962 if (value > rowdata.f_max_in_batch) |
|
963 color = '#ff4040'; |
|
964 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + fermentableAdapter.formatNumber(value, 'p1') + '</span>'; |
957 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + fermentableAdapter.formatNumber(value, 'p1') + '</span>'; |
965 } |
958 } |
966 }, |
959 }, |
967 { text: '100%', datafield: 'f_adjust_to_total_100', width: 70, align: 'center', cellsalign: 'center', |
960 { text: '100%', datafield: 'f_adjust_to_total_100', width: 70, align: 'center', cellsalign: 'center', |
968 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
961 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1004 |
997 |
1005 // Inline hops editor |
998 // Inline hops editor |
1006 var editHop = function(data) { |
999 var editHop = function(data) { |
1007 var hopSource = { |
1000 var hopSource = { |
1008 localdata: data.hops, |
1001 localdata: data.hops, |
1009 datatype: 'local', |
|
1010 cache: false, |
|
1011 async: true, |
|
1012 datafields: [ |
1002 datafields: [ |
1013 { name: 'h_name', type: 'string' }, |
1003 { name: 'h_name', type: 'string' }, |
1014 { name: 'h_origin', type: 'string' }, |
1004 { name: 'h_origin', type: 'string' }, |
1015 { name: 'h_amount', type: 'float' }, |
1005 { name: 'h_amount', type: 'float' }, |
1016 { name: 'h_cost', type: 'float' }, |
1006 { name: 'h_cost', type: 'float' }, |
1168 } |
1158 } |
1169 }, |
1159 }, |
1170 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', |
1160 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', |
1171 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1161 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1172 if (block_hop(dataRecord.inventory_reduced, rowdata.h_useat) == false) { |
1162 if (block_hop(dataRecord.inventory_reduced, rowdata.h_useat) == false) { |
1173 var amount, color = '#ffffff'; |
1163 var amount = dataAdapter.formatNumber(value, 'f1') + ' kg', |
1174 if (value < rowdata.h_amount) |
1164 color = (value < rowdata.h_amount) ? '#ff4040':'#ffffff'; |
1175 color = '#ff4040'; |
|
1176 amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; |
|
1177 if (value < 1) |
1165 if (value < 1) |
1178 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; |
1166 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; |
1179 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1167 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1180 } else { |
1168 } else { |
1181 return '<span></span>'; |
1169 return '<span></span>'; |
1217 |
1205 |
1218 // Inline miscs editor |
1206 // Inline miscs editor |
1219 var editMisc = function(data) { |
1207 var editMisc = function(data) { |
1220 var miscSource = { |
1208 var miscSource = { |
1221 localdata: data.miscs, |
1209 localdata: data.miscs, |
1222 datatype: 'local', |
|
1223 cache: false, |
|
1224 async: false, |
|
1225 datafields: [ |
1210 datafields: [ |
1226 { name: 'm_name', type: 'string' }, |
1211 { name: 'm_name', type: 'string' }, |
1227 { name: 'm_amount', type: 'float' }, |
1212 { name: 'm_amount', type: 'float' }, |
1228 { name: 'm_cost', type: 'float' }, |
1213 { name: 'm_cost', type: 'float' }, |
1229 { name: 'm_type', type: 'int' }, |
1214 { name: 'm_type', type: 'int' }, |
1400 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr + '</span>'; |
1385 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr + '</span>'; |
1401 } |
1386 } |
1402 }, |
1387 }, |
1403 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', |
1388 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', |
1404 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1389 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1405 var vstr, color, amount; |
|
1406 if (block_misc(dataRecord.inventory_reduced, rowdata.m_use_use) == false) { |
1390 if (block_misc(dataRecord.inventory_reduced, rowdata.m_use_use) == false) { |
1407 vstr = rowdata.m_amount_is_weight ? 'gr' : 'ml'; |
1391 var vstr = rowdata.m_amount_is_weight ? 'gr' : 'ml', |
1408 color = '#ffffff'; |
1392 color = (value < rowdata.m_amount) ? '#ff4040':'#ffffff', |
1409 if (value < rowdata.m_amount) |
|
1410 color = '#ff4040'; |
|
1411 amount = dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr; |
1393 amount = dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr; |
1412 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1394 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1413 } else { |
1395 } else { |
1414 return '<span></span>'; |
1396 return '<span></span>'; |
1415 } |
1397 } |
1454 |
1436 |
1455 // Inline yeasts editor |
1437 // Inline yeasts editor |
1456 var editYeast = function(data) { |
1438 var editYeast = function(data) { |
1457 var yeastSource = { |
1439 var yeastSource = { |
1458 localdata: data.yeasts, |
1440 localdata: data.yeasts, |
1459 datatype: 'local', |
|
1460 cache: false, |
|
1461 async: false, |
|
1462 datafields: [ |
1441 datafields: [ |
1463 { name: 'y_name', type: 'string' }, |
1442 { name: 'y_name', type: 'string' }, |
1464 { name: 'y_laboratory', type: 'string' }, |
1443 { name: 'y_laboratory', type: 'string' }, |
1465 { name: 'y_product_id', type: 'string' }, |
1444 { name: 'y_product_id', type: 'string' }, |
1466 { name: 'y_amount', type: 'float' }, |
1445 { name: 'y_amount', type: 'float' }, |
1596 }, |
1575 }, |
1597 { text: 'Min. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
1576 { text: 'Min. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
1598 { text: 'Max. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
1577 { text: 'Max. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
1599 { text: 'Tol. %', width: 60, align: 'right', cellsalign: 'right', datafield: 'y_tolerance', |
1578 { text: 'Tol. %', width: 60, align: 'right', cellsalign: 'right', datafield: 'y_tolerance', |
1600 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1579 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1601 var amount = '', color = '#ffffff'; |
1580 var amount = '', color = (dataRecord.est_abv > value) ? '#ff4040':'#ffffff'; |
1602 if (value > 0) { |
1581 if (value > 0) { |
1603 amount = dataAdapter.formatNumber(value, 'f1'); |
1582 amount = dataAdapter.formatNumber(value, 'f1'); |
1604 if (dataRecord.est_abv > value) |
|
1605 color = '#ff4040'; |
|
1606 } |
1583 } |
1607 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1584 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
1608 } |
1585 } |
1609 }, |
1586 }, |
1610 { text: 'Attn. %', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
1587 { text: 'Attn. %', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
1681 |
1658 |
1682 // inline mash editor |
1659 // inline mash editor |
1683 var editMash = function(data) { |
1660 var editMash = function(data) { |
1684 var mashSource = { |
1661 var mashSource = { |
1685 localdata: data.mashs, |
1662 localdata: data.mashs, |
1686 datatype: 'local', |
|
1687 cache: false, |
|
1688 async: false, |
|
1689 datafields: [ |
1663 datafields: [ |
1690 { name: 'step_name', type: 'string' }, |
1664 { name: 'step_name', type: 'string' }, |
1691 { name: 'step_type', type: 'int' }, |
1665 { name: 'step_type', type: 'int' }, |
1692 { name: 'step_volume', type: 'float' }, |
1666 { name: 'step_volume', type: 'float' }, |
1693 { name: 'step_infuse_amount', type: 'float' }, |
1667 { name: 'step_infuse_amount', type: 'float' }, |
2017 } |
1991 } |
2018 |
1992 |
2019 function calcPercentages() { |
1993 function calcPercentages() { |
2020 |
1994 |
2021 console.log('calcPercentages()'); |
1995 console.log('calcPercentages()'); |
2022 var tw = 0, rowdata, percentage, rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
1996 var tw = 0, rowdata, percentage, rowscount = dataRecord.fermentables.length; |
2023 if (rowscount > 1) { |
1997 if (rowscount > 1) { |
2024 for (i = 0; i < rowscount; i++) { |
1998 for (i = 0; i < rowscount; i++) { |
2025 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); |
1999 rowdata = dataRecord.fermentables[i]; |
2026 if (rowdata.f_added < 4) |
2000 if (rowdata.f_added < 4) |
2027 tw += Round(rowdata.f_amount, 3); |
2001 tw += Round(rowdata.f_amount, 3); |
2028 } |
2002 } |
2029 tw = Round(tw, 3); |
2003 tw = Round(tw, 3); |
2030 |
2004 |
2086 } |
2060 } |
2087 if (mashtime > 5) |
2061 if (mashtime > 5) |
2088 mashtime -= 5; //Correct last ramp > 75 |
2062 mashtime -= 5; //Correct last ramp > 75 |
2089 mashtemp = Round(mashtemp / mashtime, 2); |
2063 mashtemp = Round(mashtemp / mashtime, 2); |
2090 } else { |
2064 } else { |
2091 console.log("calcFermentables() mashGrid not loaded"); |
2065 console.log("calcFermentables() no mash steps"); |
2092 } |
2066 } |
2093 |
2067 |
2094 if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { |
2068 if (! dataRecord.fermentables.length) { |
2095 console.log("calcFermentables() fermentableGrid not loaded"); |
2069 console.log("calcFermentables() no fermentables"); |
2096 return; // grid not yet loaded. |
2070 return; // grid not yet loaded. |
2097 } |
2071 } |
2098 |
2072 |
2099 for (i = 0; i < rows.length; i++) { |
2073 for (i = 0; i < dataRecord.fermentables.length; i++) { |
2100 row = rows[i]; |
2074 row = dataRecord.fermentables[i]; |
2101 if (row.f_adjust_to_total_100) |
2075 if (row.f_adjust_to_total_100) |
2102 my_100 = true; |
2076 my_100 = true; |
2103 if (row.f_type == 1 && row.f_added < 4) // Sugar |
2077 if (row.f_type == 1 && row.f_added < 4) // Sugar |
2104 psugar += row.f_percentage; |
2078 psugar += row.f_percentage; |
2105 if (row.f_graintype == 2 && row.f_added < 4) // Crystal |
2079 if (row.f_graintype == 2 && row.f_added < 4) // Crystal |
2254 calcStage(); |
2228 calcStage(); |
2255 |
2229 |
2256 // Calculate estimated svg. |
2230 // Calculate estimated svg. |
2257 svg = 0; // default. |
2231 svg = 0; // default. |
2258 initcells = 0; |
2232 initcells = 0; |
2259 rows = $('#yeastGrid').jqxGrid('getrows'); |
2233 for (i = 0; i < dataRecord.yeasts.length; i++) { |
2260 for (i = 0; i < rows.length; i++) { |
2234 row = dataRecord.yeasts[i]; |
2261 row = rows[i]; |
|
2262 if (row.y_use == 0) { // Primary |
2235 if (row.y_use == 0) { // Primary |
2263 if (parseFloat(row.y_attenuation) > svg) |
2236 if (parseFloat(row.y_attenuation) > svg) |
2264 svg = parseFloat(row.y_attenuation); // Take the highest if multiple yeasts. |
2237 svg = parseFloat(row.y_attenuation); // Take the highest if multiple yeasts. |
2265 if (row.y_form == 0) |
2238 if (row.y_form == 0) |
2266 initcells += (parseFloat(row.y_cells) / 1000000000) * parseFloat(row.y_amount) * (dataRecord.starter_viability / 100); |
2239 initcells += (parseFloat(row.y_cells) / 1000000000) * parseFloat(row.y_amount) * (dataRecord.starter_viability / 100); |
2315 var h, m, infused = 0, mashtime = 0, mashvol = 0, vol, i, j, n, a, b, row, temp; |
2288 var h, m, infused = 0, mashtime = 0, mashvol = 0, vol, i, j, n, a, b, row, temp; |
2316 var lasttemp = 18.0; |
2289 var lasttemp = 18.0; |
2317 var graintemp = 18.0; |
2290 var graintemp = 18.0; |
2318 var tuntemp = 18.0; |
2291 var tuntemp = 18.0; |
2319 |
2292 |
2320 if ((rows = $('#mashGrid').jqxGrid('getrows')) && (mashkg > 0)) { |
2293 if (dataRecord.mashs.length && (mashkg > 0)) { |
2321 console.log('calcMash()'); |
2294 console.log('calcMash()'); |
2322 for (i = 0; i < rows.length; i++) { |
2295 for (i = 0; i < dataRecord.mashs.length; i++) { |
2323 row = $('#mashGrid').jqxGrid('getrowdata', i); |
2296 row = dataRecord.mashs[i]; |
2324 if (row.step_type == 0) { // Infusion |
2297 if (row.step_type == 0) { // Infusion |
2325 if (i == 0) { |
2298 if (i == 0) { |
2326 // First mash step, temperature from the mashtun and malt. |
2299 // First mash step, temperature from the mashtun and malt. |
2327 n = 20; // tun is preheated. |
2300 n = 20; // tun is preheated. |
2328 tuntemp = row.step_temp; |
2301 tuntemp = row.step_temp; |
2335 temp = 99; |
2308 temp = 99; |
2336 } |
2309 } |
2337 tuntemp += (temp - tuntemp) / 2; |
2310 tuntemp += (temp - tuntemp) / 2; |
2338 row.step_infuse_temp = Round(temp, 6); |
2311 row.step_infuse_temp = Round(temp, 6); |
2339 } |
2312 } |
2340 console.log('init infuse temp: ' + row.step_infuse_temp); |
2313 //console.log('init infuse temp: ' + row.step_infuse_temp); |
2341 } else { |
2314 } else { |
2342 // Calculate amount of infusion water. |
2315 // Calculate amount of infusion water. |
2343 row.step_infuse_amount = infusionVol(infused, mashkg, row.step_infuse_temp, row.step_temp, lasttemp); |
2316 row.step_infuse_amount = infusionVol(infused, mashkg, row.step_infuse_temp, row.step_temp, lasttemp); |
2344 //console.log('vol: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp); |
2317 console.log('vol: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp); |
2345 } |
2318 } |
2346 infused += row.step_infuse_amount; |
2319 infused += row.step_infuse_amount; |
2347 } else if (row.step_type == 1) { // Temperature |
2320 } else if (row.step_type == 1) { // Temperature |
2348 if (i > 0) |
2321 if (i > 0) |
2349 row.step_infuse_amount = 0; |
2322 row.step_infuse_amount = 0; |
2377 function calcFermentablesFromOG(OG) { |
2350 function calcFermentablesFromOG(OG) { |
2378 |
2351 |
2379 console.log('calcFermentablesFromOG(' + OG + ')'); |
2352 console.log('calcFermentablesFromOG(' + OG + ')'); |
2380 var amount, row, d, i, sug, tot = 0, totmass = 0, rowscount, efficiency = parseFloat($('#efficiency').jqxNumberInput('decimal')); |
2353 var amount, row, d, i, sug, tot = 0, totmass = 0, rowscount, efficiency = parseFloat($('#efficiency').jqxNumberInput('decimal')); |
2381 sug = sg_to_plato(OG) * parseFloat($('#batch_size').jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg |
2354 sug = sg_to_plato(OG) * parseFloat($('#batch_size').jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg |
2382 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
2355 rowscount = dataRecord.fermentables.length; |
2383 |
2356 |
2384 for (i = 0; i < rowscount; i++) { |
2357 for (i = 0; i < rowscount; i++) { |
2385 row = $('#fermentableGrid').jqxGrid('getrowdata', i); |
2358 row = dataRecord.fermentables[i]; |
2386 if (row.f_added < 4) { |
2359 if (row.f_added < 4) { |
2387 d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
2360 d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
2388 if (row.f_added == 0) // Mash |
2361 if (row.f_added == 0) // Mash |
2389 d = efficiency / 100 * d; |
2362 d = efficiency / 100 * d; |
2390 tot += d; |
2363 tot += d; |
2784 $('#yeast_cells').val(initcells); |
2758 $('#yeast_cells').val(initcells); |
2785 |
2759 |
2786 if (!(rows = $('#yeastGrid').jqxGrid('getrows'))) { |
2760 if (!(rows = $('#yeastGrid').jqxGrid('getrows'))) { |
2787 return; // grid not yet loaded. |
2761 return; // grid not yet loaded. |
2788 } |
2762 } |
2789 rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; |
2763 rowscount = dataRecord.yeasts.length; |
2790 if (rowscount == 0) |
2764 if (rowscount == 0) |
2791 return; // no yeast in recipe |
2765 return; // no yeast in recipe |
2792 |
2766 |
2793 $('.primary_dry').hide(); |
2767 $('.primary_dry').hide(); |
2794 $('.primary_liquid').hide(); |
2768 $('.primary_liquid').hide(); |
2795 |
2769 |
2796 var maybe_starter = 0; |
2770 var maybe_starter = 0; |
2797 var pitchrate = 0.75; // Yeast pitch rate default |
2771 var pitchrate = 0.75; // Yeast pitch rate default |
2798 for (i = 0; i < rowscount; i++) { |
2772 for (i = 0; i < rowscount; i++) { |
2799 row = $('#yeastGrid').jqxGrid('getrowdata', i); |
2773 row = dataRecord.yeasts[i]; |
2800 if (row.y_use == 0) { // primary |
2774 if (row.y_use == 0) { // primary |
2801 if (row.y_form == 1) { |
2775 if (row.y_form == 1) { |
2802 // Dry yeast |
2776 // Dry yeast |
2803 $('.primary_dry').show(); |
2777 $('.primary_dry').show(); |
2804 console.log('dry yeast: ' + row.y_gr_hl_lo + '@' + row.y_sg_lo + ' ' + row.y_gr_hl_hi + '@' + row.y_sg_hi); |
2778 console.log('dry yeast: ' + row.y_gr_hl_lo + '@' + row.y_sg_lo + ' ' + row.y_gr_hl_hi + '@' + row.y_sg_hi); |
2814 // dataRecord.starter_viability |
2788 // dataRecord.starter_viability |
2815 var yeast_grams = Round(volume * multiplier * (100 / dataRecord.starter_viability), 2); |
2789 var yeast_grams = Round(volume * multiplier * (100 / dataRecord.starter_viability), 2); |
2816 $('#yeast_grams').val(yeast_grams); |
2790 $('#yeast_grams').val(yeast_grams); |
2817 var yeast_gr_hl = Round(yeast_grams / (volume * 0.01), 2); |
2791 var yeast_gr_hl = Round(yeast_grams / (volume * 0.01), 2); |
2818 $('#yeast_gr_hl').val(yeast_gr_hl); |
2792 $('#yeast_gr_hl').val(yeast_gr_hl); |
2819 console.log('need ' + yeast_grams + ' grams, gr/hl: ' + yeast_gr_hl); |
2793 //console.log('need ' + yeast_grams + ' grams, gr/hl: ' + yeast_gr_hl); |
2820 // obj.initgram = Round(obj.volume * multiplier_yeast_needed * (100 / obj.yeastviability), 2); |
|
2821 |
2794 |
2822 } else { |
2795 } else { |
2823 // Liquid yeast |
2796 // Liquid yeast |
2824 $('.primary_liquid').show(); |
2797 $('.primary_liquid').show(); |
2825 // pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ |
2798 // pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ |
2884 $('#plato_cells').val(parseFloat(use_cells / (volume * plato))); |
2857 $('#plato_cells').val(parseFloat(use_cells / (volume * plato))); |
2885 }; |
2858 }; |
2886 |
2859 |
2887 function adjustHops(factor) { |
2860 function adjustHops(factor) { |
2888 |
2861 |
2889 console.log('adjustHops(' + factor + ')'); |
2862 //console.log('adjustHops(' + factor + ')'); |
2890 var row, i, amount, rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; |
2863 var row, i, amount, rowscount = dataRecord.hops.length; |
2891 if (rowscount == 0) |
2864 if (rowscount == 0) |
2892 return; |
2865 return; |
2893 for (i = 0; i < rowscount; i++) { |
2866 for (i = 0; i < rowscount; i++) { |
2894 row = $('#hopGrid').jqxGrid('getrowdata', i); |
2867 row = dataRecord.hops[i]; |
2895 amount = row.h_amount * factor; |
2868 amount = row.h_amount * factor; |
|
2869 dataRecord.hops[i].h_amount = amount; |
2896 $('#hopGrid').jqxGrid('setcellvalue', i, 'h_amount', amount); |
2870 $('#hopGrid').jqxGrid('setcellvalue', i, 'h_amount', amount); |
2897 } |
2871 } |
2898 }; |
2872 }; |
2899 |
2873 |
2900 function whirlpoolHops() { |
2874 function whirlpoolHops() { |
2901 var row, i, time, rowscount; |
2875 var row, i, time, rowscount = dataRecord.hops.length; |
2902 if (!(rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount)) |
|
2903 return; |
|
2904 if (rowscount == 0) |
2876 if (rowscount == 0) |
2905 return; |
2877 return; |
2906 for (i = 0; i < rowscount; i++) { |
2878 for (i = 0; i < rowscount; i++) { |
2907 row = $('#hopGrid').jqxGrid('getrowdata', i); |
2879 row = dataRecord.hops[i]; |
2908 if (row.h_useat == 4) { |
2880 if (row.h_useat == 4) { |
2909 time = parseFloat(dataRecord.brew_whirlpool9) + parseFloat(dataRecord.brew_whirlpool7) + parseFloat(dataRecord.brew_whirlpool6); |
2881 time = parseFloat(dataRecord.brew_whirlpool9) + parseFloat(dataRecord.brew_whirlpool7) + parseFloat(dataRecord.brew_whirlpool6); |
|
2882 dataRecord.hops[i].h_time = time; |
2910 $('#hopGrid').jqxGrid('setcellvalue', i, 'h_time', time); |
2883 $('#hopGrid').jqxGrid('setcellvalue', i, 'h_time', time); |
2911 } |
2884 } |
2912 } |
2885 } |
2913 }; |
2886 }; |
2914 |
2887 |
2915 function calcMiscs() { |
2888 function calcMiscs() { |
2916 |
2889 |
2917 ok_miscs = 1; |
2890 ok_miscs = 1; |
2918 var row, i, rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; |
2891 var row, i, rowscount = dataRecord.miscs.length; |
2919 if (rowscount == 0) |
2892 if (rowscount == 0) |
2920 return; |
2893 return; |
2921 for (i = 0; i < rowscount; i++) { |
2894 for (i = 0; i < rowscount; i++) { |
2922 row = $('#miscGrid').jqxGrid('getrowdata', i); |
2895 row = dataRecord.miscs[i]; |
2923 if ((((dataRecord.inventory_reduced <= 2) && (row.m_use_use <= 2)) || // Starter, Mash, Boil |
2896 if ((((dataRecord.inventory_reduced <= 2) && (row.m_use_use <= 2)) || // Starter, Mash, Boil |
2924 ((dataRecord.inventory_reduced <= 3) && (row.m_use_use == 3)) || // Primary |
2897 ((dataRecord.inventory_reduced <= 3) && (row.m_use_use == 3)) || // Primary |
2925 ((dataRecord.inventory_reduced <= 5) && (row.m_use_use == 4)) || // Secondary, Teriary |
2898 ((dataRecord.inventory_reduced <= 5) && (row.m_use_use == 4)) || // Secondary, Teriary |
2926 ((dataRecord.inventory_reduced <= 6) && (row.m_use_use == 5))) && // Bottle |
2899 ((dataRecord.inventory_reduced <= 6) && (row.m_use_use == 5))) && // Bottle |
2927 (row.m_inventory < row.m_amount)) { |
2900 (row.m_inventory < row.m_amount)) { |
2931 calcSupplies(); |
2904 calcSupplies(); |
2932 }; |
2905 }; |
2933 |
2906 |
2934 function adjustMiscs(factor) { |
2907 function adjustMiscs(factor) { |
2935 |
2908 |
2936 console.log('adjustMiscs(' + factor + ')'); |
2909 //console.log('adjustMiscs(' + factor + ')'); |
2937 var row, i, amount, rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; |
2910 var row, i, amount, rowscount = dataRecord.miscs.length; |
2938 if (rowscount == 0) |
2911 if (rowscount == 0) |
2939 return; |
2912 return; |
2940 for (i = 0; i < rowscount; i++) { |
2913 for (i = 0; i < rowscount; i++) { |
2941 row = $('#miscGrid').jqxGrid('getrowdata', i); |
2914 row = dataRecord.miscs[i]; |
2942 amount = row.m_amount * factor; |
2915 amount = row.m_amount * factor; |
|
2916 dataRecord.miscs[i].m_amount = amount; |
2943 $('#miscGrid').jqxGrid('setcellvalue', i, 'm_amount', amount); |
2917 $('#miscGrid').jqxGrid('setcellvalue', i, 'm_amount', amount); |
2944 switch (row.m_name) { |
2918 switch (row.m_name) { |
2945 case 'CaCl2': |
2919 case 'CaCl2': |
2946 $('#wa_cacl2').val(row.m_amount * 1000); |
2920 $('#wa_cacl2').val(row.m_amount * 1000); |
2947 break; |
2921 break; |
2970 } |
2944 } |
2971 }; |
2945 }; |
2972 |
2946 |
2973 function adjustYeasts(factor) { |
2947 function adjustYeasts(factor) { |
2974 |
2948 |
2975 console.log('adjustYeasts(' + factor + ')'); |
2949 //console.log('adjustYeasts(' + factor + ')'); |
2976 var row, i, amount, rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; |
2950 var row, i, amount, rowscount = dataRecord.yeasts.length; |
2977 if (rowscount == 0) |
2951 if (rowscount == 0) |
2978 return; |
2952 return; |
2979 for (i = 0; i < rowscount; i++) { |
2953 for (i = 0; i < rowscount; i++) { |
2980 row = $('#yeastGrid').jqxGrid('getrowdata', i); |
2954 row = dataRecord.yeasts[i]; |
2981 if (! dataRecord.starter_enable) { // Only adjust without a starter |
2955 if (! dataRecord.starter_enable) { // Only adjust without a starter |
2982 amount = row.y_amount * factor; |
2956 amount = row.y_amount * factor; |
|
2957 dataRecord.yeasts[i].y_amount = amount; |
2983 $('#yeastGrid').jqxGrid('setcellvalue', i, 'y_amount', amount); |
2958 $('#yeastGrid').jqxGrid('setcellvalue', i, 'y_amount', amount); |
2984 } |
2959 } |
2985 } |
2960 } |
2986 calcYeast(); |
2961 calcYeast(); |
2987 }; |
2962 }; |
2988 |
2963 |
2989 function adjustWaters(factor) { |
2964 function adjustWaters(factor) { |
2990 |
2965 |
2991 console.log('adjustWaters(' + factor + ')'); |
2966 //console.log('adjustWaters(' + factor + ')'); |
2992 var amount, row, i, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
2967 var amount, row, i, rowscount = dataRecord.mashs.length; |
2993 if (rowscount == 0) |
2968 if (rowscount == 0) |
2994 return; |
2969 return; |
2995 mash_infuse = 0; |
2970 mash_infuse = 0; |
2996 for (i = 0; i < rowscount; i++) { |
2971 for (i = 0; i < rowscount; i++) { |
2997 row = $('#mashGrid').jqxGrid('getrowdata', i); |
2972 row = dataRecord.mashs[i]; |
2998 if (row.step_type == 0) { // Infusion |
2973 if (row.step_type == 0) { // Infusion |
2999 amount = Round(parseFloat(row.step_infuse_amount) * factor, 1); |
2974 amount = Round(parseFloat(row.step_infuse_amount) * factor, 1); |
|
2975 dataRecord.mashs[i].step_infuse_amount = amount; |
3000 $('#mashGrid').jqxGrid('setcellvalue', i, 'step_infuse_amount', amount); |
2976 $('#mashGrid').jqxGrid('setcellvalue', i, 'step_infuse_amount', amount); |
3001 mash_infuse += amount; |
2977 mash_infuse += amount; |
3002 } |
2978 } |
3003 } |
2979 } |
3004 if (dataRecord.w2_amount == 0) { |
2980 if (dataRecord.w2_amount == 0) { |
3026 else |
3002 else |
3027 $('#brew_mash_efficiency').val(0); |
3003 $('#brew_mash_efficiency').val(0); |
3028 }; |
3004 }; |
3029 |
3005 |
3030 function calcEfficiencyBeforeBoil() { |
3006 function calcEfficiencyBeforeBoil() { |
3031 var m = 0, rows = {}, i, row, tot, result = 0; |
3007 var m = 0, i, row, tot, result = 0; |
3032 if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { |
3008 if (!($('#fermentableGrid').jqxGrid('getrows'))) |
3033 return; // grid not yet loaded. |
3009 return; // no grid loaded yet |
3034 } |
3010 if (dataRecord.fermentables.length == 0) |
3035 for (i = 0; i < rows.length; i++) { |
3011 return; // no fermentables |
3036 row = rows[i]; |
3012 for (i = 0; i < dataRecord.fermentables.length; i++) { |
|
3013 row = dataRecord.fermentables[i]; |
3037 if (row.f_added == 0) { // Mash |
3014 if (row.f_added == 0) { // Mash |
3038 m += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
3015 m += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
3039 } |
3016 } |
3040 } |
3017 } |
3041 tot = sg_to_plato(dataRecord.brew_preboil_sg) * (dataRecord.brew_preboil_volume / 1.04) * dataRecord.brew_preboil_sg * 10 / 1000; |
3018 tot = sg_to_plato(dataRecord.brew_preboil_sg) * (dataRecord.brew_preboil_volume / 1.04) * dataRecord.brew_preboil_sg * 10 / 1000; |
3047 } |
3024 } |
3048 |
3025 |
3049 function calcEfficiencyAfterBoil() { |
3026 function calcEfficiencyAfterBoil() { |
3050 var m = 0, // Sugars added at mash |
3027 var m = 0, // Sugars added at mash |
3051 b = 0, // Sugars added at boil |
3028 b = 0, // Sugars added at boil |
3052 rows = {}, i, row, tot, result = 0; |
3029 i, row, tot, result = 0; |
3053 if (!(rows = $('#fermentableGrid').jqxGrid('getrows'))) { |
3030 if (!($('#fermentableGrid').jqxGrid('getrows'))) { |
3054 return; // grid not yet loaded. |
3031 return; // grid not yet loaded. |
3055 } |
3032 } |
3056 for (i = 0; i < rows.length; i++) { |
3033 for (i = 0; i < dataRecord.fermentables.length; i++) { |
3057 row = rows[i]; |
3034 row = dataRecord.fermentables[i]; |
3058 if (row.f_added == 0) { // Mash |
3035 if (row.f_added == 0) { // Mash |
3059 m += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
3036 m += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
3060 } else if (row.f_added == 1) { // Boil |
3037 } else if (row.f_added == 1) { // Boil |
3061 b += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
3038 b += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
3062 } |
3039 } |
3204 return C1; |
3181 return C1; |
3205 } |
3182 } |
3206 |
3183 |
3207 function ProtonDeficit(pHZ) { |
3184 function ProtonDeficit(pHZ) { |
3208 |
3185 |
3209 var rows, i, C1, x, Result = ZRA(pHZ) * parseFloat($('#wg_amount').jqxNumberInput('decimal')); |
3186 var i, C1, x, Result = ZRA(pHZ) * parseFloat($('#wg_amount').jqxNumberInput('decimal')); |
3210 // proton deficit for the grist |
3187 // proton deficit for the grist |
3211 if ((rows = $('#fermentableGrid').jqxGrid('getrows'))) { |
3188 if (( $('#fermentableGrid').jqxGrid('getrows'))) { |
3212 for (i = 0; i < rows.length; i++) { |
3189 for (i = 0; i < dataRecord.fermentables.length; i++) { |
3213 row = rows[i]; |
3190 row = dataRecord.fermentables[i]; |
3214 if (row.f_added == 0 && row.f_graintype != 6) { // Added == Mash && graintype != No Malt |
3191 if (row.f_added == 0 && row.f_graintype != 6) { // Added == Mash && graintype != No Malt |
3215 C1 = BufferCapacity(row.f_di_ph, row.f_acid_to_ph_57, row.f_color, row.f_graintype); |
3192 C1 = BufferCapacity(row.f_di_ph, row.f_acid_to_ph_57, row.f_color, row.f_graintype); |
3216 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) |
3193 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) |
3217 Result += x * row.f_amount; |
3194 Result += x * row.f_amount; |
3218 } |
3195 } |