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