Sun, 27 Dec 2015 16:09:44 +0100
Updated several prompts. Added pump prime. Added first part of a test plan.
441 | 1 | /***************************************************************************** |
2 | * Copyright (C) 2015 | |
3 | * | |
4 | * Michiel Broek <mbroek at mbse dot eu> | |
5 | * | |
6 | * This file is part of the mbsePi-apps | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * mbsePi-apps is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free | |
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
21 | *****************************************************************************/ | |
22 | ||
23 | #include "brewco.h" | |
24 | #include "rdsession.h" | |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
444
diff
changeset
|
25 | #include "util.h" |
441 | 26 | #include "xutil.h" |
27 | ||
28 | extern int debug; | |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
29 | extern char *etcpath; |
441 | 30 | |
31 | ||
475
bec993331061
Updated several prompts. Added pump prime. Added first part of a test plan.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
32 | const char BREWSTEP[16][11] = { "NA", "BREWINIT", "WATERCHECK", "PUMPPRIME", "WAITSTART", |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
33 | "PREMASH", "MASHING", "REMOVE", "PREBOIL", "BOIL", |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
34 | "BOILDONE", "COOLING", "HOPSTAND", "WHIRLPOOL", "CLEANUP", |
475
bec993331061
Updated several prompts. Added pump prime. Added first part of a test plan.
Michiel Broek <mbroek@mbse.eu>
parents:
474
diff
changeset
|
35 | "BREWDONE" }; |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
36 | const char MASHSTEP[8][11] = { "MASH-IN", "PHYTASE", "GLUCANASE", "PROTEASE", "B-AMYLASE", "A-AMYLASE1", "A-AMYLASE2", "MASH-OUT" }; |
441 | 37 | |
38 | #define MY_ENCODING "utf-8" | |
39 | ||
40 | ||
474
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
41 | char *brewstep_name(int val) |
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
42 | { |
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
43 | static char text[41]; |
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
44 | |
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
45 | snprintf(text, 20, BREWSTEP[val]); |
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
46 | return text; |
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
47 | } |
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
48 | |
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
49 | |
441 | 50 | int do_wrsession(brew_session *brew); |
51 | int do_wrsession(brew_session *brew) | |
52 | { | |
53 | int rc = 0; | |
54 | FILE *fp; | |
55 | char *mypath = NULL; | |
56 | xmlTextWriterPtr writer; | |
57 | xmlBufferPtr buf; | |
58 | ||
59 | /* | |
60 | * Create a new XML buffer, to which the XML document will be written | |
61 | */ | |
62 | if ((buf = xmlBufferCreate()) == NULL) { | |
63 | syslog(LOG_NOTICE, "wrsession: error creating the xml buffer"); | |
64 | return 1; | |
65 | } | |
66 | ||
67 | /* | |
68 | * Create a new XmlWriter for memory, with no compression. | |
69 | */ | |
70 | if ((writer = xmlNewTextWriterMemory(buf, 0)) == NULL) { | |
71 | syslog(LOG_NOTICE, "wrsession: error creating the xml writer"); | |
72 | return 1; | |
73 | } | |
74 | ||
75 | /* | |
76 | * Use indentation instead of one long line | |
77 | */ | |
78 | if ((rc = xmlTextWriterSetIndent(writer, 2)) < 0) { | |
79 | syslog(LOG_NOTICE, "wrsession: error setting Indent"); | |
80 | return 1; | |
81 | } | |
82 | ||
83 | /* | |
84 | * Start the document with the xml default for the version, | |
85 | * encoding ISO 8859-1 and the default for the standalone | |
86 | * declaration. | |
87 | */ | |
88 | if ((rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0) { | |
89 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterStartDocument"); | |
90 | return 1; | |
91 | } | |
92 | ||
93 | /* | |
94 | * Start an element named "BREWCO". Since thist is the first | |
95 | * element, this will be the root element of the document. | |
96 | */ | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
97 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "BREWCO")) < 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
98 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterStartElement"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
99 | return 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
100 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
101 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "BREW")) < 0) { |
441 | 102 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterStartElement"); |
103 | return 1; | |
104 | } | |
105 | ||
106 | /* | |
107 | * Add an attribute with name "VERSION" and value "1" to BRWCO. | |
108 | */ | |
109 | if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { | |
110 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteElement"); | |
111 | return 1; | |
112 | } | |
113 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID_RECIPE", "%s", brew->uuid_recipe)) < 0) { | |
114 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteFormatElement"); | |
115 | return 1; | |
116 | } | |
117 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID_UNIT", "%s", brew->uuid_unit)) < 0) { | |
118 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteFormatElement"); | |
119 | return 1; | |
120 | } | |
472
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
470
diff
changeset
|
121 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", brew->name)) < 0) { |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
470
diff
changeset
|
122 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteFormatElement"); |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
470
diff
changeset
|
123 | return 1; |
55bcbf92ecab
Added initial part of the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
470
diff
changeset
|
124 | } |
444
eafb140a1ddd
Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents:
441
diff
changeset
|
125 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BREWSTEP", "%s", BREWSTEP[brew->brewstep])) < 0) { |
441 | 126 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteElement"); |
127 | return 1; | |
128 | } | |
444
eafb140a1ddd
Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents:
441
diff
changeset
|
129 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MASHSTEP", "%s", MASHSTEP[brew->mashstep])) < 0) { |
441 | 130 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteElement"); |
131 | return 1; | |
132 | } | |
444
eafb140a1ddd
Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents:
441
diff
changeset
|
133 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMEOUT", "%d", brew->timeout)) < 0) { |
441 | 134 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteElement"); |
135 | return 1; | |
136 | } | |
137 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BOILTIMER", "%d", brew->boiltimer)) < 0) { | |
138 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteElement"); | |
139 | return 1; | |
140 | } | |
141 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STARTTIME", "%d", (int)brew->starttime)) < 0) { | |
142 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteElement"); | |
143 | return 1; | |
144 | } | |
145 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENDTIME", "%d", (int)brew->endtime)) < 0) { | |
146 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterWriteElement"); | |
147 | return 1; | |
148 | } | |
149 | ||
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
150 | /* |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
151 | * Close the element named BREW. |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
152 | */ |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
153 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
154 | syslog(LOG_NOTICE, "wrrecipes: error at xmlTextWriterEndElement"); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
155 | return 1; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
156 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
157 | |
441 | 158 | /* |
159 | * All done, close any open elements | |
160 | */ | |
161 | if ((rc = xmlTextWriterEndDocument(writer)) < 0) { | |
162 | syslog(LOG_NOTICE, "wrsession: error at xmlTextWriterEndDocument"); | |
163 | return 1; | |
164 | } | |
165 | xmlFreeTextWriter(writer); | |
166 | ||
167 | /* | |
168 | * Now write the XML configuration | |
169 | */ | |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
170 | mypath = xstrcpy(etcpath); |
441 | 171 | mypath = xstrcat(mypath, (char *)"brewing.xml"); |
172 | ||
173 | if (debug) | |
174 | fprintf(stdout, "Writing %s\n", mypath); | |
175 | ||
176 | if ((fp = fopen(mypath, "w")) == NULL) { | |
177 | syslog(LOG_NOTICE, "could not rewrite %s", mypath); | |
178 | free(mypath); | |
179 | return 1; | |
180 | } | |
181 | free(mypath); | |
182 | ||
183 | fprintf(fp, "%s", (const char *) buf->content); | |
184 | fclose(fp); | |
185 | xmlBufferFree(buf); | |
186 | ||
187 | return 0; | |
188 | } | |
189 | ||
190 | ||
191 | ||
192 | int wrsession(brew_session *brew) | |
193 | { | |
194 | int rc; | |
195 | ||
196 | rc = do_wrsession(brew); | |
474
fe1c3e3e90dc
Improved steps logging. Some small fixes in the brew automation.
Michiel Broek <mbroek@mbse.eu>
parents:
473
diff
changeset
|
197 | // syslog(LOG_NOTICE, "Rewritten brewsession, rc=%d", rc); |
441 | 198 | return rc; |
199 | } | |
200 | ||
201 | ||
202 | ||
203 | /* | |
204 | * Returns: | |
205 | * 0 - All is well, session loaded. | |
206 | * 1 - Something went wrong | |
207 | * -1 - No brew session available | |
208 | */ | |
209 | int rdsession(brew_session *brew) | |
210 | { | |
444
eafb140a1ddd
Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents:
441
diff
changeset
|
211 | int i, ival; |
441 | 212 | char *mypath; |
213 | xmlDocPtr doc; | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
214 | xmlNodePtr cur, s1cur; |
441 | 215 | xmlChar *key; |
216 | ||
217 | /* | |
218 | * Search config file | |
219 | */ | |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
446
diff
changeset
|
220 | mypath = xstrcpy(etcpath); |
441 | 221 | mypath = xstrcat(mypath, (char *)"brewing.xml"); |
222 | ||
223 | /* | |
224 | * See if we have a brewing state file. | |
225 | */ | |
226 | if (file_exist(mypath, W_OK)) { | |
227 | syslog(LOG_NOTICE, "rdsession: %s not found, good.", mypath); | |
228 | free(mypath); | |
229 | return -1; | |
230 | } | |
231 | ||
232 | if ((doc = xmlParseFile(mypath)) == NULL) { | |
233 | syslog(LOG_NOTICE, "rdsession: %s not found, should not happen.", mypath); | |
234 | free(mypath); | |
235 | return -1; | |
236 | } | |
237 | syslog(LOG_NOTICE, "rdsession: using %s", mypath); | |
238 | ||
239 | if ((cur = xmlDocGetRootElement(doc)) == NULL) { | |
240 | syslog(LOG_NOTICE, "XML file %s empty.", mypath); | |
241 | xmlFreeDoc(doc); | |
242 | return 1; | |
243 | } | |
244 | if (xmlStrcmp(cur->name, (const xmlChar*)"BREWCO")) { | |
245 | syslog(LOG_NOTICE, "XML file %s is not a valid configuration file.", mypath); | |
246 | xmlFreeDoc(doc); | |
247 | return 1; | |
248 | } | |
249 | ||
250 | /* | |
251 | * Parse session | |
252 | */ | |
253 | cur = cur->xmlChildrenNode; | |
254 | while (cur != NULL) { | |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
255 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
256 | if ((! xmlStrcmp(cur->name, (const xmlChar*)"BREW"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
257 | s1cur = cur->xmlChildrenNode; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
258 | while (s1cur != NULL) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
259 | |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
260 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"UUID_RECIPE"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
261 | brew->uuid_recipe = (char *)xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
262 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
263 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"UUID_UNIT"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
264 | brew->uuid_unit = (char *)xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
444
eafb140a1ddd
Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents:
441
diff
changeset
|
265 | } |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
266 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"NAME"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
267 | brew->name = (char *)xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
268 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
269 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"BREWSTEP"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
270 | key = xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
271 | for (i = 0; i < 15; i++) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
272 | if (! xmlStrcmp(key, (const xmlChar *)BREWSTEP[i])) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
273 | brew->brewstep = i; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
274 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
275 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
276 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
277 | xmlFree(key); |
444
eafb140a1ddd
Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents:
441
diff
changeset
|
278 | } |
473
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
279 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"MASHSTEP"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
280 | key = xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
281 | for (i = 0; i < 8; i++) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
282 | if (! xmlStrcmp(key, (const xmlChar *)MASHSTEP[i])) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
283 | brew->mashstep = i; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
284 | break; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
285 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
286 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
287 | xmlFree(key); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
288 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
289 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"TIMEOUT"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
290 | key = xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
291 | if (sscanf((const char *)key, "%d", &ival) == 1) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
292 | brew->timeout = ival; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
293 | xmlFree(key); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
294 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
295 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"BOILTIMER"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
296 | key = xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
297 | if (sscanf((const char *)key, "%d", &ival) == 1) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
298 | brew->boiltimer = ival; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
299 | xmlFree(key); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
300 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
301 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"STARTTIME"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
302 | key = xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
303 | if (sscanf((const char *)key, "%d", &ival) == 1) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
304 | brew->starttime = (time_t)ival; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
305 | xmlFree(key); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
306 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
307 | if ((!xmlStrcmp(s1cur->name, (const xmlChar *)"ENDTIME"))) { |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
308 | key = xmlNodeListGetString(doc, s1cur->xmlChildrenNode, 1); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
309 | if (sscanf((const char *)key, "%d", &ival) == 1) |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
310 | brew->endtime = (time_t)ival; |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
311 | xmlFree(key); |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
312 | } |
fdd30e935079
The brew state machine is complete, works but is not bugfree
Michiel Broek <mbroek@mbse.eu>
parents:
472
diff
changeset
|
313 | s1cur = s1cur->next; |
444
eafb140a1ddd
Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents:
441
diff
changeset
|
314 | } |
441 | 315 | } |
316 | cur = cur->next; | |
317 | } | |
318 | xmlFreeDoc(doc); | |
319 | ||
320 | free(mypath); | |
321 | mypath = NULL; | |
322 | ||
323 | return 0; | |
324 | } | |
325 | ||
326 | ||
327 |