Wed, 24 Apr 2024 11:04:00 +0200
Drop fermenter volume setting.
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
654
e981d0185485
Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
652
diff
changeset
|
2 | * Copyright (C) 2014-2024 |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of the mbsePi-apps |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * mbsePi-apps is distributed in the hope that it will be useful, but |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
213
2317b8d644fa
Code cleanup, streamlined error messages.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
106 | 23 | #include "lock.h" |
24 | #include "rdconfig.h" | |
25 | #include "server.h" | |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
26 | #include "thermferm.h" |
654
e981d0185485
Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
652
diff
changeset
|
27 | #include "devices.h" |
652
16d3d4b58b5b
Moved all delay functions into a new general file.
Michiel Broek <mbroek@mbse.eu>
parents:
651
diff
changeset
|
28 | #include "delay.h" |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
29 | #include "simulator.h" |
106 | 30 | #include "lcd-pcf8574.h" |
31 | #include "lcd-buffer.h" | |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
32 | #include "slcd.h" |
198
20716bcff2b0
Added dependencies for panel
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
33 | #include "panel.h" |
654
e981d0185485
Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
652
diff
changeset
|
34 | #include "one-wire.h" |
106 | 35 | #include "futil.h" |
36 | #include "xutil.h" | |
316
73cd31dc6ce1
Moved pid function to separate files
Michiel Broek <mbroek@mbse.eu>
parents:
315
diff
changeset
|
37 | #include "pid.h" |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
38 | #include "mqtt.h" |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
39 | #include "statetbl.h" |
675
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
40 | #include "websocket.h" |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
43 | int my_shutdown = FALSE; |
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:
548
diff
changeset
|
44 | int my_reboot = FALSE; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | static pid_t pgrp, mypid; |
245
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
46 | int run_pause = FALSE; |
b01b6238eb67
You can now safely add and remove units on a running system.
Michiel Broek <mbroek@mbse.eu>
parents:
244
diff
changeset
|
47 | int run_hold = FALSE; |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
48 | int row; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
50 | extern int debug; |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
51 | extern int foreground; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | extern sys_config Config; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | extern int lcdHandle; |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
54 | extern int slcdHandle; |
646
e3edc783006b
Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents:
645
diff
changeset
|
55 | extern int my_devices_state; |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
56 | extern int my_devices_shutdown; |
646
e3edc783006b
Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents:
645
diff
changeset
|
57 | extern int my_panel_state; |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
58 | extern int my_panel_shutdown; |
646
e3edc783006b
Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents:
645
diff
changeset
|
59 | extern int my_server_state; |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
60 | extern int my_server_shutdown; |
675
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
61 | extern int my_ws_state; |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
62 | extern int my_ws_shutdown; |
646
e3edc783006b
Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents:
645
diff
changeset
|
63 | extern int my_simulator_state; |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
64 | #ifdef USE_SIMULATOR |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
65 | extern int my_simulator_shutdown; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
66 | #endif |
654
e981d0185485
Added one-wire thread and some old state table macro's. The state machine first state scans new one-wire devices and stores them in a linked list.
Michiel Broek <mbroek@mbse.eu>
parents:
652
diff
changeset
|
67 | extern int my_one_wire_state; |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
68 | extern int my_one_wire_shutdown; |
205 | 69 | int setupmenu = MENU_NONE; |
238 | 70 | units_list *current_unit = NULL; /* In panel editor this points to the current unit. */ |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
71 | float temp_temp = 20.0; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
72 | |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
73 | pthread_t my_one_wire_thread; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
74 | pthread_t my_devices_thread; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
75 | pthread_t my_panel_thread; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
76 | pthread_t my_server_thread; |
675
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
77 | pthread_t my_ws_thread; |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
78 | #ifdef USE_SIMULATOR |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
79 | pthread_t my_simulator_thread; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
80 | #endif |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
81 | |
645
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
82 | pthread_mutex_t mutexes[5]; |
646
e3edc783006b
Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents:
645
diff
changeset
|
83 | |
104 | 84 | extern const char UNITMODE[5][8]; |
195
b34a1b2421fb
Reset output when a different profile is selected. Better startup logging about the unit state. Added Beer, Fridge and partial Profile settings from the liveview weeb screen.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
85 | extern const char PROFSTATE[4][6]; |
104 | 86 | |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
87 | extern int sock; |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
88 | |
40
dafbbd5e9922
Prepared unix socket communication
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
89 | |
484
7362ebd40f26
Use user defined characters for the LCD display just like in Arduino projects.
Michiel Broek <mbroek@mbse.eu>
parents:
481
diff
changeset
|
90 | unsigned char degC[8] = { 0b01000, 0b10100, 0b01000, 0b00111, 0b01000, 0b01000, 0b01000, 0b00111 }; // [1] degree c sybmol |
7362ebd40f26
Use user defined characters for the LCD display just like in Arduino projects.
Michiel Broek <mbroek@mbse.eu>
parents:
481
diff
changeset
|
91 | unsigned char SP_Symbol[8] = { 0b11100, 0b10000, 0b11100, 0b00111, 0b11101, 0b00111, 0b00100, 0b00100 }; // [2] SP Symbol |
7362ebd40f26
Use user defined characters for the LCD display just like in Arduino projects.
Michiel Broek <mbroek@mbse.eu>
parents:
481
diff
changeset
|
92 | unsigned char CoolONOFF[8] = { 0b00000, 0b01110, 0b01000, 0b01000, 0b01000, 0b01000, 0b01110, 0b00000 }; // [3] Cool Symbol |
7362ebd40f26
Use user defined characters for the LCD display just like in Arduino projects.
Michiel Broek <mbroek@mbse.eu>
parents:
481
diff
changeset
|
93 | unsigned char RevCoolONOFF[8] = { 0b11111, 0b10001, 0b10111, 0b10111, 0b10111, 0b10111, 0b10001, 0b11111 }; // [4] Reverse Cool Symbol |
7362ebd40f26
Use user defined characters for the LCD display just like in Arduino projects.
Michiel Broek <mbroek@mbse.eu>
parents:
481
diff
changeset
|
94 | unsigned char HeatONOFF[8] = { 0b00000, 0b01010, 0b01010, 0b01110, 0b01110, 0b01010, 0b01010, 0b00000 }; // [5] HEAT symbol |
7362ebd40f26
Use user defined characters for the LCD display just like in Arduino projects.
Michiel Broek <mbroek@mbse.eu>
parents:
481
diff
changeset
|
95 | unsigned char RevHeatONOFF[8] = { 0b11111, 0b10101, 0b10101, 0b10001, 0b10001, 0b10101, 0b10101, 0b11111 }; // [6] reverse HEAT symbol |
7362ebd40f26
Use user defined characters for the LCD display just like in Arduino projects.
Michiel Broek <mbroek@mbse.eu>
parents:
481
diff
changeset
|
96 | |
7362ebd40f26
Use user defined characters for the LCD display just like in Arduino projects.
Michiel Broek <mbroek@mbse.eu>
parents:
481
diff
changeset
|
97 | |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
98 | int server(void); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | void help(void); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | void die(int); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
101 | void stopLCD(void); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
102 | #ifdef HAVE_WIRINGPI_H |
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
103 | void sendRCswitch(char *, int); |
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
104 | void stopRCswitch(void); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
105 | #endif |
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
106 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
108 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
109 | extern int mqtt_qos; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
110 | extern int mqtt_last_mid; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
111 | extern int mqtt_last_mid_sent; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
112 | extern int mqtt_mid_sent; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
113 | extern int mqtt_disconnect_sent; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
114 | extern int mqtt_connected; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
115 | extern int mqtt_status; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
116 | extern int mqtt_use; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
117 | extern struct mosquitto *mosq; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
118 | extern char *state; |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
119 | |
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
120 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | void help(void) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | { |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
124 | fprintf(stdout, "mbsePi-apps thermferm v%s starting\n\n", VERSION); |
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
125 | fprintf(stdout, "Usage: thermferm [-d] [-h]\n"); |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
126 | fprintf(stdout, " -d --debug Extra debug logging\n"); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
127 | fprintf(stdout, " -f --foreground Run in foreground\n"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | fprintf(stdout, " -h --help Display this help\n"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | void die(int onsig) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | switch (onsig) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | case SIGHUP: syslog(LOG_NOTICE, "Got SIGHUP, shutting down"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | case SIGINT: syslog(LOG_NOTICE, "Keyboard interrupt, shutting down"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | case SIGTERM: syslog(LOG_NOTICE, "Got SIGTERM, shutting down"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | break; |
326 | 142 | case SIGSEGV: syslog(LOG_NOTICE, "Got SIGSEGV, shutting down"); |
143 | my_shutdown = TRUE; | |
144 | exit(SIGSEGV); | |
145 | break; | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | default: syslog(LOG_NOTICE, "die() on signal %d", onsig); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
149 | my_shutdown = TRUE; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | |
238 | 153 | |
154 | void show_mode(void) | |
155 | { | |
156 | char buf[21]; | |
157 | ||
328 | 158 | snprintf(buf, 20, "Old mode %s", UNITMODE[current_unit->mode]); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
159 | #ifdef HAVE_WIRINGPI_H |
238 | 160 | lcdPuts(lcdHandle, buf); |
161 | lcdPosition(lcdHandle, 0, 1); | |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
162 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
163 | slcdPuts(slcdHandle, buf); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
164 | slcdPosition(slcdHandle, 0, 1); |
238 | 165 | } |
166 | ||
167 | ||
168 | ||
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
169 | void go_menu(int menu) |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
170 | { |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
171 | char buf[21]; |
238 | 172 | |
645
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
173 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
174 | pthread_mutex_lock(&mutexes[LOCK_MENU]); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
175 | #ifdef HAVE_WIRINGPI_H |
223
14700edd2a67
Removed LCD shadow copy buffer.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
176 | lcdClear(lcdHandle); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
177 | lcdPosition(lcdHandle, 0, 0); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
178 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
179 | slcdClear(slcdHandle); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
180 | slcdPosition(slcdHandle, 0, 0); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
181 | setupmenu = menu; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
182 | |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
183 | switch (menu) { |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
184 | case MENU_NONE: |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
185 | lcd_buf_show(); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
186 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
187 | |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
188 | case MENU_TOP_DEFAULT: |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
189 | #ifdef HAVE_WIRINGPI_H |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
190 | lcdPuts(lcdHandle, "Setup mode."); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
191 | lcdPosition(lcdHandle, 0, 1); |
223
14700edd2a67
Removed LCD shadow copy buffer.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
192 | lcdPuts(lcdHandle, "Up&Down = Escape"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
193 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
194 | slcdPuts(slcdHandle, "Setup mode."); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
195 | slcdPosition(slcdHandle, 0, 1); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
196 | slcdPuts(slcdHandle, "Up&Down = Escape"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
197 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
198 | |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
199 | case MENU_TOP_UNITS: |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
200 | #ifdef HAVE_WIRINGPI_H |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
201 | lcdPuts(lcdHandle, "Select units"); |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
202 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
203 | slcdPuts(slcdHandle, "Select units"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
204 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
205 | |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
206 | case MENU_UNITS: |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
207 | #ifdef HAVE_WIRINGPI_H |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
208 | lcdPuts(lcdHandle, "Choose unit:"); |
244
2f868eaefec2
Selecting units in setup does now work. Menu select variables are protected with thread locking.
Michiel Broek <mbroek@mbse.eu>
parents:
241
diff
changeset
|
209 | lcdPosition(lcdHandle, 0, 1); |
556
c2ee7f9a069e
Fixed compile for LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
554
diff
changeset
|
210 | lcdPuts(lcdHandle, current_unit->alias); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
211 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
212 | slcdPuts(slcdHandle, "Choose unit:"); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
213 | slcdPosition(slcdHandle, 0, 1); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
214 | slcdPuts(slcdHandle, current_unit->alias); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
215 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
216 | |
238 | 217 | case MENU_MODE_OFF: show_mode(); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
218 | #ifdef HAVE_WIRINGPI_H |
238 | 219 | lcdPuts(lcdHandle, "New mode OFF"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
220 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
221 | slcdPuts(slcdHandle, "New mode OFF"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
222 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
223 | |
238 | 224 | case MENU_MODE_NONE: show_mode(); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
225 | #ifdef HAVE_WIRINGPI_H |
238 | 226 | lcdPuts(lcdHandle, "New mode NONE"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
227 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
228 | slcdPuts(slcdHandle, "New mode NONE"); |
238 | 229 | break; |
230 | ||
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
231 | case MENU_NONE_HEAT: snprintf(buf, Config.lcd_cols, "Set heater %s", current_unit->heater_state ? "OFF":"ON"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
232 | #ifdef HAVE_WIRINGPI_H |
238 | 233 | lcdPuts(lcdHandle, buf); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
234 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
235 | slcdPuts(slcdHandle, buf); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
236 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
237 | |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
238 | case MENU_NONE_COOL: snprintf(buf, Config.lcd_cols, "Set cooler %s", current_unit->cooler_state ? "OFF":"ON"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
239 | #ifdef HAVE_WIRINGPI_H |
238 | 240 | lcdPuts(lcdHandle, buf); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
241 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
242 | slcdPuts(slcdHandle, buf); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
243 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
244 | |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
245 | case MENU_NONE_FAN: snprintf(buf, Config.lcd_cols, "Set fan %s", current_unit->fan_state ? "OFF":"ON"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
246 | #ifdef HAVE_WIRINGPI_H |
238 | 247 | lcdPuts(lcdHandle, buf); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
248 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
249 | slcdPuts(slcdHandle, buf); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
250 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
251 | |
238 | 252 | case MENU_MODE_BEER: show_mode(); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
253 | #ifdef HAVE_WIRINGPI_H |
238 | 254 | lcdPuts(lcdHandle, "New mode BEER"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
255 | #endif |
488
bee1f70fb42b
Small brewpanel display error fix, did not affect real hardware.
Michiel Broek <mbroek@mbse.eu>
parents:
486
diff
changeset
|
256 | slcdPuts(slcdHandle, "New mode BEER"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
257 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
258 | |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
259 | case MENU_BEER_TEMP_LO: |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
260 | #ifdef HAVE_WIRINGPI_H |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
261 | lcdPuts(lcdHandle, "Set beer low"); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
262 | lcdPosition(lcdHandle, 0, 1); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
263 | #endif |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
264 | slcdPuts(slcdHandle, "Set beer low"); |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
265 | slcdPosition(slcdHandle, 0, 1); |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
266 | snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
267 | #ifdef HAVE_WIRINGPI_H |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
268 | lcdPuts(lcdHandle, buf); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
269 | #endif |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
270 | slcdPuts(slcdHandle, buf); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
271 | break; |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
272 | |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
273 | case MENU_BEER_TEMP_HI: |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
274 | #ifdef HAVE_WIRINGPI_H |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
275 | lcdPuts(lcdHandle, "Set beer high"); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
276 | lcdPosition(lcdHandle, 0, 1); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
277 | #endif |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
278 | slcdPuts(slcdHandle, "Set beer high"); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
279 | slcdPosition(slcdHandle, 0, 1); |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
280 | snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
281 | #ifdef HAVE_WIRINGPI_H |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
282 | lcdPuts(lcdHandle, buf); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
283 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
284 | slcdPuts(slcdHandle, buf); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
285 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
286 | |
238 | 287 | case MENU_MODE_FRIDGE: show_mode(); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
288 | #ifdef HAVE_WIRINGPI_H |
238 | 289 | lcdPuts(lcdHandle, "New mode FRIDGE"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
290 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
291 | slcdPuts(slcdHandle, "New mode FRIDGE"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
292 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
293 | |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
294 | case MENU_FRIDGE_TEMP_LO: |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
295 | #ifdef HAVE_WIRINGPI_H |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
296 | lcdPuts(lcdHandle, "Set fridge low"); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
297 | lcdPosition(lcdHandle, 0, 1); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
298 | #endif |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
299 | slcdPuts(slcdHandle, "Set fridge low"); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
300 | slcdPosition(slcdHandle, 0, 1); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
301 | snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
302 | #ifdef HAVE_WIRINGPI_H |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
303 | lcdPuts(lcdHandle, buf); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
304 | #endif |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
305 | slcdPuts(slcdHandle, buf); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
306 | break; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
307 | |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
308 | case MENU_FRIDGE_TEMP_HI: |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
309 | #ifdef HAVE_WIRINGPI_H |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
310 | lcdPuts(lcdHandle, "Set fridge high"); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
311 | lcdPosition(lcdHandle, 0, 1); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
312 | #endif |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
313 | slcdPuts(slcdHandle, "Set fridge high"); |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
314 | slcdPosition(slcdHandle, 0, 1); |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
315 | snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
316 | #ifdef HAVE_WIRINGPI_H |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
317 | lcdPuts(lcdHandle, buf); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
318 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
319 | slcdPuts(slcdHandle, buf); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
320 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
321 | |
238 | 322 | case MENU_MODE_PROFILE: show_mode(); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
323 | #ifdef HAVE_WIRINGPI_H |
238 | 324 | lcdPuts(lcdHandle, "New mode PROFILE"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
325 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
326 | slcdPuts(slcdHandle, "New mode PROFILE"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
327 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
328 | |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
329 | case MENU_PROFILE_START: snprintf(buf, Config.lcd_cols, "%s", current_unit->profile_name); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
330 | #ifdef HAVE_WIRINGPI_H |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
331 | lcdPuts(lcdHandle, buf); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
332 | lcdPosition(lcdHandle, 0, 1); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
333 | lcdPuts(lcdHandle, "Start profile"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
334 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
335 | slcdPuts(slcdHandle, buf); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
336 | slcdPosition(slcdHandle, 0, 1); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
337 | slcdPuts(slcdHandle, "Start profile"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
338 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
339 | |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
340 | case MENU_PROFILE_PAUSE: snprintf(buf, Config.lcd_cols, "%s", current_unit->profile_name); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
341 | #ifdef HAVE_WIRINGPI_H |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
342 | lcdPuts(lcdHandle, buf); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
343 | lcdPosition(lcdHandle, 0, 1); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
344 | lcdPuts(lcdHandle, "Pause profile"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
345 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
346 | slcdPuts(slcdHandle, buf); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
347 | slcdPosition(slcdHandle, 0, 1); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
348 | slcdPuts(slcdHandle, "Pause profile"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
349 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
350 | |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
351 | case MENU_PROFILE_ABORT: snprintf(buf, Config.lcd_cols, "%s", current_unit->profile_name); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
352 | #ifdef HAVE_WIRINGPI_H |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
353 | lcdPuts(lcdHandle, buf); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
354 | lcdPosition(lcdHandle, 0, 1); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
355 | lcdPuts(lcdHandle, "Abort profile"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
356 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
357 | slcdPuts(slcdHandle, buf); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
358 | slcdPosition(slcdHandle, 0, 1); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
359 | slcdPuts(slcdHandle, "Abort profile"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
360 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
361 | |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
362 | case MENU_PROFILE_RESUME: snprintf(buf, Config.lcd_cols, "%s", current_unit->profile_name); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
363 | #ifdef HAVE_WIRINGPI_H |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
364 | lcdPuts(lcdHandle, buf); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
365 | lcdPosition(lcdHandle, 0, 1); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
366 | lcdPuts(lcdHandle, "Resume profile"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
367 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
368 | slcdPuts(slcdHandle, buf); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
369 | slcdPosition(slcdHandle, 0, 1); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
370 | slcdPuts(slcdHandle, "Resume profile"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
371 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
372 | |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
373 | case MENU_PROFILE_GOOFF: snprintf(buf, Config.lcd_cols, "%s", current_unit->profile_name); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
374 | #ifdef HAVE_WIRINGPI_H |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
375 | lcdPuts(lcdHandle, buf); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
376 | lcdPosition(lcdHandle, 0, 1); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
377 | lcdPuts(lcdHandle, "Set profile OFF"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
378 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
379 | slcdPuts(slcdHandle, buf); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
380 | slcdPosition(slcdHandle, 0, 1); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
381 | slcdPuts(slcdHandle, "Set profile OFF"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
382 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
383 | |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
384 | case MENU_TOP_SYS: |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
385 | #ifdef HAVE_WIRINGPI_H |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
386 | lcdPuts(lcdHandle, "System menu"); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
387 | #endif |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
388 | slcdPuts(slcdHandle, "System menu"); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
389 | break; |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
390 | |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
391 | case MENU_SYS_HALT: |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
392 | #ifdef HAVE_WIRINGPI_H |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
393 | lcdPuts(lcdHandle, "Halt system"); |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
394 | #endif |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
395 | slcdPuts(slcdHandle, "Halt system"); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
396 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
397 | |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
398 | case MENU_SYS_REBOOT: |
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
399 | #ifdef HAVE_WIRINGPI_H |
669
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
400 | lcdPuts(lcdHandle, "Restart app."); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
401 | #endif |
669
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
402 | slcdPuts(slcdHandle, "Restart app."); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
403 | break; |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
404 | } |
244
2f868eaefec2
Selecting units in setup does now work. Menu select variables are protected with thread locking.
Michiel Broek <mbroek@mbse.eu>
parents:
241
diff
changeset
|
405 | |
645
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
406 | pthread_mutex_unlock(&mutexes[LOCK_MENU]); |
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
407 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
214
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
408 | } |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
409 | |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
410 | |
37d1eb0e1d66
Added a bunch of panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
411 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
412 | void stopLCD(void) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
413 | { |
645
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
414 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
418
0bfe08c7ba6e
Reenabled code round LCD driver.
Michiel Broek <mbroek@mbse.eu>
parents:
406
diff
changeset
|
415 | #ifdef HAVE_WIRINGPI_H |
223
14700edd2a67
Removed LCD shadow copy buffer.
Michiel Broek <mbroek@mbse.eu>
parents:
221
diff
changeset
|
416 | lcdClear(lcdHandle); |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
417 | #endif |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
418 | slcdClear(slcdHandle); |
426
e54611453d29
Moved global bit defines to config.h
Michiel Broek <mbroek@mbse.eu>
parents:
423
diff
changeset
|
419 | setBacklight(0); |
645
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
420 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
421 | } |
238 | 422 | |
423 | ||
424 | ||
425 | /* | |
426 | * Change mode of current_unit | |
427 | */ | |
428 | void change_mode(int mode) | |
429 | { | |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
430 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
431 | if ((current_unit->mode == UNITMODE_OFF) && (mode != UNITMODE_OFF)) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
432 | current_unit->mqtt_flag |= MQTT_FLAG_BIRTH; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
433 | } |
238 | 434 | syslog(LOG_NOTICE, "Mode from %s to %s via panel interface", UNITMODE[current_unit->mode], UNITMODE[mode]); |
435 | current_unit->mode = mode; | |
436 | /* Allways turn everything off after a mode change */ | |
367
b9130db48c63
Fixed compiling on a real RPi
Michiel Broek <mbroek@mbse.eu>
parents:
364
diff
changeset
|
437 | current_unit->PID_cool->OutP = current_unit->PID_heat->OutP = 0.0; |
b9130db48c63
Fixed compiling on a real RPi
Michiel Broek <mbroek@mbse.eu>
parents:
364
diff
changeset
|
438 | current_unit->PID_cool->Mode = current_unit->PID_heat->Mode = PID_MODE_NONE; |
582
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
578
diff
changeset
|
439 | current_unit->heater_state = current_unit->cooler_state = current_unit->fan_state = current_unit->light_state = current_unit->light_timer = 0; |
367
b9130db48c63
Fixed compiling on a real RPi
Michiel Broek <mbroek@mbse.eu>
parents:
364
diff
changeset
|
440 | current_unit->heater_wait = current_unit->cooler_wait = current_unit->fan_wait = current_unit->light_wait = 0; |
238 | 441 | device_out(current_unit->heater_address, current_unit->heater_state); |
442 | device_out(current_unit->cooler_address, current_unit->cooler_state); | |
443 | device_out(current_unit->fan_address, current_unit->fan_state); | |
367
b9130db48c63
Fixed compiling on a real RPi
Michiel Broek <mbroek@mbse.eu>
parents:
364
diff
changeset
|
444 | device_out(current_unit->light_address, current_unit->light_state); |
238 | 445 | if (current_unit->mode == UNITMODE_PROFILE) { |
446 | /* | |
447 | * Set a sane default until it will be overruled by the | |
448 | * main processing loop. | |
449 | */ | |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
450 | current_unit->prof_target_lo = 20.0; |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
451 | current_unit->prof_target_hi = 20.0; |
406
44566f986f76
Fixed compiling on a real RPi.
Michiel Broek <mbroek@mbse.eu>
parents:
405
diff
changeset
|
452 | current_unit->prof_fridge_mode = 0; |
238 | 453 | } |
454 | } | |
455 | ||
456 | ||
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
457 | |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
458 | /* |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
459 | * Handle panel key events |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
460 | */ |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
461 | void panel_key_events(int key) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
462 | { |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
463 | units_list *unit; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
464 | int rc; |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
465 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
466 | switch (setupmenu) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
467 | case MENU_NONE: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
468 | if ((key == KEY_DOWN) || (key == KEY_UP)) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
469 | lcd_buf_step(key); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
470 | if ((key == KEY_CONFIRM) && (setupmenu == MENU_NONE)) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
471 | go_menu(MENU_TOP_DEFAULT); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
472 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
473 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
474 | case MENU_TOP_DEFAULT: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
475 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
476 | go_menu(MENU_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
477 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
478 | go_menu(MENU_TOP_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
479 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
480 | go_menu(MENU_TOP_SYS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
481 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
482 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
483 | case MENU_TOP_UNITS: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
484 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
485 | go_menu(MENU_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
486 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
487 | go_menu(MENU_TOP_SYS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
488 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
489 | go_menu(MENU_TOP_DEFAULT); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
490 | if ((key == KEY_ENTER) && Config.units) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
491 | /* |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
492 | * Start with the first unit |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
493 | */ |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
494 | current_unit = Config.units; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
495 | go_menu(MENU_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
496 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
497 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
498 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
499 | case MENU_UNITS: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
500 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
501 | go_menu(MENU_TOP_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
502 | if (key == KEY_DOWN) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
503 | if (current_unit->next) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
504 | current_unit = current_unit->next; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
505 | go_menu(MENU_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
506 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
507 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
508 | if (key == KEY_UP) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
509 | for (unit = Config.units; unit; unit = unit->next) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
510 | if (unit->next && (unit->next == current_unit)) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
511 | current_unit = unit; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
512 | go_menu(MENU_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
513 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
514 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
515 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
516 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
517 | if (key == KEY_ENTER) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
518 | /* |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
519 | * Drop into the current mode |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
520 | */ |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
521 | switch (current_unit->mode) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
522 | case UNITMODE_OFF: go_menu(MENU_MODE_OFF); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
523 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
524 | case UNITMODE_NONE: go_menu(MENU_MODE_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
525 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
526 | case UNITMODE_FRIDGE: go_menu(MENU_MODE_FRIDGE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
527 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
528 | case UNITMODE_BEER: go_menu(MENU_MODE_BEER); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
529 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
530 | case UNITMODE_PROFILE: go_menu(MENU_MODE_PROFILE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
531 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
532 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
533 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
534 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
535 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
536 | case MENU_MODE_OFF: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
537 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
538 | go_menu(MENU_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
539 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
540 | go_menu(MENU_MODE_NONE); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
541 | if (key == KEY_UP) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
542 | if (current_unit->profile_uuid) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
543 | go_menu(MENU_MODE_PROFILE); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
544 | else |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
545 | go_menu(MENU_MODE_BEER); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
546 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
547 | if (key == KEY_ENTER) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
548 | change_mode(UNITMODE_OFF); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
549 | go_menu(MENU_MODE_OFF); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
550 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
551 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
552 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
553 | case MENU_MODE_NONE: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
554 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
555 | go_menu(MENU_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
556 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
557 | go_menu(MENU_MODE_FRIDGE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
558 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
559 | go_menu(MENU_MODE_OFF); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
560 | if (key == KEY_ENTER) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
561 | if (current_unit->mode == UNITMODE_NONE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
562 | go_menu(MENU_NONE_HEAT); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
563 | else { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
564 | change_mode(UNITMODE_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
565 | go_menu(MENU_MODE_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
566 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
567 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
568 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
569 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
570 | case MENU_NONE_HEAT: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
571 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
572 | go_menu(MENU_MODE_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
573 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
574 | go_menu(MENU_NONE_COOL); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
575 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
576 | go_menu(MENU_NONE_FAN); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
577 | if (key == KEY_ENTER) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
578 | if (current_unit->heater_state) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
579 | current_unit->heater_state = 0; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
580 | else |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
581 | current_unit->heater_state = 100; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
582 | go_menu(MENU_NONE_HEAT); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
583 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
584 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
585 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
586 | case MENU_NONE_COOL: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
587 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
588 | go_menu(MENU_MODE_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
589 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
590 | go_menu(MENU_NONE_FAN); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
591 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
592 | go_menu(MENU_NONE_HEAT); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
593 | if (key == KEY_ENTER) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
594 | if (current_unit->cooler_state) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
595 | current_unit->cooler_state = 0; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
596 | else |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
597 | current_unit->cooler_state = 100; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
598 | go_menu(MENU_NONE_COOL); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
599 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
600 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
601 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
602 | case MENU_NONE_FAN: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
603 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
604 | go_menu(MENU_MODE_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
605 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
606 | go_menu(MENU_NONE_HEAT); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
607 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
608 | go_menu(MENU_NONE_COOL); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
609 | if (key == KEY_ENTER) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
610 | if (current_unit->fan_state) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
611 | current_unit->fan_state = 0; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
612 | else |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
613 | current_unit->fan_state = 100; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
614 | go_menu(MENU_NONE_FAN); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
615 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
616 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
617 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
618 | case MENU_MODE_FRIDGE: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
619 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
620 | go_menu(MENU_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
621 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
622 | go_menu(MENU_MODE_BEER); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
623 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
624 | go_menu(MENU_MODE_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
625 | if (key == KEY_ENTER) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
626 | if (current_unit->mode == UNITMODE_FRIDGE) { |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
627 | temp_temp = current_unit->fridge_set_lo; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
628 | go_menu(MENU_FRIDGE_TEMP_LO); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
629 | } else { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
630 | change_mode(UNITMODE_FRIDGE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
631 | go_menu(MENU_MODE_FRIDGE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
632 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
633 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
634 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
635 | |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
636 | case MENU_FRIDGE_TEMP_LO: |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
637 | if (key == KEY_ESCAPE) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
638 | temp_temp = current_unit->fridge_set_hi; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
639 | go_menu(MENU_FRIDGE_TEMP_HI); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
640 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
641 | if (key == KEY_DOWN) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
642 | if (temp_temp > current_unit->temp_set_min) |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
643 | temp_temp -= 0.1; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
644 | go_menu(MENU_FRIDGE_TEMP_LO); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
645 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
646 | if (key == KEY_UP) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
647 | if (temp_temp < current_unit->temp_set_max) |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
648 | temp_temp += 0.1; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
649 | go_menu(MENU_FRIDGE_TEMP_LO); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
650 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
651 | if (key == KEY_CONFIRM) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
652 | if (temp_temp != current_unit->fridge_set_lo) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
653 | syslog(LOG_NOTICE, "Fridge temp low changed from %.1f to %.1f from the panel", current_unit->fridge_set_lo, temp_temp); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
654 | current_unit->fridge_set_lo = temp_temp; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
655 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
656 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
657 | temp_temp = current_unit->fridge_set_hi; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
658 | go_menu(MENU_FRIDGE_TEMP_HI); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
659 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
660 | break; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
661 | |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
662 | case MENU_FRIDGE_TEMP_HI: |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
663 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
664 | go_menu(MENU_MODE_FRIDGE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
665 | if (key == KEY_DOWN) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
666 | if (temp_temp > current_unit->temp_set_min) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
667 | temp_temp -= 0.1; |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
668 | go_menu(MENU_FRIDGE_TEMP_HI); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
669 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
670 | if (key == KEY_UP) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
671 | if (temp_temp < current_unit->temp_set_max) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
672 | temp_temp += 0.1; |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
673 | go_menu(MENU_FRIDGE_TEMP_HI); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
674 | } |
302
3d2bd47f35b4
Use confirm instead of enter key when stepping to a new beer or fridge temperature
Michiel Broek <mbroek@mbse.eu>
parents:
297
diff
changeset
|
675 | if (key == KEY_CONFIRM) { |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
676 | if (temp_temp != current_unit->fridge_set_hi) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
677 | syslog(LOG_NOTICE, "Fridge temp high changed from %.1f to %.1f from the panel", current_unit->fridge_set_hi, temp_temp); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
678 | current_unit->fridge_set_hi = temp_temp; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
679 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
680 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
681 | go_menu(MENU_MODE_FRIDGE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
682 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
683 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
684 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
685 | case MENU_MODE_BEER: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
686 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
687 | go_menu(MENU_UNITS); |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
688 | if (key == KEY_DOWN) { |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
689 | if (current_unit->profile_uuid) |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
690 | go_menu(MENU_MODE_PROFILE); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
691 | else |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
692 | go_menu(MENU_MODE_OFF); |
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
693 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
694 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
695 | go_menu(MENU_MODE_FRIDGE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
696 | if (key == KEY_ENTER) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
697 | if (current_unit->mode == UNITMODE_BEER) { |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
698 | temp_temp = current_unit->beer_set_lo; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
699 | go_menu(MENU_BEER_TEMP_LO); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
700 | } else { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
701 | change_mode(UNITMODE_BEER); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
702 | go_menu(MENU_MODE_BEER); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
703 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
704 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
705 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
706 | |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
707 | case MENU_BEER_TEMP_LO: |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
708 | if (key == KEY_ESCAPE) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
709 | temp_temp = current_unit->beer_set_hi; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
710 | go_menu(MENU_BEER_TEMP_HI); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
711 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
712 | if (key == KEY_DOWN) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
713 | if (temp_temp > current_unit->temp_set_min) |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
714 | temp_temp -= 0.1; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
715 | go_menu(MENU_BEER_TEMP_LO); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
716 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
717 | if (key == KEY_UP) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
718 | if (temp_temp < current_unit->temp_set_max) |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
719 | temp_temp += 0.1; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
720 | go_menu(MENU_BEER_TEMP_LO); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
721 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
722 | if (key == KEY_CONFIRM) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
723 | if (temp_temp != current_unit->beer_set_lo ) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
724 | syslog(LOG_NOTICE, "Beer temp low changed from %.1f to %.1f from the panel", current_unit->beer_set_lo, temp_temp); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
725 | current_unit->beer_set_lo = temp_temp; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
726 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
727 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
728 | temp_temp = current_unit->beer_set_hi; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
729 | go_menu(MENU_BEER_TEMP_HI); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
730 | } |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
731 | break; |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
732 | |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
733 | case MENU_BEER_TEMP_HI: |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
734 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
735 | go_menu(MENU_MODE_BEER); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
736 | if (key == KEY_DOWN) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
737 | if (temp_temp > current_unit->temp_set_min) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
738 | temp_temp -= 0.1; |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
739 | go_menu(MENU_BEER_TEMP_HI); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
740 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
741 | if (key == KEY_UP) { |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
742 | if (temp_temp < current_unit->temp_set_max) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
743 | temp_temp += 0.1; |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
744 | go_menu(MENU_BEER_TEMP_HI); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
745 | } |
302
3d2bd47f35b4
Use confirm instead of enter key when stepping to a new beer or fridge temperature
Michiel Broek <mbroek@mbse.eu>
parents:
297
diff
changeset
|
746 | if (key == KEY_CONFIRM) { |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
747 | if (temp_temp != current_unit->beer_set_hi ) { |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
748 | syslog(LOG_NOTICE, "Beer temp high changed from %.1f to %.1f from the panel", current_unit->beer_set_hi, temp_temp); |
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
749 | current_unit->beer_set_hi = temp_temp; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
750 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
751 | } |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
752 | go_menu(MENU_MODE_BEER); |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
753 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
754 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
755 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
756 | case MENU_MODE_PROFILE: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
757 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
758 | go_menu(MENU_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
759 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
760 | go_menu(MENU_MODE_OFF); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
761 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
762 | go_menu(MENU_MODE_BEER); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
763 | if (key == KEY_ENTER) { |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
764 | if (current_unit->mode == UNITMODE_PROFILE) { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
765 | switch (current_unit->prof_state) { |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
766 | case PROFILE_OFF: go_menu(MENU_PROFILE_START); |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
767 | break; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
768 | case PROFILE_PAUSE: go_menu(MENU_PROFILE_RESUME); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
769 | break; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
770 | case PROFILE_RUN: go_menu(MENU_PROFILE_PAUSE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
771 | break; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
772 | case PROFILE_DONE: go_menu(MENU_PROFILE_GOOFF); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
773 | break; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
774 | } |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
775 | } else { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
776 | change_mode(UNITMODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
777 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
778 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
779 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
780 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
781 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
782 | case MENU_PROFILE_START: |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
783 | if (key == KEY_ESCAPE) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
784 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
785 | if (key == KEY_ENTER) { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
786 | current_unit->prof_state = PROFILE_RUN; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
787 | current_unit->prof_started = time(NULL); |
289
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
288
diff
changeset
|
788 | current_unit->prof_paused = current_unit->prof_primary_done = 0; |
d810df0df36a
Added code to detect primary fermentation
Michiel Broek <mbroek@mbse.eu>
parents:
288
diff
changeset
|
789 | current_unit->prof_peak_abs = current_unit->prof_peak_rel = 0.0; |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
790 | syslog(LOG_NOTICE, "Profile started from the panel"); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
791 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
792 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
793 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
794 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
795 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
796 | case MENU_PROFILE_PAUSE: |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
797 | if (key == KEY_ESCAPE) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
798 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
799 | if ((key == KEY_DOWN) || (key == KEY_UP)) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
800 | go_menu(MENU_PROFILE_ABORT); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
801 | if (key == KEY_ENTER) { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
802 | current_unit->prof_state = PROFILE_PAUSE; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
803 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
804 | syslog(LOG_NOTICE, "Profile pause from the panel"); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
805 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
806 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
807 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
808 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
809 | case MENU_PROFILE_ABORT: |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
810 | if (key == KEY_ESCAPE) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
811 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
812 | if ((key == KEY_DOWN) || (key == KEY_UP)) { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
813 | if (current_unit->prof_state == PROFILE_PAUSE) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
814 | go_menu(MENU_PROFILE_RESUME); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
815 | else if (current_unit->prof_state == PROFILE_RUN) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
816 | go_menu(MENU_PROFILE_PAUSE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
817 | } |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
818 | if ((key == KEY_ENTER) && ((current_unit->prof_state == PROFILE_RUN) || (current_unit->prof_state == PROFILE_PAUSE))) { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
819 | current_unit->prof_state = PROFILE_OFF; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
820 | current_unit->prof_started = 0; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
821 | syslog(LOG_NOTICE, "Profile aborted from the panel"); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
822 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
823 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
824 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
825 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
826 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
827 | case MENU_PROFILE_RESUME: |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
828 | if (key == KEY_ESCAPE) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
829 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
830 | if ((key == KEY_DOWN) || (key == KEY_UP)) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
831 | go_menu(MENU_PROFILE_ABORT); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
832 | if (key == KEY_ENTER) { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
833 | current_unit->prof_state = PROFILE_RUN; |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
834 | syslog(LOG_NOTICE, "Profile resume from the panel"); |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
835 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
836 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
837 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
838 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
839 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
840 | case MENU_PROFILE_GOOFF: |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
841 | if (key == KEY_ESCAPE) |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
842 | go_menu(MENU_MODE_PROFILE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
843 | if (key == KEY_ENTER) { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
844 | if (current_unit->prof_state == PROFILE_DONE) { |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
845 | current_unit->prof_state = PROFILE_OFF; |
510
2da3d3340403
Version 0.6.0. The MQTT data messages are now allways the same length so that openhab will function with the message updates.
Michiel Broek <mbroek@mbse.eu>
parents:
507
diff
changeset
|
846 | current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
847 | syslog(LOG_NOTICE, "Profile from done to off from the panel"); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
848 | } |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
849 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
850 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
851 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
852 | case MENU_TOP_SYS: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
853 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
854 | go_menu(MENU_NONE); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
855 | if (key == KEY_DOWN) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
856 | go_menu(MENU_TOP_DEFAULT); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
857 | if (key == KEY_UP) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
858 | go_menu(MENU_TOP_UNITS); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
859 | if (key == KEY_ENTER) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
860 | go_menu(MENU_SYS_HALT); |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
861 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
862 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
863 | case MENU_SYS_HALT: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
864 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
865 | go_menu(MENU_TOP_SYS); |
248
870d0be6880d
Removed two system menus that would not work correctly. All panel menus are complete now.
Michiel Broek <mbroek@mbse.eu>
parents:
247
diff
changeset
|
866 | if ((key == KEY_DOWN) || (key == KEY_UP)) |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
867 | go_menu(MENU_SYS_REBOOT); |
248
870d0be6880d
Removed two system menus that would not work correctly. All panel menus are complete now.
Michiel Broek <mbroek@mbse.eu>
parents:
247
diff
changeset
|
868 | if (key == KEY_CONFIRM) { |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
869 | rc = system("/sbin/halt"); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
870 | syslog(LOG_NOTICE, "System halt from panel: /sbin/halt rc=%d", rc); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
871 | go_menu(MENU_NONE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
872 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
873 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
874 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
875 | case MENU_SYS_REBOOT: |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
876 | if (key == KEY_ESCAPE) |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
877 | go_menu(MENU_TOP_SYS); |
248
870d0be6880d
Removed two system menus that would not work correctly. All panel menus are complete now.
Michiel Broek <mbroek@mbse.eu>
parents:
247
diff
changeset
|
878 | if ((key == KEY_DOWN) || (key == KEY_UP)) |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
879 | go_menu(MENU_SYS_HALT); |
248
870d0be6880d
Removed two system menus that would not work correctly. All panel menus are complete now.
Michiel Broek <mbroek@mbse.eu>
parents:
247
diff
changeset
|
880 | if (key == KEY_CONFIRM) { |
669
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
881 | /* |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
882 | * Restart. The server process will restart which is handled |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
883 | * in the main thread loop. |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
884 | */ |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
885 | my_reboot = my_shutdown = TRUE; |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
886 | syslog(LOG_NOTICE, "Application restart from panel"); |
247
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
887 | go_menu(MENU_NONE); |
f3d0e9445fcd
Added profile panel menus and system panel menus
Michiel Broek <mbroek@mbse.eu>
parents:
246
diff
changeset
|
888 | } |
246
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
889 | break; |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
890 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
891 | } |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
892 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
893 | |
6df404da3537
Setting fridge and beer temperature from the panel implemented
Michiel Broek <mbroek@mbse.eu>
parents:
245
diff
changeset
|
894 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
895 | int main(int argc, char *argv[]) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
896 | { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
897 | int rc, c, i; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
898 | pid_t frk; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
899 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
900 | while (1) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
901 | int option_index = 0; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
902 | static struct option long_options[] = { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
903 | {"debug", 0, 0, 'c'}, |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
904 | {"foreground", 0, 0, 'f'}, |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
905 | {"help", 0, 0, 'h'}, |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
906 | {0, 0, 0, 0} |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
907 | }; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
908 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
909 | c = getopt_long(argc, argv, "dh", long_options, &option_index); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
910 | if (c == -1) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
911 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
912 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
913 | switch (c) { |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
914 | case 'd': debug = TRUE; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
915 | break; |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
916 | case 'f': foreground = TRUE; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
917 | break; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
918 | case 'h': help(); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
919 | return 1; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
920 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
921 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
922 | |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
923 | openlog("thermferm", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER); |
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
924 | syslog(LOG_NOTICE, "mbsePi-apps thermferm v%s starting", VERSION); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
925 | |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
926 | if (rdconfig()) { |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
927 | fprintf(stderr, "Error reading configuration\n"); |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
928 | syslog(LOG_NOTICE, "Error reading configuration: halted"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
929 | return 1; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
930 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
931 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
932 | /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
933 | * Catch all the signals we can, and ignore the rest. Note that SIGKILL can't be ignored |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
934 | * but that's live. This daemon should only be stopped by SIGTERM. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
935 | * Don't catch SIGCHLD. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
936 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
937 | for (i = 0; i < NSIG; i++) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
938 | if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP)) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
939 | signal(i, (void (*))die); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
940 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
941 | |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
942 | #ifdef HAVE_WIRINGPI_H |
651
da166cb8470f
Log compile options on startup.
Michiel Broek <mbroek@mbse.eu>
parents:
648
diff
changeset
|
943 | syslog(LOG_NOTICE, "Build with wiringPi"); |
611 | 944 | if (wiringPiSetup () ) { |
945 | syslog(LOG_NOTICE, "Error wiringPiSetup(): halted"); | |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
946 | return 1; |
611 | 947 | } |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
948 | #endif |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
949 | |
651
da166cb8470f
Log compile options on startup.
Michiel Broek <mbroek@mbse.eu>
parents:
648
diff
changeset
|
950 | #ifdef USE_SIMULATOR |
da166cb8470f
Log compile options on startup.
Michiel Broek <mbroek@mbse.eu>
parents:
648
diff
changeset
|
951 | syslog(LOG_NOTICE, "Build with simulator"); |
da166cb8470f
Log compile options on startup.
Michiel Broek <mbroek@mbse.eu>
parents:
648
diff
changeset
|
952 | #endif |
da166cb8470f
Log compile options on startup.
Michiel Broek <mbroek@mbse.eu>
parents:
648
diff
changeset
|
953 | |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
954 | if (foreground) { |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
955 | /* |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
956 | * Run in foreground. |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
957 | */ |
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:
548
diff
changeset
|
958 | do { |
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:
548
diff
changeset
|
959 | rc = server(); |
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:
548
diff
changeset
|
960 | } while (my_reboot == TRUE); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
961 | } else { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
962 | /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
963 | * Server initialization is complete. Now we can fork the |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
964 | * daemon and return to the user. We need to do a setpgrp |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
965 | * so that the daemon will no longer be assosiated with the |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
966 | * users control terminal. This is done before the fork, so |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
967 | * that the child will not be a process group leader. Otherwise, |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
968 | * if the child were to open a terminal, it would become |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
969 | * associated with that terminal as its control terminal. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
970 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
971 | if ((pgrp = setpgid(0, 0)) == -1) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
972 | syslog(LOG_NOTICE, "setpgpid failed"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
973 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
974 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
975 | frk = fork(); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
976 | switch (frk) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
977 | case -1: |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
978 | syslog(LOG_NOTICE, "Daemon fork failed: %s", strerror(errno)); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
979 | stopLCD(); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
980 | exit(1); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
981 | case 0: /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
982 | * Run the daemon |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
983 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
984 | fclose(stdin); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
985 | if (open("/dev/null", O_RDONLY) != 0) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
986 | syslog(LOG_NOTICE, "Reopen of stdin to /dev/null failed"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
987 | _exit(2); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
988 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
989 | fclose(stdout); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
990 | if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 1) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
991 | syslog(LOG_NOTICE, "Reopen of stdout to /dev/null failed"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
992 | _exit(2); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
993 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
994 | fclose(stderr); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
995 | if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 2) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
996 | syslog(LOG_NOTICE, "Reopen of stderr to /dev/null failed"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
997 | _exit(2); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
998 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
999 | mypid = getpid(); |
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:
548
diff
changeset
|
1000 | do { |
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:
548
diff
changeset
|
1001 | rc = server(); |
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:
548
diff
changeset
|
1002 | } while (my_reboot == TRUE); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1003 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1004 | /* Not reached */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1005 | default: |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1006 | /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1007 | * Here we detach this process and let the child |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1008 | * run the deamon process. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1009 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1010 | syslog(LOG_NOTICE, "Starting daemon with pid %d", frk); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1011 | exit(0); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1012 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1013 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1014 | |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
1015 | killconfig(); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1016 | syslog(LOG_NOTICE, "Finished, rc=%d", rc); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1017 | return rc; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1018 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1019 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1020 | |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1021 | void do_unit(units_list *unit, int LCDunit, int seconds, int minutes) |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1022 | { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1023 | time_t now; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1024 | prof_step *step; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1025 | int rc, temp; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1026 | int run_seconds, run_minutes, run_hours, tot_minutes; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1027 | int current_step, valid_step, time_until_now, previous_fridge_mode; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1028 | float previous_target_lo, previous_target_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1029 | float LCDair, LCDbeer, LCDspL, LCDspH; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1030 | unsigned char LCDstatC, LCDstatH; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1031 | |
678
cc49115e769e
Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents:
675
diff
changeset
|
1032 | // unit->mqtt_flag &= ~MQTT_FLAG_DATA; |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1033 | unit->alarm_flag = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1034 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1035 | if (unit->air_address) { |
693
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1036 | unit->air_state = rc = device_in(unit->air_address, &temp); |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1037 | if (rc == DEVPRESENT_YES) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1038 | if (unit->air_temperature != temp) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1039 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1040 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1041 | unit->air_temperature = temp; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1042 | } |
693
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1043 | } else { |
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1044 | unit->air_state = DEVPRESENT_NO; |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1045 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1046 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1047 | if (unit->beer_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1048 | rc = device_in(unit->beer_address, &temp); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1049 | if ((rc == DEVPRESENT_NO) && unit->beer_address2) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1050 | /* Read alternative sensor */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1051 | rc = device_in(unit->beer_address2, &temp); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1052 | } |
693
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1053 | unit->beer_state = rc; |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1054 | if (rc == DEVPRESENT_YES) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1055 | if (unit->beer_temperature != temp) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1056 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1057 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1058 | unit->beer_temperature = temp; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1059 | } |
693
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1060 | } else { |
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1061 | unit->beer_state = DEVPRESENT_NO; |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1062 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1063 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1064 | if (unit->chiller_address) { |
693
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1065 | unit->chiller_state = rc = device_in(unit->chiller_address, &temp); |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1066 | if (rc == DEVPRESENT_YES) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1067 | if (unit->chiller_temperature != temp) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1068 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1069 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1070 | unit->chiller_temperature = temp; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1071 | } |
693
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1072 | } else { |
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1073 | unit->chiller_state = DEVPRESENT_NO; |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1074 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1075 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1076 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1077 | * Unit door state, default is closed. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1078 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1079 | if (unit->door_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1080 | rc = device_in(unit->door_address, &temp); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1081 | if (rc == DEVPRESENT_YES) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1082 | if (temp) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1083 | if (unit->door_state == 0) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1084 | syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1085 | unit->door_state = 1; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1086 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1087 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1088 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1089 | if (unit->door_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1090 | syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1091 | unit->door_state = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1092 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1093 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1094 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1095 | * If unit is active and the door is open |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1096 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1097 | if (unit->mode != UNITMODE_NONE) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1098 | unit->alarm_flag |= ALARM_FLAG_DOOR; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1099 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1100 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1101 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1102 | unit->door_state = 1; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1103 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1104 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1105 | unit->door_state = 1; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1106 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1107 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1108 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1109 | * Unit PSU state |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1110 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1111 | if (unit->psu_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1112 | rc = device_in(unit->psu_address, &temp); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1113 | if (rc == DEVPRESENT_YES) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1114 | if (temp) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1115 | if (unit->psu_state == 0) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1116 | syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1117 | unit->psu_state = 1; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1118 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1119 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1120 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1121 | if (unit->psu_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1122 | syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1123 | unit->psu_state = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1124 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1125 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1126 | unit->alarm_flag |= ALARM_FLAG_PSU; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1127 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1128 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1129 | unit->psu_state = 1; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1130 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1131 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1132 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1133 | * No state available, assume Ok. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1134 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1135 | unit->psu_state = 1; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1136 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1137 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1138 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1139 | * Handle profile |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1140 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1141 | if ((unit->mode == UNITMODE_PROFILE) && (unit->profile_uuid)) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1142 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1143 | * unit->prof_started - start time or 0 if not yet running. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1144 | * unit->prof_state - PROFILE_OFF|PROFILE_PAUSE|PROFILE_RUN|PROFILE_DONE |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1145 | * unit->prof_target - Calculated target temperature. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1146 | * unit->prof_paused - Internal pause counter. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1147 | * unit->prof_peak_abs - Peak temperature of the beer. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1148 | * unit->prof_peak_rel - Peak temperature between beer and fridge. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1149 | * unit->prof_primary_done - time when primary fermentation was over the peak. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1150 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1151 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1152 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1153 | * Safe defaults |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1154 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1155 | unit->prof_target_lo = unit->profile_inittemp_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1156 | unit->prof_target_hi = unit->profile_inittemp_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1157 | unit->prof_fridge_mode = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1158 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1159 | switch (unit->prof_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1160 | case PROFILE_OFF: |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1161 | unit->prof_percent = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1162 | break; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1163 | case PROFILE_PAUSE: |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1164 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1165 | * Keep current temperature, measure pause time. For |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1166 | * temperature fall thru. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1167 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1168 | unit->prof_paused++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1169 | case PROFILE_RUN: |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1170 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1171 | * Calculate current profile step and desired temperature. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1172 | * When all steps are done, set state to PROFILE_DONE. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1173 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1174 | previous_target_lo = unit->profile_inittemp_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1175 | previous_target_hi = unit->profile_inittemp_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1176 | previous_fridge_mode = unit->profile_fridge_mode; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1177 | time_until_now = current_step = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1178 | now = time(NULL); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1179 | run_seconds = (int)(now - unit->prof_started - unit->prof_paused); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1180 | run_minutes = run_seconds / 60; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1181 | run_hours = run_minutes / 60; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1182 | if (debug) |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1183 | syslog(LOG_NOTICE, "run_HMS=%d,%d,%d", run_hours, run_minutes, run_seconds); |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1184 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1185 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1186 | * Primary fermentation tests |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1187 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1188 | if ((unit->beer_temperature / 1000.0) > unit->prof_peak_abs) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1189 | unit->prof_peak_abs = unit->beer_temperature / 1000.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1190 | if (((unit->beer_temperature - unit->air_temperature) / 1000.0) > unit->prof_peak_rel) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1191 | unit->prof_peak_rel = (unit->beer_temperature - unit->air_temperature) / 1000.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1192 | if (unit->prof_primary_done == 0) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1193 | if (unit->cooler_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1194 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1195 | * There is a cooler. If the difference between the beer and air temperature |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1196 | * drops we assume the primary fermentation is done. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1197 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1198 | if (((unit->beer_temperature - unit->air_temperature) / 1000.0) < (unit->prof_peak_rel - 0.5)) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1199 | unit->prof_primary_done = time(NULL); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1200 | syslog(LOG_NOTICE, "Profile `%s' primary fermentation is ready (cooler mode)", unit->profile_name); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1201 | if (! unit->event_msg) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1202 | unit->event_msg = xstrcpy((char *)"Primary peak"); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1203 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1204 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1205 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1206 | * This method works if the unit has no cooling or if the profile allowed the |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1207 | * beer temperature to rise freely. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1208 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1209 | if ((unit->beer_temperature / 1000.0) < (unit->prof_peak_abs - 0.5)) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1210 | unit->prof_primary_done = time(NULL); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1211 | syslog(LOG_NOTICE, "Profile `%s' primary fermentation is ready (free rise mode)", unit->profile_name); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1212 | if (! unit->event_msg) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1213 | unit->event_msg = xstrcpy((char *)"Primary peak"); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1214 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1215 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1216 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1217 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1218 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1219 | * See how long this profile will take |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1220 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1221 | tot_minutes = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1222 | for (step = unit->profile_steps; step; step = step->next) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1223 | tot_minutes += ((step->steptime + step->resttime) * 60); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1224 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1225 | if ((tot_minutes == 0) && unit->profile_totalsteps) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1226 | syslog(LOG_NOTICE, "Profile `%s' steps disappeared", unit->profile_name); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1227 | unit->prof_state = PROFILE_OFF; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1228 | break; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1229 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1230 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1231 | valid_step = FALSE; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1232 | for (step = unit->profile_steps; step; step = step->next) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1233 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1234 | * step->steptime |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1235 | * step->resttime |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1236 | * step->target |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1237 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1238 | current_step++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1239 | if ((run_hours >= time_until_now) && (run_hours < (time_until_now + step->steptime + step->resttime))) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1240 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1241 | * This is our current step |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1242 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1243 | valid_step = TRUE; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1244 | if ((run_hours - time_until_now) < step->steptime) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1245 | unit->prof_target_lo = previous_target_lo + (((run_minutes - (time_until_now * 60.0)) / (step->steptime * 60.0)) * (step->target_lo - previous_target_lo)); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1246 | unit->prof_target_hi = previous_target_hi + (((run_minutes - (time_until_now * 60.0)) / (step->steptime * 60.0)) * (step->target_hi - previous_target_hi)); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1247 | if (step->fridge_mode > previous_fridge_mode) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1248 | unit->prof_fridge_mode = (((run_minutes - (time_until_now * 60)) * 100) / (step->steptime * 60)); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1249 | } else if (step->fridge_mode < previous_fridge_mode) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1250 | unit->prof_fridge_mode = 100 - (((run_minutes - (time_until_now * 60)) * 100) / (step->steptime * 60)); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1251 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1252 | unit->prof_fridge_mode = step->fridge_mode; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1253 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1254 | if (debug) |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1255 | syslog(LOG_NOTICE, "prof_fridge_mode=%d run_minutes=%d steptime=%d time_until_now=%d", |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1256 | unit->prof_fridge_mode, run_minutes, step->steptime, time_until_now); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1257 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1258 | unit->prof_target_lo = step->target_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1259 | unit->prof_target_hi = step->target_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1260 | unit->prof_fridge_mode = step->fridge_mode; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1261 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1262 | break; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1263 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1264 | time_until_now += step->steptime + step->resttime; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1265 | previous_target_lo = step->target_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1266 | previous_target_hi = step->target_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1267 | previous_fridge_mode = step->fridge_mode; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1268 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1269 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1270 | if (valid_step == TRUE) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1271 | unit->prof_percent = (100 * run_minutes) / tot_minutes; |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1272 | if (((minutes == 10) || (minutes == 40)) && (seconds == 1)) { |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1273 | syslog(LOG_NOTICE, "Profile `%s' running %dd %02d:%02d in step %d, %d%% done, fridge/beer %d%% %.3f..%.3f degrees", |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1274 | unit->profile_name, run_hours / 24, run_hours % 24, run_minutes % 60, current_step, |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1275 | unit->prof_percent, unit->prof_fridge_mode, unit->prof_target_lo, unit->prof_target_hi); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1276 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1277 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1278 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1279 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1280 | * No more steps to do |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1281 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1282 | unit->prof_state = PROFILE_DONE; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1283 | unit->prof_percent = 100; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1284 | syslog(LOG_NOTICE, "Profile `%s' is done", unit->profile_name); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1285 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1286 | if (! unit->event_msg) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1287 | unit->event_msg = xstrcpy((char *)"Profile finished"); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1288 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1289 | break; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1290 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1291 | case PROFILE_DONE: |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1292 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1293 | * Keep this state, set target temperature to the last step. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1294 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1295 | previous_target_lo = unit->profile_inittemp_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1296 | previous_target_hi = unit->profile_inittemp_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1297 | previous_fridge_mode = unit->profile_fridge_mode; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1298 | for (step = unit->profile_steps; step; step = step->next) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1299 | if ((step->steptime + step->resttime) == 0) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1300 | break; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1301 | previous_target_lo = step->target_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1302 | previous_target_hi = step->target_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1303 | previous_fridge_mode = step->fridge_mode; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1304 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1305 | unit->prof_target_lo = previous_target_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1306 | unit->prof_target_hi = previous_target_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1307 | unit->prof_fridge_mode = previous_fridge_mode; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1308 | unit->prof_percent = 100; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1309 | break; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1310 | } /* switch */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1311 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1312 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1313 | * Set some sane values |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1314 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1315 | unit->prof_target_lo = 19.8; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1316 | unit->prof_target_hi = 20.2; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1317 | unit->prof_fridge_mode = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1318 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1319 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1320 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1321 | * Manual switching |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1322 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1323 | if (unit->mode == UNITMODE_NONE) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1324 | device_out(unit->heater_address, unit->heater_state); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1325 | device_out(unit->cooler_address, unit->cooler_state); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1326 | device_out(unit->fan_address, unit->fan_state); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1327 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1328 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1329 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1330 | * Usage counters |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1331 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1332 | if (unit->heater_address && unit->heater_state) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1333 | unit->heater_usage++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1334 | if (unit->cooler_address && unit->cooler_state) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1335 | unit->cooler_usage++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1336 | if (unit->fan_address && unit->fan_state) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1337 | unit->fan_usage++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1338 | if (unit->light_address && unit->light_state) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1339 | unit->light_usage++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1340 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1341 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1342 | * Interior lights |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1343 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1344 | if (unit->light_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1345 | if (unit->light_timer) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1346 | unit->light_timer--; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1347 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1348 | if (unit->door_state && !unit->light_timer && unit->light_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1349 | if (unit->light_wait > 0) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1350 | unit->light_wait--; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1351 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1352 | unit->light_state = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1353 | syslog(LOG_NOTICE, "Unit `%s' lights On => Off", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1354 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1355 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1356 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1357 | if ((!unit->door_state || unit->light_timer) && !unit->light_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1358 | unit->light_wait = unit->light_delay; /* No delay to turn lights on */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1359 | unit->light_state = 1; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1360 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1361 | syslog(LOG_NOTICE, "Unit `%s' lights Off => On", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1362 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1363 | device_out(unit->light_address, unit->light_state); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1364 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1365 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1366 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1367 | * Temperature control in this unit |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1368 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1369 | if ((unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_BEER) || (unit->mode == UNITMODE_PROFILE)) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1370 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1371 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1372 | * Set both PID's to their input values. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1373 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1374 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1375 | if (unit->mode == UNITMODE_FRIDGE) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1376 | unit->PID_cool->SetP = unit->fridge_set_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1377 | unit->PID_heat->SetP = unit->fridge_set_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1378 | unit->PID_cool->Input = unit->PID_heat->Input = unit->air_temperature / 1000.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1379 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_BOO; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1380 | } else if (unit->mode == UNITMODE_BEER) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1381 | unit->PID_cool->SetP = unit->beer_set_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1382 | unit->PID_heat->SetP = unit->beer_set_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1383 | unit->PID_cool->Input = unit->PID_heat->Input = unit->beer_temperature / 1000.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1384 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_AUTO; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1385 | } else if (unit->mode == UNITMODE_PROFILE) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1386 | double usetemp; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1387 | unit->PID_cool->SetP = unit->prof_target_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1388 | unit->PID_heat->SetP = unit->prof_target_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1389 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1390 | * Get percentage to use from each thermometer. unit->prof_fridge_mode = 0..100 |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1391 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1392 | usetemp = ((unit->prof_fridge_mode * (unit->air_temperature / 1000.0)) + |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1393 | ((100 - unit->prof_fridge_mode) * (unit->beer_temperature / 1000.0))) / 100.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1394 | unit->PID_cool->Input = unit->PID_heat->Input = usetemp; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1395 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_AUTO; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1396 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1397 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1398 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1399 | * PID controller compute, simulate 100 mSec loops by running 10 times. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1400 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1401 | for (int i = 0; i < 10; i++) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1402 | UpdatePID(unit->PID_heat); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1403 | UpdatePID(unit->PID_cool); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1404 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1405 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1406 | * Logging |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1407 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1408 | if (unit->heater_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1409 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1410 | * Prevent extreme heating |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1411 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1412 | if ((unit->mode == UNITMODE_BEER) && ((unit->air_temperature / 1000.0) > (unit->PID_heat->Input + 8.0))) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1413 | unit->PID_heat->OutP = 0.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1414 | } |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1415 | if (seconds == 60) { |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1416 | syslog(LOG_NOTICE, "Heat: sp=%.3f Input=%.3f iState=%.3f Err=%.3f Out=%.1f", |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1417 | unit->PID_heat->SetP, unit->PID_heat->Input, unit->PID_heat->iState, unit->PID_heat->Err, unit->PID_heat->OutP); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1418 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1419 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1420 | unit->PID_heat->OutP = 0.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1421 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1422 | if (unit->cooler_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1423 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1424 | * Prevent extreme cooling |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1425 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1426 | if ((unit->mode == UNITMODE_BEER) && ((unit->air_temperature / 1000.0) < (unit->PID_cool->Input - 8.0))) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1427 | unit->PID_cool->OutP = 0.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1428 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1429 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1430 | * Prevent cooling if we use a chiller and the chiller temperature is not low enough. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1431 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1432 | if (unit->chiller_address && (unit->chiller_state == 0)) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1433 | if ((unit->chiller_temperature / 1000.0) > ((unit->air_temperature / 1000.0) - 1)) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1434 | unit->PID_cool->OutP = 0.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1435 | unit->alarm_flag |= ALARM_FLAG_CHILLER; |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1436 | if (seconds == 60) { |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1437 | syslog(LOG_NOTICE, "Cool: Air=%.2f Chiller=%.2f alarm", unit->air_temperature / 1000.0, unit->chiller_temperature / 1000.0); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1438 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1439 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1440 | } |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1441 | if (seconds == 60) { |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1442 | syslog(LOG_NOTICE, "Cool: sp=%.3f Input=%.3f iState=%.3f Err=%.3f Out=%.1f", |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1443 | unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1444 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1445 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1446 | unit->PID_cool->OutP = 0.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1447 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1448 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1449 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1450 | * Deadlock, kill lowest value. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1451 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1452 | if (unit->PID_cool->OutP && unit->PID_heat->OutP) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1453 | if (unit->PID_cool->OutP > unit->PID_heat->OutP) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1454 | unit->PID_heat->OutP = 0.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1455 | else |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1456 | unit->PID_cool->OutP = 0.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1457 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1458 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1459 | if (unit->heater_address && ! unit->cooler_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1460 | if (unit->PID_heat->OutP >= 50) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1461 | if (unit->heater_wait < unit->heater_delay) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1462 | unit->heater_wait++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1463 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1464 | int power = round(unit->PID_heat->OutP); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1465 | if (unit->heater_state != power) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1466 | syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1467 | unit->heater_state = power; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1468 | if (unit->heater_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1469 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1470 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1471 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1472 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1473 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1474 | if (unit->heater_wait > 0) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1475 | unit->heater_wait--; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1476 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1477 | if (unit->heater_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1478 | syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1479 | unit->heater_state = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1480 | if (unit->heater_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1481 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1482 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1483 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1484 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1485 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1486 | if (unit->door_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1487 | device_out(unit->heater_address, unit->heater_state); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1488 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1489 | device_out(unit->heater_address, 0); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1490 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1491 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1492 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1493 | if (unit->cooler_address && ! unit->heater_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1494 | if (unit->PID_cool->OutP >= 50) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1495 | if (unit->cooler_wait < unit->cooler_delay) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1496 | unit->cooler_wait++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1497 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1498 | int power = round(unit->PID_cool->OutP); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1499 | if (unit->cooler_state != power) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1500 | syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1501 | unit->cooler_state = power; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1502 | if (unit->cooler_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1503 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1504 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1505 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1506 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1507 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1508 | if (unit->cooler_wait > 0) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1509 | unit->cooler_wait--; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1510 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1511 | if (unit->cooler_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1512 | syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1513 | unit->cooler_state = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1514 | if (unit->cooler_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1515 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1516 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1517 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1518 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1519 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1520 | if (unit->door_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1521 | device_out(unit->cooler_address, unit->cooler_state); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1522 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1523 | device_out(unit->cooler_address, 0); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1524 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1525 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1526 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1527 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1528 | * If there is a fan, and the unit door is closed, and the unit should be doing |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1529 | * something, then turn on the global fan. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1530 | * But if there is a chiller, do not turn it on if cooling. |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1531 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1532 | if (unit->fan_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1533 | if ((unit->door_state) && (unit->cooler_state == 0)) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1534 | if (unit->fan_wait < unit->fan_delay) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1535 | unit->fan_wait++; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1536 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1537 | if (! unit->fan_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1538 | syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1539 | unit->fan_state = 100; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1540 | if (unit->fan_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1541 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1542 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1543 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1544 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1545 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1546 | if (unit->fan_wait > 0) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1547 | unit->fan_wait--; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1548 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1549 | if (unit->fan_state) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1550 | syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1551 | unit->fan_state = 0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1552 | if (unit->fan_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1553 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1554 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1555 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1556 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1557 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1558 | device_out(unit->fan_address, unit->fan_state); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1559 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1560 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1561 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1562 | unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1563 | } /* fridge beer or profile mode */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1564 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1565 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1566 | * Now everything is set and done, update the LCD display |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1567 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1568 | LCDair = unit->air_temperature / 1000.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1569 | LCDbeer = unit->beer_temperature / 1000.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1570 | LCDstatC = LCDstatH = ' '; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1571 | if (unit->heater_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1572 | if (unit->heater_state) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1573 | LCDstatH = '\6'; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1574 | else |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1575 | LCDstatH = '\5'; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1576 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1577 | if (unit->cooler_address) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1578 | if (unit->cooler_state) |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1579 | LCDstatC = '\4'; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1580 | else |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1581 | LCDstatC = '\3'; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1582 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1583 | LCDspH = LCDspL = 0.0; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1584 | if (unit->mode == UNITMODE_BEER) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1585 | LCDspH = unit->beer_set_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1586 | LCDspL = unit->beer_set_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1587 | } else if (unit->mode == UNITMODE_FRIDGE) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1588 | LCDspH = unit->fridge_set_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1589 | LCDspL = unit->fridge_set_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1590 | } else if (unit->mode == UNITMODE_PROFILE) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1591 | if (unit->prof_state != PROFILE_OFF) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1592 | LCDspL = unit->prof_target_lo; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1593 | LCDspH = unit->prof_target_hi; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1594 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1595 | } |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1596 | if (seconds == 60) { |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1597 | unit->mqtt_flag |= MQTT_FLAG_DATA; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1598 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1599 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1600 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1601 | * Write 4 rows to the LCD to display the unit state |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1602 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1603 | lcd_buf_write(row++, "Unit %d: %s ", LCDunit, UNITMODE[unit->mode]); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1604 | lcd_buf_write(row++, "%s ", unit->product_name); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1605 | lcd_buf_write(row++, "%c%5.1f\2 A%6.2f\1 ", LCDstatC, LCDspH, LCDair); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1606 | lcd_buf_write(row++, "%c%5.1f\2 B%6.2f\1 ", LCDstatH, LCDspL, LCDbeer); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1607 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1608 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1609 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1610 | * Publish MQTT messages set in flag |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1611 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1612 | if (unit->mqtt_flag) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1613 | if (unit->mqtt_flag & MQTT_FLAG_BIRTH) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1614 | publishDBirth(unit); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1615 | unit->mqtt_flag &= ~MQTT_FLAG_BIRTH; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1616 | } else { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1617 | publishDData(unit); |
678
cc49115e769e
Better websocket broadcast messages. Added GLOBAL JSON command to the server. Better logic to trigger websocket and mqtt data updates for the fermenter units. Websocket receive added fermenter mode, stage, setpoints, switches. Added more css styles for the fermenter screen. Added the fermenter screen php and javascript.
Michiel Broek <mbroek@mbse.eu>
parents:
675
diff
changeset
|
1618 | // unit->mqtt_flag &= ~MQTT_FLAG_DATA; |
665
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1619 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1620 | if (unit->mqtt_flag & MQTT_FLAG_DEATH) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1621 | publishDDeath(unit); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1622 | unit->mqtt_flag &= ~MQTT_FLAG_DEATH; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1623 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1624 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1625 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1626 | /* |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1627 | * Handle changed alarms |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1628 | */ |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1629 | if (unit->alarm_flag != unit->alarm_last) { |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1630 | syslog(LOG_NOTICE, "Unit `%s' Alarm %d => %d", unit->alias, unit->alarm_last, unit->alarm_flag); |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1631 | unit->alarm_last = unit->alarm_flag; |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1632 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1633 | } |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1634 | |
66fae54fa7ba
Fermentation processing in it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
661
diff
changeset
|
1635 | |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1636 | SM_DECL(thermferm,(char *)"thermferm") |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1637 | SM_STATES |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1638 | CheckRun, |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1639 | WaitMinute, |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1640 | DateTime, |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1641 | RoomTHB, |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1642 | Units, |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1643 | ShowLCD, |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1644 | Minute, |
667
bba6ca418e09
Removed lcd-buffer create logmessage. Combined Keys and Delay states.
Michiel Broek <mbroek@mbse.eu>
parents:
666
diff
changeset
|
1645 | Keys |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1646 | SM_NAMES |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1647 | (char *)"CheckRun", |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1648 | (char *)"WaitMinute", |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1649 | (char *)"DateTime", |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1650 | (char *)"RoomTHB", |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1651 | (char *)"Units", |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1652 | (char *)"ShowLCD", |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1653 | (char *)"Minute", |
667
bba6ca418e09
Removed lcd-buffer create logmessage. Combined Keys and Delay states.
Michiel Broek <mbroek@mbse.eu>
parents:
666
diff
changeset
|
1654 | (char *)"Keys" |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1655 | SM_EDECL |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1656 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1657 | time_t now, last = (time_t)0, ndata = (time_t)0; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1658 | int key, LCDunit, rc, temp, seconds = 0, minutes = 0; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1659 | struct tm *tm; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1660 | units_list *unit; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1661 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1662 | SM_START(CheckRun) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1663 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1664 | SM_STATE(CheckRun) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1665 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1666 | if (my_shutdown) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1667 | SM_SUCCESS; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1668 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1669 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1670 | /* |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1671 | * Use to stop processing units. Should be used when a unit is |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1672 | * added or removed. |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1673 | */ |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1674 | if (run_pause) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1675 | run_hold = TRUE; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1676 | syslog(LOG_NOTICE, "run_pause: entering hold state"); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1677 | for (;;) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1678 | mDelay(100); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1679 | if (! run_pause) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1680 | break; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1681 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1682 | syslog(LOG_NOTICE, "run_pause: leaving hold state"); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1683 | run_hold = FALSE; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1684 | /* |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1685 | * In case the LCD buffers were cleared, setup the first page. |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1686 | */ |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1687 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1688 | lcd_buf_write(1, (char *)" ThermFerm "); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1689 | lcd_buf_write(2, (char *)"Version %s ", VERSION); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1690 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1691 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1692 | SM_PROCEED(WaitMinute); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1693 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1694 | SM_STATE(WaitMinute) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1695 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1696 | if (my_shutdown) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1697 | SM_SUCCESS; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1698 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1699 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1700 | now = time(NULL); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1701 | if (now != last) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1702 | /* |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1703 | * Each second |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1704 | */ |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1705 | last = now; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1706 | seconds++; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1707 | SM_PROCEED(DateTime); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1708 | } else { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1709 | SM_PROCEED(Keys); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1710 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1711 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1712 | SM_STATE(DateTime) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1713 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1714 | row = 3; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1715 | tm = localtime(&now); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1716 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1717 | lcd_buf_write(row++, " %02d-%02d-%04d ", tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1718 | lcd_buf_write(row++, " %02d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1719 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1720 | SM_PROCEED(RoomTHB); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1721 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1722 | SM_STATE(RoomTHB) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1723 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1724 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1725 | lcd_buf_write(row, "Room temp N/A "); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1726 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1727 | int updateHT = 0; |
693
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1728 | if (Config.temp_uuid) { |
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1729 | Config.temp_state = rc = device_in(Config.temp_uuid, &temp); |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1730 | if (rc == DEVPRESENT_YES) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1731 | if (Config.temp_value != temp) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1732 | updateHT = 1; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1733 | Config.temp_value = temp; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1734 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1735 | lcd_buf_write(row, "Room temp %.1f%c ", Config.temp_value / 1000.0, 0x01); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1736 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1737 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1738 | mDelay(10); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1739 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1740 | row++; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1741 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1742 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1743 | lcd_buf_write(row, " Humidity N/A "); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1744 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
693
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1745 | if (Config.hum_uuid) { |
3518c07737d8
Version 0.9.19a2. Dropped TEMPSTATE[] and only use DEVPRESENT[] to mark devices state. Adjusted webpages for this switch in responses. Adjusted MySQL mon_fermenters enum values too. Rename some global Config records to better reflect their real use.Added one-wire json records and websocket. Announce when some onewire device changes. Add UNITS JSON command without parameter. Dropped global tempFormat setting that was never used.
Michiel Broek <mbroek@mbse.eu>
parents:
678
diff
changeset
|
1746 | Config.hum_state = rc = device_in(Config.hum_uuid, &temp); |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1747 | if (rc == DEVPRESENT_YES) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1748 | if (Config.hum_value != temp) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1749 | updateHT = 1; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1750 | Config.hum_value = temp; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1751 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1752 | lcd_buf_write(row, " Humidity %.1f%% ", Config.hum_value / 1000.0); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1753 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1754 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1755 | mDelay(10); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1756 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1757 | row++; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1758 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1759 | /* |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1760 | * If TH(B) changed. or if 5 minutes without |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1761 | * update, send the NDATA message. |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1762 | */ |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1763 | if (updateHT || (now > (ndata + 300))) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1764 | publishNData(false, 0); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1765 | ndata = now; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1766 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1767 | SM_PROCEED(Units); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1768 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1769 | SM_STATE(Units) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1770 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1771 | LCDunit = 0; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1772 | for (unit = Config.units; unit; unit = unit->next) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1773 | LCDunit++; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1774 | do_unit(unit, LCDunit, seconds, minutes); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1775 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1776 | SM_PROCEED(ShowLCD); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1777 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1778 | SM_STATE(ShowLCD) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1779 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1780 | pthread_mutex_lock(&mutexes[LOCK_MENU]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1781 | if (setupmenu == MENU_NONE) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1782 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1783 | lcd_buf_show(); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1784 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1785 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1786 | pthread_mutex_unlock(&mutexes[LOCK_MENU]); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1787 | SM_PROCEED(Minute); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1788 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1789 | SM_STATE(Minute) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1790 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1791 | if (seconds == 60) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1792 | seconds = 0; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1793 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1794 | /* |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1795 | * Publish data every minute if unit is active. |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1796 | */ |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1797 | for (unit = Config.units; unit; unit = unit->next) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1798 | if (unit->mode != UNITMODE_OFF) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1799 | publishDLog(unit); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1800 | if (unit->event_msg) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1801 | free(unit->event_msg); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1802 | unit->event_msg = NULL; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1803 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1804 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1805 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1806 | minutes++; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1807 | if (minutes == 60) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1808 | minutes = 0; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1809 | /* |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1810 | * Log usage counters every hour |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1811 | */ |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1812 | for (unit = Config.units; unit; unit = unit->next) { |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1813 | syslog(LOG_NOTICE, "Unit `%s' usage heater=%d cooler=%d fan=%d", unit->alias, unit->heater_usage, unit->cooler_usage, unit->fan_usage); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1814 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1815 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1816 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1817 | /* |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1818 | * Save the configuration each half hour. |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1819 | */ |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1820 | if ((minutes == 15) || (minutes == 45)) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1821 | wrconfig(); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1822 | } |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1823 | SM_PROCEED(Keys); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1824 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1825 | SM_STATE(Keys) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1826 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1827 | slcdDummy(slcdHandle); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1828 | key = keycheck(); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1829 | if (key != KEY_NONE) |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1830 | panel_key_events(key); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1831 | |
675
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1832 | mDelay(25); |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1833 | ws_check(); |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1834 | mDelay(25); |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1835 | SM_PROCEED(CheckRun); |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1836 | |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1837 | SM_END |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1838 | SM_RETURN |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1839 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1840 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1841 | int server(void) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1842 | { |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1843 | units_list *unit; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1844 | int rc; |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1845 | long t = 0; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1846 | |
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:
548
diff
changeset
|
1847 | syslog(LOG_NOTICE, "Server process started"); |
669
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1848 | |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1849 | if ((rc = initLCD (Config.lcd_cols, Config.lcd_rows))) { |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1850 | fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1851 | return 1; |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1852 | } |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1853 | |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1854 | #ifdef HAVE_WIRINGPI_H |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1855 | lcdCharDef(lcdHandle, 1, degC); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1856 | lcdCharDef(lcdHandle, 2, SP_Symbol); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1857 | lcdCharDef(lcdHandle, 3, CoolONOFF); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1858 | lcdCharDef(lcdHandle, 4, RevCoolONOFF); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1859 | lcdCharDef(lcdHandle, 5, HeatONOFF); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1860 | lcdCharDef(lcdHandle, 6, RevHeatONOFF); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1861 | #endif |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1862 | slcdCharDef(slcdHandle, 1, degC); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1863 | slcdCharDef(slcdHandle, 2, SP_Symbol); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1864 | slcdCharDef(slcdHandle, 3, CoolONOFF); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1865 | slcdCharDef(slcdHandle, 4, RevCoolONOFF); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1866 | slcdCharDef(slcdHandle, 5, HeatONOFF); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1867 | slcdCharDef(slcdHandle, 6, RevHeatONOFF); |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1868 | |
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:
548
diff
changeset
|
1869 | my_shutdown = my_reboot = FALSE; |
675
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1870 | my_devices_shutdown = my_panel_shutdown = my_server_shutdown = my_ws_shutdown = my_one_wire_shutdown = 0; |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1871 | my_devices_state = my_panel_state = my_server_state = my_ws_state = my_one_wire_state = 0; |
669
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1872 | my_simulator_state = 0; |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1873 | #ifdef USE_SIMULATOR |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1874 | my_simulator_shutdown = 0; |
daa22055cd3d
Reboot from the panel is now restart application. The restart is working again, also via bmsapp.
Michiel Broek <mbroek@mbse.eu>
parents:
667
diff
changeset
|
1875 | #endif |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
1876 | if (lockprog((char *)"thermferm")) { |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
1877 | syslog(LOG_NOTICE, "Can't lock"); |
34 | 1878 | return 1; |
1879 | } | |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
1880 | mqtt_connect(); |
497
18ace27338e5
Compiles mosquitto code if library is found on the system. Bumped to version 0.5.4
Michiel Broek <mbroek@mbse.eu>
parents:
496
diff
changeset
|
1881 | |
656
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1882 | /* |
675
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1883 | * Start websockets first. |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1884 | */ |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1885 | rc = pthread_create(&my_ws_thread, NULL, my_ws_loop, (void *)t ); |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1886 | if (rc) { |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1887 | fprintf(stderr, "my_ws_loop thread didn't start rc=%d\n", rc); |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1888 | syslog(LOG_NOTICE, "my_ws_loop thread didn't start rc=%d", rc); |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1889 | } else { |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1890 | t++; |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1891 | } |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1892 | |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1893 | /* |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
1894 | * Next scan the one-wire bus |
656
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1895 | */ |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
1896 | rc = pthread_create(&my_one_wire_thread, NULL, my_one_wire_loop, (void *)t ); |
656
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1897 | if (rc) { |
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1898 | fprintf(stderr, "my_one_wire_loop thread didn't start rc=%d\n", rc); |
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1899 | syslog(LOG_NOTICE, "my_one_wire_loop thread didn't start rc=%d", rc); |
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1900 | } else { |
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1901 | t++; |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
1902 | mDelay(2500); /* Wait a while to detect the devices */ |
656
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1903 | } |
ca47c742a25d
One-wire thread is now the first to start. The devices_detect() function now uses the detected one-wire linked list instead of scan the sysfs. Base code for ds2413 added in the state table, needs rework.
Michiel Broek <mbroek@mbse.eu>
parents:
654
diff
changeset
|
1904 | |
350
7283561977b1
Added door and PSU sensors. Added interior light logic and switching.
Michiel Broek <mbroek@mbse.eu>
parents:
349
diff
changeset
|
1905 | if ((rc = devices_detect())) { |
158 | 1906 | syslog(LOG_NOTICE, "Detected %d new devices", rc); |
1907 | wrconfig(); | |
1908 | } | |
1909 | ||
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
1910 | rc = pthread_create(&my_devices_thread, NULL, my_devices_loop, (void *)t ); |
164
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
1911 | if (rc) { |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
1912 | fprintf(stderr, "my_devices_loop thread didn't start rc=%d\n", rc); |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
1913 | syslog(LOG_NOTICE, "my_devices_loop thread didn't start rc=%d", rc); |
164
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
1914 | } else { |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
1915 | t++; |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
1916 | } |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
1917 | |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
1918 | rc = pthread_create(&my_server_thread, NULL, my_server_loop, (void *)t ); |
43 | 1919 | if (rc) { |
1920 | fprintf(stderr, "my_server_loop thread didn't start rc=%d\n", rc); | |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
1921 | syslog(LOG_NOTICE, "my_server_loop thread didn't start rc=%d", rc); |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
1922 | } else { |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
1923 | t++; |
43 | 1924 | } |
1925 | ||
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
1926 | rc = pthread_create(&my_panel_thread, NULL, my_panel_loop, (void *)t ); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
420
diff
changeset
|
1927 | if (rc) { |
199 | 1928 | fprintf(stderr, "my_panel_loop thread didn't start rc=%d\n", rc); |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
1929 | syslog(LOG_NOTICE, "my_panel_loop thread didn't start rc=%d", rc); |
422
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
420
diff
changeset
|
1930 | } else { |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
420
diff
changeset
|
1931 | t++; |
13502d0dda65
The brewpanel works, but still needs a lot more
Michiel Broek <mbroek@mbse.eu>
parents:
420
diff
changeset
|
1932 | } |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1933 | |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1934 | #ifdef USE_SIMULATOR |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
1935 | rc = pthread_create(&my_simulator_thread, NULL, my_simulator_loop, (void *)t ); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1936 | if (rc) { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1937 | fprintf(stderr, "my_simulator_loop thread didn't start rc=%d\n", rc); |
268
dda91dfa4aa8
All syslog logging only to LOG_NOTICE
Michiel Broek <mbroek@mbse.eu>
parents:
267
diff
changeset
|
1938 | syslog(LOG_NOTICE, "my_simulator_loop thread didn't start rc=%d", rc); |
259
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1939 | } else { |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1940 | t++; |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1941 | } |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1942 | #endif |
b7c967359771
Added framework for a simulation of a fridge with heater to use as controlled fermentor
Michiel Broek <mbroek@mbse.eu>
parents:
248
diff
changeset
|
1943 | |
497
18ace27338e5
Compiles mosquitto code if library is found on the system. Bumped to version 0.5.4
Michiel Broek <mbroek@mbse.eu>
parents:
496
diff
changeset
|
1944 | |
182 | 1945 | /* |
1946 | * Initialize units for processing | |
1947 | */ | |
1948 | for (unit = Config.units; unit; unit = unit->next) { | |
1949 | /* | |
1950 | * Safety, turn everything off | |
1951 | */ | |
525 | 1952 | unit->mqtt_flag = unit->alarm_flag = unit->alarm_last = 0; |
582
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
578
diff
changeset
|
1953 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = unit->light_timer = 0; |
350
7283561977b1
Added door and PSU sensors. Added interior light logic and switching.
Michiel Broek <mbroek@mbse.eu>
parents:
349
diff
changeset
|
1954 | unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
195
b34a1b2421fb
Reset output when a different profile is selected. Better startup logging about the unit state. Added Beer, Fridge and partial Profile settings from the liveview weeb screen.
Michiel Broek <mbroek@mbse.eu>
parents:
194
diff
changeset
|
1955 | if (unit->mode == UNITMODE_PROFILE) { |
570
1e0192b295b9
Removed useless version marks from the xml configuration. Added DCMD profile configuration to install and delete profiles in a fermenter. Removed the old profiles configuration. Removed useless xml configuration error check because none has been triggered in five years, Removed several obsolete upgrade functions. Updated the web liveview.
Michiel Broek <mbroek@mbse.eu>
parents:
569
diff
changeset
|
1956 | if (!unit->profile_uuid) |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1957 | syslog(LOG_NOTICE, "Starting unit `%s' in profile mode, no profile defined.", unit->alias); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
1958 | else { |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1959 | syslog(LOG_NOTICE, "Starting unit `%s' in profile state %s.", unit->alias, PROFSTATE[unit->prof_state]); |
499
602d9968960f
Created mqtt sourcefiles. Use flags to trigger publish messages. The main source does not know and does not care if MQTT messages will be sent. Version 0.5.5
Michiel Broek <mbroek@mbse.eu>
parents:
498
diff
changeset
|
1960 | } |
182 | 1961 | } else if (unit->mode == UNITMODE_BEER) { |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
1962 | syslog(LOG_NOTICE, "Starting unit `%s' beer cooler at %.1f - %.1f degrees", unit->alias, unit->beer_set_lo, unit->beer_set_hi); |
182 | 1963 | } else if (unit->mode == UNITMODE_FRIDGE) { |
578
d694abd9d809
Version 0.9.3. Splitted the temperature low and high settings in fridge and beer mode.
Michiel Broek <mbroek@mbse.eu>
parents:
576
diff
changeset
|
1964 | syslog(LOG_NOTICE, "Starting unit `%s' as refridgerator at %.1f - %.1f degrees", unit->alias, unit->fridge_set_lo, unit->fridge_set_hi); |
182 | 1965 | } else if (unit->mode == UNITMODE_NONE) { |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1966 | syslog(LOG_NOTICE, "Starting unit `%s' in inactive state", unit->alias); |
182 | 1967 | } else { |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1968 | syslog(LOG_NOTICE, "Starting unit `%s' in off state", unit->alias); |
182 | 1969 | } |
1970 | } | |
547
0e4d4b45249f
Versie 0.8.0. Fixed eerste DBIRTH fout geinitialiseerde waardes.
Michiel Broek <mbroek@mbse.eu>
parents:
545
diff
changeset
|
1971 | publishDBirthAll(); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1972 | |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1973 | for (unit = Config.units; unit; unit = unit->next) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1974 | if (unit->mode != UNITMODE_OFF) { |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1975 | unit->event_msg = xstrcpy((char *)"Startup"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1976 | publishDLog(unit); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1977 | free(unit->event_msg); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1978 | unit->event_msg = NULL; |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1979 | } |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
1980 | } |
182 | 1981 | |
645
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
1982 | pthread_mutex_lock(&mutexes[LOCK_LCD]); |
238 | 1983 | lcd_buf_write(1, (char *)" ThermFerm "); |
661
8c1e7a52e24f
Version 0.9.17a2. Disabled a lot of mutex locks, some are blocking and need to be fixed. This version seems to be working, more or less.
Michiel Broek <mbroek@mbse.eu>
parents:
660
diff
changeset
|
1984 | lcd_buf_write(2, (char *)"Version %s ", VERSION); |
8c1e7a52e24f
Version 0.9.17a2. Disabled a lot of mutex locks, some are blocking and need to be fixed. This version seems to be working, more or less.
Michiel Broek <mbroek@mbse.eu>
parents:
660
diff
changeset
|
1985 | // 0.9.17a2 |
645
49eb753a958b
All thread locks from wiringPi to standard pthreads.
Michiel Broek <mbroek@mbse.eu>
parents:
644
diff
changeset
|
1986 | pthread_mutex_unlock(&mutexes[LOCK_LCD]); |
33
2357e8636a60
Added user log with temperatures and cooler state
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
1987 | |
666
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1988 | /* |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1989 | * Run state table |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1990 | */ |
48cc8868f9f4
Added commandline switch --foreground, the --debug now only activates extra debug logging. No more console output. The thermferm process uses a state table, this makes the code more readable and have less large functions.
Michiel Broek <mbroek@mbse.eu>
parents:
665
diff
changeset
|
1991 | thermferm(); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1992 | |
182 | 1993 | /* |
1994 | * Stop units processing in a neat way | |
1995 | */ | |
1996 | for (unit = Config.units; unit; unit = unit->next) { | |
1997 | /* | |
1998 | * Turn everything off | |
1999 | */ | |
582
ba340e00aab2
Version 0.9.5, interior lights are now only controlled by the open door or a 5 minutes timer. The timer is started via an MQTT command. The BMS web application sends this command just before a webcam page is requested.
Chiel Broek <mbse@mbse.eu>
parents:
578
diff
changeset
|
2000 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = unit->light_timer = 0; |
350
7283561977b1
Added door and PSU sensors. Added interior light logic and switching.
Michiel Broek <mbroek@mbse.eu>
parents:
349
diff
changeset
|
2001 | unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
182 | 2002 | device_out(unit->heater_address, unit->heater_state); |
515
7ab5cf2afc0c
Only send domoticz changed values
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2003 | pub_domoticz_output(unit->heater_idx, unit->heater_state); |
182 | 2004 | device_out(unit->cooler_address, unit->cooler_state); |
515
7ab5cf2afc0c
Only send domoticz changed values
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2005 | pub_domoticz_output(unit->cooler_idx, unit->cooler_state); |
182 | 2006 | device_out(unit->fan_address, unit->fan_state); |
515
7ab5cf2afc0c
Only send domoticz changed values
Michiel Broek <mbroek@mbse.eu>
parents:
510
diff
changeset
|
2007 | pub_domoticz_output(unit->fan_idx, unit->fan_state); |
350
7283561977b1
Added door and PSU sensors. Added interior light logic and switching.
Michiel Broek <mbroek@mbse.eu>
parents:
349
diff
changeset
|
2008 | device_out(unit->light_address, unit->light_state); |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
2009 | if (unit->mode != UNITMODE_OFF) { |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
2010 | /* |
575
86496d2bc4bb
Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.
Michiel Broek <mbroek@mbse.eu>
parents:
572
diff
changeset
|
2011 | * If unit is active, publish we are dying. |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
2012 | */ |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
2013 | unit->mqtt_flag = MQTT_FLAG_DATA; |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
2014 | publishDData(unit); |
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
2015 | publishDDeath(unit); |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
2016 | unit->event_msg = xstrcpy((char *)"Shutdown"); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
2017 | publishDLog(unit); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
2018 | free(unit->event_msg); |
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
2019 | unit->event_msg = NULL; |
533
49580ca85ab7
Versie 0.6.3. MQTT device berichten alleen als een fermenter ingeschakeld is. MQTT fermenter birth en death berichhten als een fementer in of uitgeschakeld wordt. MQTT node death bericht bij normaal afsluiten van de daemon. Alle MQTT persistent berichten worden nu goed opgeruikmd.
Michiel Broek <mbroek@mbse.eu>
parents:
532
diff
changeset
|
2020 | } |
554
ab9f22ab57b5
Versie 0.8.5. Implementatie product code en product naam. Implementatie DLOG MQTT berichten. Verminderde server rotocol debug berichten.
Michiel Broek <mbroek@mbse.eu>
parents:
550
diff
changeset
|
2021 | syslog(LOG_NOTICE, "Unit `%s' stopped in mode %s", unit->alias, UNITMODE[unit->mode]); |
182 | 2022 | } |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2023 | syslog(LOG_NOTICE, "Out of loop, stopping threads.."); |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2024 | |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2025 | /* |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2026 | * Stop threads |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2027 | */ |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2028 | #ifdef USE_SIMULATOR |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2029 | my_simulator_shutdown = 1; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2030 | while (my_simulator_state) { mDelay(50); }; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2031 | #endif |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2032 | my_panel_shutdown = 1; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2033 | while (my_panel_state) { mDelay(50); }; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2034 | |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
2035 | /* |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2036 | * Cancel command and shutdown via variable, one of them |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2037 | * will stop this thread. Includes a failsafe. |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
2038 | */ |
660
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2039 | my_server_shutdown = 1; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2040 | rc = pthread_cancel(my_server_thread); |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2041 | rc = 0; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2042 | while (my_server_state) { |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2043 | mDelay(50); |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2044 | if (rc++ > 20) { |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2045 | syslog(LOG_NOTICE, "Cannot terminate my_server_loop()"); |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2046 | break; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2047 | } |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2048 | } |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2049 | |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2050 | my_devices_shutdown = 1; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2051 | while (my_devices_state) { mDelay(50); }; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2052 | my_one_wire_shutdown = 1; |
a28ef4d9afa4
Version 0.9.17a1. Revised starting and stopping the threads. Fixed stopping the command server thread. Moved one-wire tempeature sensors resolution correction to the one-wire thread. The devices thread fetches temperatures from the one-wire thread. The one-wire thread does everything for the temperature sensors. The command server uses private sockets. Still, only one session at the same time is handled.
Michiel Broek <mbroek@mbse.eu>
parents:
656
diff
changeset
|
2053 | while (my_one_wire_state) { mDelay(50); }; |
675
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
2054 | my_ws_shutdown = 1; |
825210ba2707
Added websockets to thermferm. Started new www directory for websocket enabled web. The init script now waits until thermferm is completely stopped.
Michiel Broek <mbroek@mbse.eu>
parents:
669
diff
changeset
|
2055 | while (my_ws_state) { mDelay(50); }; |
646
e3edc783006b
Running threads and locking doesn't depend on wiringPi anymore.
Michiel Broek <mbroek@mbse.eu>
parents:
645
diff
changeset
|
2056 | mqtt_disconnect(); |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
2057 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2058 | stopLCD(); |
420
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
2059 | if (sock != -1) { |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
2060 | if (shutdown(sock, SHUT_RDWR)) { |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
2061 | syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
2062 | } |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
2063 | sock = -1; |
644a6106d712
The first ideas of the brewpanel simulation are in place.
Michiel Broek <mbroek@mbse.eu>
parents:
418
diff
changeset
|
2064 | } |
561
fcfc3dbe85fa
Versie 0.8.7. Fixed a lot of memory leaks with the aid of valgrind.
Michiel Broek <mbroek@mbse.eu>
parents:
557
diff
changeset
|
2065 | lcd_buf_reset(); |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
2066 | wrconfig(); |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
2067 | ulockprog((char *)"thermferm"); |
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:
548
diff
changeset
|
2068 | |
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:
548
diff
changeset
|
2069 | syslog(LOG_NOTICE, "Server process ended"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2070 | return 0; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2071 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2072 |