Commit 7f36a431 authored by Meade's avatar Meade

Added version 5.1.0. Made things more rusty, changed two images from svg to png, and code cleanup.

parent 5eaee199
......@@ -3,7 +3,7 @@ Version=1.0
Name=BrewStillery
Comment=BrewStillery is a brewer's, vintner's, and distiller's calculator. It has a multitude of great functions, such as calculating ABV, determining carbonation, and total sparge water needed.
Exec=/usr/bin/BrewStillery
Icon=/usr/share/BrewStillery/BrewStilleryIcon.svg
Icon=/usr/share/BrewStillery/BrewStilleryIcon.png
Terminal=false
Type=Application
Categories=GTK;Utility;Science;Calculator;
\ No newline at end of file
# Maintainer: Meade And Emily <thedarkula2049@gmail.com>
pkgname=brewstillery
pkgver=5.0.0
pkgver=5.1.0
pkgrel=1
pkgdesc="BrewStillery is a brewer's, vintner's, and distiller's calculator. It has a multitude of great functions, such as calculating ABV, determining carbonation, and total sparge water needed."
url="https://monkeylog.in"
......@@ -24,8 +24,8 @@ package() {
cd $srcdir/BrewStillery-$pkgver/Arch
install -Dm755 BrewStillery.desktop "$pkgdir/usr/share/applications/BrewStillery.desktop"
cd $srcdir/BrewStillery-$pkgver/media
install -Dm755 BrewStilleryIcon.svg "$pkgdir/usr/share/BrewStillery/BrewStilleryIcon.svg"
install -Dm755 BrewStilleryLogo.svg "$pkgdir/usr/share/BrewStillery/BrewStilleryLogo.svg"
install -Dm755 BrewStilleryIcon.png "$pkgdir/usr/share/BrewStillery/BrewStilleryIcon.png"
install -Dm755 BrewStilleryLogo.png "$pkgdir/usr/share/BrewStillery/BrewStilleryLogo.png"
cd $srcdir/BrewStillery-$pkgver/media/glassware
install -dm755 "$pkgdir/usr/share/BrewStillery/glassware/"
install -Dm755 *.png "$pkgdir/usr/share/BrewStillery/glassware/"
......
This diff is collapsed.
[package]
name = "BrewStillery"
version = "5.0.0"
version = "5.1.0"
authors = ["Meade <thedarkula2049@gmail.com>", "Emily <marleybrush5@gmail.com>"]
description = "BrewStillery is a brewer's, vintner's, and distiller's calculator. It has a multitude of great functions, such as calculating ABV, determining carbonation, and total sparge water needed."
# documentation to come
......@@ -19,7 +19,7 @@ maintenance = { status = "actively-developed" }
[dependencies]
gdk = "0.7.0"
gio = "0.3.0"
clippy = {version = "*", optional = true}
# clippy = {version = "*", optional = true}
[features]
default = []
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,8 +3,8 @@
cargo build --release &&
sudo install -Dm755 ../target/release/BrewStillery /usr/bin/BrewStillery &&
sudo install -Dm755 ../Arch/BrewStillery.desktop /usr/share/applications/BrewStillery.desktop &&
sudo install -Dm755 ../media/BrewStilleryIcon.svg /usr/share/BrewStillery/BrewStilleryIcon.svg &&
sudo install -Dm755 ../media/BrewStilleryLogo.svg /usr/share/BrewStillery/BrewStilleryLogo.svg &&
sudo install -Dm755 ../media/BrewStilleryIcon.png /usr/share/BrewStillery/BrewStilleryIcon.png &&
sudo install -Dm755 ../media/BrewStilleryLogo.png /usr/share/BrewStillery/BrewStilleryLogo.png &&
sudo install -Ddm755 /usr/share/BrewStillery/glassware &&
sudo install -Dm755 ../media/glassware/*.png /usr/share/BrewStillery/glassware/ &&
sudo install -Ddm755 /usr/share/BrewStillery/buttons &&
......
......@@ -9,31 +9,24 @@ pub fn champagneCarbonationPrep(champagneCarbonationBuilderClone: &gtk::Builder)
let champagneCarbonationOutput: gtk::Entry = champagneCarbonationBuilderClone.get_object("champagneCarbonationOutput").unwrap();
let champagneCarbonationSwitch: gtk::Switch = champagneCarbonationBuilderClone.get_object("champagneCarbonationSwitch").unwrap();
let imperialOrMetric = imperialOrMetricMatch(champagneCarbonationSwitch.get_active());
if champagneVolume == 0.0 {
champagneCarbonationOutput.set_text("Enter a number");
} else if champagneVolume <= 0.0 {
champagneCarbonationOutput.set_text("Enter a positive number");
} else {
onChampagneActivate(champagneVolume, champagneCarbonationBuilderClone);
}
}
fn onChampagneActivate(champagneVolume: f64, champagneCarbonationBuilderClone: &gtk::Builder) {
let champagneCarbonationSwitch: gtk::Switch = champagneCarbonationBuilderClone.get_object("champagneCarbonationSwitch").unwrap();
if champagneCarbonationSwitch.get_active() == true {
let imperialOrMetric = "metric";
champagneCarbonationMaths(champagneVolume, imperialOrMetric, champagneCarbonationBuilderClone);
} else if champagneCarbonationSwitch.get_active() == false {
let imperialOrMetric = "imperial";
champagneCarbonationMaths(champagneVolume, imperialOrMetric, champagneCarbonationBuilderClone);
}
}
fn champagneCarbonationMaths(champagneVolume: f64, imperialOrMetric: &str, champagneCarbonationBuilderClone: &gtk::Builder) {
fn champagneCarbonationMaths(champagneVolume: f64, imperialOrMetric: imperialOrMetric, champagneCarbonationBuilderClone: &gtk::Builder) {
let champagneCarbonationOutput: gtk::Entry = champagneCarbonationBuilderClone.get_object("champagneCarbonationOutput").unwrap();
if imperialOrMetric == "imperial" {
if imperialOrMetric == imperialOrMetric::imperial {
let totalSugar = champagneVolume * 0.2;
if totalSugar == 1.0 {
let sugar = format!("{:.0} pound", totalSugar);
......@@ -42,7 +35,7 @@ fn champagneCarbonationMaths(champagneVolume: f64, imperialOrMetric: &str, champ
let sugar = format!("{:.2} pounds", totalSugar);
champagneCarbonationOutput.set_text(&sugar);
}
} else if imperialOrMetric == "metric" {
} else if imperialOrMetric == imperialOrMetric::metric {
let totalSugar = (champagneVolume * 23.986897025) / 1000.0;
if totalSugar == 1.0 {
let sugar = format!("{:.0} kilo", totalSugar);
......
......@@ -6,6 +6,12 @@ pub const finalGravityIdeal: f64 = 1.01627;
pub const finalBrixIdeal: f64 = 4.1480675;
// when finalBrix is unknown, this constant is ideal. it is the average of all BJCP styles
#[derive(PartialEq)]
pub enum imperialOrMetric {
imperial,
metric,
}
pub fn brixToGravity(brix: f64) -> f64 {
(brix / (258.6 - ((brix / 258.2) * 227.1))) + 1.0
}
......@@ -113,4 +119,11 @@ pub fn glassSize(glassType: &str) -> f64 {
"Tulip Half Pint" => 7.2,
_ => 9.8,
}
}
pub fn imperialOrMetricMatch(onOrOff: bool) -> imperialOrMetric {
match onOrOff {
false => imperialOrMetric::imperial,
true => imperialOrMetric::metric,
}
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ struct grainABVData <'a> {
seventhGrainAmount: f64,
seventhGrainInfo: (f64, f64),
glassSize: f64,
imperialOrMetric: &'a str,
imperialOrMetric: imperialOrMetric,
grainABVBuilder: &'a gtk::Builder,
}
......@@ -75,6 +75,8 @@ pub fn grainABVPrep(grainABVBuilderClone: &gtk::Builder, allOverlays: &colourOve
let grainABVGlassSizeInput: gtk::ComboBoxText = grainABVBuilderClone.get_object("grainABVGlassSizeInput").unwrap();
let grainABVGlassSizeInputBuffer = grainABVGlassSizeInput.get_active_id().unwrap();
let grainABVSwitch: gtk::Switch = grainABVBuilderClone.get_object("grainABVSwitch").unwrap();
let allInputs = grainABVData {
wortAmount: validInput(&grainABVWortInputBuffer),
firstGrainAmount: validInput(&grainABVFirstAmountInputBuffer),
......@@ -92,7 +94,7 @@ pub fn grainABVPrep(grainABVBuilderClone: &gtk::Builder, allOverlays: &colourOve
seventhGrainAmount: validInput(&grainABVSeventhAmountInputBuffer),
seventhGrainInfo: grainInfo(&grainABVSeventhTypeInputBuffer),
glassSize: glassSize(&grainABVGlassSizeInputBuffer),
imperialOrMetric: "imperial",
imperialOrMetric: imperialOrMetricMatch(grainABVSwitch.get_active()),
grainABVBuilder: grainABVBuilderClone,
};
......@@ -194,17 +196,6 @@ pub fn grainABVPrep(grainABVBuilderClone: &gtk::Builder, allOverlays: &colourOve
grainABVABVOutput.set_text("");
allOverlays.colourOutput.set_rgba(&rgbaZero);
} else {
onGrainABVActivate(allInputs, &allOverlays);
}
}
fn onGrainABVActivate(mut allInputs: grainABVData, allOverlays: &colourOverlay) {
let grainABVSwitch: gtk::Switch = allInputs.grainABVBuilder.get_object("grainABVSwitch").unwrap();
if grainABVSwitch.get_active() == true {
allInputs.imperialOrMetric = "metric";
grainABVMaths(allInputs, allOverlays);
} else if grainABVSwitch.get_active() == false {
grainABVMaths(allInputs, allOverlays);
}
}
......@@ -232,7 +223,7 @@ fn grainABVMaths(allInputs: grainABVData, allOverlays: &colourOverlay) {
alpha: 1.0,
};
if allInputs.imperialOrMetric == "imperial" {
if allInputs.imperialOrMetric == imperialOrMetric::imperial {
let totalGrain1 = grainToABV(allInputs.wortAmount, allInputs.firstGrainAmount, allInputs.firstGrainInfo.0);
let totalGrain2 = grainToABV(allInputs.wortAmount, allInputs.secondGrainAmount, allInputs.secondGrainInfo.0);
let totalGrain3 = grainToABV(allInputs.wortAmount, allInputs.thirdGrainAmount, allInputs.thirdGrainInfo.0);
......@@ -253,7 +244,7 @@ fn grainABVMaths(allInputs: grainABVData, allOverlays: &colourOverlay) {
grainABVABVOutput.set_text(&abvFormatted);
allOverlays.colourOutput.set_rgba(&rgbaOutput);
}
} else if allInputs.imperialOrMetric == "metric" {
} else if allInputs.imperialOrMetric == imperialOrMetric::metric {
let totalGrain1 = grainToABV(litresToGallons(allInputs.wortAmount), kilosToPounds(allInputs.firstGrainAmount), allInputs.firstGrainInfo.0);
let totalGrain2 = grainToABV(litresToGallons(allInputs.wortAmount), kilosToPounds(allInputs.secondGrainAmount), allInputs.secondGrainInfo.0);
let totalGrain3 = grainToABV(litresToGallons(allInputs.wortAmount), kilosToPounds(allInputs.thirdGrainAmount), allInputs.thirdGrainInfo.0);
......
......@@ -20,7 +20,7 @@ struct guestimateIBUData <'a> {
sixthHopAmount: f64,
seventhHopAlpha: f64,
seventhHopAmount: f64,
imperialOrMetric: &'a str,
imperialOrMetric: imperialOrMetric,
IBUBuilder: &'a gtk::Builder,
}
......@@ -76,6 +76,8 @@ pub fn guestimateIBUPrep(IBUBuilderClone: &gtk::Builder) {
let totalIBUSeventhHopAmountInput: gtk::Entry = IBUBuilderClone.get_object("totalIBUSeventhHopAmountInput").unwrap();
let totalIBUSeventhHopAmountInputBuffer = totalIBUSeventhHopAmountInput.get_text().expect("No input");
let totalIBUSwitch: gtk::Switch = IBUBuilderClone.get_object("totalIBUSwitch").unwrap();
let allInputs = guestimateIBUData {
preBoilBrix: validInput(&totalIBUPreBoilBrixInputBuffer),
wortVolume: validInput(&totalIBUWortVolumeInputBuffer),
......@@ -94,7 +96,7 @@ pub fn guestimateIBUPrep(IBUBuilderClone: &gtk::Builder) {
sixthHopAmount: validInput(&totalIBUSixthHopAmountInputBuffer),
seventhHopAlpha: validInput(&totalIBUSeventhHopAlphaInputBuffer),
seventhHopAmount: validInput(&totalIBUSeventhHopAmountInputBuffer),
imperialOrMetric: "imperial",
imperialOrMetric: imperialOrMetricMatch(totalIBUSwitch.get_active()),
IBUBuilder: IBUBuilderClone,
};
......@@ -109,17 +111,6 @@ pub fn guestimateIBUPrep(IBUBuilderClone: &gtk::Builder) {
} else if allInputs.preBoilBrix <= 0.0 || allInputs.wortVolume <= 0.0 || allInputs.boilTime <= 0.0 || allInputs.firstHopAlpha <= 0.0 || allInputs.firstHopAmount <= 0.0 {
totalIBUOutput.set_text("Enter a positive number");
} else {
onIBUActivate(allInputs);
}
}
fn onIBUActivate(mut allInputs: guestimateIBUData) {
let totalIBUSwitch: gtk::Switch = allInputs.IBUBuilder.get_object("totalIBUSwitch").unwrap();
if totalIBUSwitch.get_active() == true {
allInputs.imperialOrMetric = "metric";
totalIBUMaths(allInputs);
} else if totalIBUSwitch.get_active() == false {
totalIBUMaths(allInputs);
}
}
......@@ -127,7 +118,7 @@ fn onIBUActivate(mut allInputs: guestimateIBUData) {
fn totalIBUMaths(allInputs: guestimateIBUData) {
let totalIBUOutput: gtk::Entry = allInputs.IBUBuilder.get_object("totalIBUOutput").unwrap();
if allInputs.imperialOrMetric == "imperial" {
if allInputs.imperialOrMetric == imperialOrMetric::imperial {
let totalIBU1 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume, allInputs.boilTime, allInputs.firstHopAlpha, allInputs.firstHopAmount);
let totalIBU2 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume, allInputs.boilTime, allInputs.secondHopAlpha, allInputs.secondHopAmount);
let totalIBU3 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume, allInputs.boilTime, allInputs.thirdHopAlpha, allInputs.thirdHopAmount);
......@@ -137,7 +128,7 @@ fn totalIBUMaths(allInputs: guestimateIBUData) {
let totalIBU7 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume, allInputs.boilTime, allInputs.seventhHopAlpha, allInputs.seventhHopAmount);
let total = format!("{:.2} IBUs", totalIBU1 + totalIBU2 + totalIBU3 + totalIBU4 + totalIBU5 + totalIBU6 + totalIBU7);
totalIBUOutput.set_text(&total);
} else if allInputs.imperialOrMetric == "metric" {
} else if allInputs.imperialOrMetric == imperialOrMetric::metric {
let totalIBU1 = realIBU(allInputs.preBoilBrix, litresToGallons(allInputs.wortVolume), allInputs.boilTime, allInputs.firstHopAlpha, gramsToOunces(allInputs.firstHopAmount));
let totalIBU2 = realIBU(allInputs.preBoilBrix, litresToGallons(allInputs.wortVolume), allInputs.boilTime, allInputs.secondHopAlpha, gramsToOunces(allInputs.secondHopAmount));
let totalIBU3 = realIBU(allInputs.preBoilBrix, litresToGallons(allInputs.wortVolume), allInputs.boilTime, allInputs.thirdHopAlpha, gramsToOunces(allInputs.thirdHopAmount));
......
......@@ -17,6 +17,10 @@ pub fn gyleCarbonationPrep(gyleBuilderClone: &gtk::Builder) {
let gyleOutput: &gtk::Entry = &gyleBuilderClone.get_object("gyleOutput").unwrap();
let gyleCarbonationSwitch: gtk::Switch = gyleBuilderClone.get_object("gyleCarbonationSwitch").unwrap();
let imperialOrMetric = imperialOrMetricMatch(gyleCarbonationSwitch.get_active());
if startingBrix < 2.57 {
gyleOutput.set_text("Enter a Starting Brix greater than 2.57");
} else if startingBrix > 49.48 {
......@@ -26,34 +30,22 @@ pub fn gyleCarbonationPrep(gyleBuilderClone: &gtk::Builder) {
} else if startingBrix <= 0.0 || desiredCO2Level <= 0.0 || finalVolume <= 0.0 {
gyleOutput.set_text("Enter a positive number");
} else {
onGyleActivate(startingBrix, desiredCO2Level, finalVolume, gyleBuilderClone);
}
}
fn onGyleActivate(startingBrix: f64, desiredCO2Level: f64, finalVolume: f64, gyleBuilderClone: &gtk::Builder) {
let gyleCarbonationSwitch: gtk::Switch = gyleBuilderClone.get_object("gyleCarbonationSwitch").unwrap();
if gyleCarbonationSwitch.get_active() == true {
let imperialOrMetric = "metric";
gyleMaths(startingBrix, desiredCO2Level, finalVolume, imperialOrMetric, gyleBuilderClone);
} else if gyleCarbonationSwitch.get_active() == false {
let imperialOrMetric = "imperial";
gyleMaths(startingBrix, desiredCO2Level, finalVolume, imperialOrMetric, gyleBuilderClone);
}
}
fn gyleMaths(startingBrix: f64, desiredCO2Level: f64, finalVolume: f64, imperialOrMetric: &str, gyleBuilderClone: &gtk::Builder) {
fn gyleMaths(startingBrix: f64, desiredCO2Level: f64, finalVolume: f64, imperialOrMetric: imperialOrMetric, gyleBuilderClone: &gtk::Builder) {
let startingGravity = brixToGravity(startingBrix);
let startingPlato = gravityToPlato(startingGravity);
let finalPlato = gravityToPlato(finalGravityIdeal);
let gyleOutput: &gtk::Entry = &gyleBuilderClone.get_object("gyleOutput").unwrap();
if imperialOrMetric == "imperial" {
if imperialOrMetric == imperialOrMetric::imperial {
let gyleVolume = litresToGallons((0.24 * gallonsToLitres(finalVolume) * desiredCO2Level) / (startingPlato - finalPlato));
let total = format!("{:.2} gallons", gyleVolume);
gyleOutput.set_text(&total);
} else if imperialOrMetric == "metric" {
} else if imperialOrMetric == imperialOrMetric::metric {
let gyleVolume = (0.24 * finalVolume * desiredCO2Level) / (startingPlato - finalPlato);
let total = format!("{:.2} litres", gyleVolume);
gyleOutput.set_text(&total);
......
......@@ -19,6 +19,10 @@ pub fn increaseABVPrep(increaseABVBuilderClone: &gtk::Builder) {
let increaseABVSugarAddOutput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVSugarAddOutput").unwrap();
let increaseABVHoneyAddOutput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVHoneyAddOutput").unwrap();
let increaseABVSwitch: &gtk::Switch = &increaseABVBuilderClone.get_object("increaseABVSwitch").unwrap();
let imperialOrMetric = imperialOrMetricMatch(increaseABVSwitch.get_active());
if startingBrix < 2.57 {
increaseABVNewBrixOutput.set_text("Enter a brix greater than 2.57");
increaseABVSugarAddOutput.set_text("");
......@@ -36,23 +40,11 @@ pub fn increaseABVPrep(increaseABVBuilderClone: &gtk::Builder) {
increaseABVSugarAddOutput.set_text("");
increaseABVHoneyAddOutput.set_text("");
} else {
onIncreaseActivate(startingBrix, desiredABV, desiredWortVolume, increaseABVBuilderClone);
}
}
fn onIncreaseActivate(startingBrix: f64, desiredABV: f64, desiredWortVolume: f64, increaseABVBuilderClone: &gtk::Builder) {
let increaseABVSwitch: &gtk::Switch = &increaseABVBuilderClone.get_object("increaseABVSwitch").unwrap();
if increaseABVSwitch.get_active() == true {
let imperialOrMetric = "metric";
differenceBrixMaths(startingBrix, desiredABV, desiredWortVolume, imperialOrMetric, increaseABVBuilderClone);
} else if increaseABVSwitch.get_active() == false {
let imperialOrMetric = "imperial";
differenceBrixMaths(startingBrix, desiredABV, desiredWortVolume, imperialOrMetric, increaseABVBuilderClone);
}
}
fn differenceBrixMaths(startingBrix: f64, desiredABV: f64, desiredWortVolume: f64, imperialOrMetric: &str, increaseABVBuilderClone: &gtk::Builder) {
fn differenceBrixMaths(startingBrix: f64, desiredABV: f64, desiredWortVolume: f64, imperialOrMetric: imperialOrMetric, increaseABVBuilderClone: &gtk::Builder) {
let mut newStartingBrix = startingBrix;
let mut newEstimatedABV = realABV(newStartingBrix, finalBrixIdeal).0;
......@@ -68,7 +60,7 @@ fn differenceBrixMaths(startingBrix: f64, desiredABV: f64, desiredWortVolume: f6
let increaseABVSugarAddOutput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVSugarAddOutput").unwrap();
let increaseABVHoneyAddOutput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVHoneyAddOutput").unwrap();
if imperialOrMetric == "imperial" {
if imperialOrMetric == imperialOrMetric::imperial {
let sugarToAddImperial = (desiredWortVolume * 1.5 * differenceBrix) / 16.0;
let honeyToAddImperial = sugarToAddImperial * 1.25;
let sugar = format!("{} lbs {:.2} oz", sugarToAddImperial as u32, sugarToAddImperial % 1.0 * 16.0);
......@@ -76,7 +68,7 @@ fn differenceBrixMaths(startingBrix: f64, desiredABV: f64, desiredWortVolume: f6
increaseABVNewBrixOutput.set_text(&newSB);
increaseABVSugarAddOutput.set_text(&sugar);
increaseABVHoneyAddOutput.set_text(&honey);
} else if imperialOrMetric == "metric" {
} else if imperialOrMetric == imperialOrMetric::metric {
let sugarToAddMetric = ((desiredWortVolume / 3.78541) * 1.5 * differenceBrix) * 0.0283495;
let honeyToAddMetric = sugarToAddMetric * 1.250001102;
let sugar = format!("{:.2} kilos", sugarToAddMetric);
......
......@@ -2,88 +2,102 @@ use gtk;
use gtk::prelude::*;
use functions::commonFunctions::*;
struct waterSpargeData <'a> {
preFermentVolume: f64,
totalGrain: f64,
boilTime: f64,
grainAbsorption: f64,
mashThickness: f64,
imperialOrMetric: imperialOrMetric,
waterSpargeBuilder: &'a gtk::Builder,
}
pub fn waterSpargePrep(waterSpargeBuilderClone: &gtk::Builder) {
let spargePreFermentVolumeInput: gtk::Entry = waterSpargeBuilderClone.get_object("spargePreFermentVolumeInput").unwrap();
let spargePreFermentVolumeInputBuffer = spargePreFermentVolumeInput.get_text().expect("No input");
let preFermentVolume = validInput(&spargePreFermentVolumeInputBuffer);
let spargeTotalGrainInput: gtk::Entry = waterSpargeBuilderClone.get_object("spargeTotalGrainInput").unwrap();
let spargeTotalGrainInputBuffer = spargeTotalGrainInput.get_text().expect("No input");
let totalGrain = validInput(&spargeTotalGrainInputBuffer);
let spargeBoilTimeInput: gtk::Entry = waterSpargeBuilderClone.get_object("spargeBoilTimeInput").unwrap();
let spargeBoilTimeInputBuffer = spargeBoilTimeInput.get_text().expect("No input");
let boilTemp = validInput(&spargeBoilTimeInputBuffer);
let spargeMashWaterOutput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargeMashWaterOutput").unwrap();
let spargeSpargeWaterOutput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargeSpargeWaterOutput").unwrap();
let spargeTotalWaterOutput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargeTotalWaterOutput").unwrap();
if preFermentVolume < 0.0 || totalGrain < 0.0 || boilTemp < 0.0 {
let waterSpargeSwitch: gtk::Switch = waterSpargeBuilderClone.get_object("waterSpargeSwitch").unwrap();
let allInputs = waterSpargeData {
preFermentVolume: validInput(&spargePreFermentVolumeInputBuffer),
totalGrain: validInput(&spargeTotalGrainInputBuffer),
boilTime: validInput(&spargeBoilTimeInputBuffer) / 60.0,
grainAbsorption: 0.0,
mashThickness: 0.0,
imperialOrMetric: imperialOrMetricMatch(waterSpargeSwitch.get_active()),
waterSpargeBuilder: waterSpargeBuilderClone,
};
if allInputs.preFermentVolume < 0.0 || allInputs.totalGrain < 0.0 || allInputs.boilTime * 60.0 < 0.0 {
spargeMashWaterOutput.set_text("Enter a positive number");
spargeSpargeWaterOutput.set_text("");
spargeTotalWaterOutput.set_text("");
} else if preFermentVolume == 0.0 || totalGrain == 0.0 || boilTemp == 0.0 {
} else if allInputs.preFermentVolume == 0.0 || allInputs.totalGrain == 0.0 || allInputs.boilTime * 60.0 == 0.0 {
spargeMashWaterOutput.set_text("Enter all 3 inputs");
spargeSpargeWaterOutput.set_text("");
spargeTotalWaterOutput.set_text("");
} else {
onSpargeActivate(preFermentVolume, totalGrain, boilTemp, waterSpargeBuilderClone);
spargeSwitchSetValues(allInputs);
}
}
fn onSpargeActivate(preFermentVolume: f64, totalGrain: f64, boilTemp: f64, waterSpargeBuilderClone: &gtk::Builder) {
let waterSpargeSwitch: gtk::Switch = waterSpargeBuilderClone.get_object("waterSpargeSwitch").unwrap();
let boilTime: f64 = boilTemp / 60.0;
fn spargeSwitchSetValues(mut allInputs: waterSpargeData) {
if waterSpargeSwitch.get_active() == true {
let imperialOrMetric = "metric";
let grainAbsorption: f64 = 1.25181176;
if allInputs.imperialOrMetric == imperialOrMetric::imperial {
allInputs.grainAbsorption = 0.15;
// constant value of 0.15 gallons/lb
allInputs.mashThickness = 1.333;
// 1.333 quarts/lb
waterSpargeMaths(allInputs);
} else if allInputs.imperialOrMetric == imperialOrMetric::metric {
allInputs.grainAbsorption = 1.25181176;
// constant value of 1.25181176 litres/kilo
// 0.15 gal = 0.5678118 L
// 1 lb = 0.453592 kg
let mashThickness: f64 = 2.781108353;
allInputs.mashThickness = 2.781108353;
// 1.333 quarts = 1.2614885 L
// 1 lb = 0.453592 kg
// 2.781108353 litres/kilo
waterSpargeMaths(preFermentVolume, totalGrain, boilTime, grainAbsorption, mashThickness, imperialOrMetric, waterSpargeBuilderClone);
} else if waterSpargeSwitch.get_active() == false {
let imperialOrMetric = "imperial";
let grainAbsorption: f64 = 0.15;
// constant value of 0.15 gallons/lb
let mashThickness: f64 = 1.333;
// 1.333 quarts/lb
waterSpargeMaths(preFermentVolume, totalGrain, boilTime, grainAbsorption, mashThickness, imperialOrMetric, waterSpargeBuilderClone);
waterSpargeMaths(allInputs);
}
}
fn waterSpargeMaths(preFermentVolume: f64, totalGrain: f64, boilTime: f64, grainAbsorption: f64, mashThickness: f64, imperialOrMetric: &str, waterSpargeBuilderClone: &gtk::Builder) {
fn waterSpargeMaths(allInputs: waterSpargeData) {
let wortShrinkage: f64 = 0.04;
// constant value of 4%
let percentBoiloff: f64 = 0.1;
// constant value of 10%
let trubLoss = preFermentVolume * 0.05;
let trubLoss = allInputs.preFermentVolume * 0.05;
// 5% is an acceptable norm
let equipmentLoss = preFermentVolume * 0.08;
let equipmentLoss = allInputs.preFermentVolume * 0.08;
// 8% is an acceptable norm
let totalWater = (((preFermentVolume + trubLoss) / (1.0 - wortShrinkage)) / (1.0 - (boilTime * percentBoiloff))) + equipmentLoss + (totalGrain * grainAbsorption);
let mashWater = (totalGrain * mashThickness)/4.0;
let totalWater = (((allInputs.preFermentVolume + trubLoss) / (1.0 - wortShrinkage)) / (1.0 - (allInputs.boilTime * percentBoiloff))) + equipmentLoss + (allInputs.totalGrain * allInputs.grainAbsorption);
let mashWater = (allInputs.totalGrain * allInputs.mashThickness)/4.0;
let spargeWater = totalWater - mashWater;
let spargeMashWaterOutput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargeMashWaterOutput").unwrap();
let spargeSpargeWaterOutput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargeSpargeWaterOutput").unwrap();
let spargeTotalWaterOutput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargeTotalWaterOutput").unwrap();
let spargeMashWaterOutput: gtk::Entry = allInputs.waterSpargeBuilder.get_object("spargeMashWaterOutput").unwrap();
let spargeSpargeWaterOutput: gtk::Entry = allInputs.waterSpargeBuilder.get_object("spargeSpargeWaterOutput").unwrap();
let spargeTotalWaterOutput: gtk::Entry = allInputs.waterSpargeBuilder.get_object("spargeTotalWaterOutput").unwrap();
if imperialOrMetric == "imperial" {
if allInputs.imperialOrMetric == imperialOrMetric::imperial {
let mash = format!("{:.2} gallons", mashWater);
let sparge = format!("{:.2} gallons", spargeWater);
let total = format!("{:.2} gallons", totalWater);
spargeMashWaterOutput.set_text(&mash);
spargeSpargeWaterOutput.set_text(&sparge);
spargeTotalWaterOutput.set_text(&total);
} else if imperialOrMetric == "metric" {
} else if allInputs.imperialOrMetric == imperialOrMetric::metric {
let mash = format!("{:.2} litres", mashWater);
let sparge = format!("{:.2} litres", spargeWater);
let total = format!("{:.2} litres", totalWater);
......
......@@ -8,7 +8,7 @@
<property name="can_focus">False</property>
<property name="default_width">610</property>
<property name="default_height">720</property>
<property name="icon">/usr/share/BrewStillery/BrewStilleryLogo.svg</property>
<property name="icon">/usr/share/BrewStillery/BrewStilleryLogo.png</property>
<child>
<object class="GtkNotebook">
<property name="visible">True</property>
......@@ -2756,7 +2756,7 @@
<object class="GtkImage" id="brewStilleryLogo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">/usr/share/BrewStillery/BrewStilleryLogo.svg</property>
<property name="pixbuf">/usr/share/BrewStillery/BrewStilleryLogo.png</property>
</object>
<packing>
<property name="expand">False</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment