src/global.h

Tue, 03 May 2022 20:05:04 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 03 May 2022 20:05:04 +0200
changeset 190
bb6c06910f0f
parent 182
545d31130844
child 191
7446ee2fb427
permissions
-rw-r--r--

Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.

#ifndef	_GLOBAL_H
#define	_GLOBAL_H

#include <QList>
#include <QString>
#include <QTranslator>
#include <QDate>


#define Ka1		0.0000004445
#define Ka2		0.0000000000468

#define MMCa		40.048
#define MMMg		24.305
#define MMNa		22.98976928
#define MMCl		35.453
#define MMSO4		96.0626
#define MMCO3		60.01684
#define MMHCO3		61.01684
#define MMCaSO4		172.171
#define MMCaCl2		147.015
#define MMCaCO3		100.087
#define MMMgCl2		95.211		/* Since 27-06-2021 */
#define MMMgSO4		246.475
#define MMNaHCO3	84.007
#define MMNa2CO3	105.996
#define MMNaCl		58.443
#define MMCaOH2		74.06268

#define SpecificHeatWater	1.0
#define SpecificHeatMalt	0.399	//cal/g.°C
#define SlakingHeat		10.318	//cal/g.°C
#define equip_tun_weight	2.0	// 2 Kg pot
#define equip_tun_specific_heat	0.110
#define MaltVolume		0.87	// l/kg 0.688 volgens internetbronnen, gemeten 0.874 l/kg, na enige tijd maischen 0,715 l/kg (A3 Otten).

struct Acid
{
    QString     name_en;
    QString	name_nl;
    double      pK1;
    double      pK2;
    double      pK3;
    double      MolWt;
    double      AcidSG;
    double      AcidPrc;
};

extern QList<Acid>	my_acids;

/*
 * Fermentables, Hops, Miscs, Yeasts and Mashs are stored in the
 * database in json arrays. These are the QList structures.
 */
struct Fermentables
{
    QString	f_name;
    QString	f_origin;
    QString	f_supplier;
    double	f_amount;
    double	f_cost;
    int		f_type;
    double	f_yield;
    double	f_color;
    double	f_coarse_fine_diff;
    double	f_moisture;
    double	f_diastatic_power;
    double	f_protein;
    double	f_dissolved_protein;
    double	f_max_in_batch;
    int		f_graintype;
    int		f_added;
    bool	f_recommend_mash;
    bool	f_add_after_boil;
    bool	f_adjust_to_total_100;
    double	f_percentage;
    double	f_di_ph;
    double	f_acid_to_ph_57;
    double	f_inventory;		///< In product, current inventory.
    bool	f_avail;		///< Product available in database.
};


struct Hops
{
    QString	h_name;
    QString	h_origin;
    double	h_amount;
    double	h_cost;
    int		h_type;
    int		h_form;
    int		h_useat;
    double	h_time;
    double	h_alpha;
    double	h_beta;
    double	h_hsi;
    double	h_humulene;
    double	h_caryophyllene;
    double	h_cohumulone;
    double	h_myrcene;
    double	h_total_oil;
    double	h_inventory;		///< In product, current inventory.
    bool	h_avail;		///< Product available in database.
};


struct Miscs
{
    QString	m_name;
    double	m_amount;
    int		m_type;
    int		m_use_use;
    double	m_time;
    bool	m_amount_is_weight;
    double	m_cost;
    double	m_inventory;		///< In product, current inventory.
    bool	m_avail;		///< Product available in database.
};


struct Yeasts
{
    QString	y_name;
    QString	y_laboratory;
    QString	y_product_id;
    double	y_amount;
    int		y_type;
    int		y_form;
    double	y_min_temperature;
    double	y_max_temperature;
    int		y_flocculation;
    double	y_attenuation;
    double	y_cells;
    double	y_tolerance;
    int		y_use;
    bool	y_sta1;
    bool	y_bacteria;
    bool	y_harvest_top;
    int		y_harvest_time;
    double	y_pitch_temperature;
    bool	y_pofpos;
    int		y_zymocide;
    int		y_gr_hl_lo;
    double	y_sg_lo;
    int		y_gr_hl_hi;
    double	y_sg_hi;
    double	y_cost;
    double	y_inventory;		///< In product, current inventory.
    bool	y_avail;		///< Product available in database.
};


