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