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