struct Mashs
{
    QString	step_name;
    int		step_type;
    double	step_volume;		///< The water volume upto this step.
    double	step_infuse_amount;	///< Infuse/decoction volume this step.
    double	step_infuse_temp;	///< Infuse/decoction temperature.
    double	step_temp;		///< Start tmperature this step.
    double	step_time;		///< Step rest time.
    double	ramp_time;		///< Estimated ramp time to this step.
    double	end_temp;		///< End temperature this step.
    double	step_wg_ratio;		///< Current water/grain ratio.
    double	step_ph;		///< In product, measured pH.
    double	step_sg;		///< In product, measured SG.
};


/*
 * The main recipe record stored in the database.
 */
struct Recipe
{
    int		record;
    QString	uuid;
    bool	locked;
    QString	st_name;
    QString	st_letter;
    QString	st_guide;
    QString	st_category;
    int		st_category_number;
    int		st_type;
    double	st_og_min;
    double	st_og_max;
    double	st_fg_min;
    double	st_fg_max;
    double	st_ibu_min;
    double	st_ibu_max;
    double	st_color_min;
    double	st_color_max;
    double	st_carb_min;
    double	st_carb_max;
    double	st_abv_min;
    double	st_abv_max;

    QString	name;
    QString	notes;
    int		type;
    double	batch_size;
    double	boil_size;
    double	boil_time;
    double	efficiency;
    double	est_og;
    double	est_fg;
    double	est_abv;
    double	est_color;
    int		color_method;
    double	est_ibu;
    int		ibu_method;
    double	est_carb;

    double	sparge_temp;
    double	sparge_ph;
    double	sparge_volume;
    int		sparge_source;
    int		sparge_acid_type;
    double	sparge_acid_perc;
    double	sparge_acid_amount;
    double	mash_ph;
    QString	mash_name;
    bool	calc_acid;

    QString	w1_name;			///< Water source 1
    double	w1_amount;
    double	w1_calcium;
    double	w1_sulfate;
    double	w1_chloride;
    double	w1_sodium;
    double	w1_magnesium;
    double	w1_total_alkalinity;
    double	w1_ph;
    double	w1_cost;
    QString     w2_name;			///< Water source 2
    double      w2_amount;
    double      w2_calcium;
    double      w2_sulfate;
    double      w2_chloride;
    double      w2_sodium;
    double      w2_magnesium;
    double      w2_total_alkalinity;
    double      w2_ph;
    double      w2_cost;
    double      wg_amount;			///< Mixed water
    double      wg_calcium;
    double      wg_sulfate;
    double      wg_chloride;
    double      wg_sodium;
    double      wg_magnesium;
    double      wg_total_alkalinity;
    double      wg_ph;
    double      wb_calcium;			///< Treated water
    double      wb_sulfate;
    double      wb_chloride;
    double      wb_sodium;
    double      wb_magnesium;
    double      wb_total_alkalinity;
    double      wb_ph;
    int		wa_acid_name;
    double	wa_acid_perc;
    int		wa_base_name;

    QList<Fermentables>	fermentables;
    QList<Hops>		hops;
    QList<Miscs>	miscs;
    QList<Yeasts>	yeasts;
    QList<Mashs>	mashs;

    /*
     * These are not in the MySL database, but are global variables
     * that belong with the loaded recipe data and are present to
     * make things easier.
     */
    int		fermentables_row;	///< Current row, -1 is invalid.
    bool	fermentables_use100;	///< Use percentages instead of amount
    int		hops_row;
    int		miscs_row;
    int		yeasts_row;
    int		mashs_row;
    double	mashs_kg;		///< Kg fermentables in the mash.
    int		mashs_time;		///< Total mash time.
    double	preboil_sg;
};


/*
 * The main product record stored in the database.
 */
struct Product
{
    int		record;
    QString	uuid;
    QString	name;
    QString	code;
    QDate	birth;
    int		stage;
    QString     notes;
    bool	log_brew;
    bool	log_fermentation;
    bool	log_ispindel;
    bool	log_co2pressure;
    int		inventory_reduced;
    bool	locked;

    QString	eq_name;
    QString	eq_notes;
    double	eq_boil_size;
    double	eq_batch_size;
    double	eq_tun_volume;
    double	eq_tun_weight;
    double	eq_tun_specific_heat;
    int		eq_tun_material;
    double	eq_tun_height;
    double	eq_top_up_water;
    double	eq_trub_chiller_loss;
    double	eq_evap_rate;
    double	eq_boil_time;
    bool	eq_calc_boil_volume;
    double	eq_top_up_kettle;
    double	eq_hop_utilization;
    double	eq_lauter_volume;
    double	eq_lauter_height;
    double	eq_lauter_deadspace;
    double	eq_kettle_volume;
    double	eq_kettle_height;
    double	eq_mash_volume;
    double	eq_mash_max;
    double	eq_efficiency;

