brewco/brewco.h

changeset 487
d5bc44183aa4
parent 486
5a237a99a793
child 488
bee1f70fb42b
--- a/brewco/brewco.h	Thu Feb 25 22:42:54 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,324 +0,0 @@
-#ifndef _BREWCO_H
-#define	_BREWCO_H
-
-#define TRUE 1
-#define FALSE 0
-
-#include "../config.h"
-#include "pid.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <time.h>
-#include <utime.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <errno.h>
-#include <signal.h>
-#include <getopt.h>
-#include <limits.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <poll.h>
-#include <dirent.h>
-#include <uuid/uuid.h>
-#include <math.h>
-#include <zlib.h>
-
-
-#ifndef HAVE_WIRINGPI_H
-#include <pthread.h>
-#endif
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-#include <libxml/encoding.h>
-#include <libxml/xmlwriter.h>
-
-#ifdef HAVE_WIRINGPI_H
-/* wiringPi */
-#include <wiringPi.h>
-#include <pcf8574.h>
-#include <lcd.h>
-
-/*
- * Thread locks
- */
-#define LOCK_DEVICES            0
-#define LOCK_LCD                1
-#define LOCK_MENU               2
-#define LOCK_SPARE2             3
-
-
-#endif
-
-/*
- * 1-Wire devices
- */
-#define W1_FAMILY_DEFAULT       0
-#define W1_FAMILY_SMEM_01       0x01
-#define W1_FAMILY_SMEM_81       0x81
-#define W1_THERM_DS18S20        0x10
-#define W1_FAMILY_DS28E04       0x1C
-#define W1_COUNTER_DS2423       0x1D
-#define W1_THERM_DS1822         0x22
-#define W1_EEPROM_DS2433        0x23
-#define W1_THERM_DS18B20        0x28
-#define W1_FAMILY_DS2408        0x29
-#define W1_EEPROM_DS2431        0x2D
-#define W1_FAMILY_DS2760        0x30
-#define W1_FAMILY_DS2780        0x32
-#define W1_FAMILY_DS2413        0x3A
-#define W1_THERM_DS1825         0x3B
-#define W1_FAMILY_DS2781        0x3D
-#define W1_THERM_DS28EA00       0x42
-
-
-#define MBSE_SS(x) (x)?(x):"(null)"
-
-
-
-
-/*
- * Sensor strcuture
- */
-typedef struct _sensor_var {
-    char		*uuid;			/* sensor uuid			*/
-    int			state;			/* sensor state			*/
-    int			value;			/* sensor value			*/
-} sensor_var;
-
-
-
-/*
- * Switch structure
- */
-typedef struct _switch_var {
-    char		*uuid;			/* switch uuid			*/
-    int			value;			/* switch value (0..100)	*/
-    int			delay;			/* switch delay			*/
-} switch_var;
-
-
-
-/*
- * Brewing units. The sensors of the units are connected via the 1-wire bus.
- * The heaters, pumps (or mixer) are connected on the Pi GPIO. The hardware
- * is configured in the devices lists.
- */
-typedef struct _units_list {
-    struct _units_list  *next;
-    int                 version;                /* Record version               */
-    char		*uuid;			/* uuid code			*/
-    char                *name;                  /* Unit name                    */
-    int			number;			/* Unit number			*/
-    int			active;			/* 0/1 active unit		*/
-    sensor_var		hlt_sensor;		/* HLT sensor			*/
-    switch_var		hlt_heater;		/* HLT heater			*/
-    int			hlt_heater_mltfirst;	/* HLT heater MLT high priority	*/
-    sensor_var		mlt_sensor;		/* MLT sensor			*/
-    switch_var		mlt_heater;		/* MLT heater			*/
-    switch_var		mlt_pump;		/* MLT pump			*/
-    int			pump_cycle;		/* 5..15 minutes 		*/
-    int			pump_rest;		/* 1..5 minutes			*/
-    int			pump_premash;		/* 0/1				*/
-    int			pump_onmash;		/* 0/1				*/
-    int			pump_mashout;		/* 0/1				*/
-    int			pump_onboil;		/* 0/1 pump during boiling	*/
-    float		pump_stop;		/* 80..105 C			*/
-    int			skip_add;		/* 0/1 skip Add phase		*/
-    int			skip_remove;		/* 0/1 skip Remove phase	*/
-    int			skip_iodine;		/* 0/1 skip Iodine test		*/
-    int			iodine_time;		/* 0..90 minutes		*/
-    int			whirlpool;		/* off/cold/hot			*/
-    pid_var		*PID_hlt;		/* HLT PID			*/
-    pid_var		*PID_mlt;		/* MLT PID			*/
-} units_list;
-
-
-
-/*
- * External devices like sensors, relays, SSR.
- */
-typedef struct _dev_list {
-    struct _dev_list    *next;
-    int                 version;                /* Version 1                    */
-    char                *uuid;                  /* UUID of this device          */
-    int                 type;                   /* Device type                  */
-    int                 direction;              /* Device direction             */
-    int                 value;                  /* Device value                 */
-    int                 offset;                 /* Device offset value          */
-    int                 present;                /* Device present               */
-    char                *address;               /* Device address               */
-    int                 subdevice;              /* Device sub address           */
-    int                 gpiopin;                /* Device GPIO pin or -1        */
-    char                *description;           /* Device description           */
-    int                 inuse;                  /* In use counter               */
-    char                *comment;               /* What we think it is          */
-    time_t              timestamp;              /* Last updated                 */
-} devices_list;
-
-
-#define DEVTYPE_NA              0               /* Unknown device type          */
-#define DEVTYPE_W1              1               /* 1-Wire bus                   */
-#define DEVTYPE_GPIO            2               /* GPIO I/O device              */
-#define DEVTYPE_I2C             3               /* I2C bus device               */
-#define DEVTYPE_SPI             4               /* SPI bus device               */
-#ifdef USE_SIMULATOR
-#define DEVTYPE_SIM             5               /* Simulated device             */
-#endif
-
-#define DEVPRESENT_UNDEF        0               /* Precence not testable        */
-#define DEVPRESENT_NO           1               /* Device is missing            */
-#define DEVPRESENT_YES          2               /* Device is detected           */
-#define DEVPRESENT_ERROR        3               /* Device is in error           */
-
-#define DEVDIR_UNDEF            0               /* Undefined                    */
-#define DEVDIR_IN_BIN           1               /* Binary input                 */
-#define DEVDIR_OUT_BIN          2               /* Binary output                */
-#define DEVDIR_IN_ANALOG        3               /* Temperature input etc.       */
-#define DEVDIR_OUT_ANALOG       4               /* Analog steering              */
-#define DEVDIR_OUT_PWM          5               /* PWM outout                   */
-#define DEVDIR_INTERN           6               /* Internal function            */
-
-
-
-/*
- * Recipes.
- */
-typedef struct _mash_step {
-    char		*name;			/* Step name			*/
-    int			min;			/* Minimum temperature		*/
-    int			max;			/* Maximum temperature		*/
-    int			canskip;		/* 0/1 can we skip this step	*/
-    float		setpoint;		/* Temperature setpoint		*/
-    int			skip;			/* Skip this step		*/
-    int			duration;		/* Step duration		*/
-} mash_step;
-
-typedef struct _hop_stand {
-    char		*name;			/* Hop stand name		*/
-    int			min;			/* Minimum temperature		*/
-    int			max;			/* Maximum temperature		*/
-    int			hold;			/* Hold temperature at		*/
-    float		setpoint;		/* Hold temperature setpoint	*/
-    int			skip;			/* Skip this one		*/
-    int			duration;		/* Hold time			*/
-} hop_stand;
-
-typedef struct _hop_addition {
-    char		*name;			/* Hop name			*/
-    int			skip;			/* Skip addition		*/
-    int			boiltime;		/* -1=fwh, 0..boiltime		*/
-} hop_addition;
-
-typedef struct _a_recipe {
-    struct _a_recipe	*next;
-    char		*uuid;			/* Recipe uuid			*/
-    char		*code;			/* Recipe code			*/
-    char		*name;			/* Recipe name			*/
-    int                 boiltime;               /* 1..240 minutes               */
-    float		coolto;			/* Cooling target		*/
-    time_t              starttime;		/* Start time                   */
-    time_t              endtime;                /* Ending time                  */
-    mash_step		mash[8];		/* 8 mash steps			*/
-    hop_addition	hops[10];		/* 10 hop additions		*/
-    hop_stand		hopstand[3];		/* 3 hopstand slots		*/
-} a_recipe;
-
-
-
-
-#ifdef USE_SIMULATOR
-
-/*
- * Simulate a HLT and MLT.
- */
-typedef struct _simulator {
-    double		room_temperature;	/* Simulated envionment temp	*/
-    double		hlt_temperature;	/* Simulated HLT temperature	*/
-    double		hlt_heater_temp;	/* Maximum heater temp		*/
-    int			hlt_heater_volume;	/* Water volume			*/
-    int			hlt_heater_power;	/* Power of the heater		*/
-    int			hlt_heater_state;	/* Heater status		*/
-    double		mlt_temperature;	/* Simulated MLT temperature	*/
-    double		mlt_heater_temp;	/* Maximum heater temp		*/
-    int			mlt_heater_volume;	/* Water volume			*/
-    int			mlt_heater_power;	/* Power of the heater		*/
-    int			mlt_heater_state;	/* Heater status		*/
-} simulator_var;
-
-#endif
-
-
-
-typedef struct _sys_config {
-    char		*name;			/* Configuration name		*/
-    int			my_port;		/* my client/server port	*/
-    unsigned char	tempFormat;		/* Temperature format, C or F	*/
-    sensor_var		*roomtemp;		/* Environment temperature      */
-    int			lcd_cols;		/* LCD display columns		*/
-    int			lcd_rows;		/* LCD display rows		*/
-    int			lcd_address;		/* LCD display i2c address	*/
-    units_list		*units;			/* Brewing units		*/
-    devices_list	*devices;		/* Sensors and switches		*/
-#ifdef USE_SIMULATOR
-    simulator_var	*simulator;		/* Simulator			*/
-#endif
-} sys_config;
-
-
-
-/*
- * Brewing state file ~/.brewco/var/brewing.xml
- * If present a brew session is running
- */
-#define	STEP_NA		0			/* Not in any step yet		*/
-#define	STEP_BREWINIT	1			/* Initialize brew		*/
-#define	STEP_WATERCHECK	2			/* Water added?			*/
-#define	STEP_PUMPPRIME	3			/* Pump Prime			*/
-#define	STEP_WAITSTART	4			/* Wait for starttime		*/
-#define	STEP_PREMASH	5			/* Pre-mash			*/
-#define	STEP_MASHING	6			/* Mash steps			*/
-#define	STEP_MASHREMOVE	7			/* Remove mash			*/
-#define	STEP_PREBOIL	8			/* Heating before boil		*/
-#define	STEP_BOILING	9			/* Boil				*/
-#define	STEP_BOILDONE	10			/* Boil done, hopstand		*/
-#define	STEP_COOLING	11			/* Cooling			*/
-#define STEP_HOPSTAND	12			/* Hopstand			*/
-#define STEP_WHIRLPOOL	13			/* Final whirlpool		*/
-#define	STEP_CLEANUP	14			/* Cleanup			*/
-#define	STEP_BREWDONE	15			/* Final step			*/
-
-#define	MASH_NA		0			/* Not in any state yet		*/
-#define	MASH_PROMPT	1			/* Prompt for mash		*/
-#define	MASH_IODINE	2			/* Prompt for iodine test	*/
-#define	MASH_HEATING	3			/* Heating phase		*/
-#define	MASH_REST	4			/* Rest phase			*/
-#define	MASH_DONE	5			/* This step is done		*/
-
-
-
-typedef struct _brew_session {
-    char		*uuid_recipe;		/* Brewing this recipe		*/
-    char		*uuid_unit;		/* Brewing unit			*/
-    char		*name;			/* Session name			*/
-    int			brewstep;		/* Main steps			*/
-    int			mashstep;		/* Mash step			*/
-    int			timeout;		/* Generic time downcouner	*/
-    int			boiltimer;		/* Boiling downcount		*/
-    time_t		starttime;		/* Start of brew		*/
-    time_t		endtime;		/* End of brew			*/
-} brew_session;
-
-
-#endif

mercurial