thermferm/thermferm.h

Fri, 04 Jul 2014 20:00:19 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 04 Jul 2014 20:00:19 +0200
changeset 92
116226a8c70a
parent 91
901ca9858a7a
child 93
b759f814469d
permissions
-rw-r--r--

Added profiles configuration

51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1 #ifndef _MBSELIB_H
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
2 #define _MBSELIB_H
26
9322c619c525 Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3
9322c619c525 Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4
9322c619c525 Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 #define TRUE 1
9322c619c525 Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 #define FALSE 0
9322c619c525 Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
8 #include "../config.h"
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
9
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
10 #include <stdlib.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
11 #include <stdio.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
12 #include <stdint.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
13 #include <stdarg.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
14 #include <string.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
15 #include <ctype.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
16 #include <sys/types.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
17 #include <sys/stat.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
18 #include <sys/time.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
19 #include <time.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
20 #include <fcntl.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
21 #include <syslog.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
22 #include <unistd.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
23 #include <errno.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
24 #include <signal.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
25 #include <getopt.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
26 #include <limits.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
27 #include <sys/socket.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
28 #include <arpa/inet.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
29 #include <netdb.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
30 #include <poll.h>
84
ef4c0032b51f Can list the 1-wire bus
Michiel Broek <mbroek@mbse.eu>
parents: 83
diff changeset
31 #include <dirent.h>
79
eb9dd60aa791 Added uuid library
Michiel Broek <mbroek@mbse.eu>
parents: 78
diff changeset
32 #include <uuid/uuid.h>
74
879bd09e2b96 Reinstalled threads
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
33 #ifndef HAVE_WIRINGPI_H
879bd09e2b96 Reinstalled threads
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
34 #include <pthread.h>
879bd09e2b96 Reinstalled threads
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
35 #endif
73
4a28de5b9b47 Changed include files
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
36 #include <libxml/xmlmemory.h>
4a28de5b9b47 Changed include files
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
37 #include <libxml/parser.h>
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
38 #include <libxml/encoding.h>
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
39 #include <libxml/xmlwriter.h>
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
40
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
41 #ifdef HAVE_WIRINGPI_H
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
42 /* wiringPi */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
43 #include <wiringPi.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
44 #include <pcf8574.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
45 #include <lcd.h>
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
46
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
47 #endif
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
48
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
49 #define TRUE 1
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
50 #define FALSE 0
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
52 #define MBSE_SS(x) (x)?(x):"(null)"
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
53
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
54
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
55 /*
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
56 * Fermenter units. These units are connected via the 1-wire bus.
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
57 * Each unit can have:
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
58 * a DS18B20 sensor to measure the air temperature inside the unit.
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
59 * a DS18B20 sensor to measure the beer temperature.
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
60 * a DS2413 to turn the cooler and heater on or off.
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
61 * a DS2413 to switch the fan and sense the door.
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
62 */
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
63 typedef struct _units_list {
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
64 struct _units_list *next;
89
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
65 int version; /* Record version */
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
66 char *uuid; /* uid code */
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
67 char *name; /* friendly name */
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
68 float volume; /* Volume of this unit */
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
69 char *air_address; /* DS18B20 address */
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
70 float air_temp; /* Air temperature */
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
71 char *beer_address; /* DS18B20 address */
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
72 float beer_temp; /* Beer temperature */
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
73 char *io1_address; /* DS2413 address */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
74 char *io2_address; /* DS2413 address */
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
75 int heater_available; /* Heater available */
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
76 int heater_state; /* Heater status */
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
77 int cooler_available; /* Cooler available */
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
78 int cooler_state; /* Cooler status */
75
4b976601737d Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
79 int fan_available; /* Fan available */
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
80 int fan_state; /* Fan status */
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
81 int door_state; /* Door and light status */
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
82 int mode; /* Unit mode */
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
83 float beer_set; /* Beer temperature setting */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
84 float fridge_set; /* Fridge temperature setting */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
85 float temp_set_min; /* Minimum temperature */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
86 float temp_set_max; /* Maximum temperature */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
87 float idle_rangeL; /* Idle temperature low */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
88 float idle_rangeH; /* Idle range high */
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
89 char *profile; /* Active profile */
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
90 time_t prof_started; /* Profile start time */
89
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
91 int prof_state; /* Profile OFF|PAUSE|RUN|DONE */
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
92 } units_list;
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
93
76
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
94 #define UNITMODE_OFF 0 /* Unit turned off */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
95 #define UNITMODE_NONE 1 /* Unit on but does nothing */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
96 #define UNITMODE_FRIDGE 2 /* Unit acts as a fridge */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
97 #define UNITMODE_BEER 3 /* Unit acts as beer cooler */
d2c7b32f27d6 Can now write the fermenter units configurations
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
98 #define UNITMODE_PROFILE 4 /* Unit runs in profile mode */
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
99
89
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
100 #define UNITIO1_HEATER 0x01 /* Heater bit */
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
101 #define UNITIO1_COOLER 0x02 /* Cooler bit */
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
102 #define UNITIO2_FAN 0x01 /* Fan bit */
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
103 #define UNITIO2_DOOR 0x02 /* Door status */
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
104
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
105
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
106
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
107 /*
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
108 * Fermenting steps
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
109 */
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
110 typedef struct _prof_step {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
111 struct _prof_step *next;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
112 int version; /* Version 1 */
92
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
113 int steptime; /* Step time to target in hours */
116226a8c70a Added profiles configuration
Michiel Broek <mbroek@mbse.eu>
parents: 91
diff changeset
114 int resttime; /* Rest time on target in hours */
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
115 float target; /* Target temperature */
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
116 } prof_step;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
117
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
118 /*
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
119 * Fermenting profiles
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
120 */
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
121 typedef struct _prof_list {
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
122 struct _prof_list *next;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
123 int version; /* Version 1 */
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
124 char *uuid; /* Profile uuid */
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
125 char *name; /* Profile name */
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
126 prof_step *steps; /* Profile steps */
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
127 } profiles_list;
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
128
89
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
129 #define PROFILE_OFF 0 /* Profile not active */
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
130 #define PROFILE_PAUSE 1 /* Profile pause */
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
131 #define PROFILE_RUN 2 /* Profile is running */
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
132 #define PROFILE_DONE 3 /* Profile is finished */
8bab04a663dd Added profile states
Michiel Broek <mbroek@mbse.eu>
parents: 86
diff changeset
133
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
134
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
135 typedef struct _w1_therm {
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
136 struct _w1_therm *next;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
137 char *master; /* Master for this device */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
138 int bus; /* Reserved for ds2482-800 */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
139 char *name; /* Name of this device */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
140 char *alias; /* Friendly name */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
141 int present; /* 1=present, 0=absent */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
142 int lastval; /* Last valid value */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
143 int update; /* Value updated */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
144 } w1_therm;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
145
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
146 typedef struct _sys_config {
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
147 char *name; /* Configuration name */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
148 int my_port; /* my client/server port */
77
143077e54255 Added old configuration to write xml config
Michiel Broek <mbroek@mbse.eu>
parents: 76
diff changeset
149 unsigned char tempFormat; /* Temperature format, C or F */
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
150 w1_therm *w1therms; /* 1-wire temp sensors */
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
151 #ifdef HAVE_WIRINGPI_H
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
152 int lcd_cols; /* LCD display columns */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
153 int lcd_rows; /* LCD display rows */
78
c49ab5179bf3 Added lcd i2c address to xml configuration
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
154 int lcd_address; /* LCD display i2c address */
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
155 #endif
71
a09c5cdc4022 Removed rc-switch
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
156 units_list *units; /* Fermenter units */
91
901ca9858a7a Added fermenting profiles to the configuration
Michiel Broek <mbroek@mbse.eu>
parents: 89
diff changeset
157 profiles_list *profiles; /* Ferment profiles */
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
158 /* ControlSettings: */
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
159 unsigned char cs_mode; /* mode */
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
160 float cs_beerSet; /* beer temperature */
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
161 float cs_fridgeSet; /* fridge temperature */
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
162 float cs_heatEstimator;
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
163 float cs_coolEstimator;
54
c06190a58f22 More configuration changes. Writing settings implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
164 /* ControlConstants */
c06190a58f22 More configuration changes. Writing settings implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
165 float cc_tempSetMin;
c06190a58f22 More configuration changes. Writing settings implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
166 float cc_tempSetMax;
c06190a58f22 More configuration changes. Writing settings implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
167 float cc_idleRangeH;
c06190a58f22 More configuration changes. Writing settings implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
168 float cc_idleRangeL;
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
169 } sys_config;
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
170
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
171
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
172 void killconfig(void);
86
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
173 int rdconfig(void);
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
174 int wrconfig(void);
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
175
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
176
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
177 /* lock.c */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
178 int lockprog(char *);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
179 void ulockprog(char *);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
180
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
181
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
182 /* xutil.c */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
183 char *xmalloc(size_t);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
184 char *xstrcpy(char *);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
185 char *xstrcat(char *, char *);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
186
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
187
86
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
188 /* futil.c */
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
189 int mkdirs(char *, mode_t);
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
190
3d7a241329e2 Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents: 84
diff changeset
191
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
192 #ifdef HAVE_WIRINGPI_H
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
193
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
194 /* lcd-pcf8574.c */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
195 // Defines for the pcf8574 Pi LCD interface board
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
196 #define AF_BASE 100
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
197
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
198 #define AF_RS (AF_BASE + 0)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
199 #define AF_RW (AF_BASE + 1)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
200 #define AF_E (AF_BASE + 2)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
201 #define AF_BACKLIGHT (AF_BASE + 3)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
202 #define AF_DB4 (AF_BASE + 4)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
203 #define AF_DB5 (AF_BASE + 5)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
204 #define AF_DB6 (AF_BASE + 6)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
205 #define AF_DB7 (AF_BASE + 7)
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
206
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
207 void setBacklight (int);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
208 int initLCD (int, int);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
209 void mb_lcdPutchar(const int, unsigned char);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
210 void mb_lcdPuts(const int, const char *);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
211 void mb_lcdClear(const int);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
212
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
213 #endif
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
214
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
215 /* logger.c */
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
216 void logger(char *, char *, char *);
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
217
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
218 #ifdef HAVE_WIRINGPI_H
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
219 PI_THREAD (my_sensors_loop);
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
220 #else
74
879bd09e2b96 Reinstalled threads
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
221 void *my_sensors_loop(void *);
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
222 #endif
53
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
223
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
224 /* server.c */
37623517e0ef Added writing configuration
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
225 void defaultControlSettings(void);
54
c06190a58f22 More configuration changes. Writing settings implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 53
diff changeset
226 void defaultControlConstants(void);
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
227 #ifdef HAVE_WIRINGPI_H
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
228 PI_THREAD (my_server_loop);
66
805f1d285acd Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
229 #else
74
879bd09e2b96 Reinstalled threads
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
230 void *my_server_loop(void *);
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
231 #endif
26
9322c619c525 Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232
46
000399c64d3f More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
233
26
9322c619c525 Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 #endif
51
a03b6dac5398 Removed library, bumped to version 0.0.7
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
235

mercurial