    QDateTime	brew_date_start;
    double	brew_mash_ph;
    double	brew_mash_sg;
    double	brew_mash_efficiency;
    double	brew_sparge_temperature;
    double	brew_sparge_volume;
    double	brew_sparge_est;
    double	brew_sparge_ph;
    double	brew_preboil_volume;
    double	brew_preboil_sg;
    double	brew_preboil_ph;
    double	brew_preboil_efficiency;
    double	brew_aboil_volume;
    double	brew_aboil_sg;
    double	brew_aboil_ph;
    double	brew_aboil_efficiency;
    int		brew_cooling_method;
    double	brew_cooling_time;
    double	brew_cooling_to;
    double	brew_whirlpool9;
    double	brew_whirlpool7;
    double	brew_whirlpool6;
    double	brew_whirlpool2;
    double	brew_fermenter_volume;
    double	brew_fermenter_extrawater;
    double	brew_fermenter_tcloss;
    double	brew_aeration_time;
    double	brew_aeration_speed;
    int		brew_aeration_type;
    double	brew_fermenter_sg;
    double	brew_fermenter_ibu;
    double	brew_fermenter_color;
    QDateTime	brew_date_end;

    double	og;
    double	fg;
    double	primary_start_temp;
    double	primary_max_temp;
    double	primary_end_temp;
    double	primary_end_sg;
    QDate	primary_end_date;
    double	secondary_temp;
    double	secondary_end_sg;
    QDate	secondary_end_date;
    double	tertiary_temp;

    QDate	package_date;
    double	package_volume;
    double	package_infuse_amount;
    double	package_infuse_abv;
    QString	package_infuse_notes;
    double	package_abv;
    double	package_ph;
    double	bottle_amount;
    double	bottle_carbonation;
    int		bottle_priming_sugar;
    double	bottle_priming_amount;
    double	bottle_priming_water;
    double	bottle_carbonation_temp;
    double	keg_amount;
    double	keg_carbonation;
    int		keg_priming_sugar;
    double	keg_priming_amount;
    double	keg_priming_water;
    double	keg_carbonation_temp;
    bool	keg_forced_carb;
    double	keg_pressure;

    QString	taste_notes;
    double	taste_rate;
    QDate	taste_date;
    QString	taste_color;
    QString	taste_transparency;
    QString	taste_head;
    QString	taste_aroma;
    QString	taste_taste;
    QString	taste_mouthfeel;
    QString	taste_aftertaste;

    QString	st_name;
    QString	st_letter;
    QString	st_guide;
    QString	st_category;
    int		st_category_number;
    int		st_type;
    double	st_og_min;
    double	st_og_max;
    double	st_fg_min;
    double	st_fg_max;
    double	st_ibu_min;
    double	st_ibu_max;
    double	st_color_min;
    double	st_color_max;
    double	st_carb_min;
    double	st_carb_max;
    double	st_abv_min;
    double	st_abv_max;

    int		type;
    double	batch_size;
    double	boil_size;
    double	boil_time;
    double	efficiency;
    double	est_og;
    double	est_og3;
    double	est_fg;
    double	est_abv;
    double	est_color;
    int		color_method;
    double	est_ibu;
    int		ibu_method;
    double	est_carb;

    double	sparge_temp;
    double	sparge_ph;
    double	sparge_volume;
    int		sparge_source;
    int		sparge_acid_type;
    double	sparge_acid_perc;
    double	sparge_acid_amount;
    double	mash_ph;
    QString	mash_name;
    bool	calc_acid;

    QString	w1_name;			///< Water source 1
    double	w1_amount;
    double	w1_calcium;
    double	w1_sulfate;
    double	w1_chloride;
    double	w1_sodium;
    double	w1_magnesium;
    double	w1_total_alkalinity;
    double	w1_ph;
    double	w1_cost;
    QString     w2_name;			///< Water source 2
    double      w2_amount;
    double      w2_calcium;
    double      w2_sulfate;
    double      w2_chloride;
    double      w2_sodium;
    double      w2_magnesium;
    double      w2_total_alkalinity;
    double      w2_ph;
    double      w2_cost;
    double      wg_amount;			///< Mixed water
    double      wg_calcium;
    double      wg_sulfate;
    double      wg_chloride;
    double      wg_sodium;
    double      wg_magnesium;
    double      wg_total_alkalinity;
    double      wg_ph;
    double      wb_calcium;			///< Treated water
    double      wb_sulfate;
    double      wb_chloride;
    double      wb_sodium;
    double      wb_magnesium;
    double      wb_total_alkalinity;
    double      wb_ph;
    int		wa_acid_name;
    double	wa_acid_perc;
    int		wa_base_name;

