thermferm/simulator.c

Sun, 05 May 2024 17:24:54 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 05 May 2024 17:24:54 +0200
changeset 730
6eba006ed8f5
parent 724
01e3936f62d4
permissions
-rw-r--r--

Much faster shutdown of the websocket service.

259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 595
diff changeset
2 * Copyright (C) 2014-2024
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of the mbsePi-apps
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * mbsePi-apps is distributed in the hope that it will be useful, but
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
23 extern int debug;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
24
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 #include "thermferm.h"
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
26 #include "statetbl.h"
652
16d3d4b58b5b Moved all delay functions into a new general file.
Michiel Broek <mbroek@mbse.eu>
parents: 646
diff changeset
27 #include "delay.h"
714
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
28 #include "xutil.h"
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
29 #include "websocket.h"
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 #include "simulator.h"
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
32 int my_simulator_state = THREAD_OFF;
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
33 int my_simulator_command = THREAD_OFF;
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
34
646
e3edc783006b Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 595
diff changeset
35
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 #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:
diff changeset
37
262
d0014ccec615 Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 259
diff changeset
38 extern sys_config Config;
714
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
39 extern const char DEVPRESENT[4][6];
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
41
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
42
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
43 static int simulate(void);
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45
714
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
46 /*
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
47 * Return json data for one simulator
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
48 */
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
49 char *simulator_json(simulator_list *simulator)
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
50 {
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
51 char *payload, buf[64];
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
52
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
53 payload = xstrcpy((char *)"{\"uuid\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
54 payload = xstrcat(payload, simulator->uuid);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
55 payload = xstrcat(payload, (char *)"\",\"name\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
56 payload = xstrcat(payload, simulator->name);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
57 payload = xstrcat(payload, (char *)"\",\"simno\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
58 sprintf(buf, "%d", simulator->simno);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
59 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
60 payload = xstrcat(payload, (char *)",\"volume_air\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
61 sprintf(buf, "%d", simulator->volume_air);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
62 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
63 payload = xstrcat(payload, (char *)",\"volume_beer\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
64 sprintf(buf, "%d", simulator->volume_beer);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
65 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
66 payload = xstrcat(payload, (char *)",\"room\":{\"tempaddress\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
67 payload = xstrcat(payload, simulator->room_tempaddress);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
68 payload = xstrcat(payload, (char *)"\",\"temperature\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
69 sprintf(buf, "%.1f", simulator->room_temperature);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
70 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
71 payload = xstrcat(payload, (char *)",\"humaddress\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
72 payload = xstrcat(payload, simulator->room_humaddress);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
73 payload = xstrcat(payload, (char *)"\",\"humidity\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
74 sprintf(buf, "%.1f", simulator->room_humidity);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
75 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
76
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
77 payload = xstrcat(payload, (char *)"},\"air\":{\"address\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
78 payload = xstrcat(payload, simulator->air_address);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
79 payload = xstrcat(payload, (char *)"\",\"temperature\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
80 sprintf(buf, "%.4f", simulator->air_temperature);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
81 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
82 payload = xstrcat(payload, (char *)",\"present\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
83 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->air_present]);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
84 payload = xstrcat(payload, (char *)"\"},\"beer\":{\"address\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
85
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
86 payload = xstrcat(payload, simulator->beer_address);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
87 payload = xstrcat(payload, (char *)"\",\"temperature\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
88 sprintf(buf, "%.4f", simulator->beer_temperature);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
89 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
90 payload = xstrcat(payload, (char *)",\"present\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
91 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->beer_present]);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
92 payload = xstrcat(payload, (char *)"\"},\"beer2\":{\"address\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
93
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
94 payload = xstrcat(payload, simulator->beer_address2);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
95 payload = xstrcat(payload, (char *)"\",\"temperature\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
96 sprintf(buf, "%.4f", simulator->beer_temperature2);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
97 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
98 payload = xstrcat(payload, (char *)",\"present\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
99 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->beer_present2]);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
100 payload = xstrcat(payload, (char *)"\"},\"chiller\":{\"address\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
101
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
102 payload = xstrcat(payload, simulator->chiller_address);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
103 payload = xstrcat(payload, (char *)"\",\"temperature\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
104 sprintf(buf, "%.4f", simulator->chiller_temperature);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
105 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
106 payload = xstrcat(payload, (char *)",\"present\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
107 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->chiller_present]);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
108 payload = xstrcat(payload, (char *)"\"},\"cooler\":{\"address\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
109
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
110 payload = xstrcat(payload, simulator->cooler_address);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
111 payload = xstrcat(payload, (char *)"\",\"temperature\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
112 sprintf(buf, "%.4f", simulator->cooler_temp);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
113 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
114 payload = xstrcat(payload, (char *)",\"time\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
115 sprintf(buf, "%d", simulator->cooler_time);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
116 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
117 payload = xstrcat(payload, (char *)",\"size\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
118 sprintf(buf, "%.4f", simulator->cooler_size);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
119 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
120 payload = xstrcat(payload, (char *)",\"present\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
121 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->cooler_present]);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
122 payload = xstrcat(payload, (char *)"\",\"power\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
123 sprintf(buf, "%d", simulator->cooler_power);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
124 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
125 payload = xstrcat(payload, (char *)"},\"heater\":{\"address\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
126
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
127 payload = xstrcat(payload, simulator->heater_address);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
128 payload = xstrcat(payload, (char *)"\",\"temperature\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
129 sprintf(buf, "%.4f", simulator->heater_temp);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
130 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
131 payload = xstrcat(payload, (char *)",\"time\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
132 sprintf(buf, "%d", simulator->heater_time);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
133 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
134 payload = xstrcat(payload, (char *)",\"size\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
135 sprintf(buf, "%.4f", simulator->heater_size);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
136 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
137 payload = xstrcat(payload, (char *)",\"present\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
138 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->heater_present]);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
139 payload = xstrcat(payload, (char *)"\",\"power\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
140 sprintf(buf, "%d", simulator->heater_power);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
141 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
142 payload = xstrcat(payload, (char *)"},\"fan\":{\"address\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
143
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
144 payload = xstrcat(payload, simulator->fan_address);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
145 payload = xstrcat(payload, (char *)"\",\"present\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
146 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->fan_present]);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
147 payload = xstrcat(payload, (char *)"\",\"power\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
148 sprintf(buf, "%d", simulator->fan_power);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
149 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
150 payload = xstrcat(payload, (char *)"},\"light\":{\"address\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
151
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
152 payload = xstrcat(payload, simulator->light_address);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
153 payload = xstrcat(payload, (char *)"\",\"present\":\"");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
154 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->light_present]);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
155 payload = xstrcat(payload, (char *)"\",\"power\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
156 sprintf(buf, "%d", simulator->light_power);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
157 payload = xstrcat(payload, buf);
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
158 payload = xstrcat(payload, (char *)"},\"door\":{\"address\":\"");
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
159
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
160 payload = xstrcat(payload, simulator->door_address);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
161 payload = xstrcat(payload, (char *)"\",\"present\":\"");
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
162 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->door_present]);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
163 payload = xstrcat(payload, (char *)"\",\"value\":");
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
164 sprintf(buf, "%d", simulator->door_value);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
165 payload = xstrcat(payload, buf);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
166 payload = xstrcat(payload, (char *)"},\"psu\":{\"address\":\"");
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
167
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
168 payload = xstrcat(payload, simulator->psu_address);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
169 payload = xstrcat(payload, (char *)"\",\"present\":\"");
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
170 payload = xstrcat(payload, (char *)DEVPRESENT[simulator->psu_present]);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
171 payload = xstrcat(payload, (char *)"\",\"value\":");
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
172 sprintf(buf, "%d", simulator->psu_value);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
173 payload = xstrcat(payload, buf);
714
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
174 payload = xstrcat(payload, (char *)"},\"frigo_isolation\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
175
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
176 sprintf(buf, "%.4f", simulator->frigo_isolation);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
177 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
178
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
179 payload = xstrcat(payload, (char *)",\"timestamp\":");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
180 sprintf(buf, "%ld", (long)simulator->timestamp);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
181 payload = xstrcat(payload, buf);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
182 payload = xstrcat(payload, (char *)"}");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
183
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
184 return payload;
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
185 }
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
186
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
187
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
188
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
189 void simulator_ws(void)
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
190 {
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
191 bool comma = false;
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
192 char *payload = NULL, *payloadu = NULL;
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
193 simulator_list *simulator;
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
194
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
195 payload = xstrcpy((char *)"{\"type\":\"simulator\",\"metric\":[");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
196 for (simulator = Config.simulators; simulator; simulator = simulator->next) {
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
197 if (comma)
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
198 payload = xstrcat(payload, (char *)",");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
199 payloadu = simulator_json(simulator);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
200 payload = xstrcat(payload, payloadu);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
201 comma = true;
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
202 free(payloadu);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
203 payloadu = NULL;
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
204 }
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
205 payload = xstrcat(payload, (char *)"]}");
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
206 ws_broadcast(payload);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
207 free(payload);
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
208 payload = NULL;
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
209 }
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
210
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
211
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 660
diff changeset
212
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 void *my_simulator_loop(void *threadid)
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 {
724
01e3936f62d4 Log pid of each started thread so we can see which uses the most cpu time.
Michiel Broek <mbroek@mbse.eu>
parents: 716
diff changeset
215 pid_t pid = gettid();
01e3936f62d4 Log pid of each started thread so we can see which uses the most cpu time.
Michiel Broek <mbroek@mbse.eu>
parents: 716
diff changeset
216
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
217 my_simulator_command = THREAD_RUN;
724
01e3936f62d4 Log pid of each started thread so we can see which uses the most cpu time.
Michiel Broek <mbroek@mbse.eu>
parents: 716
diff changeset
218 syslog(LOG_NOTICE, "Thread my_simulator_loop started, pid=%d", pid);
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
219
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
220 /*
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
221 * Run the state machine
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
222 */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
223 simulate();
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
224
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
225 syslog(LOG_NOTICE, "Thread my_simulator_loop stopped");
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
226 return 0;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
227 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
228
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
229
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
230 SM_DECL(simulate, (char *)"simulator")
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
231 SM_STATES
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
232 Init,
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
233 Pause,
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
234 Waiting,
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
235 Run,
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
236 Websocket
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
237 SM_NAMES
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
238 (char *)"Init",
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
239 (char *)"Pause",
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
240 (char *)"Waiting",
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
241 (char *)"run",
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
242 (char *)"Websocket"
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
243 SM_EDECL
262
d0014ccec615 Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 259
diff changeset
244 simulator_list *simulator;
d0014ccec615 Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 259
diff changeset
245 time_t now, last = (time_t)0;
d0014ccec615 Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 259
diff changeset
246 int seconds = 0;
550
04c942cded91 Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents: 497
diff changeset
247 double k_room_air, sqm_room_air, thick_room_air, air_heat_transfer;
04c942cded91 Versie 0.8.3. Enkele debug console berichten verwijderd. De MQTT NCMD reboot en rebirth commando's geimplementeerd.
Michiel Broek <mbroek@mbse.eu>
parents: 497
diff changeset
248 double air_change, vhc_air = 0.00121;
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
249 double air_temp, beer_temp, chiller_temp;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
250 bool changed = false;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
252 SM_START(Init)
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
253
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
254 SM_STATE(Init)
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255
363
468ec0d96cce Back to the old PID algorythm. Version 0.3.1.
Michiel Broek <mbroek@mbse.eu>
parents: 362
diff changeset
256 for (simulator = Config.simulators; simulator; simulator = simulator->next) {
468ec0d96cce Back to the old PID algorythm. Version 0.3.1.
Michiel Broek <mbroek@mbse.eu>
parents: 362
diff changeset
257 /*
468ec0d96cce Back to the old PID algorythm. Version 0.3.1.
Michiel Broek <mbroek@mbse.eu>
parents: 362
diff changeset
258 * Heater and cooler have the air temperature
468ec0d96cce Back to the old PID algorythm. Version 0.3.1.
Michiel Broek <mbroek@mbse.eu>
parents: 362
diff changeset
259 */
468ec0d96cce Back to the old PID algorythm. Version 0.3.1.
Michiel Broek <mbroek@mbse.eu>
parents: 362
diff changeset
260 simulator->s_heat_temp = simulator->s_cool_temp = simulator->room_temperature;
468ec0d96cce Back to the old PID algorythm. Version 0.3.1.
Michiel Broek <mbroek@mbse.eu>
parents: 362
diff changeset
261 }
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
262 my_simulator_state = THREAD_RUN;
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
263 SM_PROCEED(Waiting);
363
468ec0d96cce Back to the old PID algorythm. Version 0.3.1.
Michiel Broek <mbroek@mbse.eu>
parents: 362
diff changeset
264
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
265 SM_STATE(Pause)
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
266
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
267 my_simulator_state = THREAD_PAUSE;
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
268 if (my_simulator_command == THREAD_OFF) {
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
269 SM_SUCCESS;
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
270 } else if (my_simulator_command == THREAD_RUN) {
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
271 my_simulator_state = THREAD_RUN;
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
272 SM_PROCEED(Waiting);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
273 }
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
274 mDelay(50);
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
275
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
276 SM_STATE(Waiting)
497
18ace27338e5 Compiles mosquitto code if library is found on the system. Bumped to version 0.5.4
Michiel Broek <mbroek@mbse.eu>
parents: 366
diff changeset
277
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
278 if (my_simulator_command == THREAD_OFF) {
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
279 SM_SUCCESS;
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
280 } else if (my_simulator_command == THREAD_PAUSE) {
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
281 SM_PROCEED(Pause);
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
282 }
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
283
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
284 now = time(NULL);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
285 if (now != last) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
286 last = now;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
287 seconds++;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
288 SM_PROCEED(Run);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
289 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
290 mDelay(50L);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
291
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
292 SM_STATE(Run)
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
294 changed = false;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
295 for (simulator = Config.simulators; simulator; simulator = simulator->next) {
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
296 if (my_simulator_command == THREAD_OFF) {
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
297 SM_SUCCESS;
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
298 } else if (my_simulator_command == THREAD_PAUSE) {
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
299 SM_PROCEED(Pause);
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
300 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
301
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
302 /*
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
303 * Copy to duplicates
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
304 */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
305 air_temp = simulator->air_temperature;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
306 beer_temp = simulator->beer_temperature;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
307 chiller_temp = simulator->chiller_temperature;
262
d0014ccec615 Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 259
diff changeset
308
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
309 /*
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
310 * First, calculate temperature difference between the room and the air in the
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
311 * fridge. We use the volume air to roughly calculate the total area between
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
312 * the in and outside. Calculate the effect and shift the air temperature towards
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
313 * the room temperature.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
314 */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
315 sqm_room_air = (cbrtl(simulator->volume_air) * cbrtl(simulator->volume_air) * 6) / 100; /* square meters all fridge sides */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
316 thick_room_air = 0.04; /* 4 cm walls */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
317 k_room_air = 0.03; /* Polystrene */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
318 air_heat_transfer=(k_room_air * sqm_room_air * (simulator->room_temperature - air_temp)) / thick_room_air;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
319 air_change = (air_heat_transfer / (vhc_air * ((simulator->volume_air - simulator->volume_beer) * 1000))) / 60.0;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
320 air_temp += air_change;
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
322 /*
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
323 * If heating, calculate temperature of the heating plate. If heating is off but
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
324 * the plate is warmer then the air, calculate the cooling down temperature.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
325 * Finally, calculate the new air and plate temperature.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
326 */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
327 if (simulator->heater_present == DEVPRESENT_YES && simulator->heater_power >= 50) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
328 if (simulator->s_heat_temp < simulator->heater_temp) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
329 simulator->s_heat_temp += 0.05;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
330 if (simulator->s_heat_temp > simulator->air_temperature)
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
331 air_temp += ((simulator->s_heat_temp - air_temp) / 100.0);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
332 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
333 } else {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
334 /*
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
335 * Follow the air temperature
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
336 */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
337 simulator->s_heat_temp -= (simulator->s_heat_temp - air_temp) / 25.0;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
338 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
339
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
340 /*
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
341 * If cooling, calculate temperature of the cooling plate. If cooling is off but
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
342 * the plate is colder then the air, calculate the warming up temperature.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
343 * Finsally, calculate the new air and plate temperature.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
344 */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
345 if (simulator->cooler_present == DEVPRESENT_YES && simulator->cooler_power >= 50) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
346 if (simulator->s_cool_temp > simulator->cooler_temp) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
347 simulator->s_cool_temp -= 0.05;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
348 if (simulator->s_cool_temp < air_temp)
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
349 air_temp -= ((air_temp - simulator->s_cool_temp) / 100.0);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
350 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
351 } else {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
352 simulator->s_cool_temp -= (simulator->s_cool_temp - air_temp) / 25.0;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
353 }
262
d0014ccec615 Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 259
diff changeset
354
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
355 /*
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
356 * Calculate final temperature of the beer and the air.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
357 */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
358 // Cheap trick, just follow slowly the air temp.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
359 beer_temp += ((air_temp - beer_temp) / 500.0);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
360 air_temp += ((beer_temp - air_temp) / 2500.0);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
361 chiller_temp = simulator->cooler_temp; // Link these
262
d0014ccec615 Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 259
diff changeset
362
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
363 /*
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
364 * Finally update simulated sensors with the new values.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
365 * The devices_loop will pickup the values and sets the resolution.
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
366 */
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
367 if (air_temp != simulator->air_temperature) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
368 // syslog(LOG_NOTICE, "SIM %d: air %f to %f", simulator->simno, simulator->air_temperature, air_temp);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
369 simulator->air_temperature = air_temp;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
370 changed = true;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
371 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
372 if (beer_temp != simulator->beer_temperature) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
373 // syslog(LOG_NOTICE, "SIM %d: beer %f to %f", simulator->simno, simulator->beer_temperature, beer_temp);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
374 simulator->beer_temperature = beer_temp;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
375 changed = true;
262
d0014ccec615 Simulation of fridge cold loss to the room added for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 259
diff changeset
376 }
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
377 if (chiller_temp != simulator->chiller_temperature) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
378 // syslog(LOG_NOTICE, "SIM %d: chiller %f to %f", simulator->simno, simulator->chiller_temperature, chiller_temp);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
379 simulator->chiller_temperature = chiller_temp;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
380 changed = true;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
381 }
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 }
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
383 SM_PROCEED(Websocket);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
384
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
385 SM_STATE(Websocket)
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
387 if (my_simulator_command == THREAD_OFF) {
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
388 SM_SUCCESS;
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
389 } else if (my_simulator_command == THREAD_PAUSE) {
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
390 SM_PROCEED(Pause);
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
391 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
392 if (changed) {
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
393 simulator_ws();
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
394 changed = false;
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
395 }
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
396 SM_PROCEED(Waiting);
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
397
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
398 SM_END
716
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
399
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
400 my_simulator_state = THREAD_OFF;
5c30c8ef83a8 Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.
Michiel Broek <mbroek@mbse.eu>
parents: 715
diff changeset
401
715
f5d85af156ab Added device_present() function to easy update device present from one-wire and simulator devices. When a simulator temperature sensor present is changed, the device table is changed too. Controlling simulator relays is now for each simulator. The simulator runs under the state machine. If something changed in the running simulator, all data is broadcasted over websocket. Completed the web editor.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
402 SM_RETURN
259
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404
b7c967359771 Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405 #endif

mercurial