143 for (tmp1 = Config.w1therms; tmp1; tmp1 = tmp1->next) { |
144 for (tmp1 = Config.w1therms; tmp1; tmp1 = tmp1->next) { |
144 fprintf(fp, "w1therm %s %d %s %s\n", tmp1->master, tmp1->bus, tmp1->name, tmp1->alias); |
145 fprintf(fp, "w1therm %s %d %s %s\n", tmp1->master, tmp1->bus, tmp1->name, tmp1->alias); |
145 } |
146 } |
146 fprintf(fp, "\n"); |
147 fprintf(fp, "\n"); |
147 |
148 |
148 fprintf(fp, "# Fermenter Units.\n"); |
|
149 fprintf(fp, "#\n"); |
|
150 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) { |
|
151 fprintf(fp, "unit_uid %s\n", tmp3->uid); |
|
152 if (tmp3->name) |
|
153 fprintf(fp, "unit_name %s\n", tmp3->name); |
|
154 if (tmp3->volume > 0.0) |
|
155 fprintf(fp, "unit_volume %.1f\n", tmp3->volume); |
|
156 if (tmp3->air_address) |
|
157 fprintf(fp, "unit_air_address %s\n", tmp3->air_address); |
|
158 if (tmp3->beer_address) |
|
159 fprintf(fp, "unit_beer_address %s\n", tmp3->beer_address); |
|
160 if (tmp3->io_address) |
|
161 fprintf(fp, "unit_io_address %s\n", tmp3->io_address); |
|
162 fprintf(fp, "unit_heater_available %s\n", tmp3->heater_available ? "yes":"no"); |
|
163 fprintf(fp, "unit_cooler_available %s\n", tmp3->cooler_available ? "yes":"no"); |
|
164 fprintf(fp, "unit_fan_available %s\n", tmp3->fan_available ? "yes":"no"); |
|
165 fprintf(fp, "unit_light_available %s\n", tmp3->light_available ? "yes":"no"); |
|
166 fprintf(fp, "unit_mode %d\n", tmp3->mode); |
|
167 if (tmp3->profile) { |
|
168 fprintf(fp, "unit_profile %s\n", tmp3->profile); |
|
169 fprintf(fp, "unit_prof_started %d\n", (int)tmp3->prof_started); |
|
170 } |
|
171 } |
|
172 fprintf(fp, "\n"); |
|
173 |
|
174 fprintf(fp, "# Control Settings.\n"); |
149 fprintf(fp, "# Control Settings.\n"); |
175 fprintf(fp, "#\n"); |
150 fprintf(fp, "#\n"); |
176 fprintf(fp, "cs_mode %c\n", Config.cs_mode); |
151 fprintf(fp, "cs_mode %c\n", Config.cs_mode); |
177 fprintf(fp, "cs_beerSet %.1f\n", Config.cs_beerSet); |
152 fprintf(fp, "cs_beerSet %.1f\n", Config.cs_beerSet); |
178 fprintf(fp, "cs_fridgeSet %.1f\n", Config.cs_fridgeSet); |
153 fprintf(fp, "cs_fridgeSet %.1f\n", Config.cs_fridgeSet); |
299 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "FERMENTERS")) < 0) { |
278 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "FERMENTERS")) < 0) { |
300 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
279 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
301 return 1; |
280 return 1; |
302 } |
281 } |
303 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) { |
282 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) { |
|
283 /* |
|
284 * Only configuration items are written, measured values and states |
|
285 * are written to a state file. |
|
286 */ |
304 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "UNIT")) < 0) { |
287 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "UNIT")) < 0) { |
305 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
288 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
306 return 1; |
289 return 1; |
307 } |
290 } |
308 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
291 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
309 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
292 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
310 return 1; |
293 return 1; |
311 } |
294 } |
312 |
295 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", Config.units->uuid)) < 0) { |
|
296 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
297 return 1; |
|
298 } |
|
299 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", Config.units->uuid)) < 0) { |
|
300 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
301 return 1; |
|
302 } |
|
303 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", MBSE_SS(Config.units->name))) < 0) { |
|
304 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
305 return 1; |
|
306 } |
|
307 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", Config.units->volume)) < 0) { |
|
308 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
309 return 1; |
|
310 } |
|
311 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", MBSE_SS(Config.units->air_address))) < 0) { |
|
312 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
313 return 1; |
|
314 } |
|
315 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", MBSE_SS(Config.units->beer_address))) < 0) { |
|
316 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
317 return 1; |
|
318 } |
|
319 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO1_ADDRESS", "%s", MBSE_SS(Config.units->io1_address))) < 0) { |
|
320 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
321 return 1; |
|
322 } |
|
323 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO2_ADDRESS", "%s", MBSE_SS(Config.units->io2_address))) < 0) { |
|
324 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
325 return 1; |
|
326 } |
|
327 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER", "%s", Config.units->heater_available ? "YES":"NO")) < 0) { |
|
328 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
329 return 1; |
|
330 } |
|
331 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER", "%s", Config.units->cooler_available? "YES":"NO")) < 0) { |
|
332 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
333 return 1; |
|
334 } |
|
335 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN", "%s", Config.units->fan_available ? "YES":"NO")) < 0) { |
|
336 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
337 return 1; |
|
338 } |
|
339 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[Config.units->mode] )) < 0) { |
|
340 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
341 return 1; |
|
342 } |
|
343 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", Config.units->beer_set)) < 0) { |
|
344 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
345 return 1; |
|
346 } |
|
347 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", Config.units->fridge_set)) < 0) { |
|
348 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
349 return 1; |
|
350 } |
|
351 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", Config.units->temp_set_min)) < 0) { |
|
352 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
353 return 1; |
|
354 } |
|
355 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", Config.units->temp_set_max)) < 0) { |
|
356 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
357 return 1; |
|
358 } |
|
359 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.1f", Config.units->idle_rangeL)) < 0) { |
|
360 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
361 return 1; |
|
362 } |
|
363 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.1f", Config.units->idle_rangeH)) < 0) { |
|
364 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
365 return 1; |
|
366 } |
|
367 if (Config.units->profile) { |
|
368 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", Config.units->profile)) < 0) { |
|
369 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
370 return 1; |
|
371 } |
|
372 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%d", (unsigned int)Config.units->prof_started)) < 0) { |
|
373 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
374 return 1; |
|
375 } |
|
376 } |
313 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
377 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
314 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
378 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
315 return 1; |
379 return 1; |
316 } |
380 } |
317 } |
381 } |