www/js/prod_edit.js

changeset 774
92e1e8f175a2
parent 772
f9d266eb0ec6
child 783
006078146107
equal deleted inserted replaced
773:f4161330ed01 774:92e1e8f175a2
510 { name: 'divide_type', type: 'int' }, 510 { name: 'divide_type', type: 'int' },
511 { name: 'divide_size', type: 'float' }, 511 { name: 'divide_size', type: 'float' },
512 { name: 'divide_factor', type: 'float' }, 512 { name: 'divide_factor', type: 'float' },
513 { name: 'divide_parts', type: 'int' }, 513 { name: 'divide_parts', type: 'int' },
514 { name: 'divide_part', type: 'int' }, 514 { name: 'divide_part', type: 'int' },
515 { name: 'fermentables', type: 'array' }, 515 { name: 'fermentables', type: 'string' },
516 { name: 'hops', type: 'array' }, 516 { name: 'hops', type: 'string' },
517 { name: 'miscs', type: 'array' }, 517 { name: 'miscs', type: 'string' },
518 { name: 'yeasts', type: 'array' }, 518 { name: 'yeasts', type: 'string' },
519 { name: 'mashs', type: 'array' } 519 { name: 'mashs', type: 'string' }
520 ], 520 ],
521 id: 'record', 521 id: 'record',
522 url: url + '?record=' + my_record 522 url: url + '?record=' + my_record
523 }, 523 },
524 524
1664 { name: 'step_sg', type: 'float' } 1664 { name: 'step_sg', type: 'float' }
1665 ], 1665 ],
1666 addrow: function(rowid, rowdata, position, commit) { commit(true); }, 1666 addrow: function(rowid, rowdata, position, commit) { commit(true); },
1667 deleterow: function(rowid, commit) { commit(true); } 1667 deleterow: function(rowid, commit) { commit(true); }
1668 }, 1668 },
1669 mashAdapter = new $.jqx.dataAdapter(mashSource, { 1669 mashAdapter = new $.jqx.dataAdapter(mashSource);
1670 beforeLoadComplete: function(records) { 1670
1671 mash_infuse = 0;
1672 var i, row, data = new Array();
1673 for (i = 0; i < records.length; i++) {
1674 row = records[i];
1675 if (row.step_type == 0) // Infusion
1676 mash_infuse += parseFloat(row.step_infuse_amount);
1677 row.step_wg_ratio = 0; // Init this field.
1678 data.push(row);
1679 }
1680 },
1681 });
1682 $('#mashGrid').jqxGrid({ 1671 $('#mashGrid').jqxGrid({
1683 width: 1240, 1672 width: 1240,
1684 height: 400, 1673 height: 400,
1685 source: mashAdapter, 1674 source: mashAdapter,
1686 theme: theme, 1675 theme: theme,
1890 } 1879 }
1891 1880
1892 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) { 1881 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) {
1893 var a = last_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); 1882 var a = last_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
1894 var b = step_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); 1883 var b = step_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
1895 //console.log('b - a: ' + (b - a) + ' t: ' + ((infuse_temp - step_temp) * SpecificHeatWater));
1896 //console.log('res: ' + ((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)));
1897 var vol = Round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)), 2); 1884 var vol = Round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)), 2);
1898 console.log('infusionVol(' + step_infused + ', ' + step_mashkg + ', ' + infuse_temp + ', ' + step_temp + ', ' + last_temp + '): ' + vol); 1885 //console.log('infusionVol(' + step_infused + ', ' + step_mashkg + ', ' + infuse_temp + ', ' + step_temp + ', ' + last_temp + '): ' + vol);
1899 return vol; 1886 return vol;
1900 } 1887 }
1901 1888
1902 function decoctionVol(step_volume, step_temp, prev_temp) { 1889 function decoctionVol(step_volume, step_temp, prev_temp) {
1903 var a = (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp); 1890 var a = (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp);
2301 } 2288 }
2302 //console.log('init infuse temp: ' + row.step_infuse_temp); 2289 //console.log('init infuse temp: ' + row.step_infuse_temp);
2303 } else { 2290 } else {
2304 // Calculate amount of infusion water. 2291 // Calculate amount of infusion water.
2305 row.step_infuse_amount = infusionVol(infused, mashkg, row.step_infuse_temp, row.step_temp, lasttemp); 2292 row.step_infuse_amount = infusionVol(infused, mashkg, row.step_infuse_temp, row.step_temp, lasttemp);
2306 console.log('vol: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp); 2293 //console.log('vol: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp);
2307 } 2294 }
2308 infused += row.step_infuse_amount; 2295 infused += parseFloat(row.step_infuse_amount);
2309 } else if (row.step_type == 1) { // Temperature 2296 } else if (row.step_type == 1) { // Temperature
2310 if (i > 0) 2297 if (i > 0)
2311 row.step_infuse_amount = 0; 2298 row.step_infuse_amount = 0;
2312 row.step_infuse_temp = 0; 2299 row.step_infuse_temp = 0;
2313 } else if (row.step_type == 2) { // Decoction 2300 } else if (row.step_type == 2) { // Decoction
2320 mashtime += row.step_time + row.ramp_time; 2307 mashtime += row.step_time + row.ramp_time;
2321 row.step_wg_ratio = Round(infused / mashkg, 6); 2308 row.step_wg_ratio = Round(infused / mashkg, 6);
2322 $('#mashGrid').jqxGrid('updaterow', i, row); 2309 $('#mashGrid').jqxGrid('updaterow', i, row);
2323 } 2310 }
2324 } 2311 }
2325 mashvol = mashkg * MaltVolume + infused; 2312 mashvol = Round(mashkg * MaltVolume + infused, 6);
2326 $('#est_mashvol').val(mashvol); 2313 $('#est_mashvol').val(mashvol);
2327 h = Math.floor(mashtime / 60); 2314 h = Math.floor(mashtime / 60);
2328 m = Math.floor(mashtime - (h * 60)); 2315 m = Math.floor(mashtime - (h * 60));
2329 if (h < 10) 2316 if (h < 10)
2330 h = '0' + h; 2317 h = '0' + h;
5827 rowdata.step_sg = parseFloat(event.args.value); 5814 rowdata.step_sg = parseFloat(event.args.value);
5828 }); 5815 });
5829 $('#wstep_brix').jqxNumberInput(Spin1dec); 5816 $('#wstep_brix').jqxNumberInput(Spin1dec);
5830 $('#wstep_brix').on('change', function(event) { 5817 $('#wstep_brix').on('change', function(event) {
5831 /* Use plato_to_sg at this stage */ 5818 /* Use plato_to_sg at this stage */
5832 var sg = plato_to_sg(parseFloat(event.args.value)); 5819 var sg = Round(plato_to_sg(parseFloat(event.args.value)), 4);
5833 console.log('brix: ' + parseFloat(event.args.value) + ' sg: ' + sg); 5820 console.log('brix: ' + parseFloat(event.args.value) + ' sg: ' + sg);
5834 if (sg > 1.005) { 5821 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
5835 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); 5822 if (sg <= 1.005) {
5836 rowdata.step_sg = sg; 5823 sg = 0.0;
5837 $('#wstep_sg').val(sg); 5824 }
5838 } 5825 rowdata.step_sg = sg;
5826 $('#wstep_sg').val(sg);
5839 }); 5827 });
5840 $('#wramp_time').on('change', function(event) { 5828 $('#wramp_time').on('change', function(event) {
5841 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow); 5829 var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
5842 rowdata.ramp_time = parseFloat(event.args.value); 5830 rowdata.ramp_time = parseFloat(event.args.value);
5843 calcMash(); 5831 calcMash();

mercurial