thermferm/rdconfig.c

Thu, 26 Jun 2014 21:26:33 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 26 Jun 2014 21:26:33 +0200
changeset 83
f99e9d6deff5
parent 82
d48299405980
child 86
3d7a241329e2
permissions
-rw-r--r--

Removed old ascii configuration

51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2014
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of the mbsePi-apps
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * mbsePi-apps is distributed in the hope that it will be useful, but
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with EC-65K; see the file COPYING. If not, write to the Free
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 #include "thermferm.h"
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
26 int debug = FALSE;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 static char *mypath;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 sys_config Config; /* System configuration */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
30 #define MY_ENCODING "utf-8"
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
32 const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" };
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 void killconfig(void)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 {
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 w1_therm *tmp1, *old1;
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
41 units_list *tmp2;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 if (Config.name)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 free(Config.name);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 Config.name = NULL;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 for (tmp1 = Config.w1therms; tmp1; tmp1 = old1) {
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 old1 = tmp1->next;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 if (tmp1->master)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 free(tmp1->master);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 if (tmp1->name)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 free(tmp1->name);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 if (tmp1->alias)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 free(tmp1->alias);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 free(tmp1);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 Config.w1therms = NULL;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 Config.my_port = 6554;
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
59 Config.tempFormat = 'C';
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
60
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
61 for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
62 if (tmp2->uuid)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
63 free(tmp2->uuid);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
64 if (tmp2->name)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
65 free(tmp2->name);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
66 if (tmp2->air_address)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
67 free(tmp2->air_address);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
68 if (tmp2->beer_address)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
69 free(tmp2->beer_address);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
70 if (tmp2->io1_address)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
71 free(tmp2->io1_address);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
72 if (tmp2->io2_address)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
73 free(tmp2->io2_address);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
74 if (tmp2->profile)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
75 free(tmp2->profile);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
76 free(tmp2);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
77 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
78 Config.units = NULL;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 58
diff changeset
80 #ifdef HAVE_WIRINGPI_H
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 Config.lcd_cols = 16;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 Config.lcd_rows = 2;
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 58
diff changeset
83 #endif
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
85 defaultControlSettings();
54
c06190a58f22 More configuration changes. Writing settings implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
86 defaultControlConstants();
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
87 }
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
88
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
89
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
90
83
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
91 int wrconfig(char *confxml)
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
92 {
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
93 int rc = 0;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
94 FILE *fp;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
95 xmlTextWriterPtr writer;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
96 xmlBufferPtr buf;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
97 w1_therm *tmp1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
98 units_list *tmp3;
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
99
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
100 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
101 * Create a new XML buffer, to which the XML document will be written
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
102 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
103 if ((buf = xmlBufferCreate()) == NULL) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
104 syslog(LOG_NOTICE, "wrconfig: error creating the xml buffer");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
105 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
106 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
107
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
108 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
109 * Create a new XmlWriter for memory, with no compression.
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
110 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
111 if ((writer = xmlNewTextWriterMemory(buf, 0)) == NULL) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
112 syslog(LOG_NOTICE, "wrconfig: error creating the xml writer");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
113 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
114 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
115
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
116 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
117 * Use indentation instead of one long line
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
118 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
119 if ((rc = xmlTextWriterSetIndent(writer, 2)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
120 syslog(LOG_NOTICE, "wrconfig: error setting Indent");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
121 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
122 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
123
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
124 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
125 * Start the document with the xml default for the version,
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
126 * encoding ISO 8859-1 and the default for the standalone
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
127 * declaration.
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
128 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
129 if ((rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
130 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartDocument");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
131 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
132 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
133
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
134 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
135 * Start an element named "THERMFERM". Since thist is the first
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
136 * element, this will be the root element of the document.
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
137 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
138 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "THERMFERM")) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
139 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
140 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
141 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
142
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
143 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
144 * Add an attribute with name "VERSION" and value "1" to THERMFERM.
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
145 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
146 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
147 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
148 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
149 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
150 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
151 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
152 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
153 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
154 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMPFORMAT", "%c", Config.tempFormat)) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
155 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
156 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
157 }
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
158
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
159 #ifdef HAVE_WIRINGPI_H
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
160 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
161 * Start an element named "LCDS" as child of THERMFERM.
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
162 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
163 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCDS")) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
164 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
165 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
166 }
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
167 /*
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
168 * Start one LCD. It is possible to connect 7 LCD displays on the i2c bus.
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
169 * However this program doesn't use more then one yet.
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
170 */
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
171 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCD")) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
172 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
173 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
174 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
175 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
176 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
177 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
178 }
78
c49ab5179bf3 Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
179 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "0x%x", Config.lcd_address)) < 0) {
c49ab5179bf3 Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
180 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
c49ab5179bf3 Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
181 return 1;
c49ab5179bf3 Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
182 }
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
183 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COLUMNS", "%d", Config.lcd_cols)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
184 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
185 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
186 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
187 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROWS", "%d", Config.lcd_rows)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
188 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
189 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
190 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
191 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
192 * Close the element named LCD.
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
193 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
194 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
195 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
196 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
197 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
198 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
199 * Close the element LCDS.
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
200 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
201 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
202 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
203 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
204 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
205 #endif
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
206
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
207 /*
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
208 * For backwards compatibility, the old setup
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
209 */
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
210 if (Config.w1therms) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
211 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "W1THERMS")) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
212 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
213 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
214 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
215 for (tmp1 = Config.w1therms; tmp1; tmp1 = tmp1->next) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
216 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "W1THERM")) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
217 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
218 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
219 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
220 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
221 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
222 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
223 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
224 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MASTER", "%s", tmp1->master)) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
225 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
226 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
227 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
228 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUS", "%d", tmp1->bus)) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
229 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
230 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
231 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
232 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp1->name)) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
233 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
234 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
235 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
236 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ALIAS", "%s", tmp1->alias)) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
237 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
238 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
239 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
240 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
241 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
242 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
243 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
244 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
245 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
246 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
247 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
248 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
249 }
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
250
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
251 /*
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
252 * Fermenter units
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
253 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
254 if (Config.units) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
255 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "FERMENTERS")) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
256 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
257 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
258 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
259 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
260 /*
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
261 * Only configuration items are written, measured values and states
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
262 * are written to a state file.
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
263 */
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
264 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "UNIT")) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
265 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
266 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
267 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
268 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
269 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
270 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
271 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
272 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
273 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
274 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
275 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
276 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp3->name)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
277 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
278 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
279 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
280 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", tmp3->volume)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
281 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
282 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
283 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
284 if (tmp3->air_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
285 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
286 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
287 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
288 if (tmp3->beer_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
289 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
290 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
291 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
292 if (tmp3->io1_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO1_ADDRESS", "%s", tmp3->io1_address)) < 0)) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
293 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
294 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
295 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
296 if (tmp3->io2_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO2_ADDRESS", "%s", tmp3->io2_address)) < 0)) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
297 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
298 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
299 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
300 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER", "%s", tmp3->heater_available ? "YES":"NO")) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
301 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
302 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
303 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
304 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER", "%s", tmp3->cooler_available? "YES":"NO")) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
305 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
306 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
307 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
308 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN", "%s", tmp3->fan_available ? "YES":"NO")) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
309 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
310 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
311 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
312 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
313 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
314 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
315 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
316 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", tmp3->beer_set)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
317 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
318 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
319 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
320 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", tmp3->fridge_set)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
321 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
322 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
323 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
324 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", tmp3->temp_set_min)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
325 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
326 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
327 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
328 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
329 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
330 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
331 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
332 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.1f", tmp3->idle_rangeL)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
333 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
334 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
335 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
336 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.1f", tmp3->idle_rangeH)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
337 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
338 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
339 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
340 if (tmp3->profile) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
341 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
342 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
343 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
344 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
345 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%d", (unsigned int)tmp3->prof_started)) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
346 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
347 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
348 }
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
349 }
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
350 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
351 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
352 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
353 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
354 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
355 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
356 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
357 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
358 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
359 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
360
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
361 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
362 * All done, close any open elements
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
363 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
364 if ((rc = xmlTextWriterEndDocument(writer)) < 0) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
365 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndDocument");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
366 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
367 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
368 xmlFreeTextWriter(writer);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
369
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
370 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
371 * Now write the XML configuration
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
372 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
373 if (getenv((char *)"USER") == NULL) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
374 mypath = xstrcpy((char *)"/root");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
375 } else {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
376 mypath = xstrcpy(getenv((char *)"HOME"));
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
377 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
378 mypath = xstrcat(mypath, (char *)"/mbsepi-apps/");
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
379 mypath = xstrcat(mypath, confxml);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
380
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
381 if (debug)
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
382 fprintf(stdout, "Writing %s\n", mypath);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
383
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
384 if ((fp = fopen(mypath, "w")) == NULL) {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
385 syslog(LOG_NOTICE, "could not rewrite %s", mypath);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
386 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
387 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
388
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
389 fprintf(fp, "%s", (const char *) buf->content);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
390 fclose(fp);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
391 xmlBufferFree(buf);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
392
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
393 return rc;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
398 /*
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
399 * Parse one LCD display
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
400 */
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
401 #ifdef HAVE_WIRINGPI_H
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
402 int parseLCD(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
403 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
404 xmlChar *key;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
405 int ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
406
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
407 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
408 while (cur != NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
409 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COLUMNS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
410 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
411 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
412 Config.lcd_cols = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
413 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
414 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
415 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ROWS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
416 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
417 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
418 Config.lcd_rows = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
419 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
420 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
421 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ADDRESS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
422 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
423 if (sscanf((const char *)key, "%x", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
424 Config.lcd_address = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
425 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
426 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
427 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
428 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
429
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
430 return 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
431 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
432
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
433
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
434
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
435 int parseLCDs(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
436 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
437 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
438 while (cur != NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
439 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCD"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
440 parseLCD(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
441 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
442 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
443 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
444 return 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
445 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
446 #endif
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
447
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
448
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
449
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
450 int parseW1therm(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
451 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
452 xmlChar *key;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
453 int ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
454 w1_therm *w1therm, *tmp;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
455
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
456 w1therm = (w1_therm *)malloc(sizeof(w1_therm));
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
457 w1therm->next = NULL;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
458 w1therm->master = w1therm->name = w1therm->alias = NULL;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
459 w1therm->bus = w1therm->present = w1therm->lastval = w1therm->update = 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
460
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
461 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
462 while (cur != NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
463 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
464 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
465 if (xmlStrcmp(key, (const xmlChar *)"1")) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
466 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
467 return 1;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
468 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
469 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
470 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
471 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MASTER"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
472 w1therm->master = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
473 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
474 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BUS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
475 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
476 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
477 w1therm->bus = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
478 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
479 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
480 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
481 w1therm->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
482 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
483 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ALIAS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
484 w1therm->alias = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
485 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
486 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
487 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
488
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
489 if (Config.w1therms == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
490 Config.w1therms = w1therm;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
491 } else {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
492 for (tmp = Config.w1therms; tmp; tmp = tmp->next) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
493 if (tmp->next == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
494 tmp->next = w1therm;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
495 break;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
496 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
497 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
498 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
499
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
500 return 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
501 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
502
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
503
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
504
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
505 int parseW1therms(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
506 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
507 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
508 while (cur != NULL) {
82
d48299405980 Corrected a spelling error in the xml parser
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
509 if ((!xmlStrcmp(cur->name, (const xmlChar *)"W1THERM"))) {
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
510 parseW1therm(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
511 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
512 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
513 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
514 return 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
515 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
516
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
517
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
518
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
519 /*
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
520 * Parse a fermenter unit
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
521 */
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
522 int parseUnit(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
523 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
524 xmlChar *key;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
525 int i, ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
526 float val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
527 units_list *unit, *tmp;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
528
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
529 unit = (units_list *)malloc(sizeof(units_list));
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
530 unit->next = NULL;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
531 unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->io1_address = unit->io2_address = unit->profile = NULL;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
532 unit->volume = 0.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
533 unit->heater_available = unit->cooler_available = unit->fan_available = FALSE;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
534 unit->air_temp = unit->beer_temp = unit->beer_set = unit->fridge_set = 20.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
535 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
536 unit->temp_set_min = 1.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
537 unit->temp_set_max = 30.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
538 unit->idle_rangeH = 1.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
539 unit->idle_rangeL = -1.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
540 unit->prof_started = (time_t)0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
541
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
542 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
543 while (cur != NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
544 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
545 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
546 if (xmlStrcmp(key, (const xmlChar *)"1")) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
547 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
548 return 1;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
549 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
550 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
551 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
552 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
553 unit->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
554 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
555 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
556 unit->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
557 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
558 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VOLUME"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
559 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
560 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
561 unit->volume = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
562 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
563 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
564 if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_ADDRESS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
565 unit->air_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
566 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
567 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_ADDRESS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
568 unit->beer_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
569 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
570 if ((!xmlStrcmp(cur->name, (const xmlChar *)"IO1_ADDRESS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
571 unit->io1_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
572 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
573 if ((!xmlStrcmp(cur->name, (const xmlChar *)"IO2_ADDRESS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
574 unit->io2_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
575 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
576 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
577 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
578 if (! xmlStrcmp(key, (const xmlChar *)"TRUE"))
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
579 unit->heater_available = TRUE;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
580 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
581 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
582 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
583 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
584 if (! xmlStrcmp(key, (const xmlChar *)"TRUE"))
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
585 unit->cooler_available = TRUE;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
586 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
587 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
588 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
589 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
590 if (! xmlStrcmp(key, (const xmlChar *)"TRUE"))
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
591 unit->fan_available = TRUE;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
592 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
593 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
594 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MODE"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
595 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
596 for (i = 0; i < 5; i++) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
597 if (! xmlStrcmp(key, (const xmlChar *)UNITMODE[i])) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
598 unit->mode = i;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
599 break;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
600 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
601 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
602 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
603 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
604 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_SET"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
605 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
606 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
607 unit->beer_set = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
608 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
609 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
610 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_SET"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
611 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
612 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
613 unit->fridge_set = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
614 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
615 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
616 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_SET_MIN"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
617 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
618 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
619 unit->temp_set_min = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
620 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
621 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
622 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_SET_MAX"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
623 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
624 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
625 unit->temp_set_max = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
626 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
627 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
628 if ((!xmlStrcmp(cur->name, (const xmlChar *)"IDLE_RANGE_L"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
629 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
630 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
631 unit->idle_rangeL = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
632 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
633 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
634 if ((!xmlStrcmp(cur->name, (const xmlChar *)"IDLE_RANGE_H"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
635 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
636 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
637 unit->idle_rangeH = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
638 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
639 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
640 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILE"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
641 unit->profile = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
642 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
643 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_STARTED"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
644 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
645 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
646 unit->prof_started = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
647 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
648 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
649 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
650 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
651
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
652 if (Config.units == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
653 Config.units = unit;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
654 } else {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
655 for (tmp = Config.units; tmp; tmp = tmp->next) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
656 if (tmp->next == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
657 tmp->next = unit;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
658 break;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
659 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
660 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
661 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
662
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
663 return 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
664 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
665
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
666
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
667
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
668 int parseFermenters(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
669 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
670 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
671 while (cur != NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
672 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UNIT"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
673 parseUnit(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
674 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
675 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
676 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
677 return 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
678 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
679
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
680
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
681
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
682 int rdconfig(char *config)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683 {
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
684 int rc = 0, ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
685 xmlDocPtr doc;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
686 xmlNodePtr cur;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
687 xmlChar *key;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 killconfig();
56
f7711c6ac93c Workaround for empty environment at system boot
Michiel Broek <mbroek@mbse.eu>
parents: 55
diff changeset
690 syslog(LOG_NOTICE, "HOME='%s' USER='%s' LOGNAME='%s'", MBSE_SS(getenv((char *)"HOME")), MBSE_SS(getenv((char *)"USER")), MBSE_SS(getenv((char *)"LOGNAME")));
f7711c6ac93c Workaround for empty environment at system boot
Michiel Broek <mbroek@mbse.eu>
parents: 55
diff changeset
691
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 /*
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 * Search config file
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 */
56
f7711c6ac93c Workaround for empty environment at system boot
Michiel Broek <mbroek@mbse.eu>
parents: 55
diff changeset
695 if (getenv((char *)"USER") == NULL) {
55
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
696 mypath = xstrcpy((char *)"/root");
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
697 } else {
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
698 mypath = xstrcpy(getenv((char *)"HOME"));
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
699 }
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 mypath = xstrcat(mypath, (char *)"/mbsepi-apps/");
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701 mypath = xstrcat(mypath, config);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
702 if ((doc = xmlParseFile(mypath)) == NULL) {
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 /*
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 * Not in the users home directory
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706 free(mypath);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 mypath = xstrcpy((char *)"/etc/mbsepi-apps/");
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708 mypath = xstrcat(mypath, config);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
709 if ((doc = xmlParseFile(mypath)) == NULL) {
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 /*
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
711 * Try /usr/local/etc
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
713 free(mypath);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
714 mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/");
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715 mypath = xstrcat(mypath, config);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
716 if ((doc = xmlParseFile(mypath)) == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
717 syslog(LOG_NOTICE, "rdconfig: could not parse %s", config);
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718 return 1;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 }
55
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
722 syslog(LOG_NOTICE, "rdconfig: using %s", mypath);
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
724 if ((cur = xmlDocGetRootElement(doc)) == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
725 syslog(LOG_NOTICE, "XML file %s empty.", mypath);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
726 xmlFreeDoc(doc);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
727 return 1;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
728 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
729 if (xmlStrcmp(cur->name, (const xmlChar*)"THERMFERM")) {
83
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
730 syslog(LOG_NOTICE, "XML file %s is not a valid configuration file.", mypath);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
731 xmlFreeDoc(doc);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
732 return 1;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
733 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
734
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
735 /*
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
736 * Parse configuration
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
737 */
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
738 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
739 while (cur != NULL) {
83
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
740 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
741 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
742 if (xmlStrcmp(key, (const xmlChar *)"1")) {
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
743 xmlFree(key);
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
744 syslog(LOG_NOTICE, "XML file %s is not a valid version", mypath);
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
745 return 1;
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
746 }
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
747 xmlFree(key);
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
748 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
749 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LISTEN_PORT"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
750 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
751 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
752 Config.my_port = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
753 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
754 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
755 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMPFORMAT"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
756 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
757 Config.tempFormat = key[0];
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
758 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
759 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
760 #ifdef HAVE_WIRINGPI_H
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
761 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
762 parseLCDs(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
763 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
764 #endif
82
d48299405980 Corrected a spelling error in the xml parser
Michiel Broek <mbroek@mbse.eu>
parents: 80
diff changeset
765 if ((!xmlStrcmp(cur->name, (const xmlChar *)"W1THERMS"))) {
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
766 parseW1therms(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
767 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
768 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FERMENTERS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
769 parseFermenters(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
770 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
771 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
772 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
773 xmlFreeDoc(doc);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
774
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 free(mypath);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
776 mypath = NULL;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
777
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778 return rc;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782

mercurial