main/recipes.c

changeset 114
1413c4c5cd8c
parent 93
24cb415af787
child 116
bafc2d6a0790
equal deleted inserted replaced
113:ac0c31c38959 114:1413c4c5cd8c
299 } 299 }
300 } 300 }
301 if ((_xml_depth == 5) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) { 301 if ((_xml_depth == 5) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) {
302 recipe.MashStep[recipe.Mashsteps].Name[0] = '\0'; 302 recipe.MashStep[recipe.Mashsteps].Name[0] = '\0';
303 strncat(recipe.MashStep[recipe.Mashsteps].Name, _xml_add_name, 31); 303 strncat(recipe.MashStep[recipe.Mashsteps].Name, _xml_add_name, 31);
304 recipe.MashStep[recipe.Mashsteps].Type = _xml_add_type;
305 recipe.MashStep[recipe.Mashsteps].Step_temp = _xml_add_temp; 304 recipe.MashStep[recipe.Mashsteps].Step_temp = _xml_add_temp;
306 recipe.MashStep[recipe.Mashsteps].Step_time = _xml_add_time; 305 recipe.MashStep[recipe.Mashsteps].Step_time = _xml_add_time;
307 recipe.MashStep[recipe.Mashsteps].Ramp_time = _xml_add_ramp; 306 recipe.MashStep[recipe.Mashsteps].Ramp_time = _xml_add_ramp;
308 recipe.MashStep[recipe.Mashsteps].End_temp = _xml_add_end; 307 recipe.MashStep[recipe.Mashsteps].End_temp = (_xml_add_end > 0.0) ? _xml_add_end : _xml_add_temp;
308 /*
309 * Fix problems created by Brewfather and possible others that say that
310 * the first mash step is a temperature step. It just isn't.
311 */
312 if (_xml_add_type == MASHTYPE_TEMPERATURE && recipe.Mashsteps == 0) {
313 _xml_add_type = MASHTYPE_INFUSION;
314 _xml_add_infusion = _xml_add_temp + 1.25;
315 recipe.MashStep[recipe.Mashsteps].Ramp_time = 1;
316 }
317 recipe.MashStep[recipe.Mashsteps].Type = _xml_add_type;
318 if (_xml_add_ramp == 0 && recipe.Mashsteps) {
319 recipe.MashStep[recipe.Mashsteps].Ramp_time = (uint16_t)(_xml_add_temp - recipe.MashStep[recipe.Mashsteps - 1].End_temp) + 1;
320 }
309 if (_xml_add_type == MASHTYPE_INFUSION) { 321 if (_xml_add_type == MASHTYPE_INFUSION) {
310 recipe.MashStep[recipe.Mashsteps].Infuse_temp = _xml_add_infusion; 322 recipe.MashStep[recipe.Mashsteps].Infuse_temp = _xml_add_infusion;
311 recipe.MashStep[recipe.Mashsteps].Infuse_amount = _xml_add_amount; 323 recipe.MashStep[recipe.Mashsteps].Infuse_amount = _xml_add_amount;
312 } else if (_xml_add_type == MASHTYPE_DECOCTION) { 324 } else if (_xml_add_type == MASHTYPE_DECOCTION) {
313 recipe.MashStep[recipe.Mashsteps].Infuse_temp = 0.0; 325 recipe.MashStep[recipe.Mashsteps].Infuse_temp = 98.0;
314 recipe.MashStep[recipe.Mashsteps].Infuse_amount = _xml_add_amount; 326 recipe.MashStep[recipe.Mashsteps].Infuse_amount = _xml_add_amount;
315 } else { 327 } else {
316 recipe.MashStep[recipe.Mashsteps].Infuse_temp = 0.0; 328 recipe.MashStep[recipe.Mashsteps].Infuse_temp = 0.0;
317 recipe.MashStep[recipe.Mashsteps].Infuse_amount = 0.0; 329 recipe.MashStep[recipe.Mashsteps].Infuse_amount = 0.0;
318 } 330 }
333 XML_Parser parser = XML_ParserCreate(NULL); 345 XML_Parser parser = XML_ParserCreate(NULL);
334 346
335 int done; 347 int done;
336 _xml_depth = 0; 348 _xml_depth = 0;
337 _xml_tun_temp = 0.0; 349 _xml_tun_temp = 0.0;
350 _xml_add_infusion = 0.0;
338 recipe.CoolTemp = 20.0; 351 recipe.CoolTemp = 20.0;
352 recipe.SpargeTemp = equipment.TempHLT;
339 353
340 XML_SetElementHandler(parser, startElement, endElement); 354 XML_SetElementHandler(parser, startElement, endElement);
341 XML_SetCharacterDataHandler(parser, char_data); 355 XML_SetCharacterDataHandler(parser, char_data);
342 356
343 FILE *fp = fopen(fn, "r"); 357 FILE *fp = fopen(fn, "r");
369 383
370 #if 0 384 #if 0
371 printf("Recipe: %s\n", recipe.Name); 385 printf("Recipe: %s\n", recipe.Name);
372 printf("Code : %s\n", recipe.Code); 386 printf("Code : %s\n", recipe.Code);
373 printf("Boil time %d minutes\n", recipe.BoilTime); 387 printf("Boil time %d minutes\n", recipe.BoilTime);
374 printf("n Stepname T temp time ramp inft infa\n"); 388 printf("n Stepname T temp end time ramp inft infa\n");
375 printf("- ------------------------------ - ----- ---- ---- ----- -----\n"); 389 printf("- ------------------------------ - ----- ----- ---- ---- ----- -----\n");
376 for (int i = 0; i < 8; i++) { 390 for (int i = 0; i < 8; i++) {
377 if (recipe.MashStep[i].Step_time) { 391 if (recipe.MashStep[i].Step_time) {
378 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, 392 printf("%d %-30s %d %5.2f %5.2f %4d %4d %5.2f %5.2f\n", i, recipe.MashStep[i].Name, recipe.MashStep[i].Type,
393 recipe.MashStep[i].Step_temp, recipe.MashStep[i].End_temp,
379 recipe.MashStep[i].Step_time, recipe.MashStep[i].Ramp_time, 394 recipe.MashStep[i].Step_time, recipe.MashStep[i].Ramp_time,
380 recipe.MashStep[i].Infuse_temp, recipe.MashStep[i].Infuse_amount); 395 recipe.MashStep[i].Infuse_temp, recipe.MashStep[i].Infuse_amount);
381 } 396 }
382 } 397 }
383 printf("%d additions\n", recipe.Additions); 398 printf("%d additions\n", recipe.Additions);

mercurial