thermferm/simulator.c

changeset 646
e3edc783006b
parent 595
d7342a8e7f4d
child 652
16d3d4b58b5b
equal deleted inserted replaced
645:49eb753a958b 646:e3edc783006b
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2014-2019 2 * Copyright (C) 2014-2024
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of the mbsePi-apps 6 * This file is part of the mbsePi-apps
7 * 7 *
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 #include "thermferm.h" 23 #include "thermferm.h"
24 #include "simulator.h" 24 #include "simulator.h"
25 25
26 int my_simulator_state = 0;
27
26 #ifdef USE_SIMULATOR 28 #ifdef USE_SIMULATOR
27 29
28 extern int my_shutdown; 30 extern int my_shutdown;
29 extern sys_config Config; 31 extern sys_config Config;
30 32
31 int SIMcooling = 0; 33 int SIMcooling = 0;
32 int SIMheating = 0; 34 int SIMheating = 0;
33 int SIMfan = 0; 35 int SIMfan = 0;
34 int SIMlight = 0; 36 int SIMlight = 0;
35 37
36 38
37 #ifdef HAVE_WIRINGPI_H
38 PI_THREAD (my_simulator_loop)
39 #else
40 void *my_simulator_loop(void *threadid) 39 void *my_simulator_loop(void *threadid)
41 #endif
42 { 40 {
43 simulator_list *simulator; 41 simulator_list *simulator;
44 time_t now, last = (time_t)0; 42 time_t now, last = (time_t)0;
45 int seconds = 0; 43 int seconds = 0;
46 double k_room_air, sqm_room_air, thick_room_air, air_heat_transfer; 44 double k_room_air, sqm_room_air, thick_room_air, air_heat_transfer;
47 double air_change, vhc_air = 0.00121; 45 double air_change, vhc_air = 0.00121;
48 46
47 my_simulator_state = 1;
49 syslog(LOG_NOTICE, "Thread my_simulator_loop started"); 48 syslog(LOG_NOTICE, "Thread my_simulator_loop started");
50 49
51 for (simulator = Config.simulators; simulator; simulator = simulator->next) { 50 for (simulator = Config.simulators; simulator; simulator = simulator->next) {
52 /* 51 /*
53 * Heater and cooler have the air temperature 52 * Heater and cooler have the air temperature
129 } 128 }
130 usleep(50000); 129 usleep(50000);
131 } 130 }
132 131
133 syslog(LOG_NOTICE, "Thread my_simulator_loop stopped"); 132 syslog(LOG_NOTICE, "Thread my_simulator_loop stopped");
133 my_simulator_state = 0;
134 return 0; 134 return 0;
135 } 135 }
136 136
137 137
138 #endif 138 #endif

mercurial