Wed, 25 Nov 2015 22:49:35 +0100
Brewco first phase development configuration structure.
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> |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/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 | #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
|
22 | #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
|
23 | #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
|
24 | #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
|
25 | #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
|
26 | #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
|
27 | #include <limits.h> |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
28 | #include <sys/socket.h> |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
29 | #include <arpa/inet.h> |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
30 | #include <netdb.h> |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
31 | #include <poll.h> |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
32 | #include <dirent.h> |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
33 | #include <uuid/uuid.h> |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
34 | #include <math.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
|
35 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | #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
|
37 | #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
|
38 | #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
|
39 | #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
|
40 | #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
|
41 | #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
|
42 | #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
|
43 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/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 | #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
|
45 | /* 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
|
46 | #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
|
47 | #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
|
48 | #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
|
49 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/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 | /* |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/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 | * 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
|
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 | #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
|
54 | #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
|
55 | #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
|
56 | #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
|
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 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/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 | #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
|
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 | * 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
|
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 | #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
|
65 | #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
|
66 | #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
|
67 | #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
|
68 | #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
|
69 | #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
|
70 | #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
|
71 | #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
|
72 | #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
|
73 | #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
|
74 | #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
|
75 | #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
|
76 | #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
|
77 | #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
|
78 | #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
|
79 | #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
|
80 | #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
|
81 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | #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
|
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 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
86 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
87 | /* |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
88 | * 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
|
89 | * 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
|
90 | * is configured in the devices lists. |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
91 | */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
92 | typedef struct _units_list { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
93 | struct _units_list *next; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
94 | int version; /* Record version */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
95 | char *uuid; /* uuid code */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
96 | char *name; /* Unit name */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
97 | char *hlt_sensor_address; /* HLT sensor address */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
98 | int hlt_sensor_state; /* HLT sensor state */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
99 | int hlt_sensor_value; /* HLT sensor value */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
100 | char *hlt_heater_address; /* HLT heater address */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
101 | int hlt_heater_state; /* HLT heater state 0..100 */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
102 | int hlt_heater_delay; /* HLT heater delay / 15 sec */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
103 | int hlt_heater_mltfirst; /* HLT heater MLT high priority */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
104 | char *mlt_sensor_address; /* MLT sensor address */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
105 | int mlt_sensor_state; /* MLT sensor state */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
106 | int mlt_sensor_value; /* MLT sensor value */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
107 | char *mlt_heater_address; /* MLT heater address */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
108 | int mlt_heater_state; /* MLT heater state 0..100 */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
109 | int mlt_heater_delay; /* MLT heater delay / 15 sec */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
110 | char *mlt_pump_address; /* MLT pump address */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
111 | int mlt_pump_state; /* MLT pump state 0..100 */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
112 | int mlt_pump_delay; /* MLT_pump_delay */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
113 | pid_var *PID_hlt; /* HLT PID */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
114 | pid_var *PID_mlt; /* MLT PID */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
115 | } units_list; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
116 | |
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 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
119 | /* |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
120 | * External devices like sensors, relays, SSR. |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
121 | */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
122 | typedef struct _dev_list { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
123 | struct _dev_list *next; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
124 | int version; /* Version 1 */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
125 | char *uuid; /* UUID of this device */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
126 | int type; /* Device type */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
127 | int direction; /* Device direction */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
128 | int value; /* Device value */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
129 | int offset; /* Device offset value */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
130 | int present; /* Device present */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
131 | char *address; /* Device address */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
132 | int subdevice; /* Device sub address */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
133 | int gpiopin; /* Device GPIO pin or -1 */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
134 | char *description; /* Device description */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
135 | int inuse; /* In use counter */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
136 | char *comment; /* What we think it is */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
137 | time_t timestamp; /* Last updated */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
138 | } devices_list; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
139 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
140 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
141 | #define DEVTYPE_NA 0 /* Unknown device type */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
142 | #define DEVTYPE_W1 1 /* 1-Wire bus */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
143 | #define DEVTYPE_GPIO 2 /* GPIO I/O device */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
144 | #define DEVTYPE_I2C 3 /* I2C bus device */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
145 | #define DEVTYPE_SPI 4 /* SPI bus device */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
146 | #ifdef USE_SIMULATOR |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
147 | #define DEVTYPE_SIM 5 /* Simulated device */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
148 | #endif |
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 | #define DEVPRESENT_UNDEF 0 /* Precence not testable */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
151 | #define DEVPRESENT_NO 1 /* Device is missing */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
152 | #define DEVPRESENT_YES 2 /* Device is detected */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
153 | #define DEVPRESENT_ERROR 3 /* Device is in error */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
154 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
155 | #define DEVDIR_UNDEF 0 /* Undefined */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
156 | #define DEVDIR_IN_BIN 1 /* Binary input */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
157 | #define DEVDIR_OUT_BIN 2 /* Binary output */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
158 | #define DEVDIR_IN_ANALOG 3 /* Temperature input etc. */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
159 | #define DEVDIR_OUT_ANALOG 4 /* Analog steering */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
160 | #define DEVDIR_OUT_PWM 5 /* PWM outout */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
161 | #define DEVDIR_INTERN 6 /* Internal function */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
162 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
163 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
164 | #ifdef USE_SIMULATOR |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
165 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
166 | /* |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
167 | * Simulate a HLT and MLT. |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
168 | */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
169 | typedef struct _simulator { |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
170 | struct _simulator *next; |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
171 | int version; /* Version of this record */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
172 | char *uuid; /* Simulator uuid */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
173 | char *name; /* Simulator name */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
174 | double room_temperature; /* Simulated envionment temp */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
175 | double hlt_temperature; /* Simulated HLT temperature */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
176 | double hlt_heater_temp; /* Maximum heater temp */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
177 | int hlt_heater_time; /* Time to reach temperature */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
178 | float hlt_heater_size; /* Size of the heater */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
179 | int hlt_heater_state; /* Heater status */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
180 | double mlt_temperature; /* Simulated MLT temperature */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
181 | double mlt_heater_temp; /* Maximum heater temp */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
182 | int mlt_heater_time; /* Time to reach temperature */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
183 | float mlt_heater_size; /* Size of the heater */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
184 | int mlt_heater_state; /* Heater status */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
185 | /* |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
186 | * Status values, maintained by the simulator but stored |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
187 | * here so they don't get lost over program restarts. |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
188 | */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
189 | double s_hlt_temp; /* Temp HLT */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
190 | double s_mlt_temp; /* Temp MLT */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
191 | } simulator_list; |
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 | #endif |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
194 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
195 | |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
196 | |
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
|
197 | 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
|
198 | char *name; /* Configuration name */ |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
199 | 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
|
200 | unsigned char tempFormat; /* Temperature format, C or F */ |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
201 | char *temp_address; /* Environment temperature */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
202 | int temp_state; /* 0=ok, 1=missing, 2=error */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
203 | int temp_value; /* Air temperature in C * 1000 */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
204 | char *hum_address; /* Environment huminity */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
205 | int hum_state; /* 0=ok, 1=missing, 2=error */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
206 | int hum_value; /* Huminity in % * 1000 */ |
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
|
207 | 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
|
208 | 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
|
209 | int lcd_address; /* LCD display i2c address */ |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
210 | units_list *units; /* Brewing units */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
211 | devices_list *devices; /* Sensors and switches */ |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
212 | #ifdef USE_SIMULATOR |
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
213 | simulator_list *simulators; /* Simulators */ |
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
|
214 | #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
|
215 | } 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
|
216 | |
cdf68044adaf
Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | |
434
eb724767860d
Brewco first phase development configuration structure.
Michiel Broek <mbroek@mbse.eu>
parents:
410
diff
changeset
|
218 | |
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
|
219 | #endif |