Commit 45aea8c1 authored by Meade's avatar Meade

Added version 5.2.0. Created traits and implementations. Removed PKGBUILD.

parent 09812028
# Maintainer: Meade And Emily <thedarkula2049@gmail.com>
pkgname=brewstillery
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"
arch=('i686' 'x86_64')
license=('AGPL3')
depends=('ttf-roboto')
makedepends=('git' 'cargo')
provides=('brewstillery')
conflicts=('brewstillery')
source=("https://github.com/MonkeyLog/BrewStillery/archive/$pkgver.tar.gz")
md5sums=('8926dea1ae75edf0a112b980263339f8')
build() {
cd $srcdir/BrewStillery-$pkgver
cargo build --release
}
package() {
cd $srcdir/BrewStillery-$pkgver/target/release
install -Dm755 BrewStillery "$pkgdir/usr/bin/BrewStillery"
cd $srcdir/BrewStillery-$pkgver/Arch
install -Dm755 BrewStillery.desktop "$pkgdir/usr/share/applications/BrewStillery.desktop"
cd $srcdir/BrewStillery-$pkgver/media
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/"
cd $srcdir/BrewStillery-$pkgver/media/buttons
install -dm755 "$pkgdir/usr/share/BrewStillery/buttons/"
install -Dm755 *.png "$pkgdir/usr/share/BrewStillery/buttons/"
}
\ No newline at end of file
[[package]]
name = "BrewStillery"
version = "5.1.0"
version = "5.2.0"
dependencies = [
"gdk 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -15,7 +15,7 @@ dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -38,7 +38,7 @@ dependencies = [
"cairo-sys-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -47,7 +47,7 @@ name = "cairo-sys-rs"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -66,7 +66,7 @@ dependencies = [
"glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pango 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -79,7 +79,7 @@ dependencies = [
"glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -91,7 +91,7 @@ dependencies = [
"gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -106,7 +106,7 @@ dependencies = [
"gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -121,7 +121,7 @@ dependencies = [
"glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -132,7 +132,7 @@ dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -145,7 +145,7 @@ dependencies = [
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -154,7 +154,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -165,7 +165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -187,7 +187,7 @@ dependencies = [
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pango 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -204,7 +204,7 @@ dependencies = [
"gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -216,7 +216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.35"
version = "0.2.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -228,7 +228,7 @@ dependencies = [
"glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -240,7 +240,7 @@ dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -272,7 +272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum gtk 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0847c507e52c1feaede13ef56fb4847742438602655449d5f1f782e8633f146f"
"checksum gtk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "905fcfbaaad1b44ec0b4bba9e4d527d728284c62bc2ba41fccedace2b096766f"
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
"checksum libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)" = "96264e9b293e95d25bfcbbf8a88ffd1aedc85b754eba8b7d78012f638ba220eb"
"checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121"
"checksum pango 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e81c404ab81ea7ea2fc2431a0a7672507b80e4b8bf4b41eac3fc83cc665104e"
"checksum pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34f34a1be107fe16abb2744e0e206bee4b3b07460b5fddd3009a6aaf60bd69ab"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
......
[package]
name = "BrewStillery"
version = "5.1.0"
version = "5.2.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
......
......@@ -4,6 +4,10 @@ It has a multitude of great functions, such as calculating ABV, determining carb
Written in Rust, using GTK3
## New In 5.2.0
* Created traits and implementations for common functions.
* Removed the arch PKGBUILD. It's on the AUR.
## New In 5.1.0
* Made things more rusty, changed two images from svg to png, and code cleanup.
......@@ -45,6 +49,7 @@ Written in Rust, using GTK3
* Add Sugars And Fruits To ABV From Grain
* Add Water Minerals Calculator
* Add Export To Gourmet Option
* Add unit tests
## Building:
......
......@@ -2,7 +2,7 @@
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 ../Desktop/BrewStillery.desktop /usr/share/applications/BrewStillery.desktop &&
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 &&
......
......@@ -5,13 +5,13 @@ use functions::commonFunctions::*;
pub fn champagneCarbonationPrep(champagneCarbonationBuilderClone: &gtk::Builder) {
let champagneCarbonationInput: gtk::Entry = champagneCarbonationBuilderClone.get_object("champagneCarbonationInput").unwrap();
let champagneCarbonationInputBuffer = champagneCarbonationInput.get_text().expect("No input");
let champagneVolume = validInput(&champagneCarbonationInputBuffer);
let champagneVolume = champagneCarbonationInputBuffer.validInput();
let champagneCarbonationOutput: gtk::Entry = champagneCarbonationBuilderClone.get_object("champagneCarbonationOutput").unwrap();
let champagneCarbonationSwitch: gtk::Switch = champagneCarbonationBuilderClone.get_object("champagneCarbonationSwitch").unwrap();
let imperialOrMetric = imperialOrMetricMatch(champagneCarbonationSwitch.get_active());
let imperialOrMetric = champagneCarbonationSwitch.switchMatch();
if champagneVolume == 0.0 {
champagneCarbonationOutput.set_text("Enter a number");
......
use gtk;
use gtk::prelude::*;
use std::f64::consts::E;
pub const finalGravityIdeal: f64 = 1.01627;
......@@ -12,44 +14,114 @@ pub enum imperialOrMetric {
metric,
}
pub fn brixToGravity(brix: f64) -> f64 {
(brix / (258.6 - ((brix / 258.2) * 227.1))) + 1.0
pub trait inputMatching {
fn validInput(&self) -> f64;
fn grainInfo(&self) -> (f64, f64);
fn glassSize(&self) -> f64;
}
pub fn gravityToBrix(gravity: f64) -> f64 {
((258.6 * gravity) - 258.6) / ((0.87955073 * gravity) + 0.12044926)
}
impl inputMatching for str {
fn validInput(&self) -> f64 {
let stringInput = self.parse::<f64>();
match stringInput {
Ok(number) => number,
Err(_) => 0.0,
}
}
pub fn gravityToPlato(gravity: f64) -> f64 {
135.997 * gravity.powi(3) - 630.272 * gravity.powi(2) + 1111.14 * gravity - 616.868
}
fn grainInfo(&self) -> (f64, f64) {
match self {
// First value is Gravity, second value is Lovibond
"2-Row" => (1.037, 1.8),
"6-Row" => (1.035, 1.8),
"Black" => (1.025, 500.0),
"Caramel 60" => (1.034, 60.0),
"Caramel 80" => (1.034, 80.0),
"Caramel 120" => (1.033, 120.0),
"Chocolate" => (1.034, 350.0),
"Corn" => (1.037, 1.3),
"Dextrine" => (1.033, 1.5),
"Oat" => (1.034, 1.0),
"Rice" => (1.032, 1.0),
"Rye" => (1.036, 2.0),
"Wheat" => (1.036, 1.6),
_ => (1.0, 0.0),
// Gravity set to water, and color to nothing as a catch
}
}
pub fn gramsToOunces(grams: f64) -> f64 {
0.03527396_f64 * grams
fn glassSize(&self) -> f64 {
match self {
// Value is in centimeters
"Dimple Pint" => 9.8,
"Nonick Pint" => 9.0,
"Tulip Pint" => 8.5,
"Pilsner" => 8.0,
"Maß" => 10.5,
"Dimple Half Pint" => 8.0,
"Nonick Half Pint" => 7.0,
"Tulip Half Pint" => 7.2,
_ => 9.8,
}
}
}
pub fn kilosToPounds(kilos: f64) -> f64 {
2.204623_f64 * kilos
pub trait imperialOrMetricMatch {
fn switchMatch(&self) -> imperialOrMetric;
}
pub fn litresToGallons(litres: f64) -> f64 {
0.2641729_f64 * litres
impl imperialOrMetricMatch for gtk::Switch {
fn switchMatch(&self) -> imperialOrMetric {
let state = self.get_active();
match state {
false => imperialOrMetric::imperial,
true => imperialOrMetric::metric,
}
}
}
pub fn gallonsToLitres(gallons: f64) -> f64 {
3.7854_f64 * gallons
pub trait singleInput {
fn brixToGravity(&self) -> f64;
fn gravityToBrix(&self) -> f64;
fn gravityToPlato(&self) -> f64;
fn gramsToOunces(&self) -> f64;
fn kilosToPounds(&self) -> f64;
fn litresToGallons(&self) -> f64;
fn gallonsToLitres(&self) -> f64;
}
pub fn validInput(stringToCheck: &str) -> f64 {
let stringInput = stringToCheck.parse::<f64>();
match stringInput {
Ok(number) => number,
Err(_) => 0.0,
impl singleInput for f64 {
fn brixToGravity(&self) -> f64 {
(self / (258.6 - ((self / 258.2) * 227.1))) + 1.0
}
fn gravityToBrix(&self) -> f64 {
((258.6 * self) - 258.6) / ((0.87955073 * self) + 0.12044926)
}
fn gravityToPlato(&self) -> f64 {
135.997 * self.powi(3) - 630.272 * self.powi(2) + 1111.14 * self - 616.868
}
fn gramsToOunces(&self) -> f64 {
0.03527396_f64 * self
}
fn kilosToPounds(&self) -> f64 {
2.204623_f64 * self
}
fn litresToGallons(&self) -> f64 {
0.2641729_f64 * self
}
fn gallonsToLitres(&self) -> f64 {
3.7854_f64 * self
}
}
pub fn realIBU(brix: f64, wortVolume: f64, boilTime: f64, alphaAcid: f64, hopAmount: f64) -> f64 {
(1.65 * 0.000125_f64.powf(brixToGravity(brix) - 1.0)) * ((1.0 - E.powf(-0.04 * boilTime)) / 4.15) * (( (alphaAcid / 100.0) * hopAmount * 7490.0 ) / wortVolume)
(1.65 * 0.000125_f64.powf(brix.brixToGravity() - 1.0)) * ((1.0 - E.powf(-0.04 * boilTime)) / 4.15) * (( (alphaAcid / 100.0) * hopAmount * 7490.0 ) / wortVolume)
}
pub fn realABV(startingBrix: f64, finalBrix: f64) -> (f64, f64) {
......@@ -83,47 +155,4 @@ pub fn grainToABV(volumeInGallons: f64, weightInPounds: f64, grainGravity: f64)
} else {
originalGravity
}
}
pub fn grainInfo(grainType: &str) -> (f64, f64) {
match grainType {
// First value is Gravity, second value is Lovibond
"2-Row" => (1.037, 1.8),
"6-Row" => (1.035, 1.8),
"Black" => (1.025, 500.0),
"Caramel 60" => (1.034, 60.0),
"Caramel 80" => (1.034, 80.0),
"Caramel 120" => (1.033, 120.0),
"Chocolate" => (1.034, 350.0),
"Corn" => (1.037, 1.3),
"Dextrine" => (1.033, 1.5),
"Oat" => (1.034, 1.0),
"Rice" => (1.032, 1.0),
"Rye" => (1.036, 2.0),
"Wheat" => (1.036, 1.6),
_ => (1.0, 0.0),
// Gravity set to water, and color to nothing as a catch
}
}
pub fn glassSize(glassType: &str) -> f64 {
match glassType {
// Value is in centimeters
"Dimple Pint" => 9.8,
"Nonick Pint" => 9.0,
"Tulip Pint" => 8.5,
"Pilsner" => 8.0,
"Maß" => 10.5,
"Dimple Half Pint" => 8.0,
"Nonick Half Pint" => 7.0,
"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
......@@ -78,23 +78,23 @@ pub fn grainABVPrep(grainABVBuilderClone: &gtk::Builder, allOverlays: &colourOve
let grainABVSwitch: gtk::Switch = grainABVBuilderClone.get_object("grainABVSwitch").unwrap();
let allInputs = grainABVData {
wortAmount: validInput(&grainABVWortInputBuffer),
firstGrainAmount: validInput(&grainABVFirstAmountInputBuffer),
firstGrainInfo: grainInfo(&grainABVFirstTypeInputBuffer),
secondGrainAmount: validInput(&grainABVSecondAmountInputBuffer),
secondGrainInfo: grainInfo(&grainABVSecondTypeInputBuffer),
thirdGrainAmount: validInput(&grainABVThirdAmountInputBuffer),
thirdGrainInfo: grainInfo(&grainABVThirdTypeInputBuffer),
fourthGrainAmount: validInput(&grainABVFourthAmountInputBuffer),
fourthGrainInfo: grainInfo(&grainABVFourthTypeInputBuffer),
fifthGrainAmount: validInput(&grainABVFifthAmountInputBuffer),
fifthGrainInfo: grainInfo(&grainABVFifthTypeInputBuffer),
sixthGrainAmount: validInput(&grainABVSixthAmountInputBuffer),
sixthGrainInfo: grainInfo(&grainABVSixthTypeInputBuffer),
seventhGrainAmount: validInput(&grainABVSeventhAmountInputBuffer),
seventhGrainInfo: grainInfo(&grainABVSeventhTypeInputBuffer),
glassSize: glassSize(&grainABVGlassSizeInputBuffer),
imperialOrMetric: imperialOrMetricMatch(grainABVSwitch.get_active()),
wortAmount: grainABVWortInputBuffer.validInput(),
firstGrainAmount: grainABVFirstAmountInputBuffer.validInput(),
firstGrainInfo: grainABVFirstTypeInputBuffer.grainInfo(),
secondGrainAmount: grainABVSecondAmountInputBuffer.validInput(),
secondGrainInfo: grainABVSecondTypeInputBuffer.grainInfo(),
thirdGrainAmount: grainABVThirdAmountInputBuffer.validInput(),
thirdGrainInfo: grainABVThirdTypeInputBuffer.grainInfo(),
fourthGrainAmount: grainABVFourthAmountInputBuffer.validInput(),
fourthGrainInfo: grainABVFourthTypeInputBuffer.grainInfo(),
fifthGrainAmount: grainABVFifthAmountInputBuffer.validInput(),
fifthGrainInfo: grainABVFifthTypeInputBuffer.grainInfo(),
sixthGrainAmount: grainABVSixthAmountInputBuffer.validInput(),
sixthGrainInfo: grainABVSixthTypeInputBuffer.grainInfo(),
seventhGrainAmount: grainABVSeventhAmountInputBuffer.validInput(),
seventhGrainInfo: grainABVSeventhTypeInputBuffer.grainInfo(),
glassSize: grainABVGlassSizeInputBuffer.glassSize(),
imperialOrMetric: grainABVSwitch.switchMatch(),
grainABVBuilder: grainABVBuilderClone,
};
......@@ -231,7 +231,8 @@ fn grainABVMaths(allInputs: grainABVData, allOverlays: &colourOverlay) {
let totalGrain5 = grainToABV(allInputs.wortAmount, allInputs.fifthGrainAmount, allInputs.fifthGrainInfo.0);
let totalGrain6 = grainToABV(allInputs.wortAmount, allInputs.sixthGrainAmount, allInputs.sixthGrainInfo.0);
let totalGrain7 = grainToABV(allInputs.wortAmount, allInputs.seventhGrainAmount, allInputs.seventhGrainInfo.0);
let startingBrix = gravityToBrix(1.0 + &totalGrain1 % 1.0 + &totalGrain2 % 1.0 + &totalGrain3 % 1.0 + &totalGrain4 % 1.0 + &totalGrain5 % 1.0 + &totalGrain6 % 1.0 + &totalGrain7 % 1.0);
let grainSum = 1.0 + &totalGrain1 % 1.0 + &totalGrain2 % 1.0 + &totalGrain3 % 1.0 + &totalGrain4 % 1.0 + &totalGrain5 % 1.0 + &totalGrain6 % 1.0 + &totalGrain7 % 1.0;
let startingBrix = grainSum.gravityToBrix();
let estimatedBrix = format!("{:.2}°Bx", startingBrix);
let abv = realABV(startingBrix, finalBrixIdeal).0;
let abvFormatted = format!("{:.2}%", abv);
......@@ -245,14 +246,15 @@ fn grainABVMaths(allInputs: grainABVData, allOverlays: &colourOverlay) {
allOverlays.colourOutput.set_rgba(&rgbaOutput);
}
} 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);
let totalGrain4 = grainToABV(litresToGallons(allInputs.wortAmount), kilosToPounds(allInputs.fourthGrainAmount), allInputs.fourthGrainInfo.0);
let totalGrain5 = grainToABV(litresToGallons(allInputs.wortAmount), kilosToPounds(allInputs.fifthGrainAmount), allInputs.fifthGrainInfo.0);
let totalGrain6 = grainToABV(litresToGallons(allInputs.wortAmount), kilosToPounds(allInputs.sixthGrainAmount), allInputs.sixthGrainInfo.0);
let totalGrain7 = grainToABV(litresToGallons(allInputs.wortAmount), kilosToPounds(allInputs.seventhGrainAmount), allInputs.seventhGrainInfo.0);
let startingBrix = gravityToBrix(1.0 + &totalGrain1 % 1.0 + &totalGrain2 % 1.0 + &totalGrain3 % 1.0 + &totalGrain4 % 1.0 + &totalGrain5 % 1.0 + &totalGrain6 % 1.0 + &totalGrain7 % 1.0);
let totalGrain1 = grainToABV(allInputs.wortAmount.litresToGallons(), allInputs.firstGrainAmount.kilosToPounds(), allInputs.firstGrainInfo.0);
let totalGrain2 = grainToABV(allInputs.wortAmount.litresToGallons(), allInputs.secondGrainAmount.kilosToPounds(), allInputs.secondGrainInfo.0);
let totalGrain3 = grainToABV(allInputs.wortAmount.litresToGallons(), allInputs.thirdGrainAmount.kilosToPounds(), allInputs.thirdGrainInfo.0);
let totalGrain4 = grainToABV(allInputs.wortAmount.litresToGallons(), allInputs.fourthGrainAmount.kilosToPounds(), allInputs.fourthGrainInfo.0);
let totalGrain5 = grainToABV(allInputs.wortAmount.litresToGallons(), allInputs.fifthGrainAmount.kilosToPounds(), allInputs.fifthGrainInfo.0);
let totalGrain6 = grainToABV(allInputs.wortAmount.litresToGallons(), allInputs.sixthGrainAmount.kilosToPounds(), allInputs.sixthGrainInfo.0);
let totalGrain7 = grainToABV(allInputs.wortAmount.litresToGallons(), allInputs.seventhGrainAmount.kilosToPounds(), allInputs.seventhGrainInfo.0);
let grainSum = 1.0 + &totalGrain1 % 1.0 + &totalGrain2 % 1.0 + &totalGrain3 % 1.0 + &totalGrain4 % 1.0 + &totalGrain5 % 1.0 + &totalGrain6 % 1.0 + &totalGrain7 % 1.0;
let startingBrix = grainSum.gravityToBrix();
let estimatedBrix = format!("{:.2}°Bx", startingBrix);
let abv = realABV(startingBrix, finalBrixIdeal).0;
let abvFormatted = format!("{:.2}%", abv);
......
......@@ -5,7 +5,7 @@ use functions::commonFunctions::*;
pub fn guestimatePrep(guestimatorBuilderClone: &gtk::Builder) {
let guestimatorInput: gtk::Entry = guestimatorBuilderClone.get_object("guestimatorInput").unwrap();
let guestimatorInput = guestimatorInput.get_text().expect("No input");
let startingBrix = validInput(&guestimatorInput);
let startingBrix = guestimatorInput.validInput();
let guestimatorOutput: gtk::Entry = guestimatorBuilderClone.get_object("guestimatorOutput").unwrap();
if startingBrix == 0.0 {
......
......@@ -79,24 +79,24 @@ pub fn guestimateIBUPrep(IBUBuilderClone: &gtk::Builder) {
let totalIBUSwitch: gtk::Switch = IBUBuilderClone.get_object("totalIBUSwitch").unwrap();
let allInputs = guestimateIBUData {
preBoilBrix: validInput(&totalIBUPreBoilBrixInputBuffer),
wortVolume: validInput(&totalIBUWortVolumeInputBuffer),
boilTime: validInput(&totalIBUBoilTimeInputBuffer),
firstHopAlpha: validInput(&totalIBUFirstHopAlphaInputBuffer),
firstHopAmount: validInput(&totalIBUFirstHopAmountInputBuffer),
secondHopAlpha: validInput(&totalIBUSecondHopAlphaInputBuffer),
secondHopAmount: validInput(&totalIBUSecondHopAmountInputBuffer),
thirdHopAlpha: validInput(&totalIBUThirdHopAlphaInputBuffer),
thirdHopAmount: validInput(&totalIBUThirdHopAmountInputBuffer),
fourthHopAlpha: validInput(&totalIBUFourthHopAlphaInputBuffer),
fourthHopAmount: validInput(&totalIBUFourthHopAmountInputBuffer),
fifthHopAlpha: validInput(&totalIBUFifthHopAlphaInputBuffer),
fifthHopAmount: validInput(&totalIBUFifthHopAmountInputBuffer),
sixthHopAlpha: validInput(&totalIBUSixthHopAlphaInputBuffer),
sixthHopAmount: validInput(&totalIBUSixthHopAmountInputBuffer),
seventhHopAlpha: validInput(&totalIBUSeventhHopAlphaInputBuffer),
seventhHopAmount: validInput(&totalIBUSeventhHopAmountInputBuffer),
imperialOrMetric: imperialOrMetricMatch(totalIBUSwitch.get_active()),
preBoilBrix: totalIBUPreBoilBrixInputBuffer.validInput(),
wortVolume: totalIBUWortVolumeInputBuffer.validInput(),
boilTime: totalIBUBoilTimeInputBuffer.validInput(),
firstHopAlpha: totalIBUFirstHopAlphaInputBuffer.validInput(),
firstHopAmount: totalIBUFirstHopAmountInputBuffer.validInput(),
secondHopAlpha: totalIBUSecondHopAlphaInputBuffer.validInput(),
secondHopAmount: totalIBUSecondHopAmountInputBuffer.validInput(),
thirdHopAlpha: totalIBUThirdHopAlphaInputBuffer.validInput(),
thirdHopAmount: totalIBUThirdHopAmountInputBuffer.validInput(),
fourthHopAlpha: totalIBUFourthHopAlphaInputBuffer.validInput(),
fourthHopAmount: totalIBUFourthHopAmountInputBuffer.validInput(),
fifthHopAlpha: totalIBUFifthHopAlphaInputBuffer.validInput(),
fifthHopAmount: totalIBUFifthHopAmountInputBuffer.validInput(),
sixthHopAlpha: totalIBUSixthHopAlphaInputBuffer.validInput(),
sixthHopAmount: totalIBUSixthHopAmountInputBuffer.validInput(),
seventhHopAlpha: totalIBUSeventhHopAlphaInputBuffer.validInput(),
seventhHopAmount: totalIBUSeventhHopAmountInputBuffer.validInput(),
imperialOrMetric: totalIBUSwitch.switchMatch(),
IBUBuilder: IBUBuilderClone,
};
......@@ -129,13 +129,13 @@ fn totalIBUMaths(allInputs: guestimateIBUData) {
let total = format!("{:.2} IBUs", totalIBU1 + totalIBU2 + totalIBU3 + totalIBU4 + totalIBU5 + totalIBU6 + totalIBU7);
totalIBUOutput.set_text(&total);
} 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));
let totalIBU4 = realIBU(allInputs.preBoilBrix, litresToGallons(allInputs.wortVolume), allInputs.boilTime, allInputs.fourthHopAlpha, gramsToOunces(allInputs.fourthHopAmount));
let totalIBU5 = realIBU(allInputs.preBoilBrix, litresToGallons(allInputs.wortVolume), allInputs.boilTime, allInputs.fifthHopAlpha, gramsToOunces(allInputs.fifthHopAmount));
let totalIBU6 = realIBU(allInputs.preBoilBrix, litresToGallons(allInputs.wortVolume), allInputs.boilTime, allInputs.sixthHopAlpha, gramsToOunces(allInputs.sixthHopAmount));
let totalIBU7 = realIBU(allInputs.preBoilBrix, litresToGallons(allInputs.wortVolume), allInputs.boilTime, allInputs.seventhHopAlpha, gramsToOunces(allInputs.seventhHopAmount));
let totalIBU1 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume.litresToGallons(), allInputs.boilTime, allInputs.firstHopAlpha, allInputs.firstHopAmount.gramsToOunces());
let totalIBU2 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume.litresToGallons(), allInputs.boilTime, allInputs.secondHopAlpha, allInputs.secondHopAmount.gramsToOunces());
let totalIBU3 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume.litresToGallons(), allInputs.boilTime, allInputs.thirdHopAlpha, allInputs.thirdHopAmount.gramsToOunces());
let totalIBU4 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume.litresToGallons(), allInputs.boilTime, allInputs.fourthHopAlpha, allInputs.fourthHopAmount.gramsToOunces());
let totalIBU5 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume.litresToGallons(), allInputs.boilTime, allInputs.fifthHopAlpha, allInputs.fifthHopAmount.gramsToOunces());
let totalIBU6 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume.litresToGallons(), allInputs.boilTime, allInputs.sixthHopAlpha, allInputs.sixthHopAmount.gramsToOunces());
let totalIBU7 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume.litresToGallons(), allInputs.boilTime, allInputs.seventhHopAlpha, allInputs.seventhHopAmount.gramsToOunces());
let total = format!("{:.2} IBUs", totalIBU1 + totalIBU2 + totalIBU3 + totalIBU4 + totalIBU5 + totalIBU6 + totalIBU7);
totalIBUOutput.set_text(&total);
}
......
......@@ -5,21 +5,21 @@ use functions::commonFunctions::*;
pub fn gyleCarbonationPrep(gyleBuilderClone: &gtk::Builder) {
let gyleBrixInput: gtk::Entry = gyleBuilderClone.get_object("gyleBrixInput").unwrap();
let gyleBrixInputBuffer = gyleBrixInput.get_text().expect("No input");
let startingBrix = validInput(&gyleBrixInputBuffer);
let startingBrix = gyleBrixInputBuffer.validInput();
let gyleCO2Input: gtk::Entry = gyleBuilderClone.get_object("gyleCO2Input").unwrap();
let gyleCO2InputBuffer = gyleCO2Input.get_text().expect("No input");
let desiredCO2Level = validInput(&gyleCO2InputBuffer);
let desiredCO2Level = gyleCO2InputBuffer.validInput();
let gyleWortVolumeInput: gtk::Entry = gyleBuilderClone.get_object("gyleWortVolumeInput").unwrap();
let gyleWortVolumeInputBuffer = gyleWortVolumeInput.get_text().expect("No input");
let finalVolume = validInput(&gyleWortVolumeInputBuffer);
let finalVolume = gyleWortVolumeInputBuffer.validInput();
let gyleOutput: &gtk::Entry = &gyleBuilderClone.get_object("gyleOutput").unwrap();
let gyleCarbonationSwitch: gtk::Switch = gyleBuilderClone.get_object("gyleCarbonationSwitch").unwrap();
let imperialOrMetric = imperialOrMetricMatch(gyleCarbonationSwitch.get_active());
let imperialOrMetric = gyleCarbonationSwitch.switchMatch();
if startingBrix < 2.57 {
gyleOutput.set_text("Enter a Starting Brix greater than 2.57");
......@@ -35,14 +35,14 @@ pub fn gyleCarbonationPrep(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 startingGravity = startingBrix.brixToGravity();
let startingPlato = startingGravity.gravityToPlato();
let finalPlato = finalGravityIdeal.gravityToPlato();
let gyleOutput: &gtk::Entry = &gyleBuilderClone.get_object("gyleOutput").unwrap();
if imperialOrMetric == imperialOrMetric::imperial {
let gyleVolume = litresToGallons((0.24 * gallonsToLitres(finalVolume) * desiredCO2Level) / (startingPlato - finalPlato));
let gyleVolume = ((0.24 * finalVolume.gallonsToLitres() * desiredCO2Level) / (startingPlato - finalPlato)).litresToGallons();
let total = format!("{:.2} gallons", gyleVolume);
gyleOutput.set_text(&total);
} else if imperialOrMetric == imperialOrMetric::metric {
......
......@@ -2,18 +2,23 @@ use gtk;
use gtk::prelude::*;
use functions::commonFunctions::*;
struct increaseABVData <'a> {
startingBrix: f64,
desiredABV: f64,
desiredWortVolume: f64,
imperialOrMetric: imperialOrMetric,
increaseABVBuilder: &'a gtk::Builder,
}
pub fn increaseABVPrep(increaseABVBuilderClone: &gtk::Builder) {
let increaseABVBrixInput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVBrixInput").unwrap();
let increaseABVBrixInputBuffer = increaseABVBrixInput.get_text().expect("No input");
let startingBrix = validInput(&increaseABVBrixInputBuffer);
let increaseABVABVInput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVABVInput").unwrap();
let increaseABVABVInputBuffer = increaseABVABVInput.get_text().expect("No input");
let desiredABV = validInput(&increaseABVABVInputBuffer);
let increaseABVVolumeInput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVVolumeInput").unwrap();
let increaseABVVolumeInputBuffer = increaseABVVolumeInput.get_text().expect("No input");
let desiredWortVolume = validInput(&increaseABVVolumeInputBuffer);
let increaseABVNewBrixOutput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVNewBrixOutput").unwrap();
let increaseABVSugarAddOutput: gtk::Entry = increaseABVBuilderClone.get_object("increaseABVSugarAddOutput").unwrap();
......@@ -21,55 +26,61 @@ pub fn increaseABVPrep(increaseABVBuilderClone: &gtk::Builder) {
let increaseABVSwitch: &gtk::Switch = &increaseABVBuilderClone.get_object("increaseABVSwitch").unwrap();
let imperialOrMetric = imperialOrMetricMatch(increaseABVSwitch.get_active());
let allInputs = increaseABVData {
startingBrix: increaseABVBrixInputBuffer.validInput(),
desiredABV: increaseABVABVInputBuffer.validInput(),
desiredWortVolume: increaseABVVolumeInputBuffer.validInput(),
imperialOrMetric: increaseABVSwitch.switchMatch(),
increaseABVBuilder: increaseABVBuilderClone,
};
if startingBrix < 2.57 {
if allInputs.startingBrix < 2.57 {
increaseABVNewBrixOutput.set_text("Enter a brix greater than 2.57");
increaseABVSugarAddOutput.set_text("");
increaseABVHoneyAddOutput.set_text("");
} else if startingBrix > 49.48 {
} else if allInputs.startingBrix > 49.48 {
increaseABVNewBrixOutput.set_text("Enter a brix less than 49.48");
increaseABVSugarAddOutput.set_text("");
increaseABVHoneyAddOutput.set_text("");
} else if startingBrix == 0.0 || desiredABV == 0.0 || desiredWortVolume == 0.0 {
} else if allInputs.startingBrix == 0.0 || allInputs.desiredABV == 0.0 || allInputs.desiredWortVolume == 0.0 {
increaseABVNewBrixOutput.set_text("Enter all 3 inputs");
increaseABVSugarAddOutput.set_text("");
increaseABVHoneyAddOutput.set_text("");
} else if desiredABV <= 0.0 || desiredWortVolume <= 0.0 {
} else if allInputs.desiredABV <= 0.0 || allInputs.desiredWortVolume <= 0.0 {
increaseABVNewBrixOutput.set_text("Enter a positive number");
increaseABVSugarAddOutput.set_text("");
increaseABVHoneyAddOutput.set_text("");
} else {
differenceBrixMaths(startingBrix