brewco/brewco.h

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 463
a1da58215b65
child 469
d26def846029
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 #ifndef _BREWCO_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
2 #define _BREWCO_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
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 #define TRUE 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
5 #define FALSE 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
6
cdf68044adaf Added a new brewpanel program that runs on an SDL/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 #include "../config.h"
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
8 #include "pid.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
9
cdf68044adaf Added a new brewpanel program that runs on an SDL/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 #include <stdlib.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
11 #include <stdio.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
12 #include <stdint.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
13 #include <stdarg.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
14 #include <string.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
15 #include <ctype.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
16 #include <sys/types.h>
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
17 #include <sys/socket.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
18 #include <sys/stat.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
19 #include <sys/time.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
20 #include <time.h>
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: 463
diff changeset
21 #include <utime.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
22 #include <fcntl.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
23 #include <syslog.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
24 #include <unistd.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
25 #include <errno.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
26 #include <signal.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
27 #include <getopt.h>
410
e3f8a51b566a Fixed compiling on systems without SDL libraries, and they don't need tha brewpanel program.
Michiel Broek <mbroek@mbse.eu>
parents: 409
diff changeset
28 #include <limits.h>
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
29 #include <sys/socket.h>
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
30 #include <arpa/inet.h>
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
31 #include <netdb.h>
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
32 #include <poll.h>
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
33 #include <dirent.h>
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
34 #include <uuid/uuid.h>
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
35 #include <math.h>
447
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 445
diff changeset
36 #include <zlib.h>
b48368855ec4 Read/Write PID parameters from configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 445
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 #ifndef 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
40 #include <pthread.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
41 #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
42 #include <libxml/xmlmemory.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
43 #include <libxml/parser.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
44 #include <libxml/encoding.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
45 #include <libxml/xmlwriter.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
46
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 #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
48 /* wiringPi */
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 #include <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
50 #include <pcf8574.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
51 #include <lcd.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
52
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 /*
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 * Thread locks
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 */
cdf68044adaf Added a new brewpanel program that runs on an SDL/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 #define LOCK_DEVICES 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
57 #define LOCK_LCD 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
58 #define LOCK_MENU 2
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 #define LOCK_SPARE2 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
60
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 #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
63
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 /*
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 * 1-Wire devices
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 */
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 #define W1_FAMILY_DEFAULT 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
68 #define W1_FAMILY_SMEM_01 0x01
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 #define W1_FAMILY_SMEM_81 0x81
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 #define W1_THERM_DS18S20 0x10
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 #define W1_FAMILY_DS28E04 0x1C
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 #define W1_COUNTER_DS2423 0x1D
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 #define W1_THERM_DS1822 0x22
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 #define W1_EEPROM_DS2433 0x23
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 #define W1_THERM_DS18B20 0x28
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 #define W1_FAMILY_DS2408 0x29
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 #define W1_EEPROM_DS2431 0x2D
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 #define W1_FAMILY_DS2760 0x30
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 #define W1_FAMILY_DS2780 0x32
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 #define W1_FAMILY_DS2413 0x3A
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 #define W1_THERM_DS1825 0x3B
cdf68044adaf Added a new brewpanel program that runs on an SDL/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 #define W1_FAMILY_DS2781 0x3D
cdf68044adaf Added a new brewpanel program that runs on an SDL/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 #define W1_THERM_DS28EA00 0x42
cdf68044adaf Added a new brewpanel program that runs on an SDL/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 #define MBSE_SS(x) (x)?(x):"(null)"
cdf68044adaf Added a new brewpanel program that runs on an SDL/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
cdf68044adaf Added a new brewpanel program that runs on an SDL/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
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: 441
diff changeset
89
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: 441
diff changeset
90
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
91 /*
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
92 * Sensor strcuture
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
93 */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
94 typedef struct _sensor_var {
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
95 char *uuid; /* sensor uuid */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
96 int state; /* sensor state */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
97 int value; /* sensor value */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
98 } sensor_var;
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
99
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
100
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
101
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
102 /*
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
103 * Switch structure
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
104 */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
105 typedef struct _switch_var {
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
106 char *uuid; /* switch uuid */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
107 int value; /* switch value (0..100) */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
108 int delay; /* switch delay */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
109 } switch_var;
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
110
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
111
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
112
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
113 /*
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
114 * Brewing units. The sensors of the units are connected via the 1-wire bus.
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
115 * The heaters, pumps (or mixer) are connected on the Pi GPIO. The hardware
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
116 * is configured in the devices lists.
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
117 */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
118 typedef struct _units_list {
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
119 struct _units_list *next;
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
120 int version; /* Record version */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
121 char *uuid; /* uuid code */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
122 char *name; /* Unit name */
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
123 int number; /* Unit number */
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
124 int active; /* 0/1 active unit */
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
125 sensor_var hlt_sensor; /* HLT sensor */
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
126 switch_var hlt_heater; /* HLT heater */
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
127 int hlt_heater_mltfirst; /* HLT heater MLT high priority */
449
1277fb94999f Added selecting sensors.
Michiel Broek <mbroek@mbse.eu>
parents: 447
diff changeset
128 sensor_var mlt_sensor; /* MLT sensor */
450
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
129 switch_var mlt_heater; /* MLT heater */
8fe99759c27f Added selecting output relays.
Michiel Broek <mbroek@mbse.eu>
parents: 449
diff changeset
130 switch_var mlt_pump; /* MLT pump */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
131 int pump_cycle; /* 5..15 minutes */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
132 int pump_rest; /* 1..5 minutes */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
133 int pump_premash; /* 0/1 */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
134 int pump_onmash; /* 0/1 */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
135 int pump_mashout; /* 0/1 */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
136 int pump_onboil; /* 0/1 pump during boiling */
445
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
137 float pump_stop; /* 80..105 C */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
138 int skip_add; /* 0/1 skip Add phase */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
139 int skip_remove; /* 0/1 skip Remove phase */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
140 int skip_iodine; /* 0/1 skip Iodine test */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
141 int iodine_time; /* 0..90 minutes */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
142 int whirlpool; /* off/cold/hot */
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
143 pid_var *PID_hlt; /* HLT PID */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
144 pid_var *PID_mlt; /* MLT PID */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
145 } units_list;
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
146
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
147
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
148
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
149 /*
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
150 * External devices like sensors, relays, SSR.
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
151 */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
152 typedef struct _dev_list {
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
153 struct _dev_list *next;
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
154 int version; /* Version 1 */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
155 char *uuid; /* UUID of this device */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
156 int type; /* Device type */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
157 int direction; /* Device direction */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
158 int value; /* Device value */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
159 int offset; /* Device offset value */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
160 int present; /* Device present */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
161 char *address; /* Device address */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
162 int subdevice; /* Device sub address */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
163 int gpiopin; /* Device GPIO pin or -1 */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
164 char *description; /* Device description */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
165 int inuse; /* In use counter */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
166 char *comment; /* What we think it is */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
167 time_t timestamp; /* Last updated */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
168 } devices_list;
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
169
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
170
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
171 #define DEVTYPE_NA 0 /* Unknown device type */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
172 #define DEVTYPE_W1 1 /* 1-Wire bus */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
173 #define DEVTYPE_GPIO 2 /* GPIO I/O device */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
174 #define DEVTYPE_I2C 3 /* I2C bus device */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
175 #define DEVTYPE_SPI 4 /* SPI bus device */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
176 #ifdef USE_SIMULATOR
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
177 #define DEVTYPE_SIM 5 /* Simulated device */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
178 #endif
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
179
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
180 #define DEVPRESENT_UNDEF 0 /* Precence not testable */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
181 #define DEVPRESENT_NO 1 /* Device is missing */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
182 #define DEVPRESENT_YES 2 /* Device is detected */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
183 #define DEVPRESENT_ERROR 3 /* Device is in error */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
184
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
185 #define DEVDIR_UNDEF 0 /* Undefined */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
186 #define DEVDIR_IN_BIN 1 /* Binary input */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
187 #define DEVDIR_OUT_BIN 2 /* Binary output */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
188 #define DEVDIR_IN_ANALOG 3 /* Temperature input etc. */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
189 #define DEVDIR_OUT_ANALOG 4 /* Analog steering */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
190 #define DEVDIR_OUT_PWM 5 /* PWM outout */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
191 #define DEVDIR_INTERN 6 /* Internal function */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
192
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
193
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
194
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
195 /*
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
196 * Recipes.
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
197 */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
198 typedef struct _mash_step {
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
199 char *name; /* Step name */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
200 int min; /* Minimum temperature */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
201 int max; /* Maximum temperature */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
202 int canskip; /* 0/1 can we skip this step */
445
3ec477cda546 Changed internal storage of temperatures to float. Added 2 prompts. Added editors for float and integer values. Added most of brewunit edit functions.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
203 float setpoint; /* Temperature setpoint */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
204 int skip; /* Skip this step */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
205 int duration; /* Step duration */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
206 } mash_step;
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
207
457
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
208 typedef struct _hop_stand {
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
209 char *name; /* Hop stand name */
457
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
210 int min; /* Minimum temperature */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
211 int max; /* Maximum temperature */
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
212 int hold; /* Hold temperature at */
457
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
213 float setpoint; /* Hold temperature setpoint */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
214 int skip; /* Skip this one */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
215 int duration; /* Hold time */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
216 } hop_stand;
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
217
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
218 typedef struct _hop_addition {
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
219 char *name; /* Hop name */
463
a1da58215b65 Completed the recipe editor.
Michiel Broek <mbroek@mbse.eu>
parents: 459
diff changeset
220 int skip; /* Skip addition */
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
221 int boiltime; /* -1=fwh, 0..boiltime */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
222 } hop_addition;
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
223
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
224 typedef struct _a_recipe {
459
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
225 struct _a_recipe *next;
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
226 char *uuid; /* Recipe uuid */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
227 char *code; /* Recipe code */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
228 char *name; /* Recipe name */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
229 int boiltime; /* 1..240 minutes */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
230 time_t starttime; /* Start time */
1f88be70f253 Added the beginning of the recipes editor. Added load and save of recipes file.
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
231 time_t endtime; /* Ending time */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
232 mash_step mash[8]; /* 8 mash steps */
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
233 hop_addition hops[10]; /* 10 hop additions */
457
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
234 hop_stand hopstand[3]; /* 3 hopstand slots */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
235 } a_recipe;
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
236
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
237
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
238
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
239
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
240 #ifdef USE_SIMULATOR
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
241
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
242 /*
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
243 * Simulate a HLT and MLT.
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
244 */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
245 typedef struct _simulator {
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
246 double room_temperature; /* Simulated envionment temp */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
247 double hlt_temperature; /* Simulated HLT temperature */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
248 double hlt_heater_temp; /* Maximum heater temp */
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
249 int hlt_heater_volume; /* Water volume */
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
250 int hlt_heater_power; /* Power of the heater */
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
251 int hlt_heater_state; /* Heater status */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
252 double mlt_temperature; /* Simulated MLT temperature */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
253 double mlt_heater_temp; /* Maximum heater temp */
455
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
254 int mlt_heater_volume; /* Water volume */
f84501d8dd87 Most parts of the simulator are working, needs some tuning.
Michiel Broek <mbroek@mbse.eu>
parents: 450
diff changeset
255 int mlt_heater_power; /* Power of the heater */
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
256 int mlt_heater_state; /* Heater status */
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
257 } simulator_var;
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
258
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
259 #endif
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
260
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
261
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
262
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
263 typedef struct _sys_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
264 char *name; /* Configuration name */
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
265 int my_port; /* my client/server port */
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
266 unsigned char tempFormat; /* Temperature format, C or F */
435
4b1ed6897d80 More configuration items added.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
267 sensor_var *roomtemp; /* Environment temperature */
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
268 int lcd_cols; /* LCD display columns */
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 int lcd_rows; /* LCD display rows */
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 int lcd_address; /* LCD display i2c address */
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
271 units_list *units; /* Brewing units */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
272 devices_list *devices; /* Sensors and switches */
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
273 #ifdef USE_SIMULATOR
438
7d1ec160d751 Added simulator configuration.
Michiel Broek <mbroek@mbse.eu>
parents: 435
diff changeset
274 simulator_var *simulator; /* Simulator */
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
275 #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
276 } sys_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
277
cdf68044adaf Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278
434
eb724767860d Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
279
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
280 /*
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
281 * Brewing state file ~/.brewco/var/brewing.xml
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
282 * If present a brew session is running
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
283 */
444
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
284 #define STEP_NA 0 /* Not in any step yet */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
285 #define STEP_BREWINIT 1 /* Initialize brew */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
286 #define STEP_WAITSTART 2 /* Wait for starttime */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
287 #define STEP_PREMASH 3 /* Pre-mash */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
288 #define STEP_MASHING 4 /* Mash steps */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
289 #define STEP_IODINE 5 /* Iodine test */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
290 #define STEP_MASHREMOVE 6 /* Remove mash */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
291 #define STEP_PREBOIL 7 /* Heating before boil */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
292 #define STEP_BOILING 8 /* Boil */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
293 #define STEP_BOILDONE 9 /* Boil done, hopstand */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
294 #define STEP_COOLING 10 /* Cooling */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
295 #define STEP_WHIRLPOOL 11 /* Whirlpool */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
296 #define STEP_CLEANUP 12 /* Cleanup */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
297 #define STEP_BREWDONE 13 /* Final step */
457
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
298 #define STEP_HOPSTAND1 14 /* Hopstand 88..100 */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
299 #define STEP_HOPSTAND2 15 /* Hopstand 71..77 */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
300 #define STEP_HOPSTAND3 16 /* Hopstand 60..66 */
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
301
457
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
302 #define MASH_NA 0 /* Not in any state yet */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
303 #define MASH_PROMPT 1 /* Prompt the user */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
304 #define MASH_HEATING 2 /* Heating phase */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
305 #define MASH_REST 3 /* Rest phase */
24a34b7a693d Updated configuration to allow hopstands.
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
306 #define MASH_DONE 4 /* This step is done */
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
307
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
308
444
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
309
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
310 typedef struct _brew_session {
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
311 char *uuid_recipe; /* Brewing this recipe */
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
312 char *uuid_unit; /* Brewing unit */
444
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
313 int brewstep; /* Main steps */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
314 int mashstep; /* Mash step */
eafb140a1ddd Better brew state field names.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
315 int timeout; /* Generic time downcouner */
441
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
316 int boiltimer; /* Boiling downcount */
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
317 time_t starttime; /* Start of brew */
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
318 time_t endtime; /* End of brew */
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
319 } brew_session;
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
320
bde74a8f2ad7 Added automate state file.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
321
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
322 #endif

mercurial