main/recipes.c

changeset 114
1413c4c5cd8c
parent 93
24cb415af787
child 116
bafc2d6a0790
--- a/main/recipes.c	Thu Jul 29 19:57:41 2021 +0200
+++ b/main/recipes.c	Thu Jul 29 22:36:17 2021 +0200
@@ -301,16 +301,28 @@
     if ((_xml_depth == 5) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) {
 	recipe.MashStep[recipe.Mashsteps].Name[0] = '\0';
 	strncat(recipe.MashStep[recipe.Mashsteps].Name, _xml_add_name, 31);
-	recipe.MashStep[recipe.Mashsteps].Type = _xml_add_type;
 	recipe.MashStep[recipe.Mashsteps].Step_temp = _xml_add_temp;
 	recipe.MashStep[recipe.Mashsteps].Step_time = _xml_add_time;
 	recipe.MashStep[recipe.Mashsteps].Ramp_time = _xml_add_ramp;
-	recipe.MashStep[recipe.Mashsteps].End_temp = _xml_add_end;
+	recipe.MashStep[recipe.Mashsteps].End_temp = (_xml_add_end > 0.0) ?  _xml_add_end : _xml_add_temp;
+	/*
+	 * Fix problems created by Brewfather and possible others that say that
+	 * the first mash step is a temperature step. It just isn't.
+	 */
+	if (_xml_add_type == MASHTYPE_TEMPERATURE && recipe.Mashsteps == 0) {
+	    _xml_add_type = MASHTYPE_INFUSION;
+	    _xml_add_infusion = _xml_add_temp + 1.25;
+	    recipe.MashStep[recipe.Mashsteps].Ramp_time = 1;
+	}
+	recipe.MashStep[recipe.Mashsteps].Type = _xml_add_type;
+	if (_xml_add_ramp == 0 && recipe.Mashsteps) {
+	    recipe.MashStep[recipe.Mashsteps].Ramp_time = (uint16_t)(_xml_add_temp - recipe.MashStep[recipe.Mashsteps - 1].End_temp) + 1;
+	}
 	if (_xml_add_type == MASHTYPE_INFUSION) {
 	    recipe.MashStep[recipe.Mashsteps].Infuse_temp = _xml_add_infusion;
 	    recipe.MashStep[recipe.Mashsteps].Infuse_amount = _xml_add_amount;
 	} else if (_xml_add_type == MASHTYPE_DECOCTION) {
-	    recipe.MashStep[recipe.Mashsteps].Infuse_temp = 0.0;
+	    recipe.MashStep[recipe.Mashsteps].Infuse_temp = 98.0;
 	    recipe.MashStep[recipe.Mashsteps].Infuse_amount = _xml_add_amount;
 	} else {
 	    recipe.MashStep[recipe.Mashsteps].Infuse_temp = 0.0;
@@ -335,7 +347,9 @@
     int done;
     _xml_depth = 0;
     _xml_tun_temp = 0.0;
+    _xml_add_infusion = 0.0;
     recipe.CoolTemp = 20.0;
+    recipe.SpargeTemp = equipment.TempHLT;
 
     XML_SetElementHandler(parser, startElement, endElement);
     XML_SetCharacterDataHandler(parser, char_data);
@@ -371,11 +385,12 @@
     printf("Recipe: %s\n", recipe.Name);
     printf("Code  : %s\n", recipe.Code);
     printf("Boil time %d minutes\n", recipe.BoilTime);
-    printf("n Stepname                       T  temp time ramp  inft  infa\n");
-    printf("- ------------------------------ - ----- ---- ---- ----- -----\n");
+    printf("n Stepname                       T  temp   end time ramp  inft  infa\n");
+    printf("- ------------------------------ - ----- ----- ---- ---- ----- -----\n");
     for (int i = 0; i < 8; i++) {
         if (recipe.MashStep[i].Step_time) {
-            printf("%d %-30s %d %5.2f %4d %4d %5.2f %5.2f\n", i, recipe.MashStep[i].Name, recipe.MashStep[i].Type, recipe.MashStep[i].Step_temp,
+            printf("%d %-30s %d %5.2f %5.2f %4d %4d %5.2f %5.2f\n", i, recipe.MashStep[i].Name, recipe.MashStep[i].Type,
+			    recipe.MashStep[i].Step_temp, recipe.MashStep[i].End_temp,
                             recipe.MashStep[i].Step_time, recipe.MashStep[i].Ramp_time,
 			    recipe.MashStep[i].Infuse_temp, recipe.MashStep[i].Infuse_amount);
         }

mercurial