thermferm/rdconfig.c

Thu, 07 Aug 2014 22:06:18 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 07 Aug 2014 22:06:18 +0200
changeset 194
9eaaba49450f
parent 191
c74bbc24a1c8
child 206
78fb6f99e473
permissions
-rw-r--r--

Added some ideas about profiles.

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
106
1bd9a16f5061 Added .h files
Michiel Broek <mbroek@mbse.eu>
parents: 101
diff changeset
23 #include "rdconfig.h"
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 #include "thermferm.h"
106
1bd9a16f5061 Added .h files
Michiel Broek <mbroek@mbse.eu>
parents: 101
diff changeset
25 #include "futil.h"
1bd9a16f5061 Added .h files
Michiel Broek <mbroek@mbse.eu>
parents: 101
diff changeset
26 #include "xutil.h"
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
28 int debug = FALSE;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 static char *mypath;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 sys_config Config; /* System configuration */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
32 #define MY_ENCODING "utf-8"
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
34 const char TEMPSTATE[3][8] = { "OK", "MISSING", "ERROR" };
90
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
35 const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" };
95
2c28afc329a5 Removed old brewPi settings
Michiel Broek <mbroek@mbse.eu>
parents: 92
diff changeset
36 const char UNITmode[5] = { 'o', 'n', 'f', 'b', 'p' };
90
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
37 const char PROFSTATE[4][6] = { "OFF", "PAUSE", "RUN", "DONE" };
158
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
38 const char DEVTYPE[7][6] = { "NA", "W1", "GPIO", "RC433", "DHT", "I2C", "SPI" };
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
39 const char DEVPRESENT[4][6] = { "UNDEF", "NO", "YES", "ERROR" };
162
6fc9e3f7962f Added Raspberry GPIO devices
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
40 const char DEVDIR[7][11] = { "UNDEF", "IN_BIN", "OUT_BIN", "IN_ANALOG", "OUT_ANALOG", "OUT_PWM", "INTERN" };
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41
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
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 void killconfig(void)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 {
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
46 units_list *tmp2;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
47 profiles_list *tmp3;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
48 prof_step *tmp4;
161
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
49 devices_list *device;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 if (Config.name)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 free(Config.name);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 Config.name = NULL;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 Config.my_port = 6554;
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
56 Config.tempFormat = 'C';
95
2c28afc329a5 Removed old brewPi settings
Michiel Broek <mbroek@mbse.eu>
parents: 92
diff changeset
57 if (Config.air_address)
2c28afc329a5 Removed old brewPi settings
Michiel Broek <mbroek@mbse.eu>
parents: 92
diff changeset
58 free(Config.air_address);
2c28afc329a5 Removed old brewPi settings
Michiel Broek <mbroek@mbse.eu>
parents: 92
diff changeset
59 Config.air_address = NULL;
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
60 Config.air_temperature = 20000;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
61 Config.air_state = 1; // missing
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
62
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
63 for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
64 if (tmp2->uuid)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
65 free(tmp2->uuid);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
66 if (tmp2->name)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
67 free(tmp2->name);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
68 if (tmp2->air_address)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
69 free(tmp2->air_address);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
70 if (tmp2->beer_address)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
71 free(tmp2->beer_address);
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
72 if (tmp2->heater_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
73 free(tmp2->heater_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
74 if (tmp2->cooler_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
75 free(tmp2->cooler_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
76 if (tmp2->fan_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
77 free(tmp2->fan_address);
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
78 if (tmp2->door_address)
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
79 free(tmp2->door_address);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
80 if (tmp2->profile)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
81 free(tmp2->profile);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
82 free(tmp2);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
83 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
84 Config.units = NULL;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
86 for (tmp3 = Config.profiles; tmp3; tmp3 = tmp3->next) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
87 if (tmp3->uuid)
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
88 free(tmp3->uuid);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
89 if (tmp3->name)
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
90 free(tmp3->name);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
91 if (tmp3->steps) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
92 for (tmp4 = tmp3->steps; tmp4; tmp4 = tmp4->next) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
93 free(tmp4);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
94 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
95 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
96 free(tmp3);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
97 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
98 Config.profiles = NULL;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
99
161
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
100 for (device = Config.devices; device; device = device->next) {
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
101 if (device->uuid)
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
102 free(device->uuid);
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
103 if (device->address)
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
104 free(device->address);
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
105 if (device->description)
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
106 free(device->description);
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
107 if (device->comment)
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
108 free(device->comment);
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
109 free(device);
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
110 }
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
111 Config.devices = NULL;
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
112
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 58
diff changeset
113 #ifdef HAVE_WIRINGPI_H
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 Config.lcd_cols = 16;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 Config.lcd_rows = 2;
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 58
diff changeset
116 #endif
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
117 }
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
118
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
119
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
120
166
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
121 int do_wrconfig(void);
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
122 int do_wrconfig(void)
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
123 {
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
124 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
125 FILE *fp;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
126 xmlTextWriterPtr writer;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
127 xmlBufferPtr buf;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
128 units_list *tmp3;
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
129 profiles_list *tmp4;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
130 prof_step *tmp5;
158
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
131 devices_list *device;
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
132
75
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 * 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
135 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
136 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
137 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
138 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
139 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
140
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 * 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
143 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
144 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
145 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
146 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
147 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
148
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 * 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
151 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
152 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
153 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
154 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
155 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
156
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
157 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
158 * 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
159 * 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
160 * declaration.
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
161 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
162 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
163 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
164 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
165 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
166
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
167 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
168 * 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
169 * 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
170 */
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 "THERMFERM")) < 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
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
176 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
177 * 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
178 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
179 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
180 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
181 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
182 }
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 "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
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 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
187 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
188 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
189 return 1;
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
190 }
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
191 if (Config.air_address) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
192 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", Config.air_address)) < 0) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
193 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
194 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
195 }
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
196 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", Config.air_state)) < 0) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
197 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
198 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
199 }
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
200 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", Config.air_temperature)) < 0) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
201 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
202 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
203 }
95
2c28afc329a5 Removed old brewPi settings
Michiel Broek <mbroek@mbse.eu>
parents: 92
diff changeset
204 }
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
205
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
206 #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
207 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
208 * 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
209 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
210 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
211 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
212 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
213 }
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
214 /*
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
215 * 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
216 * 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
217 */
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
218 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
219 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
220 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
221 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
222 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
223 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
224 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
225 }
78
c49ab5179bf3 Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
226 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
227 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
c49ab5179bf3 Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
228 return 1;
c49ab5179bf3 Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
229 }
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
230 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
231 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
232 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
233 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
234 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
235 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
236 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
237 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
238 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
239 * 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
240 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
241 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
242 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
243 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
244 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
245 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
246 * 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
247 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
248 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
249 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
250 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
251 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
252 #endif
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 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
255 * Fermenter units
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
256 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
257 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
258 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
259 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
260 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
261 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
262 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
263 /*
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
264 * 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
265 * are written to a state file.
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
266 */
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
267 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
268 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
269 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
270 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
271 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
272 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
273 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
274 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
275 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
276 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
277 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
278 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
279 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
280 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
281 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
282 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
283 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
284 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
285 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
286 }
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
287 if (tmp3->air_address) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
288 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
289 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
290 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
291 }
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
292 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", tmp3->air_state)) < 0)) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
293 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
294 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
295 }
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
296 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
297 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
298 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
299 }
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
300 }
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
301 if (tmp3->beer_address) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
302 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
303 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
304 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
305 }
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
306 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_STATE", "%d", tmp3->beer_state)) < 0)) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
307 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
308 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
309 }
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
310 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
311 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
312 return 1;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
313 }
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
314 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
315 if (tmp3->heater_address) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
316 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
317 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
318 return 1;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
319 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
320 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", tmp3->heater_state)) < 0)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
321 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
322 return 1;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
323 }
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
324 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
325 if (tmp3->cooler_address) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
326 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
327 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
328 return 1;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
329 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
330 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", tmp3->cooler_state)) < 0)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
331 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
332 return 1;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
333 }
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
334 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
335 if (tmp3->fan_address) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
336 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
337 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
338 return 1;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
339 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
340 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_STATE", "%d", tmp3->fan_state)) < 0)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
341 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
342 return 1;
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
343 }
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
344 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
345 if (tmp3->door_address) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
346 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
347 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
348 return 1;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
349 }
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
350 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
351 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
352 return 1;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
353 }
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
354 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
355 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
356 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
357 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
358 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
359 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
360 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
361 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
362 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
363 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
364 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
365 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
366 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
367 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
368 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
369 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
370 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
371 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
372 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
373 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
374 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
375 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
376 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
377 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
378 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
379 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
380 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
381 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
382 }
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
383 if (tmp3->profile) {
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
384 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
385 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
386 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
387 }
90
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
388 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STARTED", "%d", (unsigned int)tmp3->prof_started)) < 0) {
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
389 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
390 return 1;
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
391 }
194
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
392 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PAUSED", "%d", (unsigned int)tmp3->prof_paused)) < 0) {
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
393 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
394 return 1;
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
395 }
90
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
396 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STATE", "%s", PROFSTATE[tmp3->prof_state] )) < 0) {
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
397 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
398 return 1;
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
399 }
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
400 }
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
401 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
402 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
403 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
404 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
405 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
406 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
407 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
408 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
409 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
410 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
411
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
412 /*
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
413 * Fermenting profiles
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
414 */
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
415 if (Config.profiles) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
416 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILES")) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
417 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
418 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
419 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
420 for (tmp4 = Config.profiles; tmp4; tmp4 = tmp4->next) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
421 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILE")) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
422 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
423 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
424 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
425 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
426 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
427 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
428 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
429 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp4->uuid)) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
430 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
431 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
432 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
433 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp4->name)) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
434 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
435 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
436 }
136
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
437 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUSY", "%d", tmp4->busy)) < 0) {
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
438 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
439 return 1;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
440 }
191
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
441 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) {
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
442 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
443 return 1;
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
444 }
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
445 if (tmp4->steps) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
446 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEPS")) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
447 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
448 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
449 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
450 for (tmp5 = tmp4->steps; tmp5; tmp5 = tmp5->next) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
451 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEP")) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
452 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
453 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
454 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
455 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
456 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
457 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
458 }
92
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
459 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "RESTTIME", "%d", tmp5->resttime)) < 0) {
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
460 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
461 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
462 }
92
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
463 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STEPTIME", "%d", tmp5->steptime)) < 0) {
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
464 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
465 return 1;
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
466 }
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
467 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
468 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
469 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
470 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
471 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
472 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
473 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
474 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
475 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
476 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
477 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
478 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
479 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
480 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
481 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
482 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
483 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
484 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
485 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
486 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
487 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
488 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
489 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
490 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
491
158
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
492 if (Config.devices) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
493 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICES")) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
494 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
495 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
496 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
497 for (device = Config.devices; device; device = device->next) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
498 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICE")) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
499 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
500 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
501 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
502 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", device->version)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
503 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
504 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
505 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
506 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
507 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
508 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
509 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
510 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type])) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
511 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
512 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
513 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
514 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction])) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
515 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
516 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
517 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
518 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VALUE", "%d", device->value)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
519 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
520 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
521 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
522 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRESENT", "%s", DEVPRESENT[device->present])) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
523 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
524 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
525 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
526 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "%s", device->address)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
527 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
528 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
529 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
530 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SUBDEVICE", "%d", device->subdevice)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
531 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
532 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
533 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
534 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "GPIOPIN", "%d", device->gpiopin)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
535 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
536 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
537 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
538 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DESCRIPTION", "%s", device->description)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
539 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
540 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
541 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
542 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
543 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
544 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
545 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
546 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
547 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
548 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
549 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
550 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
551 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
552 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
553 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
554 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
555 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
556 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
557 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
558 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
559
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
560 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
561 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
562 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
563 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
564 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
565
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
566 /*
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
567 * 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
568 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
569 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
570 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
571 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
572 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
573 xmlFreeTextWriter(writer);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
574
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
575 /*
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
576 * 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
577 */
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
578 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
579 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
580 } else {
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
581 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
582 }
86
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
583 mypath = xstrcat(mypath, (char *)"/.thermferm/etc/");
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
584 mkdirs(mypath, 0755);
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
585 mypath = xstrcat(mypath, (char *)"thermferm.xml");
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
586
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
587 if (debug)
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
588 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
589
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
590 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
591 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
592 return 1;
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
593 }
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
594
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
595 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
596 fclose(fp);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
597 xmlBufferFree(buf);
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
598
166
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
599 return 0;
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
600 }
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
601
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
602
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
603
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
604 int wrconfig(void)
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
605 {
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
606 int rc;
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
607
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
608 rc = do_wrconfig();
c31ea86fec43 Forgot some close functions so tha program ran out of file descriptors. Better loggin for writing the configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 165
diff changeset
609 syslog(LOG_NOTICE, "Rewritten configuration, rc=%d", rc);
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
610 return rc;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
614
80
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 * Parse one LCD display
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
617 */
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
618 #ifdef HAVE_WIRINGPI_H
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
619 int parseLCD(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
620 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
621 xmlChar *key;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
622 int ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
623
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
624 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
625 while (cur != NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
626 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COLUMNS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
627 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
628 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
629 Config.lcd_cols = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
630 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
631 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
632 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ROWS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
633 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
634 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
635 Config.lcd_rows = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
636 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
637 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
638 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ADDRESS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
639 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
640 if (sscanf((const char *)key, "%x", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
641 Config.lcd_address = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
642 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
643 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
644 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
645 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
646
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
647 return 0;
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
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 int parseLCDs(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
653 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
654 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
655 while (cur != NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
656 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCD"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
657 parseLCD(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
658 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
659 cur = cur->next;
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 return 0;
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 #endif
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 * Parse a fermenter unit
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 int parseUnit(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
671 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
672 xmlChar *key;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
673 int i, ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
674 float val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
675 units_list *unit, *tmp;
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 unit = (units_list *)malloc(sizeof(units_list));
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
678 unit->next = NULL;
90
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
679 unit->version = 1;
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
680 unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->heater_address = \
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
681 unit->cooler_address = unit->fan_address = unit->door_address = unit->profile = NULL;
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
682 unit->volume = 0.0;
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
683 unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
684 unit->air_state = unit->beer_state = 1; // missing
90
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
685 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0;
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
686 unit->temp_set_min = 1.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
687 unit->temp_set_max = 30.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
688 unit->idle_rangeH = 1.0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
689 unit->idle_rangeL = -1.0;
194
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
690 unit->prof_started = unit->prof_paused = (time_t)0;
185
4f34271cf1e7 PID finetuning
Michiel Broek <mbroek@mbse.eu>
parents: 176
diff changeset
691 unit->PID_err_old = unit->PID_I_err = 0.0;
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
692
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
693 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
694 while (cur != NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
695 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
696 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
697 if (xmlStrcmp(key, (const xmlChar *)"1")) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
698 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
699 return 1;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
700 }
90
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
701 unit->version = 1;
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
702 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
703 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
704 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
705 unit->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
706 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
707 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
708 unit->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
709 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
710 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VOLUME"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
711 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
712 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
713 unit->volume = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
714 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
715 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
716 if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_ADDRESS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
717 unit->air_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
718 }
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
719 if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_STATE"))) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
720 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
721 if (sscanf((const char *)key, "%d", &ival) == 1)
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
722 unit->air_state = ival;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
723 xmlFree(key);
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
724 }
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
725 if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_TEMPERATURE"))) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
726 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
727 if (sscanf((const char *)key, "%d", &ival) == 1)
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
728 unit->air_temperature = ival;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
729 xmlFree(key);
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
730 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
731 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_ADDRESS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
732 unit->beer_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
733 }
101
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
734 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_STATE"))) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
735 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
736 if (sscanf((const char *)key, "%d", &ival) == 1)
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
737 unit->beer_state = ival;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
738 xmlFree(key);
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
739 }
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
740 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_TEMPERATURE"))) {
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
741 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
742 if (sscanf((const char *)key, "%d", &ival) == 1)
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
743 unit->beer_temperature = ival;
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
744 xmlFree(key);
1302abe92eb1 Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
745 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
746 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_ADDRESS"))) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
747 unit->heater_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
748 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
749 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_ADDRESS"))) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
750 unit->cooler_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
751 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
752 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN_ADDRESS"))) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
753 unit->fan_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
754 }
175
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
755 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_ADDRESS"))) {
b73490398368 Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents: 174
diff changeset
756 unit->door_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
757 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
758 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MODE"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
759 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
760 for (i = 0; i < 5; i++) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
761 if (! xmlStrcmp(key, (const xmlChar *)UNITMODE[i])) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
762 unit->mode = i;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
763 break;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
764 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
765 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
766 xmlFree(key);
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 *)"BEER_SET"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
769 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
770 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
771 unit->beer_set = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
772 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
773 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
774 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_SET"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
775 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
776 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
777 unit->fridge_set = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
778 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
779 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
780 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_SET_MIN"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
781 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
782 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
783 unit->temp_set_min = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
784 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
785 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
786 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_SET_MAX"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
787 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
788 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
789 unit->temp_set_max = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
790 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
791 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
792 if ((!xmlStrcmp(cur->name, (const xmlChar *)"IDLE_RANGE_L"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
793 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
794 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
795 unit->idle_rangeL = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
796 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
797 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
798 if ((!xmlStrcmp(cur->name, (const xmlChar *)"IDLE_RANGE_H"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
799 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
800 if (sscanf((const char *)key, "%f", &val) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
801 unit->idle_rangeH = val;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
802 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
803 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
804 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILE"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
805 unit->profile = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
806 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
807 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_STARTED"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
808 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
809 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
810 unit->prof_started = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
811 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
812 }
194
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
813 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_PAUSED"))) {
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
814 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
815 if (sscanf((const char *)key, "%d", &ival) == 1)
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
816 unit->prof_paused = ival;
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
817 xmlFree(key);
9eaaba49450f Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents: 191
diff changeset
818 }
90
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
819 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_STATE"))) {
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
820 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
821 for (i = 0; i < 4; i++) {
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
822 if (! xmlStrcmp(key, (const xmlChar *)PROFSTATE[i])) {
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
823 unit->prof_state = i;
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
824 break;
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
825 }
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
826 }
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
827 xmlFree(key);
28ee293654fd Added profile parameters
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
828 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
829 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
830 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
831
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
832 if (Config.units == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
833 Config.units = unit;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
834 } else {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
835 for (tmp = Config.units; tmp; tmp = tmp->next) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
836 if (tmp->next == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
837 tmp->next = unit;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
838 break;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
839 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
840 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
841 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
842
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
843 return 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
844 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
845
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
846
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
847
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
848 int parseFermenters(xmlDocPtr doc, xmlNodePtr cur)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
849 {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
850 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
851 while (cur != NULL) {
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
852 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UNIT"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
853 parseUnit(doc, cur);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
854 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
855 cur = cur->next;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
856 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
857 return 0;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
858 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
859
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
860
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
861
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
862 int parseStep(xmlDocPtr doc, xmlNodePtr cur, prof_step **profstep)
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
863 {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
864 xmlChar *key;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
865 int ival;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
866 float val;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
867 prof_step *step, *tmp;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
868
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
869 step = (prof_step *)malloc(sizeof(prof_step));
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
870 step->next = NULL;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
871 step->version = 1;
92
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
872 step->steptime = step->resttime = 0;
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
873 step->target = 20.0;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
874
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
875 cur = cur->xmlChildrenNode;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
876 while (cur != NULL) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
877 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
878 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
879 if (xmlStrcmp(key, (const xmlChar *)"1")) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
880 xmlFree(key);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
881 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
882 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
883 step->version = 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
884 xmlFree(key);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
885 }
92
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
886 if ((!xmlStrcmp(cur->name, (const xmlChar *)"RESTTIME"))) {
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
887 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
888 if (sscanf((const char *)key, "%d", &ival) == 1)
92
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
889 step->resttime = ival;
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
890 xmlFree(key);
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
891 }
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
892 if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEPTIME"))) {
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
893 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
894 if (sscanf((const char *)key, "%d", &ival) == 1)
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
895 step->steptime = ival;
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
896 xmlFree(key);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
897 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
898 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
899 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
900 if (sscanf((const char *)key, "%f", &val) == 1)
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
901 step->target = val;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
902 xmlFree(key);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
903 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
904 cur = cur->next;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
905 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
906
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
907 if (*profstep == NULL) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
908 *profstep = step;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
909 } else {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
910 for (tmp = *profstep; tmp; tmp = tmp->next) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
911 if (tmp->next == NULL) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
912 tmp->next = step;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
913 break;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
914 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
915 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
916 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
917 return 0;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
918 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
919
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
920
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
921
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
922 int parseSteps(xmlDocPtr doc, xmlNodePtr cur, prof_step **step)
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
923 {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
924 cur = cur->xmlChildrenNode;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
925 while (cur != NULL) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
926 if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEP"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
927 parseStep(doc, cur, step);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
928 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
929 cur = cur->next;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
930 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
931 return 0;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
932 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
933
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
934
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
935
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
936 int parseProfile(xmlDocPtr doc, xmlNodePtr cur)
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
937 {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
938 xmlChar *key;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
939 profiles_list *profile, *tmp;
136
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
940 int ival;
191
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
941 float fval;
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
942
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
943 profile = (profiles_list *)malloc(sizeof(profiles_list));
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
944 profile->next = NULL;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
945 profile->version = 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
946 profile->uuid = profile->name = NULL;
136
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
947 profile->busy = 0;
191
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
948 profile->inittemp = 20.0;
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
949 profile->steps = NULL;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
950
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
951 cur = cur->xmlChildrenNode;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
952 while (cur != NULL) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
953 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
954 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
955 if (xmlStrcmp(key, (const xmlChar *)"1")) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
956 xmlFree(key);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
957 return 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
958 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
959 profile->version = 1;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
960 xmlFree(key);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
961 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
962 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
963 profile->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
964 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
965 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
966 profile->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
967 }
136
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
968 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BUSY"))) {
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
969 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
970 if (sscanf((const char *)key, "%d", &ival) == 1)
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
971 profile->busy = ival;
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
972 xmlFree(key);
264e5ee5abfc Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
973 }
191
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
974 if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP"))) {
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
975 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
976 if (sscanf((const char *)key, "%f", &fval) == 1)
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
977 profile->inittemp = fval;
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
978 xmlFree(key);
c74bbc24a1c8 Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents: 185
diff changeset
979 }
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
980 if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEPS"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
981 parseSteps(doc, cur, &(profile)->steps);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
982 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
983 cur = cur->next;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
984 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
985
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
986 if (Config.profiles == NULL) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
987 Config.profiles = profile;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
988 } else {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
989 for (tmp = Config.profiles; tmp; tmp = tmp->next) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
990 if (tmp->next == NULL) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
991 tmp->next = profile;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
992 break;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
993 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
994 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
995 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
996
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
997 return 0;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
998 }
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
999
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1000
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1001
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1002 int parseProfiles(xmlDocPtr doc, xmlNodePtr cur)
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1003 {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1004 cur = cur->xmlChildrenNode;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1005 while (cur != NULL) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1006 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILE"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1007 parseProfile(doc, cur);
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1008 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1009 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1010 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1011 return 0;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1012 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1013
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1014
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1015
158
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1016 int parseDevice(xmlDocPtr doc, xmlNodePtr cur)
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1017 {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1018 xmlChar *key;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1019 devices_list *device, *tmp;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1020 int i, ival;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1021
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1022 device = (devices_list *)malloc(sizeof(devices_list));
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1023 device->next = NULL;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1024 device->version = 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1025 device->uuid = device->address = device->description = device->comment = NULL;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1026 device->type = device->direction = device->present = device->subdevice = device->inuse = 0;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1027 device->gpiopin = -1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1028 device->timestamp = (time_t)0;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1029
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1030 cur = cur->xmlChildrenNode;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1031 while (cur != NULL) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1032 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1033 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1034 if (xmlStrcmp(key, (const xmlChar *)"1")) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1035 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1036 return 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1037 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1038 device->version = 1;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1039 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1040 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1041 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1042 device->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1043 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1044 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TYPE"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1045 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1046 for (i = 0; i < 7; i++) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1047 if (! xmlStrcmp(key, (const xmlChar *)DEVTYPE[i])) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1048 device->type = i;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1049 break;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1050 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1051 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1052 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1053 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1054 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DIRECTION"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1055 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
162
6fc9e3f7962f Added Raspberry GPIO devices
Michiel Broek <mbroek@mbse.eu>
parents: 161
diff changeset
1056 for (i = 0; i < 7; i++) {
158
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1057 if (! xmlStrcmp(key, (const xmlChar *)DEVDIR[i])) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1058 device->direction = i;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1059 break;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1060 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1061 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1062 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1063 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1064 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VALUE"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1065 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1066 if (sscanf((const char *)key, "%d", &ival) == 1)
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1067 device->value = ival;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1068 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1069 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1070 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PRESENT"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1071 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1072 for (i = 0; i < 4; i++) {
174
244de612c572 Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
1073 if (! xmlStrcmp(key, (const xmlChar *)DEVPRESENT[i])) {
158
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1074 device->present = i;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1075 break;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1076 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1077 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1078 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1079 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1080 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ADDRESS"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1081 device->address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1082 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1083 if ((!xmlStrcmp(cur->name, (const xmlChar *)"SUBDEVICE"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1084 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1085 if (sscanf((const char *)key, "%d", &ival) == 1)
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1086 device->subdevice = ival;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1087 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1088 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1089 if ((!xmlStrcmp(cur->name, (const xmlChar *)"GPIOPIN"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1090 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1091 if (sscanf((const char *)key, "%d", &ival) == 1)
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1092 device->gpiopin = ival;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1093 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1094 }
161
493e39bb0a08 Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 158
diff changeset
1095 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DESCRIPTION"))) {
158
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1096 device->description = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1097 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1098 if ((!xmlStrcmp(cur->name, (const xmlChar *)"INUSE"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1099 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1100 if (sscanf((const char *)key, "%d", &ival) == 1)
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1101 device->inuse = ival;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1102 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1103 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1104 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COMMENT"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1105 device->comment = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1106 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1107 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TIMESTAMP"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1108 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1109 if (sscanf((const char *)key, "%d", &ival) == 1)
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1110 device->timestamp = (time_t)ival;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1111 xmlFree(key);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1112 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1113
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1114 cur = cur->next;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1115 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1116
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1117 if (Config.devices == NULL) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1118 Config.devices = device;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1119 } else {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1120 for (tmp = Config.devices; tmp; tmp = tmp->next) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1121 if (tmp->next == NULL) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1122 tmp->next = device;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1123 break;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1124 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1125 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1126 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1127
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1128 return 0;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1129 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1130
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1131
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1132
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1133 int parseDevices(xmlDocPtr doc, xmlNodePtr cur)
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1134 {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1135 cur = cur->xmlChildrenNode;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1136 while (cur != NULL) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1137 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DEVICE"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1138 parseDevice(doc, cur);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1139 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1140 cur = cur->next;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1141 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1142 return 0;
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1143 }
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1144
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1145
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1146
86
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
1147 int rdconfig(void)
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1148 {
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1149 int rc = 0, ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1150 xmlDocPtr doc;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1151 xmlNodePtr cur;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1152 xmlChar *key;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1153
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1154 killconfig();
56
f7711c6ac93c Workaround for empty environment at system boot
Michiel Broek <mbroek@mbse.eu>
parents: 55
diff changeset
1155 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
1156
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1157 /*
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1158 * Search config file
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1159 */
56
f7711c6ac93c Workaround for empty environment at system boot
Michiel Broek <mbroek@mbse.eu>
parents: 55
diff changeset
1160 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
1161 mypath = xstrcpy((char *)"/root");
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
1162 } else {
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
1163 mypath = xstrcpy(getenv((char *)"HOME"));
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
1164 }
86
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
1165 mypath = xstrcat(mypath, (char *)"/.thermferm/etc/");
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
1166 mkdirs(mypath, 0755);
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
1167 mypath = xstrcat(mypath, (char *)"thermferm.xml");
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1168 if ((doc = xmlParseFile(mypath)) == NULL) {
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1169 /*
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1170 * Not in the users home directory
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1171 */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1172 free(mypath);
86
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
1173 mypath = xstrcpy((char *)"/etc/mbsepi-apps/thermferm.xml");
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1174 if ((doc = xmlParseFile(mypath)) == NULL) {
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1175 /*
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1176 * Try /usr/local/etc
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1177 */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1178 free(mypath);
86
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
1179 mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/thermferm.xml");
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1180 if ((doc = xmlParseFile(mypath)) == NULL) {
86
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
1181 syslog(LOG_NOTICE, "rdconfig: could not find thermferm.xml");
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1182 return 1;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1183 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1184 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1185 }
55
11d7cc3bdf31 If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
1186 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
1187
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1188 if ((cur = xmlDocGetRootElement(doc)) == NULL) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1189 syslog(LOG_NOTICE, "XML file %s empty.", mypath);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1190 xmlFreeDoc(doc);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1191 return 1;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1192 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1193 if (xmlStrcmp(cur->name, (const xmlChar*)"THERMFERM")) {
83
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1194 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
1195 xmlFreeDoc(doc);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1196 return 1;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1197 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1198
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1199 /*
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1200 * Parse configuration
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1201 */
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1202 cur = cur->xmlChildrenNode;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1203 while (cur != NULL) {
83
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1204 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1205 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1206 if (xmlStrcmp(key, (const xmlChar *)"1")) {
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1207 xmlFree(key);
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1208 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
1209 return 1;
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1210 }
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1211 xmlFree(key);
f99e9d6deff5 Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents: 82
diff changeset
1212 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1213 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LISTEN_PORT"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1214 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1215 if (sscanf((const char *)key, "%d", &ival) == 1)
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1216 Config.my_port = ival;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1217 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1218 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1219 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMPFORMAT"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1220 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1221 Config.tempFormat = key[0];
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1222 xmlFree(key);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1223 }
95
2c28afc329a5 Removed old brewPi settings
Michiel Broek <mbroek@mbse.eu>
parents: 92
diff changeset
1224 if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_ADDRESS"))) {
2c28afc329a5 Removed old brewPi settings
Michiel Broek <mbroek@mbse.eu>
parents: 92
diff changeset
1225 Config.air_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
2c28afc329a5 Removed old brewPi settings
Michiel Broek <mbroek@mbse.eu>
parents: 92
diff changeset
1226 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1227 #ifdef HAVE_WIRINGPI_H
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1228 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1229 parseLCDs(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1230 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1231 #endif
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1232 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FERMENTERS"))) {
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1233 parseFermenters(doc, cur);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1234 }
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1235 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILES"))) {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1236 parseProfiles(doc, cur);
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 90
diff changeset
1237 }
158
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1238 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DEVICES"))) {
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1239 parseDevices(doc, cur);
f1b7e2ef90be Added device configuration
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1240 }
80
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1241 cur = cur->next;
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1242 }
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1243 xmlFreeDoc(doc);
81bf78a7618e Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
1244
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1245 free(mypath);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1246 mypath = NULL;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1247
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1248 return rc;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1249 }
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1250
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1251
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1252

mercurial