brewco/brewco.c

Sun, 20 Dec 2015 20:37:40 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 20 Dec 2015 20:37:40 +0100
changeset 464
4a624c071ca9
parent 459
1f88be70f253
child 465
3aac3276689d
permissions
-rw-r--r--

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.

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
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
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
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
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
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents: 441
diff changeset
35 #include "prompt.h"
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents: 441
diff changeset
36 #include "setup.h"
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents: 441
diff changeset
37
409
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 int my_shutdown = FALSE;
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 extern int debug;
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 extern sys_config Config;
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 extern int lcdHandle;
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
44 extern int slcdHandle;
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
45 extern int sock;
456
045db83dd013 Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
46 #ifdef USE_SIMULATOR
045db83dd013 Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
47 extern int SIM_cooler;
045db83dd013 Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
48 #endif
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
49 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
50 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
51
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
52
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
53
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
54 #ifndef HAVE_WIRINGPI_H
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
55 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
56 #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
57
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
451
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
59 #define MANUAL_NONE 0
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
60 #define MANUAL_SELHLT 1
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
61 #define MANUAL_SELMLT 2
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
62 #define MANUAL_HLT 11
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
63 #define MANUAL_MLT 12
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
64
453
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
65 int manual = MANUAL_NONE;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
66
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
67
451
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
68
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
69 /*
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
70 * 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
71 */
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
72 unsigned char 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
73 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
74 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
75 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
76 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
77 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
78 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
79 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
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
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
82 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
83 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
84
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 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
88 {
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 fprintf(stdout, "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
90 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
91 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
92 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
93 }
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94
cdf68044adaf Added a new brewpanel program that runs on an SDL/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 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
98 {
cdf68044adaf Added a new brewpanel program that runs on an SDL/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 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
100 #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
101 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
102 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
103 return;
045db83dd013 Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
104 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
105 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
106 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
107 #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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 }
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 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
122 }
cdf68044adaf Added a new brewpanel program that runs on an SDL/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
cdf68044adaf Added a new brewpanel program that runs on an SDL/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
cdf68044adaf Added a new brewpanel program that runs on an SDL/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
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
126 void tempstatus(double hlttemp, double mlttemp)
452
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
127 {
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
128 char text[81];
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
129
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
130 snprintf(text, 7, "%5.1f\001", hlttemp);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
131 #ifdef HAVE_WIRINGPI_H
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
132 piLock(LOCK_LCD);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
133 lcdPosition(lcdHandle, 2, 1);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
134 lcdPuts(lcdHandle, text);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
135 #endif
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
136 slcdPosition(slcdHandle, 2, 1);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
137 slcdPuts(slcdHandle, text);
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 snprintf(text, 7, "%5.1f\001", mlttemp);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
140 #ifdef HAVE_WIRINGPI_H
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
141 piLock(LOCK_LCD);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
142 lcdPosition(lcdHandle, 11, 1);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
143 lcdPuts(lcdHandle, text);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
144 #endif
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
145 slcdPosition(slcdHandle, 11, 1);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
146 slcdPuts(slcdHandle, text);
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
147 }
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
148
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
149
edc86e2d2eaa Changed device outputs and status leds.
Michiel Broek <mbroek@mbse.eu>
parents: 451
diff changeset
150
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
151 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
152 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
153 {
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
154 int key, i;
453
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
155 static int man_hlt_heat, man_mlt_heat, man_mlt_pump;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
156
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
157 switch (manual) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
158 case MANUAL_SELHLT: prompt(104, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
159 prompt(219, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
160 prompt(402, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
161 key = keywait();
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
162 if (key == KEY_DOWN)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
163 manual = MANUAL_SELMLT;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
164 if (key == KEY_RETURN)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
165 manual = MANUAL_NONE;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
166 if (key == KEY_ENTER) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
167 // TODO: prompt for water
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
168 manual = MANUAL_HLT;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
169 prompt(0, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
170 man_hlt_heat = 0, man_mlt_heat = 0, man_mlt_pump = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
171 device_out(unit->hlt_heater.uuid, man_hlt_heat);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
172 device_out(unit->mlt_heater.uuid, man_mlt_heat);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
173 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
174 }
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
175 break;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
176 case MANUAL_SELMLT: prompt(104, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
177 prompt(220, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
178 prompt(404, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
179 key = keywait();
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
180 if (key == KEY_UP)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
181 manual = MANUAL_SELHLT;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
182 if (key == KEY_RETURN)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
183 manual = MANUAL_NONE;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
184 if (key == KEY_ENTER) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
185 // TODO: prompt for water
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
186 manual = MANUAL_MLT;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
187 prompt(0, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
188 man_hlt_heat = 0, man_mlt_heat = 0, man_mlt_pump = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
189 device_out(unit->hlt_heater.uuid, man_hlt_heat);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
190 device_out(unit->mlt_heater.uuid, man_mlt_heat);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
191 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
192 }
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
193 break;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
194 case MANUAL_HLT: prompt(104, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
195 prompt(413, NULL);
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
196 tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput);
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
197
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
198 for (i = 1; i < 100; i++) {
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
199 usleep(10000);
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
200 slcdDummy(slcdHandle);
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
201 key = keycheck();
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
202 if ((key != KEY_NONE) || my_shutdown)
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
203 break;
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
204 }
453
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
205 if (key == KEY_RETURN) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
206 if (man_hlt_heat)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
207 man_hlt_heat = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
208 else
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
209 man_hlt_heat = 1;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
210 }
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
211 if (key == KEY_ESCAPE) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
212 manual = MANUAL_SELHLT;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
213 man_hlt_heat = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
214 }
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
215 device_out(unit->hlt_heater.uuid, man_hlt_heat);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
216 if (debug)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
217 fprintf(stdout, "device_out(%s, %d) HLT heater\n", unit->hlt_heater.uuid, man_hlt_heat);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
218 break;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
219 case MANUAL_MLT: prompt(104, NULL);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
220 prompt(406, NULL);
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
221 tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput);
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
222
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
223 for (i = 1; i < 100; i++) {
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
224 usleep(10000);
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
225 slcdDummy(slcdHandle);
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
226 key = keycheck();
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
227 if ((key != KEY_NONE) || my_shutdown)
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
228 break;
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
229 }
453
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
230 if (key == KEY_RETURN) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
231 if (man_mlt_heat)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
232 man_mlt_heat = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
233 else
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
234 man_mlt_heat = 1;
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 if (key == KEY_ENTER) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
237 if (man_mlt_pump)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
238 man_mlt_pump = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
239 else
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
240 man_mlt_pump = 1;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
241 }
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
242 if (key == KEY_ESCAPE) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
243 manual = MANUAL_SELMLT;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
244 man_mlt_heat = man_mlt_pump = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
245 }
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
246 device_out(unit->mlt_heater.uuid, man_mlt_heat);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
247 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
248 break;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
249 }
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
250
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
251 return 0;
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
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
254
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
255
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
256 int server(void);
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
257 int server(void)
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
258 {
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
259 int rc = 0, run = 1, key, temp;
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
260 int do_init = TRUE, seconds = 0, minutes = 0;
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
261 units_list *unit;
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
262 brew_session *brew = NULL;
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
263 #ifndef HAVE_WIRINGPI_H
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
264 long t = 0;
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
265 #endif
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
266 time_t now, last = (time_t)0;
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
267 static double hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint;
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
268
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
269 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
270
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
271 /*
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
272 * 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
273 */
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
285 // if (lockprog((char *)"brewco")) {
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
286 // syslog(LOG_NOTICE, "Can't lock");
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
287 // return 1;
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
288 // }
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
289
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
290 if (debug)
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
291 fprintf(stdout, "Begin server()\n");
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
292
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
293 if ((rc = devices_detect())) {
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
294 syslog(LOG_NOTICE, "Detected %d new devices", rc);
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
295 if (debug)
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
296 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
297 wrconfig();
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
298 }
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
299
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
300 #ifdef HAVE_WIRINGPI_H
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
301 rc = piThreadCreate(my_devices_loop);
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
302 #else
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
303 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
304 #endif
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
305 if (rc) {
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
306 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
307 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
308 #ifndef HAVE_WIRINGPI_H
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
309 } else {
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
310 t++;
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
311 #endif
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
312 }
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
313
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
314 #ifdef HAVE_WIRINGPI_H
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
315 rc = piThreadCreate(my_keyboard_loop);
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
316 #else
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
317 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
318 #endif
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
319 if (rc) {
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
320 fprintf(stderr, "my_keyboard_loop thread didn't start rc=%d\n", rc);
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
321 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
322 #ifndef HAVE_WIRINGPI_H
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
323 } else {
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
324 t++;
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
325 #endif
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
326 }
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
327
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
328 #ifdef USE_SIMULATOR
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
329 #ifdef HAVE_WIRINGPI_H
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
330 rc = piThreadCreate(my_simulator_loop);
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
331 #else
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
332 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
333 #endif
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
334 if (rc) {
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
335 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
336 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
337 #ifndef HAVE_WIRINGPI_H
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
338 } else {
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
339 t++;
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
340 #endif
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
341 }
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
342 #endif
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
343
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
344 if (! Config.units) {
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
345 /*
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
346 * 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
347 */
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
348 prompt(218, NULL); /* Add Brewsystem? */
451
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
349 prompt(407, NULL); /* --- --- Ok --- */
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
350
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
351 do {
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
352 key = keywait();
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
353 } while (key != KEY_RETURN);
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
354
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
355 if (key == KEY_RETURN) {
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
356 addUnit(1);
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
357 }
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
358 }
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
359
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
360 /*
451
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
361 * Initialize units for processing
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
362 */
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
363 for (unit = Config.units; unit; unit = unit->next) {
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
364 if (unit->active)
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
365 break;
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
366 }
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
367
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
368 if (! unit->active) {
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
369 fprintf(stdout, "No active units found\n");
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
370 }
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
371
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
372 /*
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
373 * Safety, turn everything off
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
374 */
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
375 if (unit->active) {
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
376 if (debug)
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
377 fprintf(stdout, "Starting brewsystem %d `%s'\n", unit->number, unit->name);
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
378 syslog(LOG_NOTICE, "Starting brewsystem %d `%s'", unit->number, unit->name);
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
379 }
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
380
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
381 /*
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
382 * During automation there will be a state file:
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
383 * ~/.brewco/var/brewing.xml
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
384 * If this file is present, there has been a crash.
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
385 */
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
386 brew = (brew_session *)malloc(sizeof(brew_session));
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
387 if (rdsession(brew) == 0) {
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
388 } else {
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
389 /*
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
390 * No active brew session, make that permanent.
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
391 */
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
392 free(brew);
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
393 brew = NULL;
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
394 }
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
395
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
396 do {
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
397 if (my_shutdown) {
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
398 run = 0;
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
399 break;
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
400 }
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
401
453
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
402 /*
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
403 * 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
404 */
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
405 if (do_init) {
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
406 if (debug)
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
407 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
408 syslog(LOG_NOTICE, "Initialize brewsystem %d `%s'", unit->number, unit->name);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
409 /*
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
410 * Turn everything off
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
411 */
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
412 unit->hlt_heater.value = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
413 unit->mlt_heater.value = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
414 unit->mlt_pump.value = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
415 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
416 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
417 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
418
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
419 /*
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
420 * Initialize PID's
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
421 */
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
422 hltInput = hltSetpoint = mltInput = mltSetpoint = 20.0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
423 hltOutput = mltOutput = 0;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
424 PID_init(unit->PID_hlt, &hltInput, &hltOutput, &hltSetpoint, unit->PID_hlt->dispKd, unit->PID_hlt->dispKi, unit->PID_hlt->dispKd, unit->PID_hlt->Direction);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
425 PID_setOutputLimits(unit->PID_hlt, 0, 5000);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
426 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
427 PID_init(unit->PID_mlt, &mltInput, &mltOutput, &mltSetpoint, unit->PID_mlt->dispKd, unit->PID_mlt->dispKi, unit->PID_mlt->dispKd, unit->PID_mlt->Direction);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
428 PID_setOutputLimits(unit->PID_mlt, 0, 5000);
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
429 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
430
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
431 prompt(0, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
432 prompt(101, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
433 prompt(401, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
434 manual = MANUAL_NONE;
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
435
453
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
436 do_init = FALSE;
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
437 }
76418c89b480 Moved manual menu to it's own function.
Michiel Broek <mbroek@mbse.eu>
parents: 452
diff changeset
438
451
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
439 /* run_pause code here */
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
440
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
441 /*
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
442 * 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
443 * the scheduling by themselves.
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
444 */
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
445 rc = PID_compute(unit->PID_hlt);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
446 // if (seconds < 3)
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
447 // fprintf(stdout, "hlt rc=%d");
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
448 rc = PID_compute(unit->PID_mlt);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
449 // if (seconds < 3)
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
450 // fprintf(stdout, " mlt rc=%d\n");
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
451
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
452 now = time(NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
453 if (now != last) {
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
454 /*
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
455 * Each second
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
456 */
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
457 last = now;
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
458 seconds++;
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
459 if (seconds > 59) {
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
460 seconds = 0;
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
461 minutes++;
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
462 }
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
463
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
464 //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
465
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
466 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
467 if (rc == DEVPRESENT_YES) {
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
468 hltInput = temp / 1000.0;
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
469 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
470 } 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
471 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
472 } else {
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
473 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
474 }
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
475 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
476 if (rc == DEVPRESENT_YES) {
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
477 mltInput = temp / 1000.0;
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
478 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
479 } 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
480 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
481 } else {
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
482 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
483 }
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
484
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
485 if (debug && ((seconds % 10) == 1)) {
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
486 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
487 mltInput, mltOutput, mltSetpoint, hltInput, hltOutput, hltSetpoint);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
488 }
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
489
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
490 }
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
491
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
492 if (brew) {
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
493 /*
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
494 * Automate mode
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
495 */
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
496
451
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
497 } else if (manual != MANUAL_NONE) {
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
498 /*
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
499 * Manual mode
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
500 */
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
501 manual_menu(unit, hltInput, mltInput);
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
502 if (manual == MANUAL_NONE) {
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
503 /*
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
504 * Rewrite the display
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
505 */
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
506 prompt(0, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
507 prompt(101, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
508 prompt(401, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
509 }
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
510 } else {
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
511 /*
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
512 * Not running.
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
513 */
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
514 tempstatus(hltInput, mltInput);
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
515 key = keycheck();
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
516 if (key == KEY_ENTER) {
442
1193bd7d460f Split some sources
Michiel Broek <mbroek@mbse.eu>
parents: 441
diff changeset
517 setup();
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
518 prompt(0, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
519 prompt(101, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
520 prompt(401, NULL);
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
521 } else if (key == KEY_DOWN) {
451
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
522 manual = MANUAL_SELHLT;
2247970de278 Manual mode added.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
523 }
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
524 }
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
525
454
78242696c15a Beginning of the main program loop
Michiel Broek <mbroek@mbse.eu>
parents: 453
diff changeset
526 usleep(5000); /* 5 mSec */
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
527
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
528 } while (run);
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
529
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
530 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
531 if (debug)
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
532 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
533
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
534 prompt(0, NULL);
6b80a37fdf8d Added programming display CGRAM. Added display of characters from CGRAM. Changed prompts to allow free prompt strings. More code for the brewsystem unit editor.
Michiel Broek <mbroek@mbse.eu>
parents: 442
diff changeset
535 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
536 prompt(302, NULL);
440
8df3252b688f Added prompts for the LCD. Basic processing loop written.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
537
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
538 /*
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
539 * Stop units processing in a neat way
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
540 */
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
541 for (unit = Config.units; unit; unit = unit->next) {
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
542
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
543 }
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
544
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
545 /*
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
546 * Give threads time to cleanup
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
547 */
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
548 usleep(1500000);
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
549
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
550 prompt(0, NULL);
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
551 // stopLCD();
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
552 if (sock != -1) {
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
553 if (shutdown(sock, SHUT_RDWR)) {
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
554 syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno));
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
555 }
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
556 sock = -1;
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
557 }
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
558 wrrecipes();
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
559 wrconfig();
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
560
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
561 // ulockprog((char *)"brewco");
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
562 return 0;
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
563 }
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
564
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
565
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
566
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
567 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
568 {
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 int 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
570 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
571
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 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
573 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
574 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
575 {"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
576 {"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
577 {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
578 };
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 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
581 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
582 break;
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 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
585 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
586 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
587 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
588 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
589 }
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 }
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
591
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 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
593 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
594 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
595 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
596
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
597 /*
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
598 * 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
599 */
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
600 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
601 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
602 } 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
603 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
604 }
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
605 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
606 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
607 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
608 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
609 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
610 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
611
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
612 fprintf(stdout, "home: %s etc=%s var=%s\n", homepath, etcpath, varpath);
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
613 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
614 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
615 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
616 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
617 }
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
618 if (debug)
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 440
diff changeset
619 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
620
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
621 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
622 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
623 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
624 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
625 }
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
626 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
627 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
628
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
629 /*
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 * 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
631 * 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
632 * 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
633 */
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 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
635 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
636 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
637 }
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 #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
640 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
641 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
642 #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
643
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
644 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
645 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
646 return 1;
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
647 }
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
648
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
649 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
650
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 syslog(LOG_NOTICE, "Finished, rc=%d", rc);
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
652 if (debug)
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 419
diff changeset
653 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
654 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
655 }
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657

mercurial