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