thermferm/units.c

changeset 181
4099412fca09
parent 179
417ee898fb02
equal deleted inserted replaced
180:b62644eb442f 181:4099412fca09
19 * along with EC-65K; see the file COPYING. If not, write to the Free 19 * along with EC-65K; see the file COPYING. If not, write to the Free
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 #include "thermferm.h" 23 #include "thermferm.h"
24 #include "devices.h"
24 #include "units.h" 25 #include "units.h"
25 #include "xutil.h" 26 #include "xutil.h"
26 27
27 28
28 extern int debug; 29 extern int debug;
56 #else 57 #else
57 void *my_units_loop(void *threadid) 58 void *my_units_loop(void *threadid)
58 #endif 59 #endif
59 { 60 {
60 units_list *unit; 61 units_list *unit;
61 devices_list *device;
62 int rc, temp, deviation; 62 int rc, temp, deviation;
63 63
64 /* 64 /*
65 * Initialize units for processing 65 * Initialize units for processing
66 */ 66 */
154 } 154 }
155 } 155 }
156 if (my_shutdown) 156 if (my_shutdown)
157 break; 157 break;
158 158
159 device_out(unit->heater_address, unit->heater_state);
160 if (my_shutdown)
161 break;
162 device_out(unit->cooler_address, unit->cooler_state);
163 if (my_shutdown)
164 break;
165 device_out(unit->fan_address, unit->fan_state);
166 if (my_shutdown)
167 break;
168 } 159 }
169 usleep(10000); 160 usleep(100000);
170 } 161 }
171 162
172 /* 163 /*
173 * Stop units processing in a neat way 164 * Stop units processing in a neat way
174 */ 165 */
175 for (unit = Config.units; unit; unit = unit->next) { 166 for (unit = Config.units; unit; unit = unit->next) {
176 /* 167 /*
177 * Turn everything off 168 * Turn everything off
178 */ 169 */
179 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = 0; 170 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = 0;
171 device_out(unit->heater_address, unit->heater_state);
172 device_out(unit->cooler_address, unit->cooler_state);
173 device_out(unit->fan_address, unit->fan_state);
180 syslog(LOG_NOTICE, "Stopped unit %s mode %s", unit->name, UNITMODE[unit->mode]); 174 syslog(LOG_NOTICE, "Stopped unit %s mode %s", unit->name, UNITMODE[unit->mode]);
181 } 175 }
182 176
183 syslog(LOG_NOTICE, "Thread my_units_loop stopped"); 177 syslog(LOG_NOTICE, "Thread my_units_loop stopped");
184 if (debug) 178 if (debug)

mercurial