Fixed some mess in water calculations.

Thu, 24 Mar 2022 15:46:36 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 24 Mar 2022 15:46:36 +0100
changeset 789
e6e696add0b3
parent 788
812ce4c5da2a
child 790
98bd22f6629b

Fixed some mess in water calculations.

www/export_equipments.php file | annotate | diff | comparison | revisions
www/js/prod_edit.js file | annotate | diff | comparison | revisions
--- a/www/export_equipments.php	Sat Mar 05 22:32:48 2022 +0100
+++ b/www/export_equipments.php	Thu Mar 24 15:46:36 2022 +0100
@@ -79,7 +79,7 @@
         xmlwriter_end_element($xw);
 
 	xmlwriter_start_element($xw, 'CALC_BOIL_VOLUME');
-        ($row['calc_boil_volume'] > 1) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE');
+        ($row['calc_boil_volume'] > 0) ? xmlwriter_text($xw, 'TRUE') : xmlwriter_text($xw, 'FALSE');
         xmlwriter_end_element($xw);
 
         xmlwriter_start_element($xw, 'TOP_UP_KETTLE');
--- a/www/js/prod_edit.js	Sat Mar 05 22:32:48 2022 +0100
+++ b/www/js/prod_edit.js	Thu Mar 24 15:46:36 2022 +0100
@@ -1728,6 +1728,7 @@
     calcYeast();
     calcInit();
     calcMash();
+    calcWater();
     kookTijd();
     console.log('calculations ready');
     $('#jqxLoader').jqxLoader('close');
@@ -2306,6 +2307,11 @@
     $('#mashGrid').jqxGrid('updaterow', i, row);
    }
   }
+  if ((dataRecord.w1_amount + dataRecord.w2_amount) == 0) {
+    dataRecord.w1_amount = infused;
+    $('#w1_amount').val(infused);
+    console.log("calcMash() fixed water 1 to " + infused);
+  }
   mashvol = Round(mashkg * MaltVolume + infused, 6);
   $('#est_mashvol').val(mashvol);
   h = Math.floor(mashtime / 60);
@@ -2942,7 +2948,7 @@
 
  function adjustWaters(factor) {
 
-  //console.log('adjustWaters(' + factor + ')');
+  console.log('adjustWaters(' + factor + ')');
   var amount, row, i, rowscount = dataRecord.mashs.length;
   if (rowscount == 0)
    return;
@@ -3227,7 +3233,8 @@
   }
 
   // If there is a dillute water source, mix the waters.
-  if (dataRecord.w2_name != '') {
+  if ((dataRecord.w2_name != '') && (dataRecord.w2_name != 'Geen mengwater')) {
+console.log("calcWater() mixed " + dataRecord.w2_name);
    liters = dataRecord.w1_amount + dataRecord.w2_amount;
    calcium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_calcium, dataRecord.w2_calcium);
    magnesium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_magnesium, dataRecord.w2_magnesium);
@@ -3237,6 +3244,7 @@
    total_alkalinity = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_total_alkalinity, dataRecord.w2_total_alkalinity);
    ph = -Math.log10(((Math.pow(10, -dataRecord.w1_ph) * dataRecord.w1_amount) + (Math.pow(10, -dataRecord.w2_ph) * dataRecord.w2_amount)) / liters);
   } else {
+console.log("calcWater() single");
    liters = dataRecord.w1_amount;
    calcium = dataRecord.w1_calcium;
    magnesium = dataRecord.w1_magnesium;
@@ -4049,6 +4057,7 @@
   $('#w1_name').jqxDropDownList('selectItem', dataRecord.w1_name);
   $('#w2_name').jqxDropDownList('selectItem', dataRecord.w2_name);
   // Fix tap water if zero using mash infuse amount.
+console.log("mash_infuse: " + mash_infuse + " w1: " + parseFloat($('#w1_amount').jqxNumberInput('decimal')) + " " + dataRecord.w1_amount);
   if (parseFloat($('#w1_amount').jqxNumberInput('decimal')) == 0 && mash_infuse > 0) {
    $('#w1_amount').val(mash_infuse);
    dataRecord.w1_amount = mash_infuse;
@@ -5855,7 +5864,7 @@
    $('#wg_amount').val(mash_infuse);
    console.log('new infuse amount: ' + mash_infuse);
    calcWater();
-//   calcMash();
+   calcMash();
   }
  });
  $('#wstep_infuse_temp').on('change', function(event) {

mercurial