346 sug = 3550 * fig * (0.1808 * org + 0.8192 * fig - 1.0004); |
351 sug = 3550 * fig * (0.1808 * org + 0.8192 * fig - 1.0004); |
347 $('#kcal').val(Math.round((alc + sug) / (12 * 0.0295735296))); |
352 $('#kcal').val(Math.round((alc + sug) / (12 * 0.0295735296))); |
348 } |
353 } |
349 |
354 |
350 |
355 |
|
356 function swapMash(r1, r2) { |
|
357 |
|
358 console.log('swap mash rows ' + r1 + ' ' + r2); |
|
359 var row1 = $('#mashGrid').jqxGrid('getrowdata', r1); |
|
360 var row2 = $('#mashGrid').jqxGrid('getrowdata', r2); |
|
361 var obj1 = { step_name: row1.step_name, step_type: row1.step_type, step_volume: row1.step_volume, step_infuse_amount: row1.step_infuse_amount, |
|
362 step_infuse_temp: row1.step_infuse_temp, step_temp: row1.step_temp, step_time: row1.step_time, |
|
363 ramp_time: row1.ramp_time, end_temp: row1.end_temp, step_wg_ratio: row1.step_wg_ratio }; |
|
364 var obj2 = { step_name: row2.step_name, step_type: row2.step_type, step_volume: row2.step_volume, step_infuse_amount: row2.step_infuse_amount, |
|
365 step_infuse_temp: row2.step_infuse_temp, step_temp: row2.step_temp, step_time: row2.step_time, |
|
366 ramp_time: row2.ramp_time, end_temp: row2.end_temp, step_wg_ratio: row2.step_wg_ratio }; |
|
367 $("#mashGrid").jqxGrid('updaterow', r1, obj2); |
|
368 $("#mashGrid").jqxGrid('updaterow', r2, obj1); |
|
369 } |
|
370 |
|
371 |
|
372 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) { |
|
373 var a = last_temp * (eq_tun_weight * eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); |
|
374 var b = step_temp * (eq_tun_weight * eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); |
|
375 var vol = Round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)), 2); |
|
376 console.log('infusionVol(' + step_infused + ', ' + step_mashkg + ', ' + infuse_temp + ', ' + step_temp + ', ' + last_temp + '): ' + vol); |
|
377 return vol; |
|
378 } |
|
379 |
|
380 |
|
381 function decoctionVol(step_volume, step_temp, prev_temp) { |
|
382 var a = (eq_tun_weight * eq_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp); |
|
383 var b = SpecificHeatWater * (99 - step_temp); |
|
384 var vol = 0; |
|
385 if (b > 0) |
|
386 vol = Round(a / b, 6); |
|
387 console.log('decoctionVol(' + step_volume + ', ' + step_temp + ', ' + prev_temp + '): ' + vol); |
|
388 return vol; |
|
389 } |
|
390 |
|
391 |
351 function calcMash() { |
392 function calcMash() { |
352 var infused = 0, i, row, rows; |
393 var infused = 0, vol, i, j, n, a, b, row, rows, temp; |
353 if (!(rows = $('#mashGrid').jqxGrid('getrows'))) |
394 var lasttemp = 18.0; |
354 return; |
395 var graintemp = 18.0; |
355 if (mashkg == 0) |
396 var tuntemp = 18.0; |
356 return; |
397 |
357 |
398 if ((rows = $('#mashGrid').jqxGrid('getrows')) && (mashkg > 0)) { |
358 for (i = 0; i < rows.length; i++) { |
399 console.log('calcMash()'); |
359 row = $('#mashGrid').jqxGrid('getrowdata', i); |
400 for (i = 0; i < rows.length; i++) { |
360 if (row.step_type == 0) // Infusion |
401 row = $('#mashGrid').jqxGrid('getrowdata', i); |
361 infused += row.step_infuse_amount; |
402 if (row.step_type == 0) { // Infusion |
362 $('#mashGrid').jqxGrid('setcellvalue', i, 'step_thickness', infused / mashkg); |
403 if (i == 0) { |
|
404 // First mash step, temperature from the mashtun and malt. |
|
405 n = 20; // tun is preheated. |
|
406 tuntemp = row.step_temp; |
|
407 for (j = 0; j < n; j++) { |
|
408 a = mashkg * graintemp * SpecificHeatMalt + eq_tun_weight * tuntemp * eq_tun_specific_heat; |
|
409 b = row.step_temp * (eq_tun_weight * eq_tun_specific_heat + row.step_infuse_amount * SpecificHeatWater + mashkg * SpecificHeatMalt) - SlakingHeat * mashkg; |
|
410 if (row.step_infuse_amount > 0) { |
|
411 temp = (b - a) / (row.step_infuse_amount * SpecificHeatWater); |
|
412 } else { |
|
413 temp = 99; |
|
414 } |
|
415 tuntemp += (temp - tuntemp) / 2; |
|
416 row.step_infuse_temp = Round(temp, 6); |
|
417 } |
|
418 console.log('init infuse temp: ' + row.step_infuse_temp); |
|
419 } else { |
|
420 // Calculate amount of infusion water. |
|
421 row.step_infuse_amount = infusionVol(infused, mashkg, row.step_infuse_temp, row.step_temp, lasttemp); |
|
422 //console.log('vol: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp); |
|
423 } |
|
424 infused += row.step_infuse_amount; |
|
425 } else if (row.step_type == 1) { // Temperature |
|
426 if (i > 0) |
|
427 row.step_infuse_amount = 0; |
|
428 row.step_infuse_temp = 0; |
|
429 } else if (row.step_type == 2) { // Decoction |
|
430 row.step_infuse_amount = decoctionVol(infused, row.step_temp, lasttemp); |
|
431 row.step_infuse_temp = 99; |
|
432 } |
|
433 row.step_volume = infused; |
|
434 //console.log(i + ' type: ' + row.step_type + ' volume: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp); |
|
435 lasttemp = row.step_temp; |
|
436 mashtime += row.step_time + row.ramp_time; |
|
437 row.step_wg_ratio = Round(infused / mashkg, 6); |
|
438 $('#mashGrid').jqxGrid('updaterow', i, row); |
|
439 } |
363 } |
440 } |
364 } |
441 } |
365 |
442 |
366 |
443 |
367 function calcIBUs() { |
444 function calcIBUs() { |
1683 }); |
1760 }); |
1684 }; |
1761 }; |
1685 |
1762 |
1686 // inline mash editor |
1763 // inline mash editor |
1687 var editMash = function(data) { |
1764 var editMash = function(data) { |
1688 var generaterow = function() { |
|
1689 var row = {}; |
|
1690 row['step_name'] = 'Stap 1'; |
|
1691 row['step_type'] = 0; |
|
1692 row['step_infuse_amount'] = 15; |
|
1693 row['step_temp'] = 62.0; |
|
1694 row['step_time'] = 20.0; |
|
1695 row['step_thickness'] = 0; |
|
1696 row['ramp_time'] = 1.0; |
|
1697 row['end_temp'] = 62.0; |
|
1698 return row; |
|
1699 }; |
|
1700 var mashSource = { |
1765 var mashSource = { |
1701 localdata: data.mashs, |
1766 localdata: data.mashs, |
1702 datatype: 'local', |
1767 datatype: 'local', |
1703 cache: false, |
1768 cache: false, |
1704 async: false, |
1769 async: false, |
1705 datafields: [ |
1770 datafields: [ |
1706 { name: 'step_name', type: 'string' }, |
1771 { name: 'step_name', type: 'string' }, |
1707 { name: 'step_type', type: 'int' }, |
1772 { name: 'step_type', type: 'int' }, |
|
1773 { name: 'step_volume', type: 'float' }, |
1708 { name: 'step_infuse_amount', type: 'float' }, |
1774 { name: 'step_infuse_amount', type: 'float' }, |
|
1775 { name: 'step_infuse_temp', type: 'float' }, |
1709 { name: 'step_temp', type: 'float' }, |
1776 { name: 'step_temp', type: 'float' }, |
1710 { name: 'step_time', type: 'float' }, |
1777 { name: 'step_time', type: 'float' }, |
1711 { name: 'step_thickness', type: 'float' }, |
1778 { name: 'step_wg_ratio', type: 'float' }, |
1712 { name: 'ramp_time', type: 'float' }, |
1779 { name: 'ramp_time', type: 'float' }, |
1713 { name: 'end_temp', type: 'float' } |
1780 { name: 'end_temp', type: 'float' } |
1714 ], |
1781 ], |
1715 addrow: function(rowid, rowdata, position, commit) { |
1782 addrow: function(rowid, rowdata, position, commit) { commit(true); }, |
1716 commit(true); |
1783 deleterow: function(rowid, commit) { commit(true); } |
1717 }, |
|
1718 deleterow: function(rowid, commit) { |
|
1719 commit(true); |
|
1720 } |
|
1721 }, |
1784 }, |
1722 mashAdapter = new $.jqx.dataAdapter(mashSource, { |
1785 mashAdapter = new $.jqx.dataAdapter(mashSource, { |
1723 beforeLoadComplete: function(records) { |
1786 beforeLoadComplete: function(records) { |
1724 mash_infuse = 0; |
1787 mash_infuse = 0; |
1725 var row, i, data = new Array(); |
1788 var row, i, data = new Array(); |
1726 for (i = 0; i < records.length; i++) { |
1789 for (i = 0; i < records.length; i++) { |
1727 row = records[i]; |
1790 row = records[i]; |
1728 if (row.step_type == 0) // Infusion |
1791 if (row.step_type == 0) // Infusion |
1729 mash_infuse += parseFloat(row.step_infuse_amount); |
1792 mash_infuse += parseFloat(row.step_infuse_amount); |
1730 row.step_thickness = 0; // Init this field. |
1793 row.step_wg_ratio = 0; // Init this field. |
1731 data.push(row); |
1794 data.push(row); |
1732 } |
1795 } |
1733 }, |
1796 }, |
1734 }); |
1797 }); |
1735 $('#mashGrid').jqxGrid({ |
1798 $('#mashGrid').jqxGrid({ |
1745 toolbar.append(container); |
1808 toolbar.append(container); |
1746 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); |
1809 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); |
1747 container.append('<input style="float: left; margin-left: 565px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); |
1810 container.append('<input style="float: left; margin-left: 565px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); |
1748 $('#saddrowbutton').jqxButton({ template: 'primary', theme: theme, height: 27, width: 150 }); |
1811 $('#saddrowbutton').jqxButton({ template: 'primary', theme: theme, height: 27, width: 150 }); |
1749 $('#saddrowbutton').on('click', function() { |
1812 $('#saddrowbutton').on('click', function() { |
1750 var datarow = generaterow(); |
1813 var row = {}, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
|
1814 row['step_name'] = 'Stap ' + (rowscount + 1); |
|
1815 if (rowscount > 0) { |
|
1816 row['step_type'] = 1; |
|
1817 row['step_infuse_amount'] = 0; |
|
1818 row['step_volume'] = mash_infuse; |
|
1819 } else { |
|
1820 row['step_type'] = 0; |
|
1821 row['step_infuse_amount'] = 15; |
|
1822 row['step_volume'] = 15; |
|
1823 } |
|
1824 row['step_infuse_temp'] = 0; |
|
1825 row['step_temp'] = 62.0; |
|
1826 row['step_time'] = 20.0; |
|
1827 row['step_wg_ratio'] = 0; |
|
1828 row['ramp_time'] = 1.0; |
|
1829 row['end_temp'] = 62.0; |
1751 $('#mashGrid').jqxGrid('addrow', null, datarow); |
1830 $('#mashGrid').jqxGrid('addrow', null, datarow); |
|
1831 calcMash(); |
1752 }); |
1832 }); |
1753 // delete selected yeast. |
1833 // delete selected yeast. |
1754 $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150 }); |
1834 $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150 }); |
1755 $('#sdeleterowbutton').on('click', function() { |
1835 $('#sdeleterowbutton').on('click', function() { |
1756 var id, rowscount, selectedrowindex = $('#mashGrid').jqxGrid('getselectedrowindex'); |
1836 var id, rowscount, selectedrowindex = $('#mashGrid').jqxGrid('getselectedrowindex'); |
1757 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
1837 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
1758 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1838 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1759 id = $('#mashGrid').jqxGrid('getrowid', selectedrowindex); |
1839 id = $('#mashGrid').jqxGrid('getrowid', selectedrowindex); |
1760 $('#mashGrid').jqxGrid('deleterow', id); |
1840 $('#mashGrid').jqxGrid('deleterow', id); |
|
1841 calcMash(); |
1761 } |
1842 } |
1762 }); |
1843 }); |
1763 }, |
1844 }, |
1764 ready: function() { |
1845 ready: function() { |
1765 calcFermentables(); |
1846 calcFermentables(); |
1777 }, |
1858 }, |
1778 { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1859 { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1779 { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1860 { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1780 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
1861 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
1781 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
1862 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
1782 { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1863 { text: 'Inf/dec L.', datafield: 'step_infuse_amount', width: 90, align: 'right', |
1783 { text: 'L/Kg.', datafield: 'step_thickness', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f2' }, |
1864 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
1784 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
1865 if (rowdata.step_type == 1) |
|
1866 return '<span></span>'; |
|
1867 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(value, 'f1') + '</span>'; |
|
1868 } |
|
1869 }, |
|
1870 { text: 'Inf/dec °C', datafield: 'step_infuse_temp', width: 90, align: 'right', |
|
1871 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
|
1872 if (rowdata.step_type == 1) |
|
1873 return '<span></span>'; |
|
1874 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(value, 'f2') + '</span>'; |
|
1875 } |
|
1876 }, |
|
1877 { text: 'L/Kg.', datafield: 'step_wg_ratio', width: 90, align: 'right', |
|
1878 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
|
1879 var color = '#ffffff'; |
|
1880 if (value < 2.0 || value > 6.0) |
|
1881 color = '#ff4040'; |
|
1882 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + dataAdapter.formatNumber(value, 'f2') + '</span>'; |
|
1883 } |
|
1884 }, |
|
1885 { text: '', columntype: 'button', width: 15, align: 'center', |
|
1886 cellsrenderer: function(row) { |
|
1887 if (row < 2) |
|
1888 return ' '; |
|
1889 return '▴'; |
|
1890 }, buttonclick: function(row) { |
|
1891 if (row >= 2) { |
|
1892 swapMash(row, row-1); |
|
1893 } |
|
1894 } |
|
1895 }, |
|
1896 { text: '', columntype: 'button', width: 15, align: 'center', |
|
1897 cellsrenderer: function(row) { |
|
1898 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
|
1899 if (row < 1 || row > (rowscount -2)) |
|
1900 return ' '; |
|
1901 return '▾'; |
|
1902 }, buttonclick: function(row) { |
|
1903 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
|
1904 if (row >= 1 && row <= (rowscount -2)) { |
|
1905 swapMash(row, row+1); |
|
1906 } |
|
1907 } |
|
1908 }, |
|
1909 { text: '', datafield: 'Edit', columntype: 'button', width: 80, align: 'center', |
1785 cellsrenderer: function() { |
1910 cellsrenderer: function() { |
1786 return 'Wijzig'; |
1911 return 'Wijzig'; |
1787 }, buttonclick: function(row) { |
1912 }, buttonclick: function(row) { |
1788 mashRow = row; |
1913 mashRow = row; |
1789 mashData = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
1914 mashData = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
1915 if (mashRow == 0) |
|
1916 $("#wstep_type").jqxDropDownList('disableAt', 2); |
|
1917 else |
|
1918 $("#wstep_type").jqxDropDownList('enableAt', 2); |
1790 $('#wstep_name').val(mashData.step_name); |
1919 $('#wstep_name').val(mashData.step_name); |
1791 $('#wstep_type').val(mashData.step_type); |
1920 $('#wstep_type').val(mashData.step_type); |
1792 $('#wstep_infuse_amount').val(mashData.step_infuse_amount); |
1921 $('#wstep_infuse_amount').val(mashData.step_infuse_amount); |
|
1922 $('#wstep_infuse_temp').val(mashData.step_infuse_temp); |
1793 $('#wstep_temp').val(mashData.step_temp); |
1923 $('#wstep_temp').val(mashData.step_temp); |
1794 $('#wend_temp').val(mashData.end_temp); |
1924 $('#wend_temp').val(mashData.end_temp); |
1795 $('#wstep_time').val(mashData.step_time); |
1925 $('#wstep_time').val(mashData.step_time); |
1796 $('#wramp_time').val(mashData.ramp_time); |
1926 $('#wramp_time').val(mashData.ramp_time); |
|
1927 $('#wstep_infuse_amount').hide(); // Hide all untile we need it. |
|
1928 $('#wstep_infuse_temp').hide(); |
|
1929 $('#wstep_pmpt_amount').hide(); |
|
1930 $('#wstep_pmpt_temp').hide(); |
1797 if (mashData.step_type == 0) { |
1931 if (mashData.step_type == 0) { |
1798 $('#wstep_infuse_amount').show(); |
1932 if (mashRow == 0) { |
1799 $('#wstep_pmpt').show(); |
1933 $('#wstep_infuse_amount').show(); |
1800 } else { |
1934 $('#wstep_pmpt_amount').show(); |
1801 $('#wstep_infuse_amount').hide(); |
1935 } else { |
1802 $('#wstep_pmpt').hide(); |
1936 $('#wstep_infuse_temp').show(); |
|
1937 $('#wstep_pmpt_temp').show(); |
|
1938 } |
1803 } |
1939 } |
1804 // show the popup window. |
1940 // show the popup window. |
1805 $('#popupMash').jqxWindow('open'); |
1941 $('#popupMash').jqxWindow('open'); |
1806 } |
1942 } |
1807 } |
1943 } |
3596 $('#mash_name').val(datarecord.name); |
3731 $('#mash_name').val(datarecord.name); |
3597 for (i = 0; i < datarecord.steps.length; i++) { |
3732 for (i = 0; i < datarecord.steps.length; i++) { |
3598 data = datarecord.steps[i]; |
3733 data = datarecord.steps[i]; |
3599 row = {}; |
3734 row = {}; |
3600 row['step_name'] = data.step_name; |
3735 row['step_name'] = data.step_name; |
3601 row['step_type'] = data.step_type; |
3736 row['step_type'] = parseInt(data.step_type); |
3602 // For now, but this must be smarter. |
3737 row['step_temp'] = parseFloat(data.step_temp); |
3603 if (mash_infuse == 0 && dataRecord.w1_amount > 0) |
3738 row['end_temp'] = parseFloat(data.end_temp); |
3604 mash_infuse = dataRecord.w1_amount; |
3739 row['step_time'] = parseFloat(data.step_time); |
3605 if (i == 0) |
3740 row['ramp_time'] = parseFloat(data.ramp_time); |
3606 row['step_infuse_amount'] = mash_infuse; |
3741 row['step_infuse_temp'] = 0.0; |
|
3742 row['step_infuse_amount'] = 0.0; |
|
3743 if (mash_infuse == 0 && dataRecord.wg_amount > 0) |
|
3744 mash_infuse = dataRecord.wg_amount; |
|
3745 if (data.step_type == 0) { // Infusion |
|
3746 if (i == 0) { |
|
3747 row['step_infuse_amount'] = parseFloat(mash_infuse); |
|
3748 } else { |
|
3749 row['step_infuse_temp'] = 99.0; |
|
3750 } |
|
3751 } |
|
3752 //console.log(i + ' type: ' + row['step_type'] + ' start infusion: ' + parseFloat(row['step_infuse_amount']) + ' mash_infuse: ' + mash_infuse); |
|
3753 infused += parseFloat(row['step_infuse_amount']); |
|
3754 row['step_volume'] = infused; |
|
3755 if (mashkg > 0) |
|
3756 row['step_wg_ratio'] = Round(parseFloat(mash_infuse / mashkg), 2); |
3607 else |
3757 else |
3608 row['step_infuse_amount'] = 0; |
3758 row['step_wg_ratio'] = 0; |
3609 row['step_temp'] = data.step_temp; |
|
3610 if (mashkg > 0) |
|
3611 row['step_thickness'] = parseFloat(mash_infuse / mashkg); |
|
3612 else |
|
3613 row['step_thickness'] = 0; |
|
3614 row['end_temp'] = data.end_temp; |
|
3615 row['step_time'] = data.step_time; |
|
3616 row['ramp_time'] = data.ramp_time; |
|
3617 $('#mashGrid').jqxGrid('addrow', null, row); |
3759 $('#mashGrid').jqxGrid('addrow', null, row); |
3618 } |
3760 } |
|
3761 calcMash(); |
3619 } |
3762 } |
3620 }); |
3763 }); |
3621 $('#popupMash').jqxWindow({ |
3764 $('#popupMash').jqxWindow({ |
3622 width: 800, |
3765 width: 800, |
3623 height: 350, |
3766 height: 375, |
3624 position: { x: 230, y: 100 }, |
3767 position: { x: 230, y: 100 }, |
3625 resizable: false, |
3768 resizable: false, |
3626 theme: theme, |
3769 theme: theme, |
3627 isModal: true, |
3770 isModal: true, |
3628 autoOpen: false, |
3771 autoOpen: false, |
3649 }); |
3792 }); |
3650 $('#wstep_type').on('select', function(event) { |
3793 $('#wstep_type').on('select', function(event) { |
3651 if (event.args) { |
3794 if (event.args) { |
3652 var rowdata, rows, i, row, index = event.args.index; |
3795 var rowdata, rows, i, row, index = event.args.index; |
3653 rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3796 rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3654 rowdata.step_type = index; |
3797 if (rowdata.step_type != index) { |
3655 if (index == 0) { |
3798 rowdata.step_type = index; |
3656 $('#wstep_infuse_amount').show(); |
3799 $('#wstep_infuse_amount').hide(); |
3657 $('#wstep_pmpt').show(); |
3800 $('#wstep_infuse_temp').hide(); |
3658 } else { |
3801 $('#wstep_pmpt_amount').hide(); |
|
3802 $('#wstep_pmpt_temp').hide(); |
|
3803 if (index == 0) { // Infusion |
|
3804 if (mashRow == 0) { |
|
3805 $('#wstep_infuse_amount').show(); |
|
3806 $('#wstep_pmpt_amount').show(); |
|
3807 } else { |
|
3808 $('#wstep_infuse_temp').show(); |
|
3809 $('#wstep_pmpt_temp').show(); |
|
3810 } |
|
3811 } |
|
3812 if (index == 1) { // Temperature |
|
3813 if (mashRow > 0) |
|
3814 rowdata.step_infuse_amount = 0; |
|
3815 rowdata.step_infuse_temp = 0; |
|
3816 } |
|
3817 if (index == 2) { // Decoction |
|
3818 var rowprev = $('#mashGrid').jqxGrid('getrowdata', mashRow-1); |
|
3819 rowdata.step_infuse_temp = 99; |
|
3820 rowdata.step_infuse_amount = decoctionVol(rowdata.step_volume, rowdata.step_temp, rowprev.end_temp); |
|
3821 console.log('decoction: ' + rowdata.step_infuse_amount + '/' + rowdata.step_infuse_temp); |
|
3822 } |
|
3823 $('#mashGrid').jqxGrid('updaterow', mashRow, rowdata); |
|
3824 mash_infuse = 0; |
|
3825 rows = $('#mashGrid').jqxGrid('getrows'); |
|
3826 for (i = 0; i < rows.length; i++) { |
|
3827 row = rows[i]; |
|
3828 if (row.step_type == 0) // Infusion |
|
3829 mash_infuse += parseFloat(row.step_infuse_amount); |
|
3830 } |
|
3831 calcMash(); |
|
3832 } |
|
3833 } |
|
3834 }); |
|
3835 $('#wstep_temp').jqxNumberInput(Spin1dec); |
|
3836 $('#wstep_temp').on('change', function(event) { |
|
3837 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
3838 if (rowdata.step_type == 2) { // Decoction |
|
3839 var rowprev = $('#mashGrid').jqxGrid('getrowdata', mashRow-1); |
|
3840 var a = (eq_tun_weight * eq_tun_specific_heat + rowdata.step_volume * SpecificHeatWater) * |
|
3841 (parseFloat(event.args.value) - rowprev.end_temp); |
|
3842 var b = SpecificHeatWater * (99 - parseFloat(event.args.value)); |
|
3843 if (b > 0) { |
|
3844 rowdata.step_temp = parseFloat(event.args.value); |
|
3845 rowdata.step_infuse_amount = Round(a / b, 2); |
|
3846 } else |
3659 rowdata.step_infuse_amount = 0; |
3847 rowdata.step_infuse_amount = 0; |
3660 $('#wstep_infuse_amount').hide(); |
3848 console.log('change temp ' + rowdata.step_temp + ' decoction: ' + rowdata.step_infuse_amount + '/' + rowdata.step_infuse_temp); |
3661 $('#wstep_pmpt').hide(); |
3849 } else { |
3662 } |
3850 rowdata.step_temp = parseFloat(event.args.value); |
|
3851 } |
|
3852 }); |
|
3853 $('#wend_temp').jqxNumberInput(Spin1dec); |
|
3854 $('#wend_temp').on('change', function(event) { |
|
3855 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
3856 rowdata.end_temp = parseFloat(event.args.value); |
|
3857 }); |
|
3858 $('#wstep_time').jqxNumberInput(PosInt); |
|
3859 $('#wstep_time').on('change', function(event) { |
|
3860 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
3861 rowdata.step_time = parseFloat(event.args.value); |
|
3862 }); |
|
3863 $('#wramp_time').jqxNumberInput(PosInt); |
|
3864 $('#wramp_time').on('change', function(event) { |
|
3865 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
3866 rowdata.ramp_time = parseFloat(event.args.value); |
|
3867 }); |
|
3868 $('#wstep_infuse_amount').jqxNumberInput(Spin1dec); |
|
3869 $('#wstep_infuse_amount').on('change', function(event) { |
|
3870 var i, rows, row, rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
3871 rowdata.step_infuse_amount = parseFloat(event.args.value); |
|
3872 if (mashRow == 0) { |
|
3873 rowdata.step_infuse_amount = parseFloat(event.args.value); |
3663 mash_infuse = 0; |
3874 mash_infuse = 0; |
3664 rows = $('#mashGrid').jqxGrid('getrows'); |
3875 rows = $('#mashGrid').jqxGrid('getrows'); |
3665 for (i = 0; i < rows.length; i++) { |
3876 for (i = 0; i < rows.length; i++) { |
3666 row = rows[i]; |
3877 row = rows[i]; |
3667 if (row.step_type == 0) // Infusion |
3878 if (row.step_type == 0) // Infusion |
3668 mash_infuse += parseFloat(row.step_infuse_amount); |
3879 mash_infuse += parseFloat(row.step_infuse_amount); |
3669 } |
3880 } |
3670 } |
3881 if (dataRecord.w2_amount == 0) { |
3671 }); |
3882 dataRecord.w1_amount = mash_infuse; |
3672 $('#wstep_temp').jqxNumberInput(Spin1dec); |
3883 $('#w1_amount').val(mash_infuse); |
3673 $('#wstep_temp').on('change', function(event) { |
3884 } else { |
|
3885 var w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
3886 var w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
3887 dataRecord.w1_amount = Round(w1_amount, 3); |
|
3888 dataRecord.w2_amount = Round(w2_amount, 3); |
|
3889 $('#w1_amount').val(dataRecord.w1_amount); |
|
3890 $('#w2_amount').val(dataRecord.w2_amount); |
|
3891 } |
|
3892 $('#wg_amount').val(mash_infuse); |
|
3893 console.log('new infuse amount: ' + mash_infuse); |
|
3894 calcWater(); |
|
3895 } |
|
3896 }); |
|
3897 $('#wstep_infuse_temp').jqxNumberInput(Spin1dec); |
|
3898 $('#wstep_infuse_temp').on('change', function(event) { |
|
3899 var prevdata = $('#mashGrid').jqxGrid('getrowdata', mashRow-1); |
3674 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3900 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3675 rowdata.step_temp = parseFloat(event.args.value); |
3901 rowdata.step_infuse_temp = parseFloat(event.args.value); |
3676 }); |
3902 var vol = infusionVol(prevdata.step_volume, mashkg, rowdata.step_infuse_temp, rowdata.step_temp, prevdata.end_temp); |
3677 $('#wend_temp').jqxNumberInput(Spin1dec); |
3903 console.log('new vol: ' + vol); |
3678 $('#wend_temp').on('change', function(event) { |
3904 rowdata.step_infuse_amount = vol; |
3679 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
3905 $('#wstep_infuse_amount').val(vol); |
3680 rowdata.end_temp = parseFloat(event.args.value); |
|
3681 }); |
|
3682 $('#wstep_time').jqxNumberInput(PosInt); |
|
3683 $('#wstep_time').on('change', function(event) { |
|
3684 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
3685 rowdata.step_time = parseFloat(event.args.value); |
|
3686 }); |
|
3687 $('#wramp_time').jqxNumberInput(PosInt); |
|
3688 $('#wramp_time').on('change', function(event) { |
|
3689 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
3690 rowdata.ramp_time = parseFloat(event.args.value); |
|
3691 }); |
|
3692 $('#wstep_infuse_amount').jqxNumberInput(Spin1dec); |
|
3693 $('#wstep_infuse_amount').on('change', function(event) { |
|
3694 var i, rows, row, rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
3695 rowdata.step_infuse_amount = parseFloat(event.args.value); |
|
3696 mash_infuse = 0; |
|
3697 rows = $('#mashGrid').jqxGrid('getrows'); |
|
3698 for (i = 0; i < rows.length; i++) { |
|
3699 row = rows[i]; |
|
3700 if (row.step_type == 0) // Infusion |
|
3701 mash_infuse += parseFloat(row.step_infuse_amount); |
|
3702 } |
|
3703 if (dataRecord.w2_amount == 0) { |
|
3704 dataRecord.w1_amount = mash_infuse; |
|
3705 $('#w1_amount').val(mash_infuse); |
|
3706 } else { |
|
3707 dataRecord.w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
3708 dataRecord.w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
3709 $('#w1_amount').val(dataRecord.w1_amount); |
|
3710 $('#w2_amount').val(dataRecord.w2_amount); |
|
3711 } |
|
3712 $('#wg_amount').val(mash_infuse); |
|
3713 }); |
3906 }); |
3714 |
3907 |
3715 // Tab 7, Water |
3908 // Tab 7, Water |
3716 $('#tgt_bu').jqxNumberInput(Show2wat); |
3909 $('#tgt_bu').jqxNumberInput(Show2wat); |
3717 $('#tgt_so4_cl,#got_so4_cl').jqxNumberInput(Show1wat); |
3910 $('#tgt_so4_cl,#got_so4_cl').jqxNumberInput(Show1wat); |