1471 cache: false, |
1474 cache: false, |
1472 async: false, |
1475 async: false, |
1473 datafields: [ |
1476 datafields: [ |
1474 { name: 'step_name', type: 'string' }, |
1477 { name: 'step_name', type: 'string' }, |
1475 { name: 'step_type', type: 'int' }, |
1478 { name: 'step_type', type: 'int' }, |
|
1479 { name: 'step_volume', type: 'float' }, |
1476 { name: 'step_infuse_amount', type: 'float' }, |
1480 { name: 'step_infuse_amount', type: 'float' }, |
|
1481 { name: 'step_infuse_temp', type: 'float' }, |
1477 { name: 'step_temp', type: 'float' }, |
1482 { name: 'step_temp', type: 'float' }, |
1478 { name: 'step_time', type: 'float' }, |
1483 { name: 'step_time', type: 'float' }, |
1479 { name: 'step_thickness', type: 'float' }, |
1484 { name: 'step_wg_ratio', type: 'float' }, |
1480 { name: 'ramp_time', type: 'float' }, |
1485 { name: 'ramp_time', type: 'float' }, |
1481 { name: 'end_temp', type: 'float' } |
1486 { name: 'end_temp', type: 'float' } |
1482 ], |
1487 ], |
1483 addrow: function(rowid, rowdata, position, commit) { commit(true); }, |
1488 addrow: function(rowid, rowdata, position, commit) { commit(true); }, |
1484 deleterow: function(rowid, commit) { commit(true); } |
1489 deleterow: function(rowid, commit) { commit(true); } |
1512 $('#saddrowbutton').on('click', function() { |
1517 $('#saddrowbutton').on('click', function() { |
1513 var row = {}, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
1518 var row = {}, rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
1514 row['step_name'] = 'Stap ' + (rowscount + 1); |
1519 row['step_name'] = 'Stap ' + (rowscount + 1); |
1515 if (rowscount > 0) { |
1520 if (rowscount > 0) { |
1516 row['step_type'] = 1; |
1521 row['step_type'] = 1; |
|
1522 row['step_infuse_amount'] = 0; |
|
1523 row['step_volume'] = mash_infuse; |
1517 } else { |
1524 } else { |
1518 row['step_type'] = 0; |
1525 row['step_type'] = 0; |
1519 row['step_infuse_amount'] = 15; |
1526 row['step_infuse_amount'] = 15; |
|
1527 row['step_volume'] = 15; |
1520 } |
1528 } |
|
1529 row['step_infuse_temp'] = 0; |
1521 row['step_temp'] = 62.0; |
1530 row['step_temp'] = 62.0; |
1522 row['step_time'] = 20.0; |
1531 row['step_time'] = 20.0; |
1523 row['step_thickness'] = 0; |
1532 row['step_wg_ratio'] = 0; |
1524 row['ramp_time'] = 1.0; |
1533 row['ramp_time'] = 1.0; |
1525 row['end_temp'] = 62.0; |
1534 row['end_temp'] = 62.0; |
1526 $('#mashGrid').jqxGrid('addrow', null, row); |
1535 $('#mashGrid').jqxGrid('addrow', null, row); |
|
1536 calcMash(); |
1527 }); |
1537 }); |
1528 // delete selected step. |
1538 // delete selected step. |
1529 $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); |
1539 $('#sdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); |
1530 $('#sdeleterowbutton').on('click', function() { |
1540 $('#sdeleterowbutton').on('click', function() { |
1531 var rowscount, id, selectedrowindex = $('#mashGrid').jqxGrid('getselectedrowindex'); |
1541 var rowscount, id, selectedrowindex = $('#mashGrid').jqxGrid('getselectedrowindex'); |
1532 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
1542 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
1533 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1543 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1534 id = $('#mashGrid').jqxGrid('getrowid', selectedrowindex); |
1544 id = $('#mashGrid').jqxGrid('getrowid', selectedrowindex); |
1535 $('#mashGrid').jqxGrid('deleterow', id); |
1545 $('#mashGrid').jqxGrid('deleterow', id); |
|
1546 calcMash(); |
1536 } |
1547 } |
1537 }); |
1548 }); |
1538 }, |
1549 }, |
1539 ready: function() { |
1550 ready: function() { |
1540 /* Calculate the whole recipe */ |
1551 /* Calculate the whole recipe */ |
1561 }, |
1572 }, |
1562 { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1573 { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1563 { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1574 { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1564 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
1575 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
1565 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
1576 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
1566 { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
1577 { text: 'Inf/dec L.', datafield: 'step_infuse_amount', width: 90, align: 'right', |
1567 { text: 'L/Kg.', datafield: 'step_thickness', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f2' }, |
1578 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
1568 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
1579 if (rowdata.step_type == 1) |
|
1580 return '<span></span>'; |
|
1581 var color = '#ffffff'; |
|
1582 var mvol = mashkg * MaltVolume; |
|
1583 if ((rowdata.step_wg_ratio * mashkg + mvol) > dataRecord.eq_tun_volume) |
|
1584 color = '#ff4040'; |
|
1585 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + dataAdapter.formatNumber(value, 'f1') + '</span>'; |
|
1586 } |
|
1587 }, |
|
1588 { text: 'Inf/dec °C', datafield: 'step_infuse_temp', width: 90, align: 'right', |
|
1589 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
|
1590 if (rowdata.step_type == 1) |
|
1591 return '<span></span>'; |
|
1592 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(value, 'f2') + '</span>'; |
|
1593 } |
|
1594 }, |
|
1595 { text: 'L/Kg.', datafield: 'step_wg_ratio', width: 90, align: 'right', |
|
1596 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
|
1597 var color = '#ffffff'; |
|
1598 if (value < 2.0 || value > 6.0) |
|
1599 color = '#ff4040'; |
|
1600 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + dataAdapter.formatNumber(value, 'f2') + '</span>'; |
|
1601 } |
|
1602 }, |
|
1603 { text: '', columntype: 'button', width: 15, align: 'center', |
|
1604 cellsrenderer: function(row) { |
|
1605 if (row < 2) |
|
1606 return ' '; |
|
1607 return '▴'; |
|
1608 }, buttonclick: function(row) { |
|
1609 if (row >= 2) { |
|
1610 swapMash(row, row-1); |
|
1611 } |
|
1612 } |
|
1613 }, |
|
1614 { text: '', columntype: 'button', width: 15, align: 'center', |
|
1615 cellsrenderer: function(row) { |
|
1616 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
|
1617 if (row < 1 || row > (rowscount -2)) |
|
1618 return ' '; |
|
1619 return '▾'; |
|
1620 }, buttonclick: function(row) { |
|
1621 rowscount = $('#mashGrid').jqxGrid('getdatainformation').rowscount; |
|
1622 if (row >= 1 && row <= (rowscount -2)) { |
|
1623 swapMash(row, row+1); |
|
1624 } |
|
1625 } |
|
1626 }, |
|
1627 { text: '', datafield: 'Edit', columntype: 'button', width: 80, align: 'center', |
1569 cellsrenderer: function() { |
1628 cellsrenderer: function() { |
1570 return 'Wijzig'; |
1629 return 'Wijzig'; |
1571 }, buttonclick: function(row) { |
1630 }, buttonclick: function(row) { |
1572 if (dataRecord.stage > 3) { |
1631 if (dataRecord.stage > 3) { |
1573 alert('Het maischen is al gedaan.'); |
1632 alert('Het maischen is al gedaan.'); |
1574 } else { |
1633 } else { |
1575 mashRow = row; |
1634 mashRow = row; |
1576 mashData = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
1635 mashData = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
1636 if (mashRow == 0) |
|
1637 $("#wstep_type").jqxDropDownList('disableAt', 2); |
|
1638 else |
|
1639 $("#wstep_type").jqxDropDownList('enableAt', 2); |
1577 $('#wstep_name').val(mashData.step_name); |
1640 $('#wstep_name').val(mashData.step_name); |
1578 $('#wstep_type').val(mashData.step_type); |
1641 $('#wstep_type').val(mashData.step_type); |
1579 $('#wstep_infuse_amount').val(mashData.step_infuse_amount); |
1642 $('#wstep_infuse_amount').val(mashData.step_infuse_amount); |
|
1643 $('#wstep_infuse_temp').val(mashData.step_infuse_temp); |
1580 $('#wstep_temp').val(mashData.step_temp); |
1644 $('#wstep_temp').val(mashData.step_temp); |
1581 $('#wend_temp').val(mashData.end_temp); |
1645 $('#wend_temp').val(mashData.end_temp); |
1582 $('#wstep_time').val(mashData.step_time); |
1646 $('#wstep_time').val(mashData.step_time); |
1583 $('#wramp_time').val(mashData.ramp_time); |
1647 $('#wramp_time').val(mashData.ramp_time); |
|
1648 $('#wstep_infuse_amount').hide(); // Hide all untile we need it. |
|
1649 $('#wstep_infuse_temp').hide(); |
|
1650 $('#wstep_pmpt_amount').hide(); |
|
1651 $('#wstep_pmpt_temp').hide(); |
1584 if (mashData.step_type == 0) { |
1652 if (mashData.step_type == 0) { |
1585 $('#wstep_infuse_amount').show(); |
1653 if (mashRow == 0) { |
1586 $('#wstep_pmpt').show(); |
1654 $('#wstep_infuse_amount').show(); |
1587 } else { |
1655 $('#wstep_pmpt_amount').show(); |
1588 $('#wstep_infuse_amount').hide(); |
1656 } else { |
1589 $('#wstep_pmpt').hide(); |
1657 $('#wstep_infuse_temp').show(); |
|
1658 $('#wstep_pmpt_temp').show(); |
|
1659 } |
1590 } |
1660 } |
1591 // show the popup window. |
1661 // show the popup window. |
1592 $('#popupMash').jqxWindow('open'); |
1662 $('#popupMash').jqxWindow('open'); |
1593 } |
1663 } |
1594 } |
1664 } |
1615 if (dataRecord.boil_time) { |
1685 if (dataRecord.boil_time) { |
1616 $('#brew_pmpt_koken').html('Koken ' + dataRecord.boil_time + ' minuten'); |
1686 $('#brew_pmpt_koken').html('Koken ' + dataRecord.boil_time + ' minuten'); |
1617 } else { |
1687 } else { |
1618 $('#brew_pmpt_koken').html('Koken "no-boil"'); |
1688 $('#brew_pmpt_koken').html('Koken "no-boil"'); |
1619 } |
1689 } |
|
1690 } |
|
1691 |
|
1692 function swapMash(r1, r2) { |
|
1693 |
|
1694 console.log('swap mash rows ' + r1 + ' ' + r2); |
|
1695 var row1 = $('#mashGrid').jqxGrid('getrowdata', r1); |
|
1696 var row2 = $('#mashGrid').jqxGrid('getrowdata', r2); |
|
1697 var obj1 = { step_name: row1.step_name, step_type: row1.step_type, step_volume: row1.step_volume, step_infuse_amount: row1.step_infuse_amount, |
|
1698 step_infuse_temp: row1.step_infuse_temp, step_temp: row1.step_temp, step_time: row1.step_time, |
|
1699 ramp_time: row1.ramp_time, end_temp: row1.end_temp, step_wg_ratio: row1.step_wg_ratio }; |
|
1700 var obj2 = { step_name: row2.step_name, step_type: row2.step_type, step_volume: row2.step_volume, step_infuse_amount: row2.step_infuse_amount, |
|
1701 step_infuse_temp: row2.step_infuse_temp, step_temp: row2.step_temp, step_time: row2.step_time, |
|
1702 ramp_time: row2.ramp_time, end_temp: row2.end_temp, step_wg_ratio: row2.step_wg_ratio }; |
|
1703 $("#mashGrid").jqxGrid('updaterow', r1, obj2); |
|
1704 $("#mashGrid").jqxGrid('updaterow', r2, obj1); |
|
1705 } |
|
1706 |
|
1707 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) { |
|
1708 var a = last_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); |
|
1709 var b = step_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); |
|
1710 //console.log('b - a: ' + (b - a) + ' t: ' + ((infuse_temp - step_temp) * SpecificHeatWater)); |
|
1711 //console.log('res: ' + ((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater))); |
|
1712 var vol = Round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)), 2); |
|
1713 console.log('infusionVol(' + step_infused + ', ' + step_mashkg + ', ' + infuse_temp + ', ' + step_temp + ', ' + last_temp + '): ' + vol); |
|
1714 return vol; |
|
1715 } |
|
1716 |
|
1717 function decoctionVol(step_volume, step_temp, prev_temp) { |
|
1718 var a = (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp); |
|
1719 var b = SpecificHeatWater * (99 - step_temp); |
|
1720 var vol = 0; |
|
1721 if (b > 0) |
|
1722 vol = Round(a / b, 6); |
|
1723 console.log('decoctionVol(' + step_volume + ', ' + step_temp + ', ' + prev_temp + '): ' + vol); |
|
1724 return vol; |
1620 } |
1725 } |
1621 |
1726 |
1622 function calcViability() { |
1727 function calcViability() { |
1623 var vpm = 1.00; |
1728 var vpm = 1.00; |
1624 var max = 100; |
1729 var max = 100; |
1983 $('#kcal').val(Math.round((alc + sug) / (12 * 0.0295735296))); |
2088 $('#kcal').val(Math.round((alc + sug) / (12 * 0.0295735296))); |
1984 }; |
2089 }; |
1985 |
2090 |
1986 function calcMash() { |
2091 function calcMash() { |
1987 |
2092 |
1988 var h, m, infused = 0, mashtime = 0, mashvol = 0, i, row; |
2093 var h, m, infused = 0, mashtime = 0, mashvol = 0, vol, i, j, n, a, b, row, temp; |
|
2094 var lasttemp = 18.0; |
|
2095 var graintemp = 18.0; |
|
2096 var tuntemp = 18.0; |
1989 |
2097 |
1990 if ((rows = $('#mashGrid').jqxGrid('getrows')) && (mashkg > 0)) { |
2098 if ((rows = $('#mashGrid').jqxGrid('getrows')) && (mashkg > 0)) { |
|
2099 console.log('calcMash()'); |
1991 for (i = 0; i < rows.length; i++) { |
2100 for (i = 0; i < rows.length; i++) { |
1992 row = $('#mashGrid').jqxGrid('getrowdata', i); |
2101 row = $('#mashGrid').jqxGrid('getrowdata', i); |
1993 if (row.step_type == 0) // Infusion |
2102 if (row.step_type == 0) { // Infusion |
|
2103 if (i == 0) { |
|
2104 // First mash step, temperature from the mashtun and malt. |
|
2105 n = 20; // tun is preheated. |
|
2106 tuntemp = row.step_temp; |
|
2107 for (j = 0; j < n; j++) { |
|
2108 a = mashkg * graintemp * SpecificHeatMalt + dataRecord.eq_tun_weight * tuntemp * dataRecord.eq_tun_specific_heat; |
|
2109 b = row.step_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + row.step_infuse_amount * SpecificHeatWater + mashkg * SpecificHeatMalt) - SlakingHeat * mashkg; |
|
2110 if (row.step_infuse_amount > 0) { |
|
2111 temp = (b - a) / (row.step_infuse_amount * SpecificHeatWater); |
|
2112 } else { |
|
2113 temp = 99; |
|
2114 } |
|
2115 tuntemp += (temp - tuntemp) / 2; |
|
2116 row.step_infuse_temp = Round(temp, 6); |
|
2117 } |
|
2118 console.log('init infuse temp: ' + row.step_infuse_temp); |
|
2119 } else { |
|
2120 // Calculate amount of infusion water. |
|
2121 row.step_infuse_amount = infusionVol(infused, mashkg, row.step_infuse_temp, row.step_temp, lasttemp); |
|
2122 //console.log('vol: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp); |
|
2123 } |
1994 infused += row.step_infuse_amount; |
2124 infused += row.step_infuse_amount; |
|
2125 } else if (row.step_type == 1) { // Temperature |
|
2126 if (i > 0) |
|
2127 row.step_infuse_amount = 0; |
|
2128 row.step_infuse_temp = 0; |
|
2129 } else if (row.step_type == 2) { // Decoction |
|
2130 row.step_infuse_amount = decoctionVol(infused, row.step_temp, lasttemp); |
|
2131 row.step_infuse_temp = 99; |
|
2132 } |
|
2133 row.step_volume = infused; |
|
2134 //console.log(i + ' type: ' + row.step_type + ' volume: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp); |
|
2135 lasttemp = row.step_temp; |
1995 mashtime += row.step_time + row.ramp_time; |
2136 mashtime += row.step_time + row.ramp_time; |
1996 $('#mashGrid').jqxGrid('setcellvalue', i, 'step_thickness', infused / mashkg); |
2137 row.step_wg_ratio = Round(infused / mashkg, 6); |
|
2138 $('#mashGrid').jqxGrid('updaterow', i, row); |
1997 } |
2139 } |
1998 } |
2140 } |
1999 mashvol = mashkg * MaltVolume + infused; |
2141 mashvol = mashkg * MaltVolume + infused; |
2000 $('#est_mashvol').val(mashvol); |
2142 $('#est_mashvol').val(mashvol); |
2001 h = Math.floor(mashtime / 60); |
2143 h = Math.floor(mashtime / 60); |
5413 $('#mash_name').val(datarecord.name); |
5555 $('#mash_name').val(datarecord.name); |
5414 for (i = 0; i < datarecord.steps.length; i++) { |
5556 for (i = 0; i < datarecord.steps.length; i++) { |
5415 data = datarecord.steps[i]; |
5557 data = datarecord.steps[i]; |
5416 row = {}; |
5558 row = {}; |
5417 row['step_name'] = data.step_name; |
5559 row['step_name'] = data.step_name; |
5418 row['step_type'] = data.step_type; |
5560 row['step_type'] = parseInt(data.step_type); |
5419 // For now, but this must be smarter. |
5561 row['step_temp'] = parseFloat(data.step_temp); |
5420 if (mash_infuse == 0 && dataRecord.w1_amount > 0) |
5562 row['end_temp'] = parseFloat(data.end_temp); |
5421 mash_infuse = dataRecord.w1_amount; |
5563 row['step_time'] = parseFloat(data.step_time); |
5422 if (i == 0) |
5564 row['ramp_time'] = parseFloat(data.ramp_time); |
5423 row['step_infuse_amount'] = mash_infuse; |
5565 row['step_infuse_temp'] = 0.0; |
|
5566 row['step_infuse_amount'] = 0.0; |
|
5567 if (mash_infuse == 0 && dataRecord.wg_amount > 0) |
|
5568 mash_infuse = dataRecord.wg_amount; |
|
5569 if (data.step_type == 0) { // Infusion |
|
5570 if (i == 0) { |
|
5571 row['step_infuse_amount'] = parseFloat(mash_infuse); |
|
5572 } else { |
|
5573 row['step_infuse_temp'] = 99.0; |
|
5574 } |
|
5575 } |
|
5576 //console.log(i + ' type: ' + row['step_type'] + ' start infusion: ' + parseFloat(row['step_infuse_amount']) + ' mash_infuse: ' + mash_infuse); |
|
5577 infused += parseFloat(row['step_infuse_amount']); |
|
5578 row['step_volume'] = infused; |
|
5579 if (mashkg > 0) |
|
5580 row['step_wg_ratio'] = Round(parseFloat(mash_infuse / mashkg), 2); |
5424 else |
5581 else |
5425 row['step_infuse_amount'] = 0; |
5582 row['step_wg_ratio'] = 0; |
5426 if (mashkg > 0) |
|
5427 row['step_thickness'] = parseFloat(mash_infuse / mashkg); |
|
5428 else |
|
5429 row['step_thickness'] = 0; |
|
5430 row['step_temp'] = data.step_temp; |
|
5431 row['end_temp'] = data.end_temp; |
|
5432 row['step_time'] = data.step_time; |
|
5433 row['ramp_time'] = data.ramp_time; |
|
5434 $('#mashGrid').jqxGrid('addrow', null, row); |
5583 $('#mashGrid').jqxGrid('addrow', null, row); |
5435 } |
5584 } |
5436 calcMash(); |
5585 calcMash(); |
5437 } |
5586 } |
5438 }); |
5587 }); |
5440 $('#est_mashvol').jqxNumberInput(Show1dec); |
5589 $('#est_mashvol').jqxNumberInput(Show1dec); |
5441 $('#est_mashtime').jqxTooltip({ content: 'De totale tijdsduur van het maischen.' }); |
5590 $('#est_mashtime').jqxTooltip({ content: 'De totale tijdsduur van het maischen.' }); |
5442 $('#est_mashtime').jqxInput({ theme: theme, width: 70, height: 23 }); |
5591 $('#est_mashtime').jqxInput({ theme: theme, width: 70, height: 23 }); |
5443 $('#popupMash').jqxWindow({ |
5592 $('#popupMash').jqxWindow({ |
5444 width: 800, |
5593 width: 800, |
5445 height: 350, |
5594 height: 375, |
5446 position: { x: 230, y: 100 }, |
5595 position: { x: 230, y: 100 }, |
5447 resizable: false, |
5596 resizable: false, |
5448 theme: theme, |
5597 theme: theme, |
5449 isModal: true, |
5598 isModal: true, |
5450 autoOpen: false, |
5599 autoOpen: false, |
5451 cancelButton: $('#MashReady'), |
5600 cancelButton: $('#MashReady'), |
5452 modalOpacity: 0.40 |
5601 modalOpacity: 0.40 |
5453 }); |
5602 }); |
5454 $('#MashReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
5603 $('#MashReady').jqxButton({ template: 'success', width: '90px', theme: theme }); |
5455 $('#MashReady').click(function() { |
5604 $('#MashReady').click(function() { |
|
5605 calcFermentables(); |
|
5606 calcWater(); |
|
5607 calcSparge(); |
5456 calcMash(); |
5608 calcMash(); |
5457 }); |
5609 }); |
5458 $('#wstep_name').jqxInput({ theme: theme, width: 320, height: 23 }); |
5610 $('#wstep_name').jqxInput({ theme: theme, width: 320, height: 23 }); |
5459 $('#wstep_name').on('change', function(event) { |
5611 $('#wstep_name').on('change', function(event) { |
5460 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
5612 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
5461 rowdata.step_name = event.args.value; |
5613 rowdata.step_name = $('#wstep_name').val(); |
5462 }); |
5614 }); |
5463 $('#wstep_type').jqxDropDownList({ |
5615 $('#wstep_type').jqxDropDownList({ |
5464 theme: theme, |
5616 theme: theme, |
5465 source: MashStepTypeAdapter, |
5617 source: MashStepTypeAdapter, |
5466 valueMember: 'id', |
5618 valueMember: 'id', |
5471 }); |
5623 }); |
5472 $('#wstep_type').on('select', function(event) { |
5624 $('#wstep_type').on('select', function(event) { |
5473 if (event.args) { |
5625 if (event.args) { |
5474 var rowdata, i, rows, row, index = event.args.index; |
5626 var rowdata, i, rows, row, index = event.args.index; |
5475 rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
5627 rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
5476 rowdata.step_type = index; |
5628 if (rowdata.step_type != index) { |
5477 if (index == 0) { |
5629 rowdata.step_type = index; |
5478 $('#wstep_infuse_amount').show(); |
5630 $('#wstep_infuse_amount').hide(); |
5479 $('#wstep_pmpt').show(); |
5631 $('#wstep_infuse_temp').hide(); |
5480 } else { |
5632 $('#wstep_pmpt_amount').hide(); |
|
5633 $('#wstep_pmpt_temp').hide(); |
|
5634 if (index == 0) { // Infusion |
|
5635 if (mashRow == 0) { |
|
5636 $('#wstep_infuse_amount').show(); |
|
5637 $('#wstep_pmpt_amount').show(); |
|
5638 } else { |
|
5639 $('#wstep_infuse_temp').show(); |
|
5640 $('#wstep_pmpt_temp').show(); |
|
5641 } |
|
5642 } |
|
5643 if (index == 1) { // Temperature |
|
5644 if (mashRow > 0) |
|
5645 rowdata.step_infuse_amount = 0; |
|
5646 rowdata.step_infuse_temp = 0; |
|
5647 } |
|
5648 if (index == 2) { // Decoction |
|
5649 var rowprev = $('#mashGrid').jqxGrid('getrowdata', mashRow-1); |
|
5650 rowdata.step_infuse_temp = 99; |
|
5651 rowdata.step_infuse_amount = decoctionVol(rowdata.step_volume, rowdata.step_temp, rowprev.end_temp); |
|
5652 console.log('decoction: ' + rowdata.step_infuse_amount + '/' + rowdata.step_infuse_temp); |
|
5653 } |
|
5654 $('#mashGrid').jqxGrid('updaterow', mashRow, rowdata); |
|
5655 mash_infuse = 0; |
|
5656 rows = $('#mashGrid').jqxGrid('getrows'); |
|
5657 for (i = 0; i < rows.length; i++) { |
|
5658 row = rows[i]; |
|
5659 if (row.step_type == 0) // Infusion |
|
5660 mash_infuse += parseFloat(row.step_infuse_amount); |
|
5661 } |
|
5662 calcMash(); |
|
5663 } |
|
5664 } |
|
5665 }); |
|
5666 $('#wstep_temp').on('change', function(event) { |
|
5667 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
5668 if (rowdata.step_type == 2) { // Decoction |
|
5669 var rowprev = $('#mashGrid').jqxGrid('getrowdata', mashRow-1); |
|
5670 var a = (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + rowdata.step_volume * SpecificHeatWater) * |
|
5671 (parseFloat(event.args.value) - rowprev.end_temp); |
|
5672 var b = SpecificHeatWater * (99 - parseFloat(event.args.value)); |
|
5673 if (b > 0) { |
|
5674 rowdata.step_temp = parseFloat(event.args.value); |
|
5675 rowdata.step_infuse_amount = Round(a / b, 2); |
|
5676 } else |
5481 rowdata.step_infuse_amount = 0; |
5677 rowdata.step_infuse_amount = 0; |
5482 $('#wstep_infuse_amount').hide(); |
5678 console.log('change temp ' + rowdata.step_temp + ' decoction: ' + rowdata.step_infuse_amount + '/' + rowdata.step_infuse_temp); |
5483 $('#wstep_pmpt').hide(); |
5679 } else { |
5484 } |
5680 rowdata.step_temp = parseFloat(event.args.value); |
|
5681 } |
|
5682 }); |
|
5683 $('#wstep_temp,#wend_temp,#wstep_infuse_amount,#wstep_infuse_temp').jqxNumberInput(Spin1dec); |
|
5684 $('#wend_temp').on('change', function(event) { |
|
5685 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
5686 rowdata.end_temp = parseFloat(event.args.value); |
|
5687 }); |
|
5688 $('#wstep_time,#wramp_time').jqxNumberInput(PosInt); |
|
5689 $('#wstep_time').on('change', function(event) { |
|
5690 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
5691 rowdata.step_time = parseFloat(event.args.value); |
|
5692 calcMash(); |
|
5693 }); |
|
5694 $('#wramp_time').on('change', function(event) { |
|
5695 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
5696 rowdata.ramp_time = parseFloat(event.args.value); |
|
5697 calcMash(); |
|
5698 }); |
|
5699 $('#wstep_infuse_amount').on('change', function(event) { |
|
5700 var row, i, rows, rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
5701 rowdata.step_infuse_amount = parseFloat(event.args.value); |
|
5702 if (mashRow == 0) { |
|
5703 rowdata.step_infuse_amount = parseFloat(event.args.value); |
5485 mash_infuse = 0; |
5704 mash_infuse = 0; |
5486 rows = $('#mashGrid').jqxGrid('getrows'); |
5705 rows = $('#mashGrid').jqxGrid('getrows'); |
5487 for (i = 0; i < rows.length; i++) { |
5706 for (i = 0; i < rows.length; i++) { |
5488 row = rows[i]; |
5707 row = rows[i]; |
5489 if (row.step_type == 0) // Infusion |
5708 if (row.step_type == 0) // Infusion |
5490 mash_infuse += parseFloat(row.step_infuse_amount); |
5709 mash_infuse += parseFloat(row.step_infuse_amount); |
5491 } |
5710 } |
5492 } |
5711 if (dataRecord.w2_amount == 0) { |
5493 }); |
5712 dataRecord.w1_amount = mash_infuse; |
5494 $('#wstep_temp').on('change', function(event) { |
5713 $('#w1_amount').val(mash_infuse); |
|
5714 } else { |
|
5715 var w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
5716 var w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
5717 dataRecord.w1_amount = Round(w1_amount, 3); |
|
5718 dataRecord.w2_amount = Round(w2_amount, 3); |
|
5719 $('#w1_amount').val(dataRecord.w1_amount); |
|
5720 $('#w2_amount').val(dataRecord.w2_amount); |
|
5721 } |
|
5722 $('#wg_amount').val(mash_infuse); |
|
5723 console.log('new infuse amount: ' + mash_infuse); |
|
5724 calcWater(); |
|
5725 // calcMash(); |
|
5726 } |
|
5727 }); |
|
5728 $('#wstep_infuse_temp').on('change', function(event) { |
|
5729 var prevdata = $('#mashGrid').jqxGrid('getrowdata', mashRow-1); |
5495 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
5730 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
5496 rowdata.step_temp = parseFloat(event.args.value); |
5731 rowdata.step_infuse_temp = parseFloat(event.args.value); |
5497 }); |
5732 var vol = infusionVol(prevdata.step_volume, mashkg, rowdata.step_infuse_temp, rowdata.step_temp, prevdata.end_temp); |
5498 $('#wstep_temp,#wend_temp,#wstep_infuse_amount').jqxNumberInput(Spin1dec); |
5733 console.log('new vol: ' + vol); |
5499 $('#wend_temp').on('change', function(event) { |
5734 rowdata.step_infuse_amount = vol; |
5500 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
5735 $('#wstep_infuse_amount').val(vol); |
5501 rowdata.end_temp = parseFloat(event.args.value); |
|
5502 }); |
|
5503 $('#wstep_time,#wramp_time').jqxNumberInput(PosInt); |
|
5504 $('#wstep_time').on('change', function(event) { |
|
5505 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
5506 rowdata.step_time = parseFloat(event.args.value); |
|
5507 calcMash(); |
|
5508 }); |
|
5509 $('#wramp_time').on('change', function(event) { |
|
5510 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
5511 rowdata.ramp_time = parseFloat(event.args.value); |
|
5512 calcMash(); |
|
5513 }); |
|
5514 $('#wstep_infuse_amount').on('change', function(event) { |
|
5515 var row, i, rows, rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); |
|
5516 rowdata.step_infuse_amount = parseFloat(event.args.value); |
|
5517 mash_infuse = 0; |
|
5518 rows = $('#mashGrid').jqxGrid('getrows'); |
|
5519 for (i = 0; i < rows.length; i++) { |
|
5520 row = rows[i]; |
|
5521 if (row.step_type == 0) // Infusion |
|
5522 mash_infuse += parseFloat(row.step_infuse_amount); |
|
5523 } |
|
5524 if (dataRecord.w2_amount == 0) { |
|
5525 dataRecord.w1_amount = mash_infuse; |
|
5526 $('#w1_amount').val(mash_infuse); |
|
5527 } else { |
|
5528 var w1_amount = (dataRecord.w1_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
5529 var w2_amount = (dataRecord.w2_amount / (dataRecord.w1_amount + dataRecord.w2_amount)) * mash_infuse; |
|
5530 dataRecord.w1_amount = Round(w1_amount, 3); |
|
5531 dataRecord.w2_amount = Round(w2_amount, 3); |
|
5532 $('#w1_amount').val(dataRecord.w1_amount); |
|
5533 $('#w2_amount').val(dataRecord.w2_amount); |
|
5534 } |
|
5535 $('#wg_amount').val(mash_infuse); |
|
5536 calcFermentables(); |
|
5537 calcWater(); |
|
5538 calcSparge(); |
|
5539 calcMash(); |
|
5540 }); |
5736 }); |
5541 |
5737 |
5542 // Tab 8, Water |
5738 // Tab 8, Water |
5543 $('#tgt_bu').jqxNumberInput(Show2wat); |
5739 $('#tgt_bu').jqxNumberInput(Show2wat); |
5544 $('#tgt_so4_cl,#got_so4_cl').jqxNumberInput(Show1wat); |
5740 $('#tgt_so4_cl,#got_so4_cl').jqxNumberInput(Show1wat); |