Fri, 20 Mar 2015 16:56:07 +0100
Added support for all 1-wire temperature sensors that are in the Linux kernel source.
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
2 | * Copyright (C) 2014-2015 |
51
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" }; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
37 | const char DEVTYPE[8][6] = { "NA", "W1", "GPIO", "RC433", "DHT", "I2C", "SPI", "SIM" }; |
158 | 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; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
49 | #ifdef USE_SIMULATOR |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
50 | simulator_list *simulator; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
51 | #endif |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | if (Config.name) |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | free(Config.name); |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | Config.name = NULL; |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | Config.my_port = 6554; |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
58 | Config.tempFormat = 'C'; |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
59 | if (Config.temp_address) |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
60 | free(Config.temp_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
61 | if (Config.hum_address) |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
62 | free(Config.hum_address); |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
63 | Config.temp_address = Config.hum_address = NULL; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
64 | Config.temp_value = 20000; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
65 | 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
|
66 | Config.hum_value = 50000; |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
67 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
68 | for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
69 | if (tmp2->uuid) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
70 | free(tmp2->uuid); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
71 | if (tmp2->name) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
72 | free(tmp2->name); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
73 | if (tmp2->air_address) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
74 | free(tmp2->air_address); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
75 | if (tmp2->beer_address) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
76 | 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
|
77 | 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
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | 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
|
82 | free(tmp2->fan_address); |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
83 | if (tmp2->light_address) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
84 | free(tmp2->light_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
|
85 | 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
|
86 | free(tmp2->door_address); |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
87 | if (tmp2->psu_address) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
88 | free(tmp2->psu_address); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
89 | if (tmp2->profile) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
90 | free(tmp2->profile); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
91 | free(tmp2); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
92 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
93 | Config.units = NULL; |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
95 | for (tmp3 = Config.profiles; tmp3; tmp3 = tmp3->next) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
96 | if (tmp3->uuid) |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
97 | free(tmp3->uuid); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
98 | if (tmp3->name) |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
99 | free(tmp3->name); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
100 | if (tmp3->steps) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
101 | for (tmp4 = tmp3->steps; tmp4; tmp4 = tmp4->next) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
102 | free(tmp4); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
103 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
104 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
105 | free(tmp3); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
106 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
107 | Config.profiles = NULL; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
108 | |
161
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
109 | for (device = Config.devices; device; device = device->next) { |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
110 | if (device->uuid) |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
111 | free(device->uuid); |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
112 | if (device->address) |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
113 | free(device->address); |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
114 | if (device->description) |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
115 | free(device->description); |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
116 | if (device->comment) |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
117 | free(device->comment); |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
118 | free(device); |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
119 | } |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
120 | Config.devices = NULL; |
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
121 | |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
122 | #ifdef USE_SIMULATOR |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
123 | for (simulator = Config.simulators; simulator; simulator = simulator->next) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
124 | if (simulator->uuid) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
125 | free(simulator->uuid); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
126 | if (simulator->name) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
127 | free(simulator->name); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
128 | free(simulator); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
129 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
130 | Config.simulators = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
131 | #endif |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
132 | |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
133 | #ifdef HAVE_WIRINGPI_H |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | Config.lcd_cols = 16; |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | Config.lcd_rows = 2; |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
136 | #endif |
53 | 137 | } |
138 | ||
139 | ||
140 | ||
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
|
141 | 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
|
142 | int do_wrconfig(void) |
53 | 143 | { |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
144 | 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
|
145 | FILE *fp; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
146 | xmlTextWriterPtr writer; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
147 | xmlBufferPtr buf; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
148 | units_list *tmp3; |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
149 | profiles_list *tmp4; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
150 | prof_step *tmp5; |
158 | 151 | devices_list *device; |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
152 | #ifdef USE_SIMULATOR |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
153 | simulator_list *simulator; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
154 | #endif |
53 | 155 | |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
156 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
157 | * 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
|
158 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
159 | if ((buf = xmlBufferCreate()) == NULL) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
160 | syslog(LOG_NOTICE, "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
|
161 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
162 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
163 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
164 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
165 | * 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
|
166 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
167 | if ((writer = xmlNewTextWriterMemory(buf, 0)) == NULL) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
168 | syslog(LOG_NOTICE, "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
|
169 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
170 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
171 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
172 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
173 | * 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
|
174 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
175 | if ((rc = xmlTextWriterSetIndent(writer, 2)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
176 | syslog(LOG_NOTICE, "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
|
177 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
178 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
179 | |
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 | * 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
|
182 | * 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
|
183 | * declaration. |
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 = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
186 | syslog(LOG_NOTICE, "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
|
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 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
189 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
190 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
191 | * 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
|
192 | * 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
|
193 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
194 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "THERMFERM")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
195 | syslog(LOG_NOTICE, "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
|
196 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
197 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
198 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
199 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
200 | * 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
|
201 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
202 | if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
203 | syslog(LOG_NOTICE, "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
|
204 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
205 | } |
286
674efa17be1d
The global system name was not saved or restored from the configuration file.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
206 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", Config.name)) < 0) { |
674efa17be1d
The global system name was not saved or restored from the configuration file.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
207 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
674efa17be1d
The global system name was not saved or restored from the configuration file.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
208 | return 1; |
674efa17be1d
The global system name was not saved or restored from the configuration file.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
209 | } |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
210 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
211 | syslog(LOG_NOTICE, "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
|
212 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
213 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
214 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMPFORMAT", "%c", Config.tempFormat)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
215 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
216 | return 1; |
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
217 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
218 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_ADDRESS", "%s", Config.temp_address)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
219 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
220 | return 1; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
221 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
222 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_STATE", "%d", Config.temp_state)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
223 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
224 | return 1; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
225 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
226 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_VALUE", "%d", Config.temp_value)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
227 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
228 | return 1; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
229 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
230 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_ADDRESS", "%s", Config.hum_address)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
231 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
232 | return 1; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
233 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
234 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_STATE", "%d", Config.hum_state)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
235 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
236 | return 1; |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
237 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
238 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
239 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
240 | return 1; |
95 | 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 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
243 | #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
|
244 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
245 | * 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
|
246 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
247 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCDS")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
248 | syslog(LOG_NOTICE, "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
|
249 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
250 | } |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
251 | /* |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
252 | * 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
|
253 | * 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
|
254 | */ |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
255 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "LCD")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
256 | syslog(LOG_NOTICE, "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
|
257 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
258 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
259 | if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
260 | syslog(LOG_NOTICE, "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
|
261 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
262 | } |
78
c49ab5179bf3
Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
263 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "0x%x", Config.lcd_address)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
264 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
78
c49ab5179bf3
Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
265 | return 1; |
c49ab5179bf3
Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
266 | } |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
267 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COLUMNS", "%d", Config.lcd_cols)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
268 | syslog(LOG_NOTICE, "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
|
269 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
270 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
271 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROWS", "%d", Config.lcd_rows)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
272 | syslog(LOG_NOTICE, "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
|
273 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
274 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
275 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
276 | * 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
|
277 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
278 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
279 | syslog(LOG_NOTICE, "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
|
280 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
281 | } |
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 | * 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
|
284 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
285 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
286 | syslog(LOG_NOTICE, "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
|
287 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
288 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
289 | #endif |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
290 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
291 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
292 | * Fermenter units |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
293 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
294 | 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
|
295 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "FERMENTERS")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
296 | syslog(LOG_NOTICE, "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
|
297 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
298 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
299 | 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
|
300 | /* |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
301 | * 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
|
302 | * are written to a state file. |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
303 | */ |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
304 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "UNIT")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
305 | syslog(LOG_NOTICE, "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
|
306 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
307 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
308 | if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
309 | syslog(LOG_NOTICE, "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
|
310 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
311 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
312 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
313 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
314 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
315 | } |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
316 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp3->name)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
317 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
318 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
319 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
320 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME", "%.1f", tmp3->volume)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
321 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
322 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
323 | } |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
324 | if (tmp3->air_address) { |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
325 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
326 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
327 | return 1; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
328 | } |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
329 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", tmp3->air_state)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
330 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
331 | return 1; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
332 | } |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
333 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
334 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
335 | return 1; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
336 | } |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
337 | } |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
338 | if (tmp3->beer_address) { |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
339 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
340 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
341 | return 1; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
342 | } |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
343 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_STATE", "%d", tmp3->beer_state)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
344 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
345 | return 1; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
346 | } |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
347 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
348 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
349 | return 1; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
350 | } |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
351 | } |
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
|
352 | 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
|
353 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
354 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
355 | return 1; |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
356 | } |
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 (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", tmp3->heater_state)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
358 | syslog(LOG_NOTICE, "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
|
359 | 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
|
360 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
361 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_DELAY", "%d", tmp3->heater_delay)) < 0)) { |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
362 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
363 | return 1; |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
364 | } |
293 | 365 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_USAGE", "%d", tmp3->heater_usage)) < 0)) { |
366 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); | |
367 | return 1; | |
368 | } | |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
369 | } |
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
|
370 | 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
|
371 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
372 | syslog(LOG_NOTICE, "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
|
373 | 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
|
374 | } |
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
|
375 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", tmp3->cooler_state)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
376 | syslog(LOG_NOTICE, "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
|
377 | 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
|
378 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
379 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_DELAY", "%d", tmp3->cooler_delay)) < 0)) { |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
380 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
381 | return 1; |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
382 | } |
293 | 383 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_USAGE", "%d", tmp3->cooler_usage)) < 0)) { |
384 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); | |
385 | return 1; | |
386 | } | |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
387 | } |
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
|
388 | 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
|
389 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
390 | syslog(LOG_NOTICE, "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
|
391 | 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
|
392 | } |
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
|
393 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_STATE", "%d", tmp3->fan_state)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
394 | syslog(LOG_NOTICE, "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
|
395 | 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
|
396 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
397 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_DELAY", "%d", tmp3->fan_delay)) < 0)) { |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
398 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
399 | return 1; |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
400 | } |
293 | 401 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_USAGE", "%d", tmp3->fan_usage)) < 0)) { |
402 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); | |
403 | return 1; | |
404 | } | |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
405 | } |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
406 | if (tmp3->light_address) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
407 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_ADDRESS", "%s", tmp3->light_address)) < 0)) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
408 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
409 | return 1; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
410 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
411 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_STATE", "%d", tmp3->light_state)) < 0)) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
412 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
413 | return 1; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
414 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
415 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_DELAY", "%d", tmp3->light_delay)) < 0)) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
416 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
417 | return 1; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
418 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
419 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_USAGE", "%d", tmp3->light_usage)) < 0)) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
420 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
421 | return 1; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
422 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
423 | } |
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
|
424 | 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
|
425 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
426 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
427 | 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
|
428 | } |
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
|
429 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
430 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
431 | 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
|
432 | } |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
433 | } |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
434 | if (tmp3->psu_address) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
435 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_ADDRESS", "%s", tmp3->psu_address)) < 0)) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
436 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
437 | return 1; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
438 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
439 | if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_STATE", "%d", tmp3->psu_state)) < 0)) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
440 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
441 | return 1; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
442 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
443 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
444 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
445 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
446 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
447 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
448 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", tmp3->beer_set)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
449 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
450 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
451 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
452 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_SET", "%.1f", tmp3->fridge_set)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
453 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
454 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
455 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
456 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MIN", "%.1f", tmp3->temp_set_min)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
457 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
458 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
459 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
460 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
461 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
462 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
463 | } |
312
7b0f819a3805
Added more precision to the unit low and high black window margins. Switched to PID routine from Pid without a PhD. The PID compute routine is now in the one second loop. The switch delay times are now in seconds, 0..720.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
464 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.2f", tmp3->idle_rangeL)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
465 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
466 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
467 | } |
312
7b0f819a3805
Added more precision to the unit low and high black window margins. Switched to PID routine from Pid without a PhD. The PID compute routine is now in the one second loop. The switch delay times are now in seconds, 0..720.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
468 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.2f", tmp3->idle_rangeH)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
469 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
470 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
471 | } |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
472 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KP", "%.2f", tmp3->PID_Kp)) < 0) { |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
473 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
474 | return 1; |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
475 | } |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
476 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KD", "%.2f", tmp3->PID_Kd)) < 0) { |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
477 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
478 | return 1; |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
479 | } |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
480 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KI", "%.2f", tmp3->PID_Ki)) < 0) { |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
481 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
482 | return 1; |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
483 | } |
77
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
484 | if (tmp3->profile) { |
143077e54255
Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents:
76
diff
changeset
|
485 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
486 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
487 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
488 | } |
90 | 489 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STARTED", "%d", (unsigned int)tmp3->prof_started)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
490 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
90 | 491 | return 1; |
492 | } | |
194
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
493 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PAUSED", "%d", (unsigned int)tmp3->prof_paused)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
494 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
194
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
495 | return 1; |
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
496 | } |
90 | 497 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STATE", "%s", PROFSTATE[tmp3->prof_state] )) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
498 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
499 | return 1; |
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
500 | } |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
501 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PEAK_ABS", "%.3f", tmp3->prof_peak_abs)) < 0) { |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
502 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
503 | return 1; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
504 | } |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
505 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PEAK_REL", "%.3f", tmp3->prof_peak_rel)) < 0) { |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
506 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
507 | return 1; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
508 | } |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
509 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PRIMARY_DONE", "%d", (unsigned int)tmp3->prof_primary_done)) < 0) { |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
510 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
511 | return 1; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
512 | } |
76
d2c7b32f27d6
Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents:
75
diff
changeset
|
513 | } |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
514 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
515 | syslog(LOG_NOTICE, "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
|
516 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
517 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
518 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
519 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
520 | syslog(LOG_NOTICE, "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
|
521 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
522 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
523 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
524 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
525 | /* |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
526 | * Fermenting profiles |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
527 | */ |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
528 | if (Config.profiles) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
529 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILES")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
530 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
531 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
532 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
533 | for (tmp4 = Config.profiles; tmp4; tmp4 = tmp4->next) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
534 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "PROFILE")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
535 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
536 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
537 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
538 | if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
539 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
540 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
541 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
542 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp4->uuid)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
543 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
544 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
545 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
546 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp4->name)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
547 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
548 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
549 | } |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
550 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUSY", "%d", tmp4->busy)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
551 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
552 | return 1; |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
553 | } |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
554 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
555 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
556 | return 1; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
557 | } |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
558 | if (tmp4->steps) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
559 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEPS")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
560 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
561 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
562 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
563 | for (tmp5 = tmp4->steps; tmp5; tmp5 = tmp5->next) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
564 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEP")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
565 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
566 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
567 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
568 | if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
569 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
570 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
571 | } |
92 | 572 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "RESTTIME", "%d", tmp5->resttime)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
573 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
574 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
575 | } |
92 | 576 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STEPTIME", "%d", tmp5->steptime)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
577 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
92 | 578 | return 1; |
579 | } | |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
580 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
581 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
582 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
583 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
584 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
585 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
586 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
587 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
588 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
589 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
590 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
591 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
592 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
593 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
594 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
595 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
596 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
597 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
598 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
599 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
600 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
601 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
602 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
603 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
604 | |
158 | 605 | if (Config.devices) { |
606 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICES")) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
607 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
158 | 608 | return 1; |
609 | } | |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
610 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
611 | piLock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
612 | #endif |
158 | 613 | for (device = Config.devices; device; device = device->next) { |
614 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICE")) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
615 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
158 | 616 | return 1; |
617 | } | |
618 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", device->version)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
619 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 620 | return 1; |
621 | } | |
622 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
623 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
158 | 624 | return 1; |
625 | } | |
626 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type])) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
627 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
158 | 628 | return 1; |
629 | } | |
630 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction])) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
631 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
158 | 632 | return 1; |
633 | } | |
634 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VALUE", "%d", device->value)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
635 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 636 | return 1; |
637 | } | |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
638 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "OFFSET", "%d", device->offset)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
639 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
640 | return 1; |
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
641 | } |
158 | 642 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRESENT", "%s", DEVPRESENT[device->present])) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
643 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
158 | 644 | return 1; |
645 | } | |
646 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "%s", device->address)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
647 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 648 | return 1; |
649 | } | |
650 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SUBDEVICE", "%d", device->subdevice)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
651 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 652 | return 1; |
653 | } | |
654 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "GPIOPIN", "%d", device->gpiopin)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
655 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 656 | return 1; |
657 | } | |
658 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DESCRIPTION", "%s", device->description)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
659 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 660 | return 1; |
661 | } | |
662 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
663 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 664 | return 1; |
665 | } | |
666 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
667 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 668 | return 1; |
669 | } | |
670 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
671 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
158 | 672 | return 1; |
673 | } | |
674 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
675 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
158 | 676 | return 1; |
677 | } | |
678 | } | |
240
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
679 | #ifdef HAVE_WIRINGPI_H |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
680 | piUnlock(LOCK_DEVICES); |
6bdda35b4a13
Added thread locks for device processing
Michiel Broek <mbroek@mbse.eu>
parents:
235
diff
changeset
|
681 | #endif |
158 | 682 | |
683 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
684 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
158 | 685 | return 1; |
686 | } | |
687 | } | |
688 | ||
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
689 | #ifdef USE_SIMULATOR |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
690 | if (Config.simulators) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
691 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "SIMULATORS")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
692 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
693 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
694 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
695 | for (simulator = Config.simulators; simulator; simulator = simulator->next) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
696 | if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "SIMULATOR")) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
697 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
698 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
699 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
700 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", simulator->version)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
701 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
702 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
703 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
704 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", simulator->uuid)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
705 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
706 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
707 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
708 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", simulator->name)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
709 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
710 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
711 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
712 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME_AIR", "%d", simulator->volume_air)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
713 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
714 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
715 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
716 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VOLUME_BEER", "%d", simulator->volume_beer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
717 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
718 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
719 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
720 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ROOM_TEMPERATURE", "%.1f", simulator->room_temperature)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
721 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
722 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
723 | } |
262
d0014ccec615
Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
259
diff
changeset
|
724 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%f", simulator->air_temperature)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
725 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
726 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
727 | } |
262
d0014ccec615
Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
259
diff
changeset
|
728 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%f", simulator->beer_temperature)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
729 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
730 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
731 | } |
262
d0014ccec615
Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
259
diff
changeset
|
732 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_TEMP", "%f", simulator->cooler_temp)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
733 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
734 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
735 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
736 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_TIME", "%d", simulator->cooler_time)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
737 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
738 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
739 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
740 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_SIZE", "%.3f", simulator->cooler_size)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
741 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
742 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
743 | } |
262
d0014ccec615
Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
259
diff
changeset
|
744 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_TEMP", "%f", simulator->heater_temp)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
745 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
746 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
747 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
748 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_TIME", "%d", simulator->heater_time)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
749 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
750 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
751 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
752 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_SIZE", "%.3f", simulator->heater_size)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
753 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
754 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
755 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
756 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", simulator->heater_state)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
757 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
758 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
759 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
760 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", simulator->cooler_state)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
761 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
762 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
763 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
764 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIGO_ISOLATION", "%.3f", simulator->frigo_isolation)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
765 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
766 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
767 | } |
262
d0014ccec615
Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
259
diff
changeset
|
768 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_YEAST_HEAT", "%f", simulator->s_yeast_heat)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
769 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
770 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
771 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
772 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_YEAST_STARTED", "%d", (int)simulator->s_yeast_started)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
773 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
774 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
775 | } |
262
d0014ccec615
Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
259
diff
changeset
|
776 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_COOL_TEMP", "%f", simulator->s_cool_temp)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
777 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
778 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
779 | } |
262
d0014ccec615
Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
259
diff
changeset
|
780 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_HEAT_TEMP", "%f", simulator->s_heat_temp)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
781 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
782 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
783 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
784 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_COOL_CHANGED", "%d", (int)simulator->s_cool_changed)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
785 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
786 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
787 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
788 | if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_HEAT_CHANGED", "%d", (int)simulator->s_heat_changed)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
789 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
790 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
791 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
792 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
793 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
794 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
795 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
796 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
797 | if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
798 | syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
799 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
800 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
801 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
802 | #endif |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
803 | |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
804 | /* |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
805 | * 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
|
806 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
807 | if ((rc = xmlTextWriterEndDocument(writer)) < 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
808 | syslog(LOG_NOTICE, "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
|
809 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
810 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
811 | xmlFreeTextWriter(writer); |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
812 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
813 | /* |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
814 | * 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
|
815 | */ |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
816 | 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
|
817 | 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
|
818 | } else { |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
819 | 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
|
820 | } |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
821 | 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
|
822 | mkdirs(mypath, 0755); |
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
823 | 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
|
824 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
825 | if (debug) |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
826 | 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
|
827 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
828 | if ((fp = fopen(mypath, "w")) == NULL) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
829 | syslog(LOG_NOTICE, "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
|
830 | return 1; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
831 | } |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
832 | |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
833 | 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
|
834 | fclose(fp); |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
835 | xmlBufferFree(buf); |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
836 | |
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
|
837 | 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
|
838 | } |
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
|
839 | |
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
|
840 | |
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
|
841 | |
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
|
842 | 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
|
843 | { |
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
|
844 | 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
|
845 | |
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
|
846 | rc = do_wrconfig(); |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
847 | syslog(LOG_NOTICE, "Rewritten configuration, rc=%d", rc); |
53 | 848 | return rc; |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
849 | } |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
850 | |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
851 | |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
852 | |
80
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 | * Parse one LCD display |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
855 | */ |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
856 | #ifdef HAVE_WIRINGPI_H |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
857 | int parseLCD(xmlDocPtr doc, xmlNodePtr cur) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
858 | { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
859 | xmlChar *key; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
860 | int ival; |
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 | cur = cur->xmlChildrenNode; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
863 | while (cur != NULL) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
864 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"COLUMNS"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
865 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
866 | if (sscanf((const char *)key, "%d", &ival) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
867 | Config.lcd_cols = ival; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
868 | xmlFree(key); |
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 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"ROWS"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
871 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
872 | if (sscanf((const char *)key, "%d", &ival) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
873 | Config.lcd_rows = ival; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
874 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
875 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
876 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"ADDRESS"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
877 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
878 | if (sscanf((const char *)key, "%x", &ival) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
879 | Config.lcd_address = ival; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
880 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
881 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
882 | cur = cur->next; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
883 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
884 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
885 | return 0; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
886 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
887 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
888 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
889 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
890 | int parseLCDs(xmlDocPtr doc, xmlNodePtr cur) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
891 | { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
892 | cur = cur->xmlChildrenNode; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
893 | while (cur != NULL) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
894 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCD"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
895 | parseLCD(doc, cur); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
896 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
897 | cur = cur->next; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
898 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
899 | return 0; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
900 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
901 | #endif |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
902 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
903 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
904 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
905 | /* |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
906 | * Parse a fermenter unit |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
907 | */ |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
908 | int parseUnit(xmlDocPtr doc, xmlNodePtr cur) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
909 | { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
910 | xmlChar *key; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
911 | int i, ival; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
912 | float val; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
913 | units_list *unit, *tmp; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
914 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
915 | unit = (units_list *)malloc(sizeof(units_list)); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
916 | unit->next = NULL; |
90 | 917 | 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
|
918 | unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->heater_address = \ |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
919 | unit->cooler_address = unit->fan_address = unit->door_address = \ |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
920 | unit->light_address = unit->psu_address = unit->profile = NULL; |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
921 | unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
922 | 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
|
923 | unit->air_state = unit->beer_state = 1; // missing |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
924 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = \ |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
925 | unit->light_state = unit->psu_state = unit->mode = unit->prof_state = 0; |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
926 | unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
927 | unit->light_delay = 1; /* 15 seconds delay */ |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
928 | unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
929 | unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0; |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
930 | unit->temp_set_min = 1.0; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
931 | unit->temp_set_max = 30.0; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
932 | unit->idle_rangeH = 1.0; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
933 | unit->idle_rangeL = -1.0; |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
934 | unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0; |
284
9e6fb5aed618
Profile progress is visible in the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
270
diff
changeset
|
935 | unit->prof_percent = 0; |
313 | 936 | unit->PID_dState = unit->PID_iState = unit->PID_Kp = unit->PID_Kd = unit->PID_Ki = 0.0; |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
937 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
938 | cur = cur->xmlChildrenNode; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
939 | while (cur != NULL) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
940 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
941 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
942 | if (xmlStrcmp(key, (const xmlChar *)"1")) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
943 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
944 | return 1; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
945 | } |
90 | 946 | unit->version = 1; |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
947 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
948 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
949 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
950 | unit->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
951 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
952 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
953 | unit->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
954 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
955 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VOLUME"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
956 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
957 | if (sscanf((const char *)key, "%f", &val) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
958 | unit->volume = val; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
959 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
960 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
961 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_ADDRESS"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
962 | unit->air_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
963 | } |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
964 | 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
|
965 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
966 | 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
|
967 | unit->air_state = ival; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
968 | xmlFree(key); |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
969 | } |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
970 | 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
|
971 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
972 | 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
|
973 | unit->air_temperature = ival; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
974 | xmlFree(key); |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
975 | } |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
976 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_ADDRESS"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
977 | unit->beer_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
978 | } |
101
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
979 | 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
|
980 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
981 | 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
|
982 | unit->beer_state = ival; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
983 | xmlFree(key); |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
984 | } |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
985 | 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
|
986 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
987 | 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
|
988 | unit->beer_temperature = ival; |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
989 | xmlFree(key); |
1302abe92eb1
Made temperature sensors working in the units
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
990 | } |
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
|
991 | 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
|
992 | unit->heater_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
993 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
994 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_DELAY"))) { |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
995 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
996 | if (sscanf((const char *)key, "%d", &ival) == 1) |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
997 | unit->heater_delay = ival; |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
998 | xmlFree(key); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
999 | } |
293 | 1000 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_USAGE"))) { |
1001 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1002 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1003 | unit->heater_usage = ival; | |
1004 | xmlFree(key); | |
1005 | } | |
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
|
1006 | 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
|
1007 | unit->cooler_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1008 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1009 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_DELAY"))) { |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1010 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1011 | if (sscanf((const char *)key, "%d", &ival) == 1) |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1012 | unit->cooler_delay = ival; |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1013 | xmlFree(key); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1014 | } |
293 | 1015 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_USAGE"))) { |
1016 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1017 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1018 | unit->cooler_usage = ival; | |
1019 | xmlFree(key); | |
1020 | } | |
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
|
1021 | 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
|
1022 | unit->fan_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1023 | } |
270
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1024 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN_DELAY"))) { |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1025 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1026 | if (sscanf((const char *)key, "%d", &ival) == 1) |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1027 | unit->fan_delay = ival; |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1028 | xmlFree(key); |
df81d583c2c3
The PID commands have an adjustable delay, default 5 minutes
Michiel Broek <mbroek@mbse.eu>
parents:
268
diff
changeset
|
1029 | } |
293 | 1030 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN_USAGE"))) { |
1031 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1032 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1033 | unit->fan_usage = ival; | |
1034 | xmlFree(key); | |
1035 | } | |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1036 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_ADDRESS"))) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1037 | unit->light_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1038 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1039 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_DELAY"))) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1040 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1041 | if (sscanf((const char *)key, "%d", &ival) == 1) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1042 | unit->light_delay = ival; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1043 | xmlFree(key); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1044 | } |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1045 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_USAGE"))) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1046 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1047 | if (sscanf((const char *)key, "%d", &ival) == 1) |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1048 | unit->light_usage = ival; |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1049 | xmlFree(key); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1050 | } |
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
|
1051 | 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
|
1052 | unit->door_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1053 | } |
306
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1054 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PSU_ADDRESS"))) { |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1055 | unit->psu_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
97602274eb58
Updated to add support for lights in a fermenter unit and a Power Supply status.
Michiel Broek <mbroek@mbse.eu>
parents:
293
diff
changeset
|
1056 | } |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1057 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"MODE"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1058 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1059 | for (i = 0; i < 5; i++) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1060 | if (! xmlStrcmp(key, (const xmlChar *)UNITMODE[i])) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1061 | unit->mode = i; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1062 | break; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1063 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1064 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1065 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1066 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1067 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_SET"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1068 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1069 | if (sscanf((const char *)key, "%f", &val) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1070 | unit->beer_set = val; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1071 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1072 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1073 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_SET"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1074 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1075 | if (sscanf((const char *)key, "%f", &val) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1076 | unit->fridge_set = val; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1077 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1078 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1079 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_SET_MIN"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1080 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1081 | if (sscanf((const char *)key, "%f", &val) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1082 | unit->temp_set_min = val; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1083 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1084 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1085 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_SET_MAX"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1086 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1087 | if (sscanf((const char *)key, "%f", &val) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1088 | unit->temp_set_max = val; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1089 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1090 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1091 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"IDLE_RANGE_L"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1092 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1093 | if (sscanf((const char *)key, "%f", &val) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1094 | unit->idle_rangeL = val; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1095 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1096 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1097 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"IDLE_RANGE_H"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1098 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1099 | if (sscanf((const char *)key, "%f", &val) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1100 | unit->idle_rangeH = val; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1101 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1102 | } |
310
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1103 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KP"))) { |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1104 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1105 | if (sscanf((const char *)key, "%f", &val) == 1) |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1106 | unit->PID_Kp = val; |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1107 | xmlFree(key); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1108 | } |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1109 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KD"))) { |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1110 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1111 | if (sscanf((const char *)key, "%f", &val) == 1) |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1112 | unit->PID_Kd = val; |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1113 | xmlFree(key); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1114 | } |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1115 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KI"))) { |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1116 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1117 | if (sscanf((const char *)key, "%f", &val) == 1) |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1118 | unit->PID_Ki = val; |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1119 | xmlFree(key); |
53774295e14a
Added Kp, Kd and Ki settings to the units. Bumped to version 0.2.9
Michiel Broek <mbroek@mbse.eu>
parents:
306
diff
changeset
|
1120 | } |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1121 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILE"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1122 | unit->profile = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1123 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1124 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_STARTED"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1125 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1126 | if (sscanf((const char *)key, "%d", &ival) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1127 | unit->prof_started = ival; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1128 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1129 | } |
194
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1130 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_PAUSED"))) { |
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1131 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1132 | if (sscanf((const char *)key, "%d", &ival) == 1) |
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1133 | unit->prof_paused = ival; |
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1134 | xmlFree(key); |
9eaaba49450f
Added some ideas about profiles.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
1135 | } |
90 | 1136 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_STATE"))) { |
1137 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
217 | 1138 | for (i = 0; i < 5; i++) { |
90 | 1139 | if (! xmlStrcmp(key, (const xmlChar *)PROFSTATE[i])) { |
1140 | unit->prof_state = i; | |
1141 | break; | |
1142 | } | |
1143 | } | |
1144 | xmlFree(key); | |
1145 | } | |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1146 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_PEAK_ABS"))) { |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1147 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1148 | if (sscanf((const char *)key, "%f", &val) == 1) |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1149 | unit->prof_peak_abs = val; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1150 | xmlFree(key); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1151 | } |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1152 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_PEAK_REL"))) { |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1153 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1154 | if (sscanf((const char *)key, "%f", &val) == 1) |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1155 | unit->prof_peak_rel = val; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1156 | xmlFree(key); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1157 | } |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1158 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_PRIMARY_DONE"))) { |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1159 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1160 | if (sscanf((const char *)key, "%d", &ival) == 1) |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1161 | unit->prof_primary_done = ival; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1162 | xmlFree(key); |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
286
diff
changeset
|
1163 | } |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1164 | cur = cur->next; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1165 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1166 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1167 | if (Config.units == NULL) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1168 | Config.units = unit; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1169 | } else { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1170 | for (tmp = Config.units; tmp; tmp = tmp->next) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1171 | if (tmp->next == NULL) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1172 | tmp->next = unit; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1173 | break; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1174 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1175 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1176 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1177 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1178 | return 0; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1179 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1180 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1181 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1182 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1183 | int parseFermenters(xmlDocPtr doc, xmlNodePtr cur) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1184 | { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1185 | cur = cur->xmlChildrenNode; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1186 | while (cur != NULL) { |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1187 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"UNIT"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1188 | parseUnit(doc, cur); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1189 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1190 | cur = cur->next; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1191 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1192 | return 0; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1193 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1194 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1195 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1196 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1197 | 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
|
1198 | { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1199 | xmlChar *key; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1200 | int ival; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1201 | float val; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1202 | prof_step *step, *tmp; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1203 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1204 | step = (prof_step *)malloc(sizeof(prof_step)); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1205 | step->next = NULL; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1206 | step->version = 1; |
92 | 1207 | step->steptime = step->resttime = 0; |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1208 | step->target = 20.0; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1209 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1210 | cur = cur->xmlChildrenNode; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1211 | while (cur != NULL) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1212 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1213 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1214 | if (xmlStrcmp(key, (const xmlChar *)"1")) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1215 | xmlFree(key); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1216 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1217 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1218 | step->version = 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1219 | xmlFree(key); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1220 | } |
92 | 1221 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"RESTTIME"))) { |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1222 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1223 | if (sscanf((const char *)key, "%d", &ival) == 1) |
92 | 1224 | step->resttime = ival; |
1225 | xmlFree(key); | |
1226 | } | |
1227 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEPTIME"))) { | |
1228 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1229 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1230 | step->steptime = ival; | |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1231 | xmlFree(key); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1232 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1233 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1234 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1235 | if (sscanf((const char *)key, "%f", &val) == 1) |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1236 | step->target = val; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1237 | xmlFree(key); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1238 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1239 | cur = cur->next; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1240 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1241 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1242 | if (*profstep == NULL) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1243 | *profstep = step; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1244 | } else { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1245 | for (tmp = *profstep; tmp; tmp = tmp->next) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1246 | if (tmp->next == NULL) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1247 | tmp->next = step; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1248 | break; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1249 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1250 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1251 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1252 | return 0; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1253 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1254 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1255 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1256 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1257 | 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
|
1258 | { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1259 | cur = cur->xmlChildrenNode; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1260 | while (cur != NULL) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1261 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEP"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1262 | parseStep(doc, cur, step); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1263 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1264 | cur = cur->next; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1265 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1266 | return 0; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1267 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1268 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1269 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1270 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1271 | int parseProfile(xmlDocPtr doc, xmlNodePtr cur) |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1272 | { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1273 | xmlChar *key; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1274 | profiles_list *profile, *tmp; |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
1275 | int ival; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
1276 | float fval; |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1277 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1278 | profile = (profiles_list *)malloc(sizeof(profiles_list)); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1279 | profile->next = NULL; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1280 | profile->version = 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1281 | profile->uuid = profile->name = NULL; |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
1282 | profile->busy = 0; |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
1283 | profile->inittemp = 20.0; |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1284 | profile->steps = NULL; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1285 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1286 | cur = cur->xmlChildrenNode; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1287 | while (cur != NULL) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1288 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1289 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1290 | if (xmlStrcmp(key, (const xmlChar *)"1")) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1291 | xmlFree(key); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1292 | return 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1293 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1294 | profile->version = 1; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1295 | xmlFree(key); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1296 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1297 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1298 | profile->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1299 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1300 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1301 | profile->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1302 | } |
136
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
1303 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"BUSY"))) { |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
1304 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
1305 | if (sscanf((const char *)key, "%d", &ival) == 1) |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
1306 | profile->busy = ival; |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
1307 | xmlFree(key); |
264e5ee5abfc
Profiles now have a busy state
Michiel Broek <mbroek@mbse.eu>
parents:
106
diff
changeset
|
1308 | } |
191
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
1309 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP"))) { |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
1310 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
1311 | 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
|
1312 | profile->inittemp = fval; |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
1313 | xmlFree(key); |
c74bbc24a1c8
Client/Server communication is now almost final
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
1314 | } |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1315 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEPS"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1316 | parseSteps(doc, cur, &(profile)->steps); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1317 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1318 | cur = cur->next; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1319 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1320 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1321 | if (Config.profiles == NULL) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1322 | Config.profiles = profile; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1323 | } else { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1324 | for (tmp = Config.profiles; tmp; tmp = tmp->next) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1325 | if (tmp->next == NULL) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1326 | tmp->next = profile; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1327 | break; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1328 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1329 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1330 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1331 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1332 | return 0; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1333 | } |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1334 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1335 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1336 | |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1337 | int parseProfiles(xmlDocPtr doc, xmlNodePtr cur) |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1338 | { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1339 | cur = cur->xmlChildrenNode; |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1340 | while (cur != NULL) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1341 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILE"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1342 | parseProfile(doc, cur); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1343 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1344 | cur = cur->next; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1345 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1346 | return 0; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1347 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1348 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1349 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1350 | |
158 | 1351 | int parseDevice(xmlDocPtr doc, xmlNodePtr cur) |
1352 | { | |
1353 | xmlChar *key; | |
1354 | devices_list *device, *tmp; | |
1355 | int i, ival; | |
1356 | ||
1357 | device = (devices_list *)malloc(sizeof(devices_list)); | |
1358 | device->next = NULL; | |
1359 | device->version = 1; | |
1360 | 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
|
1361 | device->type = device->direction = device->present = device->subdevice = device->inuse = device->offset = 0; |
158 | 1362 | device->gpiopin = -1; |
1363 | device->timestamp = (time_t)0; | |
1364 | ||
1365 | cur = cur->xmlChildrenNode; | |
1366 | while (cur != NULL) { | |
1367 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { | |
1368 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1369 | if (xmlStrcmp(key, (const xmlChar *)"1")) { | |
1370 | xmlFree(key); | |
1371 | return 1; | |
1372 | } | |
1373 | device->version = 1; | |
1374 | xmlFree(key); | |
1375 | } | |
1376 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { | |
1377 | device->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1378 | } | |
1379 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"TYPE"))) { | |
1380 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1381 | for (i = 0; i < 8; i++) { |
158 | 1382 | if (! xmlStrcmp(key, (const xmlChar *)DEVTYPE[i])) { |
1383 | device->type = i; | |
1384 | break; | |
1385 | } | |
1386 | } | |
1387 | xmlFree(key); | |
1388 | } | |
1389 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"DIRECTION"))) { | |
1390 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
162
6fc9e3f7962f
Added Raspberry GPIO devices
Michiel Broek <mbroek@mbse.eu>
parents:
161
diff
changeset
|
1391 | for (i = 0; i < 7; i++) { |
158 | 1392 | if (! xmlStrcmp(key, (const xmlChar *)DEVDIR[i])) { |
1393 | device->direction = i; | |
1394 | break; | |
1395 | } | |
1396 | } | |
1397 | xmlFree(key); | |
1398 | } | |
1399 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VALUE"))) { | |
1400 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1401 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1402 | device->value = ival; | |
1403 | xmlFree(key); | |
1404 | } | |
209
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
1405 | 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
|
1406 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
1407 | 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
|
1408 | device->offset = ival; |
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
1409 | xmlFree(key); |
c5b1dfd83e81
Added offset value for sensor that need it
Michiel Broek <mbroek@mbse.eu>
parents:
206
diff
changeset
|
1410 | } |
158 | 1411 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PRESENT"))) { |
1412 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1413 | for (i = 0; i < 4; i++) { | |
174 | 1414 | if (! xmlStrcmp(key, (const xmlChar *)DEVPRESENT[i])) { |
158 | 1415 | device->present = i; |
1416 | break; | |
1417 | } | |
1418 | } | |
1419 | xmlFree(key); | |
1420 | } | |
1421 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"ADDRESS"))) { | |
1422 | device->address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1423 | } | |
1424 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"SUBDEVICE"))) { | |
1425 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1426 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1427 | device->subdevice = ival; | |
1428 | xmlFree(key); | |
1429 | } | |
1430 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"GPIOPIN"))) { | |
1431 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1432 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1433 | device->gpiopin = ival; | |
1434 | xmlFree(key); | |
1435 | } | |
161
493e39bb0a08
Small fixes for device configuration
Michiel Broek <mbroek@mbse.eu>
parents:
158
diff
changeset
|
1436 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"DESCRIPTION"))) { |
158 | 1437 | device->description = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1438 | } | |
1439 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"INUSE"))) { | |
1440 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1441 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1442 | device->inuse = ival; | |
1443 | xmlFree(key); | |
1444 | } | |
1445 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"COMMENT"))) { | |
1446 | device->comment = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1447 | } | |
1448 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"TIMESTAMP"))) { | |
1449 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); | |
1450 | if (sscanf((const char *)key, "%d", &ival) == 1) | |
1451 | device->timestamp = (time_t)ival; | |
1452 | xmlFree(key); | |
1453 | } | |
1454 | ||
1455 | cur = cur->next; | |
1456 | } | |
1457 | ||
1458 | if (Config.devices == NULL) { | |
1459 | Config.devices = device; | |
1460 | } else { | |
1461 | for (tmp = Config.devices; tmp; tmp = tmp->next) { | |
1462 | if (tmp->next == NULL) { | |
1463 | tmp->next = device; | |
1464 | break; | |
1465 | } | |
1466 | } | |
1467 | } | |
1468 | ||
1469 | return 0; | |
1470 | } | |
1471 | ||
1472 | ||
1473 | ||
1474 | int parseDevices(xmlDocPtr doc, xmlNodePtr cur) | |
1475 | { | |
1476 | cur = cur->xmlChildrenNode; | |
1477 | while (cur != NULL) { | |
1478 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"DEVICE"))) { | |
1479 | parseDevice(doc, cur); | |
1480 | } | |
1481 | cur = cur->next; | |
1482 | } | |
1483 | return 0; | |
1484 | } | |
1485 | ||
1486 | ||
1487 | ||
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1488 | #ifdef USE_SIMULATOR |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1489 | int parseSimulator(xmlDocPtr doc, xmlNodePtr cur) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1490 | { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1491 | xmlChar *key; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1492 | simulator_list *simulator, *tmp; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1493 | int ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1494 | float fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1495 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1496 | simulator = (simulator_list *)malloc(sizeof(simulator_list)); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1497 | simulator->next = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1498 | simulator->version = 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1499 | simulator->uuid = simulator->name = NULL; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1500 | simulator->volume_air = simulator->volume_beer = 0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1501 | simulator->room_temperature = simulator->air_temperature = simulator->beer_temperature = simulator->s_cool_temp = simulator->s_heat_temp = 20.0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1502 | simulator->cooler_temp = simulator->cooler_size = simulator->heater_temp = simulator->heater_size = simulator->frigo_isolation = 0.0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1503 | simulator->cooler_time = simulator->heater_time = simulator->cooler_state = simulator->heater_state = 0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1504 | simulator->s_yeast_started = simulator->s_cool_changed = simulator->s_heat_changed = (time_t)0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1505 | simulator->s_yeast_heat = simulator->s_cool_temp = simulator->s_heat_temp = 0.0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1506 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1507 | cur = cur->xmlChildrenNode; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1508 | while (cur != NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1509 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1510 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1511 | if (xmlStrcmp(key, (const xmlChar *)"1")) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1512 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1513 | return 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1514 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1515 | simulator->version = 1; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1516 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1517 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1518 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1519 | simulator->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1520 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1521 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1522 | simulator->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1523 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1524 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VOLUME_AIR"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1525 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1526 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1527 | simulator->volume_air = ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1528 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1529 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1530 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VOLUME_BEER"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1531 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1532 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1533 | simulator->volume_beer = ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1534 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1535 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1536 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"ROOM_TEMPERATURE"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1537 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1538 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1539 | simulator->room_temperature = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1540 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1541 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1542 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_TEMPERATURE"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1543 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1544 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1545 | simulator->air_temperature = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1546 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1547 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1548 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_TEMPERATURE"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1549 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1550 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1551 | simulator->beer_temperature = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1552 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1553 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1554 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_TEMP"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1555 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1556 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1557 | simulator->cooler_temp = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1558 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1559 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1560 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_TIME"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1561 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1562 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1563 | simulator->cooler_time = ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1564 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1565 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1566 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_SIZE"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1567 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1568 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1569 | simulator->cooler_size = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1570 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1571 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1572 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_TEMP"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1573 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1574 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1575 | simulator->heater_temp = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1576 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1577 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1578 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_TIME"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1579 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1580 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1581 | simulator->heater_time = ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1582 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1583 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1584 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_SIZE"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1585 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1586 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1587 | simulator->heater_size = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1588 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1589 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1590 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_STATE"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1591 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1592 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1593 | simulator->heater_state = ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1594 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1595 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1596 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_STATE"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1597 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1598 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1599 | simulator->cooler_state = ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1600 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1601 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1602 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIGO_ISOLATION"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1603 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1604 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1605 | simulator->frigo_isolation = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1606 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1607 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1608 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1609 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"S_YEAST_HEAT"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1610 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1611 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1612 | simulator->s_yeast_heat = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1613 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1614 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1615 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"S_YEAST_STARTED"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1616 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1617 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1618 | simulator->s_yeast_started = (time_t)ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1619 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1620 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1621 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"S_COOL_TEMP"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1622 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1623 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1624 | simulator->s_cool_temp = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1625 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1626 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1627 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"S_HEAT_TEMP"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1628 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1629 | if (sscanf((const char *)key, "%f", &fval) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1630 | simulator->s_heat_temp = fval; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1631 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1632 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1633 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"S_COOL_CHANGED"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1634 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1635 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1636 | simulator->s_cool_changed = (time_t)ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1637 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1638 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1639 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"S_HEAT_CHANGED"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1640 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1641 | if (sscanf((const char *)key, "%d", &ival) == 1) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1642 | simulator->s_heat_changed = (time_t)ival; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1643 | xmlFree(key); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1644 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1645 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1646 | cur = cur->next; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1647 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1648 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1649 | if (Config.simulators == NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1650 | Config.simulators = simulator; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1651 | } else { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1652 | for (tmp = Config.simulators; tmp; tmp = tmp->next) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1653 | if (tmp->next == NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1654 | tmp->next = simulator; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1655 | break; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1656 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1657 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1658 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1659 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1660 | return 0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1661 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1662 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1663 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1664 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1665 | int parseSimulators(xmlDocPtr doc, xmlNodePtr cur) |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1666 | { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1667 | cur = cur->xmlChildrenNode; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1668 | while (cur != NULL) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1669 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"SIMULATOR"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1670 | parseSimulator(doc, cur); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1671 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1672 | cur = cur->next; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1673 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1674 | return 0; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1675 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1676 | #endif |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1677 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1678 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1679 | |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
1680 | int rdconfig(void) |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1681 | { |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1682 | int rc = 0, ival; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1683 | xmlDocPtr doc; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1684 | xmlNodePtr cur; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1685 | xmlChar *key; |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1686 | |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1687 | killconfig(); |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
1688 | syslog(LOG_NOTICE, "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
|
1689 | |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1690 | /* |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1691 | * Search config file |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1692 | */ |
56
f7711c6ac93c
Workaround for empty environment at system boot
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
1693 | 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
|
1694 | mypath = xstrcpy((char *)"/root"); |
11d7cc3bdf31
If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
1695 | } else { |
11d7cc3bdf31
If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
1696 | mypath = xstrcpy(getenv((char *)"HOME")); |
11d7cc3bdf31
If /home/mbroek is not set, assume root user.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
1697 | } |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
1698 | 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
|
1699 | mkdirs(mypath, 0755); |
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
1700 | mypath = xstrcat(mypath, (char *)"thermferm.xml"); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1701 | if ((doc = xmlParseFile(mypath)) == NULL) { |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1702 | /* |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1703 | * Not in the users home directory |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1704 | */ |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1705 | free(mypath); |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
1706 | mypath = xstrcpy((char *)"/etc/mbsepi-apps/thermferm.xml"); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1707 | if ((doc = xmlParseFile(mypath)) == NULL) { |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1708 | /* |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1709 | * Try /usr/local/etc |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1710 | */ |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1711 | free(mypath); |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
1712 | 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
|
1713 | if ((doc = xmlParseFile(mypath)) == NULL) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
1714 | syslog(LOG_NOTICE, "rdconfig: could not find thermferm.xml"); |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1715 | return 1; |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1716 | } |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1717 | } |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1718 | } |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
1719 | syslog(LOG_NOTICE, "rdconfig: using %s", mypath); |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1720 | |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1721 | if ((cur = xmlDocGetRootElement(doc)) == NULL) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
1722 | syslog(LOG_NOTICE, "XML file %s empty.", mypath); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1723 | xmlFreeDoc(doc); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1724 | return 1; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1725 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1726 | if (xmlStrcmp(cur->name, (const xmlChar*)"THERMFERM")) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
1727 | syslog(LOG_NOTICE, "XML file %s is not a valid configuration file.", mypath); |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1728 | xmlFreeDoc(doc); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1729 | return 1; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1730 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1731 | |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1732 | /* |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1733 | * Parse configuration |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1734 | */ |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1735 | cur = cur->xmlChildrenNode; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1736 | while (cur != NULL) { |
83
f99e9d6deff5
Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
1737 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
f99e9d6deff5
Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
1738 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
f99e9d6deff5
Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
1739 | if (xmlStrcmp(key, (const xmlChar *)"1")) { |
f99e9d6deff5
Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
1740 | xmlFree(key); |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
262
diff
changeset
|
1741 | syslog(LOG_NOTICE, "XML file %s is not a valid version", mypath); |
83
f99e9d6deff5
Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
1742 | return 1; |
f99e9d6deff5
Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
1743 | } |
f99e9d6deff5
Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
1744 | xmlFree(key); |
f99e9d6deff5
Removed old ascii configuration
Michiel Broek <mbroek@mbse.eu>
parents:
82
diff
changeset
|
1745 | } |
286
674efa17be1d
The global system name was not saved or restored from the configuration file.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
1746 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { |
674efa17be1d
The global system name was not saved or restored from the configuration file.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
1747 | Config.name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
674efa17be1d
The global system name was not saved or restored from the configuration file.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
1748 | } |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1749 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"LISTEN_PORT"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1750 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1751 | if (sscanf((const char *)key, "%d", &ival) == 1) |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1752 | Config.my_port = ival; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1753 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1754 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1755 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMPFORMAT"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1756 | key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1757 | Config.tempFormat = key[0]; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1758 | xmlFree(key); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1759 | } |
206
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
1760 | 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
|
1761 | 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
|
1762 | } |
78fb6f99e473
Added GLOBAL GET and GLOBAL PUT commands.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
1763 | 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
|
1764 | Config.hum_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
95 | 1765 | } |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1766 | #ifdef HAVE_WIRINGPI_H |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1767 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1768 | parseLCDs(doc, cur); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1769 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1770 | #endif |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1771 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"FERMENTERS"))) { |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1772 | parseFermenters(doc, cur); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1773 | } |
91
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1774 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILES"))) { |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1775 | parseProfiles(doc, cur); |
901ca9858a7a
Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
1776 | } |
158 | 1777 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"DEVICES"))) { |
1778 | parseDevices(doc, cur); | |
1779 | } | |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1780 | #ifdef USE_SIMULATOR |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1781 | if ((!xmlStrcmp(cur->name, (const xmlChar *)"SIMULATORS"))) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1782 | parseSimulators(doc, cur); |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1783 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
1784 | #endif |
80
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1785 | cur = cur->next; |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1786 | } |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1787 | xmlFreeDoc(doc); |
81bf78a7618e
Switched to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents:
78
diff
changeset
|
1788 | |
51
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1789 | free(mypath); |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1790 | mypath = NULL; |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1791 | |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1792 | return rc; |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1793 | } |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1794 | |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1795 | |
a03b6dac5398
Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1796 |