4 */ |
4 */ |
5 |
5 |
6 #include "config.h" |
6 #include "config.h" |
7 |
7 |
8 |
8 |
9 extern sButton Buttons[MAXBUTTONS]; |
9 extern sButton Buttons[MAXBUTTONS]; ///< Buttons definitions |
10 extern int Main_Screen; |
10 extern int Main_Screen; ///< Current screen |
11 |
11 |
12 bool r_UpdateRec = false; |
12 bool r_UpdateRec = false; ///< Update record flag |
13 int r_CurrentRec = 1; |
13 int r_CurrentRec = 1; ///< Current record |
14 int r_Records = 1; |
14 int r_Records = 1; ///< Total records |
15 int r_Imported = 0; |
15 int r_Imported = 0; ///< Total imported |
16 char _xml_element[10][32]; |
16 char _xml_element[10][32]; ///< XML element array |
17 int _xml_depth; |
17 int _xml_depth; ///< Current depths |
18 int _xml_mashsteps; |
18 int _xml_mashsteps; ///< Mash steps |
19 char _xml_add_name[64]; |
19 char _xml_add_name[64]; ///< Mash name |
20 int _xml_add_type; |
20 int _xml_add_type; ///< Mash type |
21 int _xml_add_time; |
21 int _xml_add_time; ///< Mash rest time |
22 int _xml_add_ramp; |
22 int _xml_add_ramp; ///< Mash ramp time |
23 float _xml_add_temp; |
23 float _xml_add_temp; ///< Mash temperature |
24 float _xml_tun_temp; |
24 float _xml_tun_temp; ///< TUN temperature |
25 bool _xml_add_valid; |
25 bool _xml_add_valid; ///< Add is valid |
26 |
26 |
27 static const char *TAG = "recipes"; |
27 static const char *TAG = "recipes"; |
28 |
28 |
29 char char_data_buffer[1024]; |
29 char char_data_buffer[1024]; ///< Data buffer |
30 size_t offs; |
30 size_t offs; ///< Offset in buffer |
31 bool overflow; |
31 bool overflow; ///< Overflow in buffer |
32 |
32 |
33 |
33 |
34 |
34 |
|
35 /** |
|
36 * @brief Add addition to the recipe. |
|
37 * @param Name The addition name. |
|
38 * @param Type The addition type. |
|
39 * @param Time The addition time to add. |
|
40 */ |
35 void Addition_Add(char *Name, uint8_t Type, uint16_t Time) |
41 void Addition_Add(char *Name, uint8_t Type, uint16_t Time) |
36 { |
42 { |
37 printf("Addition_Add(%s, %d, %d)\n", Name, Type, Time); |
43 printf("Addition_Add(%s, %d, %d)\n", Name, Type, Time); |
38 if (! recipe.Additions) { |
44 if (! recipe.Additions) { |
39 // No entries yet, add the first one. |
45 // No entries yet, add the first one. |
78 recipe.Additions++; |
84 recipe.Additions++; |
79 } |
85 } |
80 |
86 |
81 |
87 |
82 |
88 |
|
89 /** |
|
90 * @brief Reset the parser buffer. |
|
91 */ |
83 void reset_char_data_buffer (void) |
92 void reset_char_data_buffer (void) |
84 { |
93 { |
85 offs = 0; |
94 offs = 0; |
86 overflow = false; |
95 overflow = false; |
87 } |
96 } |
88 |
97 |
89 |
98 |
90 |
99 |
91 void char_data (void *userData, const XML_Char *s, int len) |
100 /** |
|
101 * @brief Datahandler get bytes into the data buffer. |
|
102 */ |
|
103 void char_data(void *userData, const XML_Char *s, int len) |
92 { |
104 { |
93 if (!overflow) { |
105 if (!overflow) { |
94 if (len + offs >= sizeof(char_data_buffer) ) { |
106 if (len + offs >= sizeof(char_data_buffer) ) { |
95 overflow = true; |
107 overflow = true; |
96 } else { |
108 } else { |
213 } |
227 } |
214 } |
228 } |
215 |
229 |
216 |
230 |
217 |
231 |
|
232 /** |
|
233 * @brief Start new XML element. |
|
234 * @param userData |
|
235 * @param name XML element name |
|
236 * @param attr XML element attribute |
|
237 */ |
218 void startElement(void *userData, const char *name, const char **attr) |
238 void startElement(void *userData, const char *name, const char **attr) |
219 { |
239 { |
220 sprintf(_xml_element[_xml_depth], "%s", name); |
240 sprintf(_xml_element[_xml_depth], "%s", name); |
221 _xml_depth++; |
241 _xml_depth++; |
222 process_char_data_buffer(); |
242 process_char_data_buffer(); |
223 reset_char_data_buffer(); |
243 reset_char_data_buffer(); |
224 } |
244 } |
225 |
245 |
226 |
246 |
227 |
247 |
|
248 /** |
|
249 * @brief End XML element |
|
250 * @param userData |
|
251 * @param name XML element name |
|
252 */ |
228 void endElement(void *userData, const char *name) |
253 void endElement(void *userData, const char *name) |
229 { |
254 { |
230 process_char_data_buffer(); |
255 process_char_data_buffer(); |
231 reset_char_data_buffer(); |
256 reset_char_data_buffer(); |
232 if ((_xml_depth == 4) && (strcmp("HOP", _xml_element[3]) == 0)) { |
257 if ((_xml_depth == 4) && (strcmp("HOP", _xml_element[3]) == 0)) { |
323 break; |
348 break; |
324 } |
349 } |
325 } |
350 } |
326 } |
351 } |
327 |
352 |
|
353 #if 0 |
328 printf("Recipe: %s\n", recipe.Name); |
354 printf("Recipe: %s\n", recipe.Name); |
329 printf("Code : %s\n", recipe.Code); |
355 printf("Code : %s\n", recipe.Code); |
330 printf("Boil time %d minutes\n", recipe.BoilTime); |
356 printf("Boil time %d minutes\n", recipe.BoilTime); |
331 printf("n Stepname temp time ramp\n"); |
357 printf("n Stepname temp time ramp\n"); |
332 printf("- ------------------------------ ----- ---- ----\n"); |
358 printf("- ------------------------------ ----- ---- ----\n"); |
350 if (recipe.Whirlpool6) |
376 if (recipe.Whirlpool6) |
351 printf("Whirlpool6 %d\n", recipe.Whirlpool6); |
377 printf("Whirlpool6 %d\n", recipe.Whirlpool6); |
352 if (recipe.Whirlpool2) |
378 if (recipe.Whirlpool2) |
353 printf("Whirlpool2 %d\n", recipe.Whirlpool2); |
379 printf("Whirlpool2 %d\n", recipe.Whirlpool2); |
354 printf("SpargeTemp %5.2f\n", recipe.SpargeTemp); |
380 printf("SpargeTemp %5.2f\n", recipe.SpargeTemp); |
|
381 #endif |
355 |
382 |
356 return 0; |
383 return 0; |
357 } |
384 } |
358 |
385 |
359 |
386 |