Sun, 20 Dec 2015 23:26:03 +0100
Manual mode works with heat percentages.
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; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
41 | int HLTpercent = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
42 | int MLTpercent = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
43 | int man_mlt_pump = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
44 | int man_hlt_heat = 50; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
45 | int man_mlt_heat = 50; |
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
|
46 | 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
|
47 | 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
|
48 | extern int lcdHandle; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
49 | extern int slcdHandle; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
50 | 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
|
51 | #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
|
52 | 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
|
53 | #endif |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
54 | char *etcpath = NULL; |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
55 | char *varpath = NULL; |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
56 | |
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
|
57 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
58 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
59 | #ifndef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
60 | 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
|
61 | #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
|
62 | |
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
|
63 | |
451 | 64 | #define MANUAL_NONE 0 |
65 | #define MANUAL_SELHLT 1 | |
66 | #define MANUAL_SELMLT 2 | |
67 | #define MANUAL_HLT 11 | |
68 | #define MANUAL_MLT 12 | |
69 | ||
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
70 | #define PERC_INIT 0 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
71 | #define PERC_MLT 1 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
72 | #define PERC_HLT 2 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
73 | #define PERC_REST 3 |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
74 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
75 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
76 | int manual = MANUAL_NONE; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
77 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
78 | |
451 | 79 | |
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
|
80 | /* |
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
|
81 | * 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
|
82 | */ |
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
|
83 | 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
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | 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
|
88 | 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
|
89 | 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
|
90 | 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
|
91 | |
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
|
92 | |
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
|
93 | 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
|
94 | 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
|
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 | |
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
|
97 | |
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
|
98 | 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
|
99 | { |
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
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | } |
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 | |
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 | |
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 | |
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 | 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
|
109 | { |
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 | 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
|
111 | #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
|
112 | 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
|
113 | 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
|
114 | 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
|
115 | 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
|
116 | 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
|
117 | 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
|
118 | #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
|
119 | 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
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | 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
|
124 | 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
|
125 | 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
|
126 | 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
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | } |
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
|
131 | |
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
|
132 | 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
|
133 | } |
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
|
134 | |
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
|
135 | |
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
|
136 | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
137 | void tempstatus(double hlttemp, double mlttemp) |
452
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
138 | { |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
139 | char text[81]; |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
140 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
141 | snprintf(text, 7, "%5.1f\001", hlttemp); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
142 | #ifdef HAVE_WIRINGPI_H |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
143 | piLock(LOCK_LCD); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
144 | lcdPosition(lcdHandle, 2, 1); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
145 | lcdPuts(lcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
146 | #endif |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
147 | slcdPosition(slcdHandle, 2, 1); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
148 | slcdPuts(slcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
149 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
150 | snprintf(text, 7, "%5.1f\001", mlttemp); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
151 | #ifdef HAVE_WIRINGPI_H |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
152 | piLock(LOCK_LCD); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
153 | lcdPosition(lcdHandle, 11, 1); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
154 | lcdPuts(lcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
155 | #endif |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
156 | slcdPosition(slcdHandle, 11, 1); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
157 | slcdPuts(slcdHandle, text); |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
158 | } |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
159 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
160 | |
edc86e2d2eaa
Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents:
451
diff
changeset
|
161 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
162 | void manual_prompt(void) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
163 | { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
164 | switch (manual) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
165 | case MANUAL_SELHLT: prompt(104, NULL); /* " MANUAL MODE " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
166 | prompt(219, NULL); /* " Manual HLT " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
167 | prompt(402, NULL); /* "--- dwn quit ok " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
168 | break; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
169 | case MANUAL_SELMLT: prompt(104, NULL); /* " MANUAL MODE " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
170 | prompt(220, NULL); /* " Manual MLT " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
171 | prompt(404, NULL); /* " up --- quit ok " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
172 | break; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
173 | case MANUAL_HLT: prompt(0, NULL); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
174 | prompt(104, NULL); /* " MANUAL MODE " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
175 | prompt(413, NULL); /* "UP* *DWN heat --- " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
176 | break; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
177 | case MANUAL_MLT: prompt(0, NULL); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
178 | prompt(104, NULL); /* " MANUAL MODE " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
179 | prompt(406, NULL); /* "UP* *DWN heat pmp " */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
180 | break; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
181 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
182 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
183 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
184 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
185 | |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
186 | /* |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
187 | * Manual menu for testing your equipment. |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
188 | */ |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
189 | 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
|
190 | 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
|
191 | { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
192 | int key; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
193 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
194 | switch (manual) { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
195 | case MANUAL_SELHLT: slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
196 | key = keycheck(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
197 | if (key == KEY_DOWN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
198 | manual = MANUAL_SELMLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
199 | manual_prompt(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
200 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
201 | if (key == KEY_RETURN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
202 | manual = MANUAL_NONE; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
203 | HLTpercent = MLTpercent = man_mlt_pump = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
204 | device_out(unit->mlt_pump.uuid, man_mlt_pump); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
205 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
206 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
207 | // TODO: prompt for water |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
208 | manual = MANUAL_HLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
209 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
210 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
211 | break; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
212 | case MANUAL_SELMLT: slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
213 | key = keycheck(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
214 | if (key == KEY_UP) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
215 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
216 | manual_prompt(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
217 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
218 | if (key == KEY_RETURN) { |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
219 | manual = MANUAL_NONE; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
220 | HLTpercent = MLTpercent = man_mlt_pump = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
221 | device_out(unit->mlt_pump.uuid, man_mlt_pump); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
222 | } |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
223 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
224 | // TODO: prompt for water |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
225 | manual = MANUAL_MLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
226 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
227 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
228 | break; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
229 | case MANUAL_HLT: tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
230 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
231 | slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
232 | key = keycheck(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
233 | if (key == KEY_RETURN) { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
234 | if (HLTpercent) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
235 | HLTpercent = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
236 | else |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
237 | HLTpercent = man_hlt_heat; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
238 | } |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
239 | if ((key == KEY_DOWN) && (man_hlt_heat > 1)) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
240 | man_hlt_heat--; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
241 | if ((key == KEY_UP) && (man_hlt_heat < 100)) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
242 | man_hlt_heat++; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
243 | if (HLTpercent) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
244 | HLTpercent = man_hlt_heat; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
245 | if (key == KEY_ESCAPE) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
246 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
247 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
248 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
249 | break; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
250 | case MANUAL_MLT: tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
251 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
252 | slcdDummy(slcdHandle); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
253 | key = keycheck(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
254 | if (key == KEY_RETURN) { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
255 | if (MLTpercent) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
256 | MLTpercent = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
257 | else |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
258 | MLTpercent = man_mlt_heat; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
259 | } |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
260 | if ((key == KEY_DOWN) && (man_mlt_heat > 1)) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
261 | man_mlt_heat--; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
262 | if ((key == KEY_UP) && (man_mlt_heat < 100)) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
263 | man_mlt_heat++; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
264 | if (MLTpercent) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
265 | MLTpercent = man_mlt_heat; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
266 | if (key == KEY_ENTER) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
267 | if (man_mlt_pump) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
268 | man_mlt_pump = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
269 | else |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
270 | man_mlt_pump = 1; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
271 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
272 | if (key == KEY_ESCAPE) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
273 | manual = MANUAL_SELMLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
274 | manual_prompt(); |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
275 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
276 | 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
|
277 | break; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
278 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
279 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
280 | return 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
281 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
282 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
283 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
284 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
285 | int server(void); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
286 | int server(void) |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
287 | { |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
288 | int rc = 0, run = 1, key, temp, MLTp, HLTp, percslot, percfase = PERC_INIT; |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
289 | int do_init = TRUE, seconds = 0, minutes = 0; |
441 | 290 | units_list *unit; |
291 | brew_session *brew = NULL; | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
292 | #ifndef HAVE_WIRINGPI_H |
441 | 293 | long t = 0; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
294 | #endif |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
295 | time_t now, last = (time_t)0; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
296 | static double hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
297 | long nowmillis, perctimer; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
298 | |
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
|
299 | 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
|
300 | |
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
|
301 | /* |
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
|
302 | * 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
|
303 | */ |
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
|
304 | 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
|
305 | 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
|
306 | 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
|
307 | 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
|
308 | 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
|
309 | 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
|
310 | 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
|
311 | 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
|
312 | 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
|
313 | 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
|
314 | |
465 | 315 | if (lockprog((char *)"brewco")) { |
316 | syslog(LOG_NOTICE, "Can't lock"); | |
317 | return 1; | |
318 | } | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
319 | |
441 | 320 | if (debug) |
321 | fprintf(stdout, "Begin server()\n"); | |
322 | ||
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
323 | if ((rc = devices_detect())) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
324 | syslog(LOG_NOTICE, "Detected %d new devices", rc); |
441 | 325 | if (debug) |
326 | 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
|
327 | wrconfig(); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
328 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
329 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
330 | #ifdef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
331 | rc = piThreadCreate(my_devices_loop); |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
332 | #else |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
333 | 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
|
334 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
335 | if (rc) { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
336 | 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
|
337 | 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
|
338 | #ifndef HAVE_WIRINGPI_H |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
339 | } else { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
340 | t++; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
341 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
342 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
343 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
344 | #ifdef HAVE_WIRINGPI_H |
441 | 345 | rc = piThreadCreate(my_keyboard_loop); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
346 | #else |
441 | 347 | 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
|
348 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
349 | if (rc) { |
441 | 350 | fprintf(stderr, "my_keyboard_loop thread didn't start rc=%d\n", rc); |
351 | 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
|
352 | #ifndef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
353 | } else { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
354 | t++; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
355 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
356 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
357 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
358 | #ifdef USE_SIMULATOR |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
359 | #ifdef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
360 | rc = piThreadCreate(my_simulator_loop); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
361 | #else |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
362 | 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
|
363 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
364 | if (rc) { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
365 | 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
|
366 | 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
|
367 | #ifndef HAVE_WIRINGPI_H |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
368 | } else { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
369 | t++; |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
370 | #endif |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
371 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
372 | #endif |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
373 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
374 | if (! Config.units) { |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
375 | /* |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
376 | * 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
|
377 | */ |
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
|
378 | prompt(218, NULL); /* Add Brewsystem? */ |
451 | 379 | prompt(407, NULL); /* --- --- Ok --- */ |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
380 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
381 | do { |
441 | 382 | key = keywait(); |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
383 | } while (key != KEY_RETURN); |
441 | 384 | |
385 | if (key == KEY_RETURN) { | |
386 | addUnit(1); | |
387 | } | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
388 | } |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
389 | |
441 | 390 | /* |
451 | 391 | * Initialize units for processing |
392 | */ | |
393 | for (unit = Config.units; unit; unit = unit->next) { | |
394 | if (unit->active) | |
395 | break; | |
396 | } | |
397 | ||
398 | if (! unit->active) { | |
399 | fprintf(stdout, "No active units found\n"); | |
400 | } | |
401 | ||
402 | /* | |
403 | * Safety, turn everything off | |
404 | */ | |
405 | if (unit->active) { | |
406 | if (debug) | |
407 | fprintf(stdout, "Starting brewsystem %d `%s'\n", unit->number, unit->name); | |
408 | syslog(LOG_NOTICE, "Starting brewsystem %d `%s'", unit->number, unit->name); | |
409 | } | |
410 | ||
411 | /* | |
441 | 412 | * During automation there will be a state file: |
413 | * ~/.brewco/var/brewing.xml | |
414 | * If this file is present, there has been a crash. | |
415 | */ | |
416 | brew = (brew_session *)malloc(sizeof(brew_session)); | |
417 | if (rdsession(brew) == 0) { | |
418 | } else { | |
419 | /* | |
420 | * No active brew session, make that permanent. | |
421 | */ | |
422 | free(brew); | |
423 | brew = NULL; | |
424 | } | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
425 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
426 | do { |
441 | 427 | if (my_shutdown) { |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
428 | run = 0; |
441 | 429 | break; |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
430 | } |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
431 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
432 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
433 | * 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
|
434 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
435 | if (do_init) { |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
436 | if (debug) |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
437 | 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
|
438 | 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
|
439 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
440 | * Turn everything off |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
441 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
442 | unit->hlt_heater.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
443 | unit->mlt_heater.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
444 | unit->mlt_pump.value = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
445 | 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
|
446 | 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
|
447 | 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
|
448 | |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
449 | /* |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
450 | * Initialize PID's |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
451 | */ |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
452 | hltInput = hltSetpoint = mltInput = mltSetpoint = 20.0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
453 | hltOutput = mltOutput = 0; |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
454 | 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
|
455 | 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
|
456 | 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
|
457 | 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
|
458 | 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
|
459 | 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
|
460 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
461 | prompt(0, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
462 | prompt(101, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
463 | prompt(401, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
464 | manual = MANUAL_NONE; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
465 | |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
466 | do_init = FALSE; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
467 | nowmillis = perctimer = millis(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
468 | percslot = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
469 | percfase = PERC_INIT; |
453
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
470 | } |
76418c89b480
Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents:
452
diff
changeset
|
471 | |
451 | 472 | /* run_pause code here */ |
473 | ||
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
474 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
475 | * 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
|
476 | * the scheduling by themselves. |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
477 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
478 | rc = PID_compute(unit->PID_hlt); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
479 | // if (seconds < 3) |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
480 | // fprintf(stdout, "hlt rc=%d"); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
481 | rc = PID_compute(unit->PID_mlt); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
482 | // if (seconds < 3) |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
483 | // fprintf(stdout, " mlt rc=%d\n"); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
484 | |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
485 | /* |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
486 | * 50 mSeconds loop for heater elements timing. |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
487 | */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
488 | nowmillis = millis(); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
489 | if (nowmillis > (perctimer + 50)) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
490 | percslot++; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
491 | if (percfase == PERC_INIT) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
492 | HLTp = HLTpercent; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
493 | MLTp = MLTpercent; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
494 | if ((MLTp + HLTp) > 100) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
495 | HLTp = 100 - MLTp; /* The HLT has lower priority */ |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
496 | if (MLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
497 | percfase = PERC_MLT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
498 | device_out(unit->mlt_heater.uuid, 1); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
499 | } else if (HLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
500 | percfase = PERC_HLT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
501 | device_out(unit->hlt_heater.uuid, 1); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
502 | } else { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
503 | percfase = PERC_REST; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
504 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
505 | if (debug) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
506 | fprintf(stdout, " perslot MLT=%d%% HLT=%d%% fase=%d\n", MLTp, HLTp, percfase); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
507 | } else if (percfase == PERC_MLT) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
508 | if (percslot > MLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
509 | if (debug) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
510 | fprintf(stdout, " perslot %d MLT off\n", percslot); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
511 | device_out(unit->mlt_heater.uuid, 0); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
512 | if (HLTp) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
513 | if (debug) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
514 | fprintf(stdout, " perslot %d HLT on\n", percslot); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
515 | device_out(unit->hlt_heater.uuid, 1); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
516 | percfase = PERC_HLT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
517 | } else { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
518 | percfase = PERC_REST; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
519 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
520 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
521 | } else if (percfase == PERC_HLT) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
522 | if (percslot > (MLTp + HLTp)) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
523 | if (debug) |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
524 | fprintf(stdout, " perslot %d HLT off\n", percslot); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
525 | device_out(unit->hlt_heater.uuid, 0); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
526 | percfase = PERC_REST; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
527 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
528 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
529 | if (percslot == 100) { |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
530 | percslot = 0; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
531 | percfase = PERC_INIT; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
532 | device_out(unit->hlt_heater.uuid, 0); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
533 | device_out(unit->mlt_heater.uuid, 0); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
534 | fprintf(stdout, " perslot complete\n"); |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
535 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
536 | perctimer = nowmillis; |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
537 | } |
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
538 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
539 | now = time(NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
540 | if (now != last) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
541 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
542 | * Each second |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
543 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
544 | last = now; |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
545 | seconds++; |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
546 | if (seconds > 59) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
547 | seconds = 0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
548 | minutes++; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
549 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
550 | |
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
|
551 | //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
|
552 | |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
553 | 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
|
554 | if (rc == DEVPRESENT_YES) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
555 | hltInput = temp / 1000.0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
556 | 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
|
557 | } 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
|
558 | 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
|
559 | } else { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
560 | 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
|
561 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
562 | 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
|
563 | if (rc == DEVPRESENT_YES) { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
564 | mltInput = temp / 1000.0; |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
565 | 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
|
566 | } 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
|
567 | 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
|
568 | } else { |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
569 | 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
|
570 | } |
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
571 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
572 | if (debug && ((seconds % 10) == 1)) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
573 | 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
|
574 | mltInput, mltOutput, mltSetpoint, hltInput, hltOutput, hltSetpoint); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
575 | } |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
576 | |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
577 | } |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
578 | |
441 | 579 | if (brew) { |
580 | /* | |
581 | * Automate mode | |
582 | */ | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
583 | |
451 | 584 | } else if (manual != MANUAL_NONE) { |
585 | /* | |
586 | * Manual mode | |
587 | */ | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
588 | manual_menu(unit, hltInput, mltInput); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
589 | if (manual == MANUAL_NONE) { |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
590 | /* |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
591 | * Rewrite the display |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
592 | */ |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
593 | prompt(0, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
594 | prompt(101, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
595 | prompt(401, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
596 | } |
441 | 597 | } else { |
598 | /* | |
599 | * Not running. | |
600 | */ | |
455
f84501d8dd87
Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents:
454
diff
changeset
|
601 | tempstatus(hltInput, mltInput); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
602 | key = keycheck(); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
603 | if (key == KEY_ENTER) { |
442 | 604 | setup(); |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
605 | prompt(0, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
606 | prompt(101, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
607 | prompt(401, NULL); |
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
608 | } else if (key == KEY_DOWN) { |
451 | 609 | manual = MANUAL_SELHLT; |
466
49a5318256f0
Manual mode works with heat percentages.
Michiel Broek <mbroek@mbse.eu>
parents:
465
diff
changeset
|
610 | manual_prompt(); |
451 | 611 | } |
441 | 612 | } |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
613 | |
454
78242696c15a
Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents:
453
diff
changeset
|
614 | usleep(5000); /* 5 mSec */ |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
615 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
616 | } while (run); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
617 | |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
618 | 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
|
619 | if (debug) |
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
620 | 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
|
621 | |
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
|
622 | 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
|
623 | 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
|
624 | prompt(302, NULL); |
440
8df3252b688f
Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents:
438
diff
changeset
|
625 | |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
626 | /* |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
627 | * Stop units processing in a neat way |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
628 | */ |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
629 | for (unit = Config.units; unit; unit = unit->next) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
630 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
631 | } |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
632 | |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
633 | /* |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
634 | * Give threads time to cleanup |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
635 | */ |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
636 | usleep(1500000); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
637 | |
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
|
638 | prompt(0, NULL); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
639 | // stopLCD(); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
640 | if (sock != -1) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
641 | if (shutdown(sock, SHUT_RDWR)) { |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
642 | syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno)); |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
643 | } |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
644 | sock = -1; |
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
645 | } |
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
|
646 | wrrecipes(); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
647 | 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
|
648 | |
465 | 649 | ulockprog((char *)"brewco"); |
438
7d1ec160d751
Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents:
434
diff
changeset
|
650 | return 0; |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
651 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
652 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
653 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
654 | |
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
|
655 | 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
|
656 | { |
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
|
657 | int rc = 0, c, i; |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
658 | char *homepath = NULL; |
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
|
659 | |
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
|
660 | 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
|
661 | 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
|
662 | 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
|
663 | {"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
|
664 | {"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
|
665 | {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
|
666 | }; |
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
|
667 | |
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
|
668 | 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
|
669 | 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
|
670 | 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
|
671 | |
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
|
672 | 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
|
673 | 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
|
674 | 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
|
675 | 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
|
676 | 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
|
677 | } |
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
|
678 | } |
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
|
679 | |
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
|
680 | 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
|
681 | 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
|
682 | 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
|
683 | 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
|
684 | |
464
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
685 | /* |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
686 | * Set home directory path |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
687 | */ |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
688 | if (getenv((char *)"USER") == NULL) { |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
689 | homepath = xstrcpy((char *)"/root"); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
690 | } else { |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
691 | homepath = xstrcpy(getenv((char *)"HOME")); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
692 | } |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
693 | varpath = xstrcpy(homepath); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
694 | varpath = xstrcat(varpath, (char *)"/.brewco/var/"); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
695 | etcpath = xstrcpy(homepath); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
696 | etcpath = xstrcat(etcpath, (char *)"/.brewco/etc/"); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
697 | mkdirs(varpath, 0755); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
698 | mkdirs(etcpath, 0755); |
4a624c071ca9
Added file copy. Move home directory detection to the main program function. During opening of the main configuration file, backups are made, 10 revisions in total.
Michiel Broek <mbroek@mbse.eu>
parents:
459
diff
changeset
|
699 | |
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
|
700 | 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
|
701 | 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
|
702 | 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
|
703 | 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
|
704 | } |
441 | 705 | if (debug) |
706 | 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
|
707 | |
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
|
708 | 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
|
709 | 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
|
710 | 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
|
711 | 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
|
712 | } |
1f88be70f253
Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents:
456
diff
changeset
|
713 | 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
|
714 | 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
|
715 | |
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
|
716 | /* |
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
|
717 | * 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
|
718 | * 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
|
719 | * 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
|
720 | */ |
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
|
721 | 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
|
722 | 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
|
723 | 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
|
724 | } |
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
|
725 | |
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
|
726 | #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
|
727 | 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
|
728 | 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
|
729 | #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
|
730 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
731 | 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
|
732 | 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
|
733 | return 1; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
734 | } |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
735 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
736 | 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
|
737 | |
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
|
738 | syslog(LOG_NOTICE, "Finished, rc=%d", rc); |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
739 | if (debug) |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
419
diff
changeset
|
740 | 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
|
741 | 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
|
742 | } |
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
|
743 | |
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
|
744 |