Wed, 16 Dec 2015 22:06:11 +0100
Changed some prompt numbers. Added name editor.
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (C) 2015 |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of the mbsePi-apps |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * mbsePi-apps is distributed in the hope that it will be useful, but |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
441 | 23 | #include "brewco.h" |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | #include "rdconfig.h" |
441 | 25 | #include "rdsession.h" |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
26 | #include "rdrecipes.h" |
446
78e9d5234d15
Switched to PID code from Arduino
Michiel Broek <mbroek@mbse.eu>
parents:
444
diff
changeset
|
27 | #include "util.h" |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | #include "xutil.h" |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
29 | #include "lcd-pcf8574.h" |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
30 | #include "slcd.h" |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
31 | #include "lock.h" |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
32 | #include "devices.h" |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
33 | #include "keyboard.h" |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
34 | #include "simulator.h" |
442 | 35 | #include "prompt.h" |
36 | #include "setup.h" | |
37 | ||
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | int my_shutdown = FALSE; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | extern int debug; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | extern sys_config Config; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | extern int lcdHandle; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
44 | extern int slcdHandle; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
45 | extern int sock; |
456
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
46 | #ifdef USE_SIMULATOR |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
47 | extern int SIM_cooler; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
48 | #endif |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
49 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
50 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
51 | #ifndef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
52 | pthread_t threads[5]; |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | #endif |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | |
451 | 56 | #define MANUAL_NONE 0 |
57 | #define MANUAL_SELHLT 1 | |
58 | #define MANUAL_SELMLT 2 | |
59 | #define MANUAL_HLT 11 | |
60 | #define MANUAL_MLT 12 | |
61 | ||
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
62 | int manual = MANUAL_NONE; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
63 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
64 | |
451 | 65 | |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
66 | /* |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
67 | * CGRAM characters |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
68 | */ |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
69 | unsigned char degC[8] = { 0b01000, 0b10100, 0b01000, 0b00111, 0b01000, 0b01000, 0b01000, 0b00111 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
70 | unsigned char degF[8] = { 0b01000, 0b10100, 0b01000, 0b00111, 0b00100, 0b00110, 0b00100, 0b00100 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
71 | unsigned char SP_Symbol[8] = { 0b11100, 0b10000, 0b11100, 0b00111, 0b11101, 0b00111, 0b00100, 0b00100 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
72 | unsigned char PumpONOFF[8] = { 0b00000, 0b01110, 0b01010, 0b01110, 0b01000, 0b01000, 0b01000, 0b00000 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
73 | unsigned char RevPumpONOFF[8] = { 0b11111, 0b10001, 0b10101, 0b10001, 0b10111, 0b10111, 0b10111, 0b11111 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
74 | unsigned char HeatONOFF[8] = { 0b00000, 0b01010, 0b01010, 0b01110, 0b01110, 0b01010, 0b01010, 0b00000 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
75 | unsigned char RevHeatONOFF[8] = { 0b11111, 0b10101, 0b10101, 0b10001, 0b10001, 0b10101, 0b10101, 0b11111 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
76 | unsigned char Language[8] = { 0b11111, 0b00010, 0b01000, 0b11111, 0b00000, 0b10001, 0b10101, 0b11111 }; |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
77 | |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
78 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | void help(void); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | void die(int); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | void help(void) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | fprintf(stdout, "mbsePi-apps brewco v%s starting\n\n", VERSION); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | fprintf(stdout, "Usage: brewco [-d] [-h]\n"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | fprintf(stdout, " -d --debug Debug and run in foreground\n"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | fprintf(stdout, " -h --help Display this help\n"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | void die(int onsig) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | switch (onsig) { |
456
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
97 | #ifdef USE_SIMULATOR |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
98 | case SIGUSR1: syslog(LOG_NOTICE, "Got SIGUSR1, start cooler"); |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
99 | SIM_cooler = TRUE; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
100 | return; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
101 | case SIGUSR2: syslog(LOG_NOTICE, "Got SIGUSR2, stop cooler"); |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
102 | SIM_cooler = FALSE; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
103 | return; |
045db83dd013
Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents:
455
diff
changeset
|
104 | #endif |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | case SIGHUP: syslog(LOG_NOTICE, "Got SIGHUP, shutting down"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | case SIGINT: syslog(LOG_NOTICE, "Keyboard interrupt, shutting down"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | case SIGTERM: syslog(LOG_NOTICE, "Got SIGTERM, shutting down"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | case SIGSEGV: syslog(LOG_NOTICE, "Got SIGSEGV, shutting down"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | my_shutdown = TRUE; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | exit(SIGSEGV); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | default: syslog(LOG_NOTICE, "die() on signal %d", onsig); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | my_shutdown = TRUE; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
123 | void tempstatus(double hlttemp, double mlttemp) |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
124 | { |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
125 | char text[81]; |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
126 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
127 | snprintf(text, 7, "%5.1f\001", hlttemp); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
128 | #ifdef HAVE_WIRINGPI_H |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
129 | piLock(LOCK_LCD); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
130 | lcdPosition(lcdHandle, 2, 1); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
131 | lcdPuts(lcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
132 | #endif |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
133 | slcdPosition(slcdHandle, 2, 1); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
134 | slcdPuts(slcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
135 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
136 | snprintf(text, 7, "%5.1f\001", mlttemp); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
137 | #ifdef HAVE_WIRINGPI_H |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
138 | piLock(LOCK_LCD); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
139 | lcdPosition(lcdHandle, 11, 1); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
140 | lcdPuts(lcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
141 | #endif |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
142 | slcdPosition(slcdHandle, 11, 1); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
143 | slcdPuts(slcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
144 | } |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
145 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
146 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
147 | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
148 | int manual_menu(units_list *, double, double); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
149 | int manual_menu(units_list *unit, double hlt, double mlt) |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
150 | { |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
151 | int key, i; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
152 | static int man_hlt_heat, man_mlt_heat, man_mlt_pump; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
153 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
154 | switch (manual) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
155 | case MANUAL_SELHLT: prompt(104, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
156 | prompt(219, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
157 | prompt(402, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
158 | key = keywait(); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
159 | if (key == KEY_DOWN) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
160 | manual = MANUAL_SELMLT; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
161 | if (key == KEY_RETURN) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
162 | manual = MANUAL_NONE; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
163 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
164 | // TODO: prompt for water |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
165 | manual = MANUAL_HLT; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
166 | prompt(0, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
167 | man_hlt_heat = 0, man_mlt_heat = 0, man_mlt_pump = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
168 | device_out(unit->hlt_heater.uuid, man_hlt_heat); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
169 | device_out(unit->mlt_heater.uuid, man_mlt_heat); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
170 | device_out(unit->mlt_pump.uuid, man_mlt_pump); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
171 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
172 | break; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
173 | case MANUAL_SELMLT: prompt(104, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
174 | prompt(220, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
175 | prompt(404, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
176 | key = keywait(); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
177 | if (key == KEY_UP) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
178 | manual = MANUAL_SELHLT; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
179 | if (key == KEY_RETURN) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
180 | manual = MANUAL_NONE; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
181 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
182 | // TODO: prompt for water |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
183 | manual = MANUAL_MLT; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
184 | prompt(0, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
185 | man_hlt_heat = 0, man_mlt_heat = 0, man_mlt_pump = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
186 | device_out(unit->hlt_heater.uuid, man_hlt_heat); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
187 | device_out(unit->mlt_heater.uuid, man_mlt_heat); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
188 | device_out(unit->mlt_pump.uuid, man_mlt_pump); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
189 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
190 | break; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
191 | case MANUAL_HLT: prompt(104, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
192 | prompt(413, NULL); |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
193 | tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
194 | |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
195 | for (i = 1; i < 100; i++) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
196 | usleep(10000); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
197 | slcdDummy(slcdHandle); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
198 | key = keycheck(); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
199 | if ((key != KEY_NONE) || my_shutdown) |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
200 | break; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
201 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
202 | if (key == KEY_RETURN) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
203 | if (man_hlt_heat) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
204 | man_hlt_heat = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
205 | else |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
206 | man_hlt_heat = 1; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
207 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
208 | if (key == KEY_ESCAPE) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
209 | manual = MANUAL_SELHLT; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
210 | man_hlt_heat = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
211 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
212 | device_out(unit->hlt_heater.uuid, man_hlt_heat); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
213 | if (debug) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
214 | fprintf(stdout, "device_out(%s, %d) HLT heater\n", unit->hlt_heater.uuid, man_hlt_heat); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
215 | break; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
216 | case MANUAL_MLT: prompt(104, NULL); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
217 | prompt(406, NULL); |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
218 | tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
219 | |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
220 | for (i = 1; i < 100; i++) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
221 | usleep(10000); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
222 | slcdDummy(slcdHandle); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
223 | key = keycheck(); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
224 | if ((key != KEY_NONE) || my_shutdown) |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
225 | break; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
226 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
227 | if (key == KEY_RETURN) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
228 | if (man_mlt_heat) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
229 | man_mlt_heat = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
230 | else |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
231 | man_mlt_heat = 1; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
232 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
233 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
234 | if (man_mlt_pump) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
235 | man_mlt_pump = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
236 | else |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
237 | man_mlt_pump = 1; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
238 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
239 | if (key == KEY_ESCAPE) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
240 | manual = MANUAL_SELMLT; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
241 | man_mlt_heat = man_mlt_pump = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
242 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
243 | device_out(unit->mlt_heater.uuid, man_mlt_heat); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
244 | device_out(unit->mlt_pump.uuid, man_mlt_pump); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
245 | break; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
246 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
247 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
248 | return 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
249 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
250 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
251 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
252 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
253 | int server(void); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
254 | int server(void) |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
255 | { |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
256 | int rc = 0, run = 1, key, temp; |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
257 | int do_init = TRUE, seconds = 0, minutes = 0; |
441 | 258 | units_list *unit; |
259 | brew_session *brew = NULL; | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
260 | #ifndef HAVE_WIRINGPI_H |
441 | 261 | long t = 0; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
262 | #endif |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
263 | time_t now, last = (time_t)0; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
264 | static double hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
265 | |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
266 | prompt(101, NULL); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
267 | |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
268 | /* |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
269 | * Define special characters in the display CGRAM |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
270 | */ |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
271 | if (Config.tempFormat == 'C') |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
272 | slcdCharDef(slcdHandle, 1, degC); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
273 | else |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
274 | slcdCharDef(slcdHandle, 1, degF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
275 | slcdCharDef(slcdHandle, 2, SP_Symbol); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
276 | slcdCharDef(slcdHandle, 3, PumpONOFF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
277 | slcdCharDef(slcdHandle, 4, RevPumpONOFF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
278 | slcdCharDef(slcdHandle, 5, HeatONOFF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
279 | slcdCharDef(slcdHandle, 6, RevHeatONOFF); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
280 | slcdCharDef(slcdHandle, 7, Language); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
281 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
282 | // if (lockprog((char *)"brewco")) { |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
283 | // syslog(LOG_NOTICE, "Can't lock"); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
284 | // return 1; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
285 | // } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
286 | |
441 | 287 | if (debug) |
288 | fprintf(stdout, "Begin server()\n"); | |
289 | ||
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
290 | if ((rc = devices_detect())) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
291 | syslog(LOG_NOTICE, "Detected %d new devices", rc); |
441 | 292 | if (debug) |
293 | fprintf(stdout, "Detected %d new devices\n", rc); | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
294 | wrconfig(); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
295 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
296 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
297 | #ifdef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
298 | rc = piThreadCreate(my_devices_loop); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
299 | #else |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
300 | rc = pthread_create(&threads[t], NULL, my_devices_loop, (void *)t ); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
301 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
302 | if (rc) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
303 | fprintf(stderr, "my_devices_loop thread didn't start rc=%d\n", rc); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
304 | syslog(LOG_NOTICE, "my_devices_loop thread didn't start rc=%d", rc); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
305 | #ifndef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
306 | } else { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
307 | t++; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
308 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
309 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
310 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
311 | #ifdef HAVE_WIRINGPI_H |
441 | 312 | rc = piThreadCreate(my_keyboard_loop); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
313 | #else |
441 | 314 | rc = pthread_create(&threads[t], NULL, my_keyboard_loop, (void *)t ); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
315 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
316 | if (rc) { |
441 | 317 | fprintf(stderr, "my_keyboard_loop thread didn't start rc=%d\n", rc); |
318 | syslog(LOG_NOTICE, "my_keyboard_loop thread didn't start rc=%d", rc); | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
319 | #ifndef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
320 | } else { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
321 | t++; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
322 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
323 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
324 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
325 | #ifdef USE_SIMULATOR |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
326 | #ifdef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
327 | rc = piThreadCreate(my_simulator_loop); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
328 | #else |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
329 | rc = pthread_create(&threads[t], NULL, my_simulator_loop, (void *)t ); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
330 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
331 | if (rc) { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
332 | fprintf(stderr, "my_simulator_loop thread didn't start rc=%d\n", rc); |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
333 | syslog(LOG_NOTICE, "my_simulator_loop thread didn't start rc=%d", rc); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
334 | #ifndef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
335 | } else { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
336 | t++; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
337 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
338 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
339 | #endif |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
340 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
341 | if (! Config.units) { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
342 | /* |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
343 | * No brewsystems defined, add the first |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
344 | */ |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
345 | prompt(218, NULL); /* Add Brewsystem? */ |
451 | 346 | prompt(407, NULL); /* --- --- Ok --- */ |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
347 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
348 | do { |
441 | 349 | key = keywait(); |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
350 | } while (key != KEY_RETURN); |
441 | 351 | |
352 | if (key == KEY_RETURN) { | |
353 | addUnit(1); | |
354 | } | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
355 | } |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
356 | |
441 | 357 | /* |
451 | 358 | * Initialize units for processing |
359 | */ | |
360 | for (unit = Config.units; unit; unit = unit->next) { | |
361 | if (unit->active) | |
362 | break; | |
363 | } | |
364 | ||
365 | if (! unit->active) { | |
366 | fprintf(stdout, "No active units found\n"); | |
367 | } | |
368 | ||
369 | /* | |
370 | * Safety, turn everything off | |
371 | */ | |
372 | if (unit->active) { | |
373 | if (debug) | |
374 | fprintf(stdout, "Starting brewsystem %d `%s'\n", unit->number, unit->name); | |
375 | syslog(LOG_NOTICE, "Starting brewsystem %d `%s'", unit->number, unit->name); | |
376 | } | |
377 | ||
378 | /* | |
441 | 379 | * During automation there will be a state file: |
380 | * ~/.brewco/var/brewing.xml | |
381 | * If this file is present, there has been a crash. | |
382 | */ | |
383 | brew = (brew_session *)malloc(sizeof(brew_session)); | |
384 | if (rdsession(brew) == 0) { | |
385 | } else { | |
386 | /* | |
387 | * No active brew session, make that permanent. | |
388 | */ | |
389 | free(brew); | |
390 | brew = NULL; | |
391 | } | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
392 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
393 | do { |
441 | 394 | if (my_shutdown) { |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
395 | run = 0; |
441 | 396 | break; |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
397 | } |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
398 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
399 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
400 | * Do we need to initialize this unit? |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
401 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
402 | if (do_init) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
403 | if (debug) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
404 | fprintf(stdout, "Initialize brewsystem %d `%s'\n", unit->number, unit->name); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
405 | syslog(LOG_NOTICE, "Initialize brewsystem %d `%s'", unit->number, unit->name); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
406 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
407 | * Turn everything off |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
408 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
409 | unit->hlt_heater.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
410 | unit->mlt_heater.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
411 | unit->mlt_pump.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
412 | device_out(unit->hlt_heater.uuid, 0); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
413 | device_out(unit->mlt_heater.uuid, 0); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
414 | device_out(unit->mlt_pump.uuid, 0); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
415 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
416 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
417 | * Initialize PID's |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
418 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
419 | hltInput = hltSetpoint = mltInput = mltSetpoint = 20.0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
420 | hltOutput = mltOutput = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
421 | PID_init(unit->PID_hlt, &hltInput, &hltOutput, &hltSetpoint, unit->PID_hlt->dispKd, unit->PID_hlt->dispKi, unit->PID_hlt->dispKd, unit->PID_hlt->Direction); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
422 | PID_setOutputLimits(unit->PID_hlt, 0, 5000); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
423 | PID_setSampleTime(unit->PID_hlt, unit->PID_hlt->SampleTime); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
424 | PID_init(unit->PID_mlt, &mltInput, &mltOutput, &mltSetpoint, unit->PID_mlt->dispKd, unit->PID_mlt->dispKi, unit->PID_mlt->dispKd, unit->PID_mlt->Direction); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
425 | PID_setOutputLimits(unit->PID_mlt, 0, 5000); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
426 | PID_setSampleTime(unit->PID_mlt, unit->PID_mlt->SampleTime); |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
427 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
428 | prompt(0, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
429 | prompt(101, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
430 | prompt(401, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
431 | manual = MANUAL_NONE; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
432 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
433 | do_init = FALSE; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
434 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
435 | |
451 | 436 | /* run_pause code here */ |
437 | ||
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
438 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
439 | * Update PID's, even if they are off. Both PID's will do |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
440 | * the scheduling by themselves. |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
441 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
442 | rc = PID_compute(unit->PID_hlt); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
443 | // if (seconds < 3) |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
444 | // fprintf(stdout, "hlt rc=%d"); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
445 | rc = PID_compute(unit->PID_mlt); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
446 | // if (seconds < 3) |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
447 | // fprintf(stdout, " mlt rc=%d\n"); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
448 | |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
449 | now = time(NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
450 | if (now != last) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
451 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
452 | * Each second |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
453 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
454 | last = now; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
455 | seconds++; |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
456 | if (seconds > 59) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
457 | seconds = 0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
458 | minutes++; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
459 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
460 | |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
461 | //fprintf(stdout, "%d seconds %d minutes %ld millis\n", seconds, minutes, millis()); |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
462 | |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
463 | rc = device_in(unit->hlt_sensor.uuid, &temp); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
464 | if (rc == DEVPRESENT_YES) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
465 | hltInput = temp / 1000.0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
466 | unit->hlt_sensor.state = 0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
467 | } else if (rc == DEVPRESENT_ERROR) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
468 | unit->hlt_sensor.state = 1; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
469 | } else { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
470 | unit->hlt_sensor.state = 2; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
471 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
472 | rc = device_in(unit->mlt_sensor.uuid, &temp); |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
473 | if (rc == DEVPRESENT_YES) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
474 | mltInput = temp / 1000.0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
475 | unit->mlt_sensor.state = 0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
476 | } else if (rc == DEVPRESENT_ERROR) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
477 | unit->mlt_sensor.state = 1; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
478 | } else { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
479 | unit->mlt_sensor.state = 2; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
480 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
481 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
482 | if (debug && ((seconds % 10) == 1)) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
483 | fprintf(stdout, "MLT: In=%.2lf Out=%.2lf Set=%.2lf HLT: In=%.2lf Out=%.2lf Set=%.2lf\n", |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
484 | mltInput, mltOutput, mltSetpoint, hltInput, hltOutput, hltSetpoint); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
485 | } |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
486 | |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
487 | } |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
488 | |
441 | 489 | if (brew) { |
490 | /* | |
491 | * Automate mode | |
492 | */ | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
493 | |
451 | 494 | } else if (manual != MANUAL_NONE) { |
495 | /* | |
496 | * Manual mode | |
497 | */ | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
498 | manual_menu(unit, hltInput, mltInput); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
499 | if (manual == MANUAL_NONE) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
500 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
501 | * Rewrite the display |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
502 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
503 | prompt(0, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
504 | prompt(101, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
505 | prompt(401, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
506 | } |
441 | 507 | } else { |
508 | /* | |
509 | * Not running. | |
510 | */ | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
511 | tempstatus(hltInput, mltInput); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
512 | key = keycheck(); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
513 | if (key == KEY_ENTER) { |
442 | 514 | setup(); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
515 | prompt(0, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
516 | prompt(101, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
517 | prompt(401, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
518 | } else if (key == KEY_DOWN) { |
451 | 519 | manual = MANUAL_SELHLT; |
520 | } | |
441 | 521 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
522 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
523 | usleep(5000); /* 5 mSec */ |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
524 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
525 | } while (run); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
526 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
527 | syslog(LOG_NOTICE, "Out of loop"); |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
528 | if (debug) |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
529 | fprintf(stdout, (char *)"Out of loop\n"); |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
530 | |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
531 | prompt(0, NULL); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
532 | prompt(101, NULL); |
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
533 | prompt(302, NULL); |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
534 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
535 | /* |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
536 | * Stop units processing in a neat way |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
537 | */ |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
538 | for (unit = Config.units; unit; unit = unit->next) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
539 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
540 | } |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
541 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
542 | /* |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
543 | * Give threads time to cleanup |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
544 | */ |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
545 | usleep(1500000); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
546 | |
443
6b80a37fdf8d
Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents:
442
diff
changeset
|
547 | prompt(0, NULL); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
548 | // stopLCD(); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
549 | if (sock != -1) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
550 | if (shutdown(sock, SHUT_RDWR)) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
551 | syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
552 | } |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
553 | sock = -1; |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
554 | } |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
555 | wrrecipes(); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
556 | wrconfig(); |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
557 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
558 | // ulockprog((char *)"brewco"); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
559 | return 0; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
560 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
561 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
562 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
563 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
564 | int main(int argc, char *argv[]) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
565 | { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
566 | int rc = 0, c, i; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
567 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
568 | while (1) { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
569 | int option_index = 0; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
570 | static struct option long_options[] = { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
571 | {"debug", 0, 0, 'c'}, |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
572 | {"help", 0, 0, 'h'}, |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
573 | {0, 0, 0, 0} |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
574 | }; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
575 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
576 | c = getopt_long(argc, argv, "dh", long_options, &option_index); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
577 | if (c == -1) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
578 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
579 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
580 | switch (c) { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
581 | case 'd': debug = TRUE; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
582 | break; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
583 | case 'h': help(); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
584 | return 1; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
585 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
586 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
587 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
588 | openlog("brewco", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
589 | syslog(LOG_NOTICE, "mbsePi-apps brewco v%s starting", VERSION); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
590 | if (debug) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
591 | fprintf(stdout, "mbsePi-apps brewco v%s starting\n", VERSION); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
592 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
593 | if (rdconfig()) { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
594 | fprintf(stderr, "Error reading configuration\n"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
595 | syslog(LOG_NOTICE, "Error reading configuration: halted"); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
596 | return 1; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
597 | } |
441 | 598 | if (debug) |
599 | fprintf(stdout, "configuration loaded\n"); | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
600 | |
459
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
601 | if (rdrecipes()) { |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
602 | fprintf(stderr, "Error reading recipes\n"); |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
603 | syslog(LOG_NOTICE, "Error reading recipes: halted"); |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
604 | return 1; |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
605 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
606 | if (debug) |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
607 | fprintf(stdout, "recipes loaded\n"); |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
608 | |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
609 | /* |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
610 | * Catch all the signals we can, and ignore the rest. Note that SIGKILL can't be ignored |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
611 | * but that's live. This daemon should only be stopped by SIGTERM. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
612 | * Don't catch SIGCHLD. |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
613 | */ |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
614 | for (i = 0; i < NSIG; i++) { |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
615 | if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP)) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
616 | signal(i, (void (*))die); |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
617 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
618 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
619 | #ifdef HAVE_WIRINGPI_H |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
620 | if (wiringPiSetup () ) |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
621 | return 1; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
622 | #endif |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
623 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
624 | if ((rc = initLCD (Config.lcd_cols, Config.lcd_rows))) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
625 | fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
626 | return 1; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
627 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
628 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
629 | rc = server(); |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
630 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
631 | syslog(LOG_NOTICE, "Finished, rc=%d", rc); |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
632 | if (debug) |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
633 | fprintf(stdout, "Finished, rc=%d\n", rc); |
409
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
634 | return rc; |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
635 | } |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
636 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
637 |