Added extra mash step fields for infusion steps. Added these fields in recipe import too.

Thu, 25 Oct 2018 17:36:02 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 25 Oct 2018 17:36:02 +0200
changeset 15
34b1eb93e71a
parent 14
9fbdf8e0bd52
child 16
d43b393a4461

Added extra mash step fields for infusion steps. Added these fields in recipe import too.

main/config.c file | annotate | diff | comparison | revisions
main/config.h file | annotate | diff | comparison | revisions
main/recipes.c file | annotate | diff | comparison | revisions
--- a/main/config.c	Wed Oct 24 23:17:41 2018 +0200
+++ b/main/config.c	Thu Oct 25 17:36:02 2018 +0200
@@ -426,14 +426,21 @@
 	sprintf(recipe.Name, "Recipe 1");
 	sprintf(recipe.Code, "001");
 	sprintf(recipe.MashStep[0].Name, "Mash-in");
-	recipe.MashStep[0].Temperature = 67.5;
+	recipe.MashStep[0].Type = MASHTYPE_INFUSION;
+	recipe.MashStep[0].Temperature = recipe.MashStep[0].Infusion_temp = 67.5;
+	recipe.MashStep[0].Infusion_amount = 15.0;
 	recipe.MashStep[0].Resttime = 1;
+	recipe.MashStep[0].Ramptime = 1;
 	sprintf(recipe.MashStep[1].Name, "Mash");
+	recipe.MashStep[1].Type = MASHTYPE_TEMPERATURE;
 	recipe.MashStep[1].Temperature = 67.0;
 	recipe.MashStep[1].Resttime = 75;
+	recipe.MashStep[1].Ramptime = 1;
 	sprintf(recipe.MashStep[7].Name, "Mash-out");
+	recipe.MashStep[7].Type = MASHTYPE_TEMPERATURE;
 	recipe.MashStep[7].Temperature = 78.0; 
 	recipe.MashStep[7].Resttime = 5;
+	recipe.MashStep[7].Ramptime = 11;
 	recipe.BoilTime = 60;
 	recipe.Additions = 2;
 	sprintf(recipe.Addition[0].Name, "Hop");
