www/js/prod_edit.js

changeset 774
92e1e8f175a2
parent 772
f9d266eb0ec6
child 783
006078146107
--- a/www/js/prod_edit.js	Sat Aug 21 16:14:44 2021 +0200
+++ b/www/js/prod_edit.js	Tue Aug 31 20:48:37 2021 +0200
@@ -512,11 +512,11 @@
    { name: 'divide_factor', type: 'float' },
    { name: 'divide_parts', type: 'int' },
    { name: 'divide_part', type: 'int' },
-   { name: 'fermentables', type: 'array' },
-   { name: 'hops', type: 'array' },
-   { name: 'miscs', type: 'array' },
-   { name: 'yeasts', type: 'array' },
-   { name: 'mashs', type: 'array' }
+   { name: 'fermentables', type: 'string' },
+   { name: 'hops', type: 'string' },
+   { name: 'miscs', type: 'string' },
+   { name: 'yeasts', type: 'string' },
+   { name: 'mashs', type: 'string' }
   ],
   id: 'record',
   url: url + '?record=' + my_record
@@ -1666,19 +1666,8 @@
    addrow: function(rowid, rowdata, position, commit) { commit(true); },
    deleterow: function(rowid, commit) { commit(true); }
   },
-  mashAdapter = new $.jqx.dataAdapter(mashSource, {
-   beforeLoadComplete: function(records) {
-    mash_infuse = 0;
-    var i, row, data = new Array();
-    for (i = 0; i < records.length; i++) {
-     row = records[i];
-     if (row.step_type == 0) // Infusion
-      mash_infuse += parseFloat(row.step_infuse_amount);
-     row.step_wg_ratio = 0; // Init this field.
-     data.push(row);
-    }
-   },
-  });
+  mashAdapter = new $.jqx.dataAdapter(mashSource);
+
   $('#mashGrid').jqxGrid({
    width: 1240,
    height: 400,
@@ -1892,10 +1881,8 @@
  function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) {
   var a = last_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
   var b = step_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
-  //console.log('b - a: ' + (b - a) + ' t: ' + ((infuse_temp - step_temp) * SpecificHeatWater));
-  //console.log('res: ' + ((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)));
   var vol = Round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)), 2);
-  console.log('infusionVol(' + step_infused + ', ' + step_mashkg + ', ' + infuse_temp + ', ' + step_temp + ', ' + last_temp + '): ' + vol);
+  //console.log('infusionVol(' + step_infused + ', ' + step_mashkg + ', ' + infuse_temp + ', ' + step_temp + ', ' + last_temp + '): ' + vol);
   return vol;
  }
 
@@ -2303,9 +2290,9 @@
      } else {
       // Calculate amount of infusion water.
       row.step_infuse_amount = infusionVol(infused, mashkg, row.step_infuse_temp, row.step_temp, lasttemp);
-      console.log('vol: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp);
+      //console.log('vol: ' + row.step_infuse_amount + ' temp: ' + row.step_infuse_temp);
      }
-     infused += row.step_infuse_amount;
+     infused += parseFloat(row.step_infuse_amount);
     } else if (row.step_type == 1) { // Temperature
      if (i > 0)
       row.step_infuse_amount = 0;
@@ -2322,7 +2309,7 @@
     $('#mashGrid').jqxGrid('updaterow', i, row);
    }
   }
-  mashvol = mashkg * MaltVolume + infused;
+  mashvol = Round(mashkg * MaltVolume + infused, 6);
   $('#est_mashvol').val(mashvol);
   h = Math.floor(mashtime / 60);
   m = Math.floor(mashtime - (h * 60));
@@ -5829,13 +5816,14 @@
  $('#wstep_brix').jqxNumberInput(Spin1dec);
  $('#wstep_brix').on('change', function(event) {
   /* Use plato_to_sg at this stage */
-  var sg = plato_to_sg(parseFloat(event.args.value));
+  var sg = Round(plato_to_sg(parseFloat(event.args.value)), 4);
 console.log('brix: ' + parseFloat(event.args.value) + ' sg: ' + sg);
-  if (sg > 1.005) {
-   var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
-   rowdata.step_sg = sg;
-   $('#wstep_sg').val(sg);
+  var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);
+  if (sg <= 1.005) {
+   sg = 0.0;
   }
+  rowdata.step_sg = sg;
+  $('#wstep_sg').val(sg);
  });
  $('#wramp_time').on('change', function(event) {
   var rowdata = $('#mashGrid').jqxGrid('getrowdata', mashRow);

mercurial