    bool	starter_enable;
    int		starter_type;
    double	starter_sg;
    int		starter_viability;
    QDate	yeast_prod_date;
    double	yeast_pitchrate;
    int		prop1_type;
    double	prop1_volume;
    int         prop2_type;
    double      prop2_volume;
    int         prop3_type;
    double      prop3_volume;
    int         prop4_type;
    double      prop4_volume;

    int		divide_type;
    double	divide_size;
    double	divide_factor;
    int		divide_parts;
    int		divide_part;

    QList<Fermentables>	fermentables;
    QList<Hops>		hops;
    QList<Miscs>	miscs;
    QList<Yeasts>	yeasts;
    QList<Mashs>	mashs;

    /*
     * These are not in the MySL database, but are global variables
     * that belong with the loaded product data and are present to
     * make things easier.
     */
    int		fermentables_row;	///< Current row, -1 is invalid.
    bool	fermentables_use100;	///< Use percentages instead of amount
    bool	fermentables_ok;	///< Inventory check
    int		hops_row;
    bool	hops_ok;
    int		miscs_row;
    bool	miscs_ok;
    int		yeasts_row;
    bool	yeasts_ok;
    bool	waters_ok;
    int		mashs_row;
    double	mashs_kg;		///< Kg fermentables in the mash.
    int		mashs_time;		///< Total mash time.
    double	est_mash_sg;
    double	preboil_sg;
};


extern Recipe		*recipe;
extern Product		*product;

extern QString		my_brewery_name;
extern QByteArray	my_logoByteArray;
extern int		my_factor_mashhop;
extern int		my_factor_fwh;
extern int		my_factor_pellet;
extern int		my_factor_plug;
extern int		my_factor_wethop;
extern int		my_factor_cryohop;
extern int		my_ibu_method;
extern int		my_color_method;
extern double		my_brix_correction;
extern double		my_grain_absorbtion;
extern int		my_default_water;
extern QString		my_yeastlab;

enum ProdStages {
	PROD_STAGE_PLAN,
	PROD_STAGE_WAIT,
	PROD_STAGE_BREW,
	PROD_STAGE_PRIMARY,
	PROD_STAGE_SECONDARY,
	PROD_STAGE_TERTIARY,
	PROD_STAGE_PACKAGE,
	PROD_STAGE_CARBONATION,
	PROD_STAGE_MATURE,
	PROD_STAGE_TASTE,
	PROD_STAGE_READY,
	PROD_STAGE_CLOSED
};

extern const QStringList prod_stages;
extern const QStringList prod_split;
extern const QStringList recipe_types;
extern const QStringList style_types;

enum FermentableTypes {
	FERMENTABLE_TYPE_GRAIN,
	FERMENTABLE_TYPE_SUGAR,
	FERMENTABLE_TYPE_EXTRACT,
	FERMENTABLE_TYPE_DRY_EXTRACT,
	FERMENTABLE_TYPE_ADJUCT
};

extern const QStringList fermentable_types;

enum FermentableGraintypes {
	FERMENTABLE_GRAINTYPE_BASE,
	FERMENTABLE_GRAINTYPE_ROAST,
	FERMENTABLE_GRAINTYPE_CRYSTAL,
	FERMENTABLE_GRAINTYPE_KILNED,
	FERMENTABLE_GRAINTYPE_SOUR_MALT,
	FERMENTABLE_GRAINTYPE_SPECIAL,
	FERMENTABLE_GRAINTYPE_NO_MALT
};

extern const QStringList fermentable_graintypes;

enum FermentableAdded {
	FERMENTABLE_ADDED_MASH,
	FERMENTABLE_ADDED_BOIL,
	FERMENTABLE_ADDED_FERMENTATION,
	FERMENTABLE_ADDED_LAGERING,
	FERMENTABLE_ADDED_BOTTLE,
	FERMENTABLE_ADDED_KEGS
};

extern const QStringList fermentable_added;
extern const QStringList hop_types;
extern const QStringList hop_forms;
extern const QStringList hop_useat;
extern const QStringList misc_types;
extern const QStringList misc_uses;
extern const QStringList yeast_types;
extern const QStringList yeast_forms;
extern const QStringList yeast_use;
extern const QStringList starters;
extern const QStringList step_types;
extern const QStringList tun_materials;

#endif

mercurial