thermferm/rdconfig.c

changeset 77
143077e54255
parent 76
d2c7b32f27d6
child 78
c49ab5179bf3
equal deleted inserted replaced
76:d2c7b32f27d6 77:143077e54255
58 {(char *)"cs_mode", getuch, (char **)&Config.cs_mode}, 58 {(char *)"cs_mode", getuch, (char **)&Config.cs_mode},
59 {(char *)"cs_beerSet", getfloat, (char **)&Config.cs_beerSet}, 59 {(char *)"cs_beerSet", getfloat, (char **)&Config.cs_beerSet},
60 {(char *)"cs_fridgeSet", getfloat, (char **)&Config.cs_fridgeSet}, 60 {(char *)"cs_fridgeSet", getfloat, (char **)&Config.cs_fridgeSet},
61 {(char *)"cs_heatEstimator", getfloat, (char **)&Config.cs_heatEstimator}, 61 {(char *)"cs_heatEstimator", getfloat, (char **)&Config.cs_heatEstimator},
62 {(char *)"cs_coolEstimator", getfloat, (char **)&Config.cs_coolEstimator}, 62 {(char *)"cs_coolEstimator", getfloat, (char **)&Config.cs_coolEstimator},
63 {(char *)"cc_tempFormat", getuch, (char **)&Config.cc_tempFormat}, 63 {(char *)"cc_tempFormat", getuch, (char **)&Config.tempFormat},
64 {(char *)"cc_tempSetMin", getfloat, (char **)&Config.cc_tempSetMin}, 64 {(char *)"cc_tempSetMin", getfloat, (char **)&Config.cc_tempSetMin},
65 {(char *)"cc_tempSetMax", getfloat, (char **)&Config.cc_tempSetMax}, 65 {(char *)"cc_tempSetMax", getfloat, (char **)&Config.cc_tempSetMax},
66 {(char *)"cc_idleRangeH", getfloat, (char **)&Config.cc_idleRangeH}, 66 {(char *)"cc_idleRangeH", getfloat, (char **)&Config.cc_idleRangeH},
67 {(char *)"cc_idleRangeL", getfloat, (char **)&Config.cc_idleRangeL}, 67 {(char *)"cc_idleRangeL", getfloat, (char **)&Config.cc_idleRangeL},
68 {NULL, NULL, NULL} 68 {NULL, NULL, NULL}
155 fprintf(fp, "cs_coolEstimator %.1f\n", Config.cs_coolEstimator); 155 fprintf(fp, "cs_coolEstimator %.1f\n", Config.cs_coolEstimator);
156 fprintf(fp, "\n"); 156 fprintf(fp, "\n");
157 157
158 fprintf(fp, "# Control Constants.\n"); 158 fprintf(fp, "# Control Constants.\n");
159 fprintf(fp, "#\n"); 159 fprintf(fp, "#\n");
160 fprintf(fp, "cc_tempFormat %c\n", Config.cc_tempFormat); 160 fprintf(fp, "cc_tempFormat %c\n", Config.tempFormat);
161 fprintf(fp, "cc_tempSetMin %.1f\n", Config.cc_tempSetMin); 161 fprintf(fp, "cc_tempSetMin %.1f\n", Config.cc_tempSetMin);
162 fprintf(fp, "cc_tempSetMax %.1f\n", Config.cc_tempSetMax); 162 fprintf(fp, "cc_tempSetMax %.1f\n", Config.cc_tempSetMax);
163 fprintf(fp, "cc_idleRangeH %.1f\n", Config.cc_idleRangeH); 163 fprintf(fp, "cc_idleRangeH %.1f\n", Config.cc_idleRangeH);
164 fprintf(fp, "cc_idleRangeL %.1f\n", Config.cc_idleRangeL); 164 fprintf(fp, "cc_idleRangeL %.1f\n", Config.cc_idleRangeL);
165 fprintf(fp, "\n"); 165 fprintf(fp, "\n");
219 */ 219 */
220 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { 220 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
221 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 221 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
222 return 1; 222 return 1;
223 } 223 }
224
225 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) { 224 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) {
225 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
226 return 1;
227 }
228 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMPFORMAT", "%c", Config.tempFormat)) < 0) {
226 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 229 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
227 return 1; 230 return 1;
228 } 231 }
229 232
230 #ifdef HAVE_WIRINGPI_H 233 #ifdef HAVE_WIRINGPI_H
268 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 271 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
269 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); 272 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
270 return 1; 273 return 1;
271 } 274 }
272 #endif 275 #endif
276
277 /*
278 * For backwards compatibility, the old setup
279 */
280 if (Config.w1therms) {
281 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "W1THERMS")) < 0) {
282 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
283 return 1;
284 }
285 for (tmp1 = Config.w1therms; tmp1; tmp1 = tmp1->next) {
286 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "W1THERM")) < 0) {
287 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
288 return 1;
289 }
290 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
291 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
292 return 1;
293 }
294 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MASTER", "%s", tmp1->master)) < 0) {
295 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
296 return 1;
297 }
298 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUS", "%d", tmp1->bus)) < 0) {
299 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
300 return 1;
301 }
302 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp1->name)) < 0) {
303 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
304 return 1;
305 }
306 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ALIAS", "%s", tmp1->alias)) < 0) {
307 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
308 return 1;
309 }
310 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
311 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
312 return 1;
313 }
314 }
315 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
316 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
317 return 1;
318 }
319 }
273 320
274 /* 321 /*
275 * Fermenter units 322 * Fermenter units
276 */ 323 */
277 if (Config.units) { 324 if (Config.units) {
290 } 337 }
291 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { 338 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
292 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); 339 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
293 return 1; 340 return 1;
294 } 341 }
295 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", Config.units->uuid)) < 0) { 342 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) {
296 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 343 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
297 return 1; 344 return 1;
298 } 345 }
299 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", Config.units->uuid)) < 0) { 346 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", MBSE_SS(tmp3->name))) < 0) {
300 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 347 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
301 return 1; 348 return 1;
302 } 349 }
303 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", MBSE_SS(Config.units->name))) < 0) { 350 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", tmp3->volume)) < 0) {
304 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 351 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
305 return 1; 352 return 1;
306 } 353 }
307 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", Config.units->volume)) < 0) { 354 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", MBSE_SS(tmp3->air_address))) < 0) {
308 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 355 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
309 return 1; 356 return 1;
310 } 357 }
311 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", MBSE_SS(Config.units->air_address))) < 0) { 358 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", MBSE_SS(tmp3->beer_address))) < 0) {
312 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 359 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
313 return 1; 360 return 1;
314 } 361 }
315 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", MBSE_SS(Config.units->beer_address))) < 0) { 362 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO1_ADDRESS", "%s", MBSE_SS(tmp3->io1_address))) < 0) {
316 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 363 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
317 return 1; 364 return 1;
318 } 365 }
319 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO1_ADDRESS", "%s", MBSE_SS(Config.units->io1_address))) < 0) { 366 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO2_ADDRESS", "%s", MBSE_SS(tmp3->io2_address))) < 0) {
320 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 367 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
321 return 1; 368 return 1;
322 } 369 }
323 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO2_ADDRESS", "%s", MBSE_SS(Config.units->io2_address))) < 0) { 370 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER", "%s", tmp3->heater_available ? "YES":"NO")) < 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"); 371 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
329 return 1; 372 return 1;
330 } 373 }
331 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER", "%s", Config.units->cooler_available? "YES":"NO")) < 0) { 374 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER", "%s", tmp3->cooler_available? "YES":"NO")) < 0) {
332 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 375 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
333 return 1; 376 return 1;
334 } 377 }
335 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN", "%s", Config.units->fan_available ? "YES":"NO")) < 0) { 378 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN", "%s", tmp3->fan_available ? "YES":"NO")) < 0) {
336 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 379 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
337 return 1; 380 return 1;
338 } 381 }
339 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[Config.units->mode] )) < 0) { 382 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) {
340 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 383 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
341 return 1; 384 return 1;
342 } 385 }
343 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", Config.units->beer_set)) < 0) { 386 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", tmp3->beer_set)) < 0) {
344 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 387 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
345 return 1; 388 return 1;
346 } 389 }
347 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", Config.units->fridge_set)) < 0) { 390 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", tmp3->fridge_set)) < 0) {
348 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 391 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
349 return 1; 392 return 1;
350 } 393 }
351 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", Config.units->temp_set_min)) < 0) { 394 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", tmp3->temp_set_min)) < 0) {
352 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 395 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
353 return 1; 396 return 1;
354 } 397 }
355 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", Config.units->temp_set_max)) < 0) { 398 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) {
356 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 399 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
357 return 1; 400 return 1;
358 } 401 }
359 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.1f", Config.units->idle_rangeL)) < 0) { 402 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.1f", tmp3->idle_rangeL)) < 0) {
360 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 403 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
361 return 1; 404 return 1;
362 } 405 }
363 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.1f", Config.units->idle_rangeH)) < 0) { 406 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.1f", tmp3->idle_rangeH)) < 0) {
364 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 407 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
365 return 1; 408 return 1;
366 } 409 }
367 if (Config.units->profile) { 410 if (tmp3->profile) {
368 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", Config.units->profile)) < 0) { 411 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) {
369 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 412 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
370 return 1; 413 return 1;
371 } 414 }
372 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%d", (unsigned int)Config.units->prof_started)) < 0) { 415 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%d", (unsigned int)tmp3->prof_started)) < 0) {
373 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 416 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
374 return 1; 417 return 1;
375 } 418 }
376 } 419 }
377 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 420 if ((rc = xmlTextWriterEndElement(writer)) < 0) {

mercurial