www/js/prod_edit.js

changeset 133
22d28dd9c041
parent 123
b4aaf52941e9
child 149
ff45488d480e
equal deleted inserted replaced
132:aaefac2d08a3 133:22d28dd9c041
86 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size)); 86 preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size));
87 console.log("preboil_sg: " + preboil_sg); 87 console.log("preboil_sg: " + preboil_sg);
88 console.log("est_color: " + kw_to_ebc(dataRecord.color_method, colorw)); 88 console.log("est_color: " + kw_to_ebc(dataRecord.color_method, colorw));
89 $("#est_og").val(estimate_sg(sugarsf, parseFloat(dataRecord.batch_size))); 89 $("#est_og").val(estimate_sg(sugarsf, parseFloat(dataRecord.batch_size)));
90 $('#est_color').val(kw_to_ebc(dataRecord.color_method, colorw)); 90 $('#est_color').val(kw_to_ebc(dataRecord.color_method, colorw));
91 };
92
93 function calcFermentablesFromOG(OG) {
94
95 console.log("calcFermentablesFromOG("+OG+")");
96 var i, j, sug, d, tot, totmass;
97 var vol, vol1, vol2, sug2;
98 var mass1, mass2, efficiency;
99
100 for (j = 1; j < 15; j++) { // Maybe needed if there is equipment, not here.
101 vol = 0;
102 sug2 = 0;
103 efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal'));
104 var rows = $('#fermentableGrid').jqxGrid('getrows');
105 for (i = 0; i < rows.length; i++) {
106 row = rows[i];
107 if ((row.f_added == "Fermentation") || (row.f_added == "Lagering") || (row.f_added == "Bottle")) {
108 var x = (row.f_yield / 100) * (1 - row.f_moisture / 100);
109 vol += row.f_amount / (x * sugardensity + (1 - x) * 1);
110 sug2 += row.f_amount * x;
111 }
112 }
113 // if FEquipment <> NIL then /* Use this for prod_edit.js
114 // begin
115 // sug:= SGToPlato(OG) * OG / 100; //kg/l
116 // vol1:= FBatchSize.Value - FEquipment.TrubChillerLoss.Value;
117 // vol2:= vol1 + FEquipment.TopUpWater.Value + vol;
118 // sug:= sug * vol2; //kg in het gistvat
119 // sug:= sug - sug2; //kg voor toevoeging in gistvat
120 // if vol1 > 0 then
121 // sug:= sug * FBatchSize.Value / vol1; //kg in kookketel
122 // sug:= sug + sug2;
123 // end
124 // else
125 sug = sg_to_plato(OG) * parseFloat($("#batch_size").jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg
126
127 tot = 0;
128 d = 0;
129 for (i = 0; i < rows.length; i++) {
130 row = rows[i];
131 d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100);
132 if (row.f_added == "Mash")
133 d = efficiency / 100 * d;
134 tot += d;
135 }
136 if (tot)
137 totmass = sug / tot;
138 else
139 totmass = 0;
140
141 if (totmass) {
142 console.log("pass:"+j+" totmass:"+totmass);
143 for (i = 0; i < rows.length; i++) {
144 row = rows[i];
145 row.f_amount = row.f_percentage / 100 * totmass;
146 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_amount", row.f_percentage / 100 * totmass);
147 }
148 }
149 };
150 //CalcWaterBalance;
91 }; 151 };
92 152
93 function calcIBUs() { 153 function calcIBUs() {
94 var total_ibus = 0; 154 var total_ibus = 0;
95 for (var i = 0; i < dataRecord.hops.length; i++) { 155 for (var i = 0; i < dataRecord.hops.length; i++) {

mercurial