--- a/main/config.h	Wed Oct 24 23:17:41 2018 +0200
+++ b/main/config.h	Thu Oct 25 17:36:02 2018 +0200
@@ -325,6 +325,15 @@
 
 
 /**
+ * @brief Mash step type
+ */
+typedef enum {
+    MASHTYPE_INFUSION = 0,
+    MASHTYPE_TEMPERATURE,
+    MASHTYPE_DECOCTION,
+} MASHSTEP_TYPE;
+
+/**
  * @brief Addition types
  */
 typedef enum {
@@ -343,9 +352,12 @@
  */
 typedef struct strMashStep {
     char		Name[32];			///< Step name.
+    uint8_t		Type;				///< Step Type.
     float		Temperature;			///< Step temperature.
     uint16_t		Resttime;			///< Step resttime.
-    uint16_t		Steptime;			///< Step time to reach temp.
+    uint16_t		Ramptime;			///< Step time to reach temp.
+    float		Infusion_amount;		///< Infusion amount in liters.
+    float		Infusion_temp;			///< Infusion temperature.
 } mashstep_t;
 
 /**
--- a/main/recipes.c	Wed Oct 24 23:17:41 2018 +0200
+++ b/main/recipes.c	Thu Oct 25 17:36:02 2018 +0200
@@ -26,6 +26,8 @@
 int                             _xml_add_time;			///< Mash rest time
 int				_xml_add_ramp;			///< Mash ramp time
 float				_xml_add_temp;			///< Mash temperature
+float				_xml_add_amount;		///< Mash infusion amount
+float				_xml_add_infusion;		///< Mash infusion temperature
 float				_xml_tun_temp;			///< TUN temperature
 bool                            _xml_add_valid;			///< Add is valid
 
@@ -214,12 +216,22 @@
 		    } else if (strcmp("TYPE", _xml_element[5]) == 0) {
 			// Temperature Infusion Decoction
 			_xml_add_valid = (strcmp("Temperature", char_data_buffer) == 0);
+			if (strcmp("Infusion", char_data_buffer) == 0)
+			    _xml_add_type = MASHTYPE_INFUSION;
+			else if (strcmp("Temperature", char_data_buffer) == 0)
+			    _xml_add_type = MASHTYPE_TEMPERATURE;
+			else if (strcmp("Decoction", char_data_buffer) == 0)
+			    _xml_add_type = MASHTYPE_DECOCTION;
 		    } else if (strcmp("STEP_TEMP", _xml_element[5]) == 0) {
 			_xml_add_temp = atof(char_data_buffer);
 		    } else if (strcmp("STEP_TIME", _xml_element[5]) == 0) {
 			_xml_add_time = atoi(char_data_buffer);
 		    } else if (strcmp("RAMP_TIME", _xml_element[5]) == 0) {
 			_xml_add_ramp = atoi(char_data_buffer);
+		    } else if (strcmp("INFUSE_AMOUNT", _xml_element[5]) == 0) {
+			_xml_add_amount = atof(char_data_buffer);
+		    } else if (strcmp("INFUSE_TEMP", _xml_element[5]) == 0) {
+			_xml_add_infusion = atof(char_data_buffer);
 		    }
 		} else if ((_xml_depth >= 4) && (strcmp("TUN_TEMP", _xml_element[3]) == 0)) {
 		    // Save this and check later if this is the strike temperature.
@@ -278,9 +290,17 @@
 //	printf("Flush End MASH_STEP %d %s\n", _xml_depth, _xml_add_name);
 	_xml_mashsteps++;
 	sprintf(recipe.MashStep[_xml_mashsteps].Name, "%s", _xml_add_name);
+	recipe.MashStep[_xml_mashsteps].Type = _xml_add_type;
 	recipe.MashStep[_xml_mashsteps].Temperature = _xml_add_temp;
 	recipe.MashStep[_xml_mashsteps].Resttime = _xml_add_time;
-	recipe.MashStep[_xml_mashsteps].Steptime = _xml_add_ramp;
+	recipe.MashStep[_xml_mashsteps].Ramptime = _xml_add_ramp;
+	if (_xml_add_type == MASHTYPE_INFUSION) {
+	    recipe.MashStep[_xml_mashsteps].Infusion_temp = _xml_add_infusion;
+	    recipe.MashStep[_xml_mashsteps].Infusion_amount = _xml_add_amount;
+	} else {
+	    recipe.MashStep[_xml_mashsteps].Infusion_temp = 0.0;
+	    recipe.MashStep[_xml_mashsteps].Infusion_amount = 0.0;
+	}
     }
     _xml_depth--;
 }
@@ -344,27 +364,34 @@
 		// Got it, move.
 		sprintf(recipe.MashStep[7].Name, "%s", recipe.MashStep[i].Name);
 		recipe.MashStep[i].Name[0] = '\0';
+		recipe.MashStep[7].Type = recipe.MashStep[i].Type;
+		recipe.MashStep[i].Type = 0;
 		recipe.MashStep[7].Temperature = recipe.MashStep[i].Temperature;
 		recipe.MashStep[i].Temperature = 0.0;
 		recipe.MashStep[7].Resttime = recipe.MashStep[i].Resttime;
 		recipe.MashStep[i].Resttime = 0;
-		recipe.MashStep[7].Steptime = recipe.MashStep[i].Steptime;
-		recipe.MashStep[i].Steptime = 0;
+		recipe.MashStep[7].Ramptime = recipe.MashStep[i].Ramptime;
+		recipe.MashStep[i].Ramptime = 0;
+		recipe.MashStep[7].Infusion_temp = recipe.MashStep[i].Infusion_temp;
+		recipe.MashStep[i].Infusion_temp = 0.0;
+		recipe.MashStep[7].Infusion_amount = recipe.MashStep[i].Infusion_amount;
+		recipe.MashStep[i].Infusion_amount = 0.0;
 		break;
 	    }
 	}
     }
 
-#if 0
+#if 1
     printf("Recipe: %s\n", recipe.Name);
     printf("Code  : %s\n", recipe.Code);
     printf("Boil time %d minutes\n", recipe.BoilTime);
-    printf("n Stepname                         temp time ramp\n");
-    printf("- ------------------------------  ----- ---- ----\n");
+    printf("n Stepname                       T  temp time ramp  inft  infa\n");
+    printf("- ------------------------------ - ----- ---- ---- ----- -----\n");
     for (int i = 0; i < 8; i++) {
         if (recipe.MashStep[i].Resttime) {
-            printf("%d %-31s %5.2f %4d %4d\n", i, recipe.MashStep[i].Name, recipe.MashStep[i].Temperature,
-                            recipe.MashStep[i].Resttime, recipe.MashStep[i].Steptime);
+            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].Temperature,
+                            recipe.MashStep[i].Resttime, recipe.MashStep[i].Ramptime,
+			    recipe.MashStep[i].Infusion_temp, recipe.MashStep[i].Infusion_amount);
         }
     }
     printf("%d additions\n", recipe.Additions);
@@ -676,16 +703,16 @@
 			    sprintf(tmp, "Maisch stap %d rusttijd in minuten", i);
 			    EditUint16(tmp, &recipe.MashStep[i].Resttime, 1, 480);
 			    if (i == 1) {
-				recipe.MashStep[i].Steptime = 1;
+				recipe.MashStep[i].Ramptime = 1;
 			    } else {
-				recipe.MashStep[i].Steptime = (int)(recipe.MashStep[i].Temperature - recipe.MashStep[i - 1].Temperature);
+				recipe.MashStep[i].Ramptime = (int)(recipe.MashStep[i].Temperature - recipe.MashStep[i - 1].Temperature);
 			    }
 			}
 			mintemp = recipe.MashStep[mashsteps].Temperature;
 			EditFloat("Uitmaischen temperatuur", &recipe.MashStep[7].Temperature, mintemp, 80, 2);
 			recipe.MashStep[7].Temperature = ((int)(recipe.MashStep[7].Temperature * 4)) / 4.0;
 			EditUint16("Uitmaischen tijd in minuten", &recipe.MashStep[7].Resttime, 1, 15);
-			recipe.MashStep[7].Steptime = (int)(recipe.MashStep[7].Temperature - recipe.MashStep[mashsteps].Temperature);
+			recipe.MashStep[7].Ramptime = (int)(recipe.MashStep[7].Temperature - recipe.MashStep[mashsteps].Temperature);
 			// Zero any higher steps to diable them.
 			for (int i = (mashsteps + 1); i < 7; i++)
 			    recipe.MashStep[i].Resttime = 0;

mercurial