Commit 5bc0d967 authored by Meade's avatar Meade

Added version 6.2.0. Annotated types to all variables. Cleaned up logic in...

Added version 6.2.0. Annotated types to all variables. Cleaned up logic in realABVFormatting(). Updated tests.
parent e393f718
## New In 6.2.0
* * Annotated types to all variables
* * Cleaned up unnecessary logic in `realABVFormatting()`
* * Updated tests to include all logic cases
## New In 6.1.0
* * Made use lines explicit
* * Fixed strict floating point comparisons
......
[[package]]
name = "BrewStillery"
version = "6.1.0"
version = "6.2.0"
dependencies = [
"gdk 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
......
[package]
name = "BrewStillery"
version = "6.1.0"
version = "6.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,10 +4,10 @@ It has a multitude of great functions, such as calculating ABV, determining carb
Written in Rust, using GTK3
## New In 6.1.0
* * Made use lines explicit
* * Fixed strict floating point comparisons
* * Changed `.validInput()` to return NAN instead of 0.0. Also changed all logic to use `.is_nan()` to match.
## New In 6.2.0
* * Annotated types to all variables
* * Cleaned up unnecessary logic in `realABVFormatting()`
* * Updated tests to include all logic cases
## Full Changelog
* [Available Here](CHANGELOG.md)
......
......@@ -4,27 +4,27 @@ use functions::commonFunctions::{imperialOrMetric, inputMatching, singleInput};
pub fn champagneCarbonationPrep(champagneCarbonationBuilder: &gtk::Builder) {
let champagneCarbonationVolume: gtk::Entry = champagneCarbonationBuilder.get_object("champagneCarbonationVolume").expect("champagneCarbonationPrep(), champagneCarbonationVolume");
let champagneCarbonationVolumeBuffer = champagneCarbonationVolume.get_text().expect("champagneCarbonationPrep(), champagneCarbonationVolumeBuffer");
let champagneVolume = champagneCarbonationVolumeBuffer.validInput();
let champagneCarbonationVolumeBuffer: String = champagneCarbonationVolume.get_text().expect("champagneCarbonationPrep(), champagneCarbonationVolumeBuffer");
let champagneVolume: f64 = champagneCarbonationVolumeBuffer.validInput();
let champagneCarbonationSugar: gtk::Entry = champagneCarbonationBuilder.get_object("champagneCarbonationSugar").expect("champagneCarbonationPrep(), champagneCarbonationSugar");
let champagneCarbonationUnits: gtk::ComboBoxText = champagneCarbonationBuilder.get_object("champagneCarbonationUnits").expect("champagneCarbonationPrep(), champagneCarbonationUnits");
let champagneCarbonationUnitsBuffer = champagneCarbonationUnits.get_active_id().expect("champagneCarbonationPrep(), champagneCarbonationUnitsBuffer");
let imperialOrMetric = champagneCarbonationUnitsBuffer.unitMatch();
let champagneCarbonationUnitsBuffer: String = champagneCarbonationUnits.get_active_id().expect("champagneCarbonationPrep(), champagneCarbonationUnitsBuffer");
let imperialOrMetric: imperialOrMetric = champagneCarbonationUnitsBuffer.unitMatch();
if champagneVolume.is_nan() {
champagneCarbonationSugar.set_text("Enter a number");
} else if champagneVolume <= 0.0 {
champagneCarbonationSugar.set_text("Enter a positive number");
} else {
let totalSugar = champagneCarbonationMaths(champagneVolume, imperialOrMetric);
let totalSugar: f64 = champagneCarbonationMaths(champagneVolume, imperialOrMetric);
champagneOutput(totalSugar, imperialOrMetric, champagneCarbonationBuilder)
}
}
pub fn champagneCarbonationMaths(champagneVolume: f64, imperialOrMetric: imperialOrMetric) -> f64 {
let mut totalSugar = 0.0;
let mut totalSugar: f64 = 0.0;
if imperialOrMetric == imperialOrMetric::imperialGB {
totalSugar = champagneVolume.gallonsGBToGallonsUS().volumeToSugarChampagne();
......@@ -38,7 +38,7 @@ pub fn champagneCarbonationMaths(champagneVolume: f64, imperialOrMetric: imperia
}
pub fn champagneCarbonationFormatting(totalSugar: f64, imperialOrMetric: imperialOrMetric) -> String {
let mut sugar = String::from("");
let mut sugar: String = String::from("");
if imperialOrMetric == imperialOrMetric::imperialGB || imperialOrMetric == imperialOrMetric::imperialUS {
if totalSugar < 0.995 {
......@@ -68,7 +68,7 @@ pub fn champagneCarbonationFormatting(totalSugar: f64, imperialOrMetric: imperia
fn champagneOutput(totalSugar: f64, imperialOrMetric: imperialOrMetric, champagneCarbonationBuilder: &gtk::Builder) {
let champagneCarbonationSugar: gtk::Entry = champagneCarbonationBuilder.get_object("champagneCarbonationSugar").expect("champagneCarbonationPrep(), champagneCarbonationSugar");
let sugar = champagneCarbonationFormatting(totalSugar, imperialOrMetric);
let sugar: String = champagneCarbonationFormatting(totalSugar, imperialOrMetric);
champagneCarbonationSugar.set_text(&sugar);
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ pub trait allOverlays {
impl allOverlays for gtk::Builder {
fn new(&self) -> colourOverlay {
let allOverlays = colourOverlay {
let allOverlays: colourOverlay = colourOverlay {
overlay: self.get_object("grainABVColourOverlay").expect("commonFunctions, allOverlays"),
colourOutput: gtk::ColorButton::new(),
dimplePint: gtk::Image::new_from_file("/usr/share/BrewStillery/glassware/Dimple.png"),
......@@ -239,28 +239,28 @@ pub fn realIBU(brix: f64, wortVolume: f64, alphaAcid: f64, hopAmount: f64, boilT
pub fn realABVAndAttenuation(startingBrix: f64, finalBrix: f64) -> (f64, f64) {
let wortCorrectionFactor: f64 = 1.040;
let initialRefractiveIndex = startingBrix / wortCorrectionFactor;
let finalRefractiveIndex = finalBrix / wortCorrectionFactor;
let initialRefractiveIndex: f64 = startingBrix / wortCorrectionFactor;
let finalRefractiveIndex: f64 = finalBrix / wortCorrectionFactor;
let newCubic = (1.0 - 0.0044992999999999995 * initialRefractiveIndex) + (0.0117741 * finalRefractiveIndex) + (0.000275806 * initialRefractiveIndex.powi(2)) - (0.00127169 * finalRefractiveIndex.powi(2)) - (7.27999e-06 * initialRefractiveIndex.powi(3)) + (6.32929e-05 * finalRefractiveIndex.powi(3));
let newCubic: f64 = (1.0 - 0.0044992999999999995 * initialRefractiveIndex) + (0.0117741 * finalRefractiveIndex) + (0.000275806 * initialRefractiveIndex.powi(2)) - (0.00127169 * finalRefractiveIndex.powi(2)) - (7.27999e-06 * initialRefractiveIndex.powi(3)) + (6.32929e-05 * finalRefractiveIndex.powi(3));
let apparentAttenuation = 1.0 - (0.18080000000000002 * (668.72 * newCubic - 463.37 - 205.347 * newCubic.powi(2)) + 0.8192 * (668.72 * newCubic - 463.37 - 205.347 * newCubic.powi(2))) / (initialRefractiveIndex);
let apparentAttenuation: f64 = 1.0 - (0.18080000000000002 * (668.72 * newCubic - 463.37 - 205.347 * newCubic.powi(2)) + 0.8192 * (668.72 * newCubic - 463.37 - 205.347 * newCubic.powi(2))) / (initialRefractiveIndex);
let attenuation = apparentAttenuation * 0.8192 * 100.0;
let attenuation: f64 = apparentAttenuation * 0.8192 * 100.0;
let abv = ((0.01 / 0.8192) * (initialRefractiveIndex - (0.18080000000000002 * initialRefractiveIndex + 0.8192 * (668.72 * newCubic - 463.37 - 205.347 * newCubic.powi(2)))) / (2.0665-0.010665 * initialRefractiveIndex)) * 100.0;
let abv: f64 = ((0.01 / 0.8192) * (initialRefractiveIndex - (0.18080000000000002 * initialRefractiveIndex + 0.8192 * (668.72 * newCubic - 463.37 - 205.347 * newCubic.powi(2)))) / (2.0665-0.010665 * initialRefractiveIndex)) * 100.0;
(abv, attenuation)
}
pub fn grainToGravity(volumeInGallonsUS: f64, weightInPounds: f64, grainGravity: f64) -> f64 {
let extractPotential = grainGravity.fract() * 1000.0;
let extractionEfficiency = 0.57;
let extractPotential: f64 = grainGravity.fract() * 1000.0;
let extractionEfficiency: f64 = 0.57;
// sane default here of 57%
let mut originalGravity = 1.0;
let mut originalGravity: f64 = 1.0;
// set to the gravity of water
let specificGravityPoints = (weightInPounds * extractPotential * extractionEfficiency) / volumeInGallonsUS;
let specificGravityPoints: f64 = (weightInPounds * extractPotential * extractionEfficiency) / volumeInGallonsUS;
if specificGravityPoints != 0.0 {
originalGravity = specificGravityPoints / 1000.0 + 1.0;
......
......@@ -46,57 +46,57 @@ pub struct grainABVData {
pub fn grainToABVPrep(allOverlays: &colourOverlay, grainABVBuilder: &gtk::Builder) {
let grainABVWortVolume: gtk::Entry = grainABVBuilder.get_object("grainABVWortVolume").expect("grainToABVPrep(), grainABVWortVolume");
let grainABVWortVolumeBuffer = grainABVWortVolume.get_text().expect("grainToABVPrep(), grainABVWortVolumeBuffer");
let grainABVWortVolumeBuffer: String = grainABVWortVolume.get_text().expect("grainToABVPrep(), grainABVWortVolumeBuffer");
let grainABVFirstAmount: gtk::Entry = grainABVBuilder.get_object("grainABVFirstAmount").expect("grainToABVPrep(), grainABVFirstAmount");
let grainABVFirstAmountBuffer = grainABVFirstAmount.get_text().expect("grainToABVPrep(), grainABVFirstAmountBuffer");
let grainABVFirstAmountBuffer: String = grainABVFirstAmount.get_text().expect("grainToABVPrep(), grainABVFirstAmountBuffer");
let grainABVFirstType: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVFirstType").expect("grainToABVPrep(), grainABVFirstType");
let grainABVFirstTypeBuffer = grainABVFirstType.get_active_id().expect("grainToABVPrep(), grainABVFirstTypeBuffer");
let grainABVFirstTypeBuffer: String = grainABVFirstType.get_active_id().expect("grainToABVPrep(), grainABVFirstTypeBuffer");
let grainABVSecondAmount: gtk::Entry = grainABVBuilder.get_object("grainABVSecondAmount").expect("grainToABVPrep(), grainABVSecondAmount");
let grainABVSecondAmountBuffer = grainABVSecondAmount.get_text().expect("grainToABVPrep(), grainABVSecondAmountBuffer");
let grainABVSecondAmountBuffer: String = grainABVSecondAmount.get_text().expect("grainToABVPrep(), grainABVSecondAmountBuffer");
let grainABVSecondType: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVSecondType").expect("grainToABVPrep(), grainABVSecondType");
let grainABVSecondTypeBuffer = grainABVSecondType.get_active_id().expect("grainToABVPrep(), grainABVSecondTypeBuffer");
let grainABVSecondTypeBuffer: String = grainABVSecondType.get_active_id().expect("grainToABVPrep(), grainABVSecondTypeBuffer");
let grainABVThirdAmount: gtk::Entry = grainABVBuilder.get_object("grainABVThirdAmount").expect("grainToABVPrep(), grainABVThirdAmount");
let grainABVThirdAmountBuffer = grainABVThirdAmount.get_text().expect("grainToABVPrep(), grainABVThirdAmountBuffer");
let grainABVThirdAmountBuffer: String = grainABVThirdAmount.get_text().expect("grainToABVPrep(), grainABVThirdAmountBuffer");
let grainABVThirdType: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVThirdType").expect("grainToABVPrep(), grainABVThirdType");
let grainABVThirdTypeBuffer = grainABVThirdType.get_active_id().expect("grainToABVPrep(), grainABVThirdTypeBuffer");
let grainABVThirdTypeBuffer: String = grainABVThirdType.get_active_id().expect("grainToABVPrep(), grainABVThirdTypeBuffer");
let grainABVFourthAmount: gtk::Entry = grainABVBuilder.get_object("grainABVFourthAmount").expect("grainToABVPrep(), grainABVFourthAmount");
let grainABVFourthAmountBuffer = grainABVFourthAmount.get_text().expect("grainToABVPrep(), grainABVFourthAmountBuffer");
let grainABVFourthAmountBuffer: String = grainABVFourthAmount.get_text().expect("grainToABVPrep(), grainABVFourthAmountBuffer");
let grainABVFourthType: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVFourthType").expect("grainToABVPrep(), grainABVFourthType");
let grainABVFourthTypeBuffer = grainABVFourthType.get_active_id().expect("grainToABVPrep(), grainABVFourthTypeBuffer");
let grainABVFourthTypeBuffer: String = grainABVFourthType.get_active_id().expect("grainToABVPrep(), grainABVFourthTypeBuffer");
let grainABVFifthAmount: gtk::Entry = grainABVBuilder.get_object("grainABVFifthAmount").expect("grainToABVPrep(), grainABVFifthAmount");
let grainABVFifthAmountBuffer = grainABVFifthAmount.get_text().expect("grainToABVPrep(), grainABVFifthAmountBuffer");
let grainABVFifthAmountBuffer: String = grainABVFifthAmount.get_text().expect("grainToABVPrep(), grainABVFifthAmountBuffer");
let grainABVFifthType: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVFifthType").expect("grainToABVPrep(), grainABVFifthType");
let grainABVFifthTypeBuffer = grainABVFifthType.get_active_id().expect("grainToABVPrep(), grainABVFifthTypeBuffer");
let grainABVFifthTypeBuffer: String = grainABVFifthType.get_active_id().expect("grainToABVPrep(), grainABVFifthTypeBuffer");
let grainABVSixthAmount: gtk::Entry = grainABVBuilder.get_object("grainABVSixthAmount").expect("grainToABVPrep(), grainABVSixthAmount");
let grainABVSixthAmountBuffer = grainABVSixthAmount.get_text().expect("grainToABVPrep(), grainABVSixthAmountBuffer");
let grainABVSixthAmountBuffer: String = grainABVSixthAmount.get_text().expect("grainToABVPrep(), grainABVSixthAmountBuffer");
let grainABVSixthType: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVSixthType").expect("grainToABVPrep(), grainABVSixthType");
let grainABVSixthTypeBuffer = grainABVSixthType.get_active_id().expect("grainToABVPrep(), grainABVSixthTypeBuffer");
let grainABVSixthTypeBuffer: String = grainABVSixthType.get_active_id().expect("grainToABVPrep(), grainABVSixthTypeBuffer");
let grainABVSeventhAmount: gtk::Entry = grainABVBuilder.get_object("grainABVSeventhAmount").expect("grainToABVPrep(), grainABVSeventhAmount");
let grainABVSeventhAmountBuffer = grainABVSeventhAmount.get_text().expect("grainToABVPrep(), grainABVSeventhAmountBuffer");
let grainABVSeventhAmountBuffer: String = grainABVSeventhAmount.get_text().expect("grainToABVPrep(), grainABVSeventhAmountBuffer");
let grainABVSeventhType: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVSeventhType").expect("grainToABVPrep(), grainABVSeventhType");
let grainABVSeventhTypeBuffer = grainABVSeventhType.get_active_id().expect("grainToABVPrep(), grainABVSeventhTypeBuffer");
let grainABVSeventhTypeBuffer: String = grainABVSeventhType.get_active_id().expect("grainToABVPrep(), grainABVSeventhTypeBuffer");
let grainABVGlassSize: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVGlassSize").expect("grainToABVPrep(), grainABVGlassSize");
let grainABVGlassSizeBuffer = grainABVGlassSize.get_active_id().expect("grainToABVPrep(), grainABVGlassSizeBuffer");
let grainABVGlassSizeBuffer: String = grainABVGlassSize.get_active_id().expect("grainToABVPrep(), grainABVGlassSizeBuffer");
let grainABVUnits: gtk::ComboBoxText = grainABVBuilder.get_object("grainABVUnits").expect("grainToABVPrep(), grainABVUnits");
let grainABVUnitsBuffer = grainABVUnits.get_active_id().expect("grainToABVPrep(), grainABVUnitsBuffer");
let grainABVUnitsBuffer: String = grainABVUnits.get_active_id().expect("grainToABVPrep(), grainABVUnitsBuffer");
let allInputs = grainABVData {
let allInputs: grainABVData = grainABVData {
wortAmount: grainABVWortVolumeBuffer.validInput(),
firstGrainAmount: grainABVFirstAmountBuffer.validInput(),
firstGrainGravity: grainABVFirstTypeBuffer.grainGravity(),
......@@ -244,7 +244,7 @@ pub fn grainToABVMaths(allInputs: &mut grainABVData) -> &mut grainABVData {
if allInputs.totalGrain5.is_nan() { allInputs.totalGrain5 = 0.0; }
if allInputs.totalGrain6.is_nan() { allInputs.totalGrain6 = 0.0; }
if allInputs.totalGrain7.is_nan() { allInputs.totalGrain7 = 0.0; }
let grainSum = 1.0 + allInputs.totalGrain1.fract() + allInputs.totalGrain2.fract() + allInputs.totalGrain3.fract() + allInputs.totalGrain4.fract() + allInputs.totalGrain5.fract() + allInputs.totalGrain6.fract() + allInputs.totalGrain7.fract();
let grainSum: f64 = 1.0 + allInputs.totalGrain1.fract() + allInputs.totalGrain2.fract() + allInputs.totalGrain3.fract() + allInputs.totalGrain4.fract() + allInputs.totalGrain5.fract() + allInputs.totalGrain6.fract() + allInputs.totalGrain7.fract();
allInputs.startingBrix = grainSum.gravityToBrix();
allInputs.abvFinal = realABVAndAttenuation(allInputs.startingBrix, FINAL_BRIX_IDEAL).0;
} else if allInputs.imperialOrMetric == imperialOrMetric::imperialUS {
......@@ -261,7 +261,7 @@ pub fn grainToABVMaths(allInputs: &mut grainABVData) -> &mut grainABVData {
if allInputs.totalGrain5.is_nan() { allInputs.totalGrain5 = 0.0; }
if allInputs.totalGrain6.is_nan() { allInputs.totalGrain6 = 0.0; }
if allInputs.totalGrain7.is_nan() { allInputs.totalGrain7 = 0.0; }
let grainSum = 1.0 + allInputs.totalGrain1.fract() + allInputs.totalGrain2.fract() + allInputs.totalGrain3.fract() + allInputs.totalGrain4.fract() + allInputs.totalGrain5.fract() + allInputs.totalGrain6.fract() + allInputs.totalGrain7.fract();
let grainSum: f64 = 1.0 + allInputs.totalGrain1.fract() + allInputs.totalGrain2.fract() + allInputs.totalGrain3.fract() + allInputs.totalGrain4.fract() + allInputs.totalGrain5.fract() + allInputs.totalGrain6.fract() + allInputs.totalGrain7.fract();
allInputs.startingBrix = grainSum.gravityToBrix();
allInputs.abvFinal = realABVAndAttenuation(allInputs.startingBrix, FINAL_BRIX_IDEAL).0;
} else if allInputs.imperialOrMetric == imperialOrMetric::metric {
......@@ -278,7 +278,7 @@ pub fn grainToABVMaths(allInputs: &mut grainABVData) -> &mut grainABVData {
if allInputs.totalGrain5.is_nan() { allInputs.totalGrain5 = 0.0; }
if allInputs.totalGrain6.is_nan() { allInputs.totalGrain6 = 0.0; }
if allInputs.totalGrain7.is_nan() { allInputs.totalGrain7 = 0.0; }
let grainSum = 1.0 + allInputs.totalGrain1.fract() + allInputs.totalGrain2.fract() + allInputs.totalGrain3.fract() + allInputs.totalGrain4.fract() + allInputs.totalGrain5.fract() + allInputs.totalGrain6.fract() + allInputs.totalGrain7.fract();
let grainSum: f64 = 1.0 + allInputs.totalGrain1.fract() + allInputs.totalGrain2.fract() + allInputs.totalGrain3.fract() + allInputs.totalGrain4.fract() + allInputs.totalGrain5.fract() + allInputs.totalGrain6.fract() + allInputs.totalGrain7.fract();
allInputs.startingBrix = grainSum.gravityToBrix();
allInputs.abvFinal = realABVAndAttenuation(allInputs.startingBrix, FINAL_BRIX_IDEAL).0;
}
......@@ -296,13 +296,13 @@ pub fn grainToABVFormatting(allInputs: &mut grainABVData) -> &mut grainABVData {
}
pub fn grainToABVColour(allInputs: &grainABVData) -> RGBA {
let singleMCU1 = singleMCU(allInputs.wortAmount, allInputs.firstGrainAmount, allInputs.firstGrainLovibond);
let mut singleMCU2 = 0.0;
let mut singleMCU3 = 0.0;
let mut singleMCU4 = 0.0;
let mut singleMCU5 = 0.0;
let mut singleMCU6 = 0.0;
let mut singleMCU7 = 0.0;
let singleMCU1: f64 = singleMCU(allInputs.wortAmount, allInputs.firstGrainAmount, allInputs.firstGrainLovibond);
let mut singleMCU2: f64 = 0.0;
let mut singleMCU3: f64 = 0.0;
let mut singleMCU4: f64 = 0.0;
let mut singleMCU5: f64 = 0.0;
let mut singleMCU6: f64 = 0.0;
let mut singleMCU7: f64 = 0.0;
if !allInputs.secondGrainAmount.is_nan() {
singleMCU2 = singleMCU(allInputs.wortAmount, allInputs.secondGrainAmount, allInputs.secondGrainLovibond);
}
......@@ -327,8 +327,8 @@ pub fn grainToABVColour(allInputs: &grainABVData) -> RGBA {
singleMCU7 = singleMCU(allInputs.wortAmount, allInputs.seventhGrainAmount, allInputs.seventhGrainLovibond);
}
let totalMCU = singleMCU1 + singleMCU2 + singleMCU3 + singleMCU4 + singleMCU5 + singleMCU6 + singleMCU7;
let beerSRM = beerSRM(totalMCU);
let totalMCU: f64 = singleMCU1 + singleMCU2 + singleMCU3 + singleMCU4 + singleMCU5 + singleMCU6 + singleMCU7;
let beerSRM: f64 = beerSRM(totalMCU);
let (lOut, aOut, bOut) = grainSRMToLAB(allInputs.glassSize, beerSRM);
let (xOut, yOut, zOut) = grainLABToXYZ(lOut, aOut, bOut);
let rgbaOutput: RGBA = if allInputs.abvFinal > 26.0 || allInputs.abvFinal <= 0.0 {
......@@ -346,7 +346,7 @@ fn grainToABVOutput(mut allInputs: grainABVData, allOverlays: &colourOverlay, gr
grainToABVMaths(&mut allInputs);
grainToABVFormatting(&mut allInputs);
let rgbaOutput = grainToABVColour(&allInputs);
let rgbaOutput: RGBA = grainToABVColour(&allInputs);
grainABVFinalBrix.set_text(&allInputs.estimatedBrixFormatted);
grainABVFinalABV.set_text(&allInputs.abvFormatted);
......
......@@ -4,8 +4,8 @@ use functions::commonFunctions::{inputMatching, realABVAndAttenuation, FINAL_BRI
pub fn guestimateABVPrep(guestimatorBuilder: &gtk::Builder) {
let guestimatorStartingBrix: gtk::Entry = guestimatorBuilder.get_object("guestimatorStartingBrix").expect("guestimateABVPrep(), guestimatorStartingBrix");
let guestimatorStartingBrixBuffer = guestimatorStartingBrix.get_text().expect("guestimateABVPrep(), guestimatorStartingBrixBuffer");
let startingBrix = guestimatorStartingBrixBuffer.validInput();
let guestimatorStartingBrixBuffer: String = guestimatorStartingBrix.get_text().expect("guestimateABVPrep(), guestimatorStartingBrixBuffer");
let startingBrix: f64 = guestimatorStartingBrixBuffer.validInput();
let guestimatorTemporaryOutput: gtk::Entry = guestimatorBuilder.get_object("guestimatorABV").expect("guestimateABVPrep(), guestimatorTemporaryOutput");
if startingBrix.is_nan() {
......@@ -20,14 +20,14 @@ pub fn guestimateABVPrep(guestimatorBuilder: &gtk::Builder) {
}
pub fn guestimateABVFormatting(startingBrix: f64) -> String {
let finalABV = format!("{:.2}%", realABVAndAttenuation(startingBrix, FINAL_BRIX_IDEAL).0);
let finalABV: String = format!("{:.2}%", realABVAndAttenuation(startingBrix, FINAL_BRIX_IDEAL).0);
finalABV
}
fn guestimateABVOutput(startingBrix: f64, guestimatorBuilder: &gtk::Builder) {
let guestimatorABV: gtk::Entry = guestimatorBuilder.get_object("guestimatorABV").expect("guestimateABVOutput(), guestimatorABV");
let finalABV = guestimateABVFormatting(startingBrix);
let finalABV: String = guestimateABVFormatting(startingBrix);
guestimatorABV.set_text(&finalABV);
}
\ No newline at end of file
......@@ -39,78 +39,78 @@ pub struct guestimateIBUData {
pub fn guestimateIBUPrep(IBUBuilder: &gtk::Builder) {
let totalIBUPreBoilBrix: gtk::Entry = IBUBuilder.get_object("totalIBUPreBoilBrix").expect("guestimateIBUPrep(), totalIBUPreBoilBrix");
let totalIBUPreBoilBrixBuffer = totalIBUPreBoilBrix.get_text().expect("guestimateIBUPrep(), totalIBUPreBoilBrixBuffer");
let totalIBUPreBoilBrixBuffer: String = totalIBUPreBoilBrix.get_text().expect("guestimateIBUPrep(), totalIBUPreBoilBrixBuffer");
let totalIBUWortVolume: gtk::Entry = IBUBuilder.get_object("totalIBUWortVolume").expect("guestimateIBUPrep(), totalIBUWortVolume");
let totalIBUWortVolumeBuffer = totalIBUWortVolume.get_text().expect("guestimateIBUPrep(), totalIBUWortVolumeBuffer");
let totalIBUWortVolumeBuffer: String = totalIBUWortVolume.get_text().expect("guestimateIBUPrep(), totalIBUWortVolumeBuffer");
let totalIBUFirstHopAlpha: gtk::Entry = IBUBuilder.get_object("totalIBUFirstHopAlpha").expect("guestimateIBUPrep(), totalIBUFirstHopAlpha");
let totalIBUFirstHopAlphaBuffer = totalIBUFirstHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUFirstHopAlphaBuffer");
let totalIBUFirstHopAlphaBuffer: String = totalIBUFirstHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUFirstHopAlphaBuffer");
let totalIBUFirstHopAmount: gtk::Entry = IBUBuilder.get_object("totalIBUFirstHopAmount").expect("guestimateIBUPrep(), totalIBUFirstHopAmount");
let totalIBUFirstHopAmountBuffer = totalIBUFirstHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUFirstHopAmountBuffer");
let totalIBUFirstHopAmountBuffer: String = totalIBUFirstHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUFirstHopAmountBuffer");
let totalIBUFirstHopBoilTime: gtk::Entry = IBUBuilder.get_object("totalIBUFirstHopBoilTime").expect("guestimateIBUPrep(), totalIBUFirstHopBoilTime");
let totalIBUFirstHopBoilTimeBuffer = totalIBUFirstHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUFirstHopBoilTimeBuffer");
let totalIBUFirstHopBoilTimeBuffer: String = totalIBUFirstHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUFirstHopBoilTimeBuffer");
let totalIBUSecondHopAlpha: gtk::Entry = IBUBuilder.get_object("totalIBUSecondHopAlpha").expect("guestimateIBUPrep(), totalIBUSecondHopAlpha");
let totalIBUSecondHopAlphaBuffer = totalIBUSecondHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUSecondHopAlphaBuffer");
let totalIBUSecondHopAlphaBuffer: String = totalIBUSecondHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUSecondHopAlphaBuffer");
let totalIBUSecondHopAmount: gtk::Entry = IBUBuilder.get_object("totalIBUSecondHopAmount").expect("guestimateIBUPrep(), totalIBUSecondHopAmount");
let totalIBUSecondHopAmountBuffer = totalIBUSecondHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUSecondHopAmountBuffer");
let totalIBUSecondHopAmountBuffer: String = totalIBUSecondHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUSecondHopAmountBuffer");
let totalIBUSecondHopBoilTime: gtk::Entry = IBUBuilder.get_object("totalIBUSecondHopBoilTime").expect("guestimateIBUPrep(), totalIBUSecondHopBoilTime");
let totalIBUSecondHopBoilTimeBuffer = totalIBUSecondHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUSecondHopBoilTimeBuffer");
let totalIBUSecondHopBoilTimeBuffer: String = totalIBUSecondHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUSecondHopBoilTimeBuffer");
let totalIBUThirdHopAlpha: gtk::Entry = IBUBuilder.get_object("totalIBUThirdHopAlpha").expect("guestimateIBUPrep(), totalIBUThirdHopAlpha");
let totalIBUThirdHopAlphaBuffer = totalIBUThirdHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUThirdHopAlphaBuffer");
let totalIBUThirdHopAlphaBuffer: String = totalIBUThirdHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUThirdHopAlphaBuffer");
let totalIBUThirdHopAmount: gtk::Entry = IBUBuilder.get_object("totalIBUThirdHopAmount").expect("guestimateIBUPrep(), totalIBUThirdHopAmount");
let totalIBUThirdHopAmountBuffer = totalIBUThirdHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUThirdHopAmountBuffer");
let totalIBUThirdHopAmountBuffer: String = totalIBUThirdHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUThirdHopAmountBuffer");
let totalIBUThirdHopBoilTime: gtk::Entry = IBUBuilder.get_object("totalIBUThirdHopBoilTime").expect("guestimateIBUPrep(), totalIBUThirdHopBoilTime");
let totalIBUThirdHopBoilTimeBuffer = totalIBUThirdHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUThirdHopBoilTimeBuffer");
let totalIBUThirdHopBoilTimeBuffer: String = totalIBUThirdHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUThirdHopBoilTimeBuffer");
let totalIBUFourthHopAlpha: gtk::Entry = IBUBuilder.get_object("totalIBUFourthHopAlpha").expect("guestimateIBUPrep(), totalIBUFourthHopAlpha");
let totalIBUFourthHopAlphaBuffer = totalIBUFourthHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUFourthHopAlphaBuffer");
let totalIBUFourthHopAlphaBuffer: String = totalIBUFourthHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUFourthHopAlphaBuffer");
let totalIBUFourthHopAmount: gtk::Entry = IBUBuilder.get_object("totalIBUFourthHopAmount").expect("guestimateIBUPrep(), totalIBUFourthHopAmount");
let totalIBUFourthHopAmountBuffer = totalIBUFourthHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUFourthHopAmountBuffer");
let totalIBUFourthHopAmountBuffer: String = totalIBUFourthHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUFourthHopAmountBuffer");
let totalIBUFourthHopBoilTime: gtk::Entry = IBUBuilder.get_object("totalIBUFourthHopBoilTime").expect("guestimateIBUPrep(), totalIBUFourthHopBoilTime");
let totalIBUFourthHopBoilTimeBuffer = totalIBUFourthHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUFourthHopBoilTimeBuffer");
let totalIBUFourthHopBoilTimeBuffer: String = totalIBUFourthHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUFourthHopBoilTimeBuffer");
let totalIBUFifthHopAlpha: gtk::Entry = IBUBuilder.get_object("totalIBUFifthHopAlpha").expect("guestimateIBUPrep(), totalIBUFifthHopAlpha");
let totalIBUFifthHopAlphaBuffer = totalIBUFifthHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUFifthHopAlphaBuffer");
let totalIBUFifthHopAlphaBuffer: String = totalIBUFifthHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUFifthHopAlphaBuffer");
let totalIBUFifthHopAmount: gtk::Entry = IBUBuilder.get_object("totalIBUFifthHopAmount").expect("guestimateIBUPrep(), totalIBUFifthHopAmount");
let totalIBUFifthHopAmountBuffer = totalIBUFifthHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUFifthHopAmountBuffer");
let totalIBUFifthHopAmountBuffer: String = totalIBUFifthHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUFifthHopAmountBuffer");
let totalIBUFifthHopBoilTime: gtk::Entry = IBUBuilder.get_object("totalIBUFifthHopBoilTime").expect("guestimateIBUPrep(), totalIBUFifthHopBoilTime");
let totalIBUFifthHopBoilTimeBuffer = totalIBUFifthHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUFifthHopBoilTimeBuffer");
let totalIBUFifthHopBoilTimeBuffer: String = totalIBUFifthHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUFifthHopBoilTimeBuffer");
let totalIBUSixthHopAlpha: gtk::Entry = IBUBuilder.get_object("totalIBUSixthHopAlpha").expect("guestimateIBUPrep(), totalIBUSixthHopAlpha");
let totalIBUSixthHopAlphaBuffer = totalIBUSixthHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUSixthHopAlphaBuffer");
let totalIBUSixthHopAlphaBuffer: String = totalIBUSixthHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUSixthHopAlphaBuffer");
let totalIBUSixthHopAmount: gtk::Entry = IBUBuilder.get_object("totalIBUSixthHopAmount").expect("guestimateIBUPrep(), totalIBUSixthHopAmount");
let totalIBUSixthHopAmountBuffer = totalIBUSixthHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUSixthHopAmountBuffer");
let totalIBUSixthHopAmountBuffer: String = totalIBUSixthHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUSixthHopAmountBuffer");
let totalIBUSixthHopBoilTime: gtk::Entry = IBUBuilder.get_object("totalIBUSixthHopBoilTime").expect("guestimateIBUPrep(), totalIBUSixthHopBoilTime");
let totalIBUSixthHopBoilTimeBuffer = totalIBUSixthHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUSixthHopBoilTimeBuffer");
let totalIBUSixthHopBoilTimeBuffer: String = totalIBUSixthHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUSixthHopBoilTimeBuffer");
let totalIBUSeventhHopAlpha: gtk::Entry = IBUBuilder.get_object("totalIBUSeventhHopAlpha").expect("guestimateIBUPrep(), totalIBUSeventhHopAlpha");
let totalIBUSeventhHopAlphaBuffer = totalIBUSeventhHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUSeventhHopAlphaBuffer");
let totalIBUSeventhHopAlphaBuffer: String = totalIBUSeventhHopAlpha.get_text().expect("guestimateIBUPrep(), totalIBUSeventhHopAlphaBuffer");
let totalIBUSeventhHopAmount: gtk::Entry = IBUBuilder.get_object("totalIBUSeventhHopAmount").expect("guestimateIBUPrep(), totalIBUSeventhHopAmount");
let totalIBUSeventhHopAmountBuffer = totalIBUSeventhHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUSeventhHopAmountBuffer");
let totalIBUSeventhHopAmountBuffer: String = totalIBUSeventhHopAmount.get_text().expect("guestimateIBUPrep(), totalIBUSeventhHopAmountBuffer");
let totalIBUSeventhHopBoilTime: gtk::Entry = IBUBuilder.get_object("totalIBUSeventhHopBoilTime").expect("guestimateIBUPrep(), totalIBUSeventhHopBoilTime");
let totalIBUSeventhHopBoilTimeBuffer = totalIBUSeventhHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUSeventhHopBoilTimeBuffer");
let totalIBUSeventhHopBoilTimeBuffer: String = totalIBUSeventhHopBoilTime.get_text().expect("guestimateIBUPrep(), totalIBUSeventhHopBoilTimeBuffer");
let totalIBUUnits: gtk::ComboBoxText = IBUBuilder.get_object("totalIBUUnits").expect("guestimateIBUPrep(), totalIBUUnits");
let totalIBUUnitsBuffer = totalIBUUnits.get_active_id().expect("guestimateIBUPrep(), totalIBUUnitsBuffer");
let totalIBUUnitsBuffer: String = totalIBUUnits.get_active_id().expect("guestimateIBUPrep(), totalIBUUnitsBuffer");
let allInputs = guestimateIBUData {
let allInputs: guestimateIBUData = guestimateIBUData {
preBoilBrix: totalIBUPreBoilBrixBuffer.validInput(),
wortVolume: totalIBUWortVolumeBuffer.validInput(),
firstHopAlpha: totalIBUFirstHopAlphaBuffer.validInput(),
......@@ -160,7 +160,7 @@ pub fn guestimateIBUPrep(IBUBuilder: &gtk::Builder) {
}
pub fn totalIBUMaths(mut allInputs: guestimateIBUData) -> f64 {
let mut finalOutputFloat = 0.0;
let mut finalOutputFloat: f64 = 0.0;
if allInputs.imperialOrMetric == imperialOrMetric::imperialGB {
allInputs.totalIBU1 = realIBU(allInputs.preBoilBrix, allInputs.wortVolume.gallonsGBToGallonsUS(), allInputs.firstHopAlpha, allInputs.firstHopAmount, allInputs.firstHopBoilTime);
......@@ -213,7 +213,7 @@ pub fn totalIBUMaths(mut allInputs: guestimateIBUData) -> f64 {
}
pub fn totalIBUFormatting(finalOutputFloat: f64) -> String {
let finalOutput;
let finalOutput: String;
if finalOutputFloat >= 0.995 && finalOutputFloat < 1.005 {
finalOutput = format!("{:.0} IBU", finalOutputFloat);
......@@ -229,8 +229,8 @@ pub fn totalIBUFormatting(finalOutputFloat: f64) -> String {
fn totalIBUOutput(allInputs: guestimateIBUData, IBUBuilder: &gtk::Builder) {
let totalIBUFinal: gtk::Entry = IBUBuilder.get_object("totalIBUFinal").expect("guestimateIBUPrep(), totalIBUFinal");
let finalOutputFloat = totalIBUMaths(allInputs);
let finalOutput = totalIBUFormatting(finalOutputFloat);
let finalOutputFloat: f64 = totalIBUMaths(allInputs);
let finalOutput: String = totalIBUFormatting(finalOutputFloat);
totalIBUFinal.set_text(&finalOutput);
}
\ No newline at end of file
......@@ -13,22 +13,22 @@ pub struct gyleData {
pub fn gyleCarbonationPrep(gyleBuilder: &gtk::Builder) {
let gyleStartingBrix: gtk::Entry = gyleBuilder.get_object("gyleStartingBrix").expect("gyleCarbonationPrep(), gyleStartingBrix");
let gyleStartingBrixBuffer = gyleStartingBrix.get_text().expect("gyleCarbonationPrep(), gyleStartingBrixBuffer");
let startingBrix = gyleStartingBrixBuffer.validInput();
let gyleStartingBrixBuffer: String = gyleStartingBrix.get_text().expect("gyleCarbonationPrep(), gyleStartingBrixBuffer");
let startingBrix: f64 = gyleStartingBrixBuffer.validInput();
let gyleDesiredCO2: gtk::Entry = gyleBuilder.get_object("gyleDesiredCO2").expect("gyleCarbonationPrep(), gyleDesiredCO2");
let gyleDesiredCO2Buffer = gyleDesiredCO2.get_text().expect("gyleCarbonationPrep(), gyleDesiredCO2Buffer");
let desiredCO2LevelTemp = gyleDesiredCO2Buffer.validInput();
let gyleDesiredCO2Buffer: String = gyleDesiredCO2.get_text().expect("gyleCarbonationPrep(), gyleDesiredCO2Buffer");
let desiredCO2LevelTemp: f64 = gyleDesiredCO2Buffer.validInput();
let gyleWortVolume: gtk::Entry = gyleBuilder.get_object("gyleWortVolume").expect("gyleCarbonationPrep(), gyleWortVolume");
let gyleWortVolumeBuffer = gyleWortVolume.get_text().expect("gyleCarbonationPrep(), gyleWortVolumeBuffer");
let finalVolumeTemp = gyleWortVolumeBuffer.validInput();
let gyleWortVolumeBuffer: String = gyleWortVolume.get_text().expect("gyleCarbonationPrep(), gyleWortVolumeBuffer");
let finalVolumeTemp: f64 = gyleWortVolumeBuffer.validInput();
let gyleTemporaryOutput: &gtk::Entry = &gyleBuilder.get_object("gyleCarbonationOutput").expect("gyleCarbonationPrep(), gyleTemporaryOutput");
let gyleCarbonationUnits: gtk::ComboBoxText = gyleBuilder.get_object("gyleCarbonationUnits").expect("gyleCarbonationPrep(), gyleCarbonationUnits");
let gyleCarbonationUnitsBuffer = gyleCarbonationUnits.get_active_id().expect("gyleCarbonationPrep(), gyleCarbonationUnitsBuffer");
let imperialOrMetric = gyleCarbonationUnitsBuffer.unitMatch();
let gyleCarbonationUnitsBuffer: String = gyleCarbonationUnits.get_active_id().expect("gyleCarbonationPrep(), gyleCarbonationUnitsBuffer");
let imperialOrMetric: imperialOrMetric = gyleCarbonationUnitsBuffer.unitMatch();
if startingBrix < 2.57 {
gyleTemporaryOutput.set_text("Enter a Starting Brix greater than 2.57");
......@@ -39,7 +39,7 @@ pub fn gyleCarbonationPrep(gyleBuilder: &gtk::Builder) {
} else if startingBrix <= 0.0 || desiredCO2LevelTemp <= 0.0 || finalVolumeTemp <= 0.0 {
gyleTemporaryOutput.set_text("Enter a positive number");
} else {
let allInputs = gyleData {
let allInputs: gyleData = gyleData {
startingGravity: startingBrix.brixToGravity(),
desiredCO2Level: desiredCO2LevelTemp,
finalVolume: finalVolumeTemp,
......@@ -62,8 +62,8 @@ pub fn gyleCarbonationVolumeUnits(allInputs: &mut gyleData) -> &mut gyleData {
}
pub fn gyleCarbonationMaths(mut allInputs: gyleData) -> gyleData {
let startingPlato = allInputs.startingGravity.gravityToPlato();
let finalPlatoIdeal = FINAL_GRAVITY_IDEAL.gravityToPlato();
let startingPlato: f64 = allInputs.startingGravity.gravityToPlato();
let finalPlatoIdeal: f64 = FINAL_GRAVITY_IDEAL.gravityToPlato();
allInputs.gyleVolumeFloat = (0.24 * allInputs.finalVolume * allInputs.desiredCO2Level) / (startingPlato - finalPlatoIdeal);
......@@ -72,11 +72,13 @@ pub fn gyleCarbonationMaths(mut allInputs: gyleData) -> gyleData {
pub fn gyleCarbonationFormatting(allInputs: gyleData) -> String {
let mut finalOutput = String::from("");
let mut finalOutput: String = String::from("");
let gyleCarbonationMathsOutput: gyleData;
let gyleVolumeFinal: f64;
if allInputs.imperialOrMetric == imperialOrMetric::imperialGB {
let gyleCarbonationMathsOutput = gyleCarbonationMaths(allInputs);
let gyleVolumeFinal = gyleCarbonationMathsOutput.gyleVolumeFloat.litresToGallonsGB();
gyleCarbonationMathsOutput = gyleCarbonationMaths(allInputs);
gyleVolumeFinal = gyleCarbonationMathsOutput.gyleVolumeFloat.litresToGallonsGB();
if gyleVolumeFinal >= 0.995 && gyleVolumeFinal < 1.005 {
finalOutput = format!("{:.0} gallon", gyleVolumeFinal);
} else if gyleVolumeFinal.fract() >= 0.995 || gyleVolumeFinal.fract() < 0.005 {
......@@ -85,8 +87,8 @@ pub fn gyleCarbonationFormatting(allInputs: gyleData) -> String {
finalOutput = format!("{:.2} gallons", gyleVolumeFinal);
}
} else if allInputs.imperialOrMetric == imperialOrMetric::imperialUS {
let gyleCarbonationMathsOutput = gyleCarbonationMaths(allInputs);
let gyleVolumeFinal = gyleCarbonationMathsOutput.gyleVolumeFloat.litresToGallonsUS();
gyleCarbonationMathsOutput = gyleCarbonationMaths(allInputs);
gyleVolumeFinal = gyleCarbonationMathsOutput.gyleVolumeFloat.litresToGallonsUS();
if gyleVolumeFinal >= 0.995 && gyleVolumeFinal < 1.005 {
finalOutput = format!("{:.0} gallon", gyleVolumeFinal);
} else if gyleVolumeFinal.fract() >= 0.995 || gyleVolumeFinal.fract() < 0.005 {
......@@ -95,8 +97,8 @@ pub fn gyleCarbonationFormatting(allInputs: gyleData) -> String {
finalOutput = format!("{:.2} gallons", gyleVolumeFinal);
}
} else if allInputs.imperialOrMetric == imperialOrMetric::metric {
let gyleCarbonationMathsOutput = gyleCarbonationMaths(allInputs);
let gyleVolumeFinal = gyleCarbonationMathsOutput.gyleVolumeFloat;
gyleCarbonationMathsOutput = gyleCarbonationMaths(allInputs);
gyleVolumeFinal = gyleCarbonationMathsOutput.gyleVolumeFloat;
if gyleVolumeFinal >= 0.995 && gyleVolumeFinal < 1.005 {
finalOutput = format!("{:.0} litre", gyleVolumeFinal);
} else if gyleVolumeFinal.fract() >= 0.995 || gyleVolumeFinal.fract() < 0.005 {
......@@ -114,9 +116,9 @@ fn gyleCarbonationOutput(mut allInputs: gyleData, gyleBuilder: &gtk::Builder) {
gyleCarbonationVolumeUnits(&mut allInputs);
let finalOutputFloat = gyleCarbonationMaths(allInputs);
let finalOutputFloat: gyleData = gyleCarbonationMaths(allInputs);
let finalOutput = gyleCarbonationFormatting(finalOutputFloat);
let finalOutput: String = gyleCarbonationFormatting(finalOutputFloat);
gyleCarbonationOutput.set_text(&finalOutput);
}
\ No newline at end of file
......@@ -26,20 +26,20 @@ pub struct sugarOutputStrings {
pub fn increaseABVPrep(increaseABVBuilder: &gtk::Builder) {
let increaseABVStartingBrix: gtk::Entry = increaseABVBuilder.get_object("increaseABVStartingBrix").expect("increaseABVPrep(), increaseABVStartingBrix");
let increaseABVBrixBuffer = increaseABVStartingBrix.get_text().expect("increaseABVPrep(), increaseABVBrixBuffer");
let increaseABVBrixBuffer: String = increaseABVStartingBrix.get_text().expect("increaseABVPrep(), increaseABVBrixBuffer");
let increaseABVDesiredABV: gtk::Entry = increaseABVBuilder.get_object("increaseABVDesiredABV").expect("increaseABVPrep(), increaseABVDesiredABV");
let increaseABVABVBuffer = increaseABVDesiredABV.get_text().expect("increaseABVPrep(), increaseABVABVBuffer");
let increaseABVABVBuffer: String = increaseABVDesiredABV.get_text().expect("increaseABVPrep(), increaseABVABVBuffer");
let increaseABVCurrentVolume: gtk::Entry = increaseABVBuilder.get_object("increaseABVCurrentVolume").expect("increaseABVPrep(), increaseABVCurrentVolume");
let increaseABVVolumeBuffer = increaseABVCurrentVolume.get_text().expect("increaseABVPrep(), increaseABVVolumeBuffer");
let increaseABVVolumeBuffer: String = increaseABVCurrentVolume.get_text().expect("increaseABVPrep(), increaseABVVolumeBuffer");
let increaseABVFinalBrix: gtk::Entry = increaseABVBuilder.get_object("increaseABVFinalBrix").expect("increaseABVPrep(), increaseABVFinalBrix");
let increaseABVSugar: gtk::Entry = increaseABVBuilder.get_object("increaseABVSugar").expect("increaseABVPrep(), increaseABVSugar");
let increaseABVHoney: gtk::Entry = increaseABVBuilder.get_object("increaseABVHoney").expect("increaseABVPrep(), increaseABVHoney");
let increaseABVUnits: gtk::ComboBoxText = increaseABVBuilder.get_object("increaseABVUnits").expect("increaseABVPrep(), increaseABVUnits");
let increaseABVUnitsBuffer = increaseABVUnits.get_active_id().expect("increaseABVPrep(), increaseABVUnitsBuffer");
let increaseABVUnitsBuffer: String = increaseABVUnits.get_active_id().expect("increaseABVPrep(), increaseABVUnitsBuffer");
let allInputs = increaseABVData {
startingBrix: increaseABVBrixBuffer.validInput(),
......@@ -70,17 +70,17 @@ pub fn increaseABVPrep(increaseABVBuilder: &gtk::Builder) {
}
pub fn increaseABVMaths(allInputs: &increaseABVData) -> finalSugarFloat {
let mut newStartingBrix = allInputs.startingBrix;
let mut newEstimatedABV = realABVAndAttenuation(newStartingBrix, FINAL_BRIX_IDEAL).0;
let mut newStartingBrix: f64 = allInputs.startingBrix;
let mut newEstimatedABV: f64 = realABVAndAttenuation(newStartingBrix, FINAL_BRIX_IDEAL).0;
while newEstimatedABV <= allInputs.desiredABV {
newStartingBrix = newStartingBrix + 0.001;
newEstimatedABV = realABVAndAttenuation(newStartingBrix, FINAL_BRIX_IDEAL).0;
}
let differenceBrix = newStartingBrix - allInputs.startingBrix;
let differenceBrix: f64 = newStartingBrix - allInputs.startingBrix;
let mut finalOutputFloat = finalSugarFloat {
let mut finalOutputFloat: finalSugarFloat = finalSugarFloat {
newStartingBrixFinal: newStartingBrix,
sugarToAdd: 0.0,
honeyToAdd: 0.0,
......@@ -103,7 +103,7 @@ pub fn increaseABVMaths(allInputs: &increaseABVData) -> finalSugarFloat {
}
pub fn increaseABVFormatting(allInputs: &increaseABVData, finalOutputFloat: finalSugarFloat) -> sugarOutputStrings {
let mut finalOutput = sugarOutputStrings {
let mut finalOutput: sugarOutputStrings = sugarOutputStrings {
newStartingBrixFinal: format!("{:.2}°Bx", finalOutputFloat.newStartingBrixFinal),
sugarAmount: String::from(""),
honeyAmount: String::from(""),
......@@ -159,8 +159,8 @@ fn increaseABVOutput(allInputs: increaseABVData, increaseABVBuilder: &gtk::Build
let increaseABVSugar: gtk::Entry = increaseABVBuilder.get_object("increaseABVSugar").expect("increaseABVOutput(), increaseABVFinalBrix");
let increaseABVHoney: gtk::Entry = increaseABVBuilder.get_object("increaseABVHoney").expect("increaseABVOutput(), increaseABVFinalBrix");
let finalOutputFloat = increaseABVMaths(&allInputs);
let finalOutput = increaseABVFormatting(&allInputs, finalOutputFloat);
let finalOutputFloat: finalSugarFloat = increaseABVMaths(&allInputs);
let finalOutput: sugarOutputStrings = increaseABVFormatting(&allInputs, finalOutputFloat);
increaseABVFinalBrix.set_text(&finalOutput.newStartingBrixFinal);
increaseABVSugar.set_text(&finalOutput.sugarAmount);
......
......@@ -4,12 +4,12 @@ use functions::commonFunctions::{inputMatching, realABVAndAttenuation};
pub fn realABVPrep(realABVBuilder: &gtk::Builder) {
let realABVStartingBrix: gtk::Entry = realABVBuilder.get_object("realABVStartingBrix").expect("realABVPrep(), realABVStartingBrix");
let realABVStartingBrixBuffer = realABVStartingBrix.get_text().expect("realABVPrep(), realABVStartingBrixBuffer");
let startingBrix = realABVStartingBrixBuffer.validInput();
let realABVStartingBrixBuffer: String = realABVStartingBrix.get_text().expect("realABVPrep(), realABVStartingBrixBuffer");
let startingBrix: f64 = realABVStartingBrixBuffer.validInput();
let realABVFinalBrix: gtk::Entry = realABVBuilder.get_object("realABVFinalBrix").expect("realABVPrep(), realABVFinalrealABVFinalBrixBrixInput");
let realABVFinalBrixInputBuffer = realABVFinalBrix.get_text().expect("realABVPrep(), realABVFinalBrixInputBuffer");
let finalBrix = realABVFinalBrixInputBuffer.validInput();
let realABVFinalBrixInputBuffer: String = realABVFinalBrix.get_text().expect("realABVPrep(), realABVFinalBrixInputBuffer");
let finalBrix: f64 = realABVFinalBrixInputBuffer.validInput();
let realABVFinalABV: gtk::Entry = realABVBuilder.get_object("realABVFinalABV").expect("realABVPrep(), realABVFinalABV");
let realABVRealAttenuation: gtk::Entry = realABVBuilder.get_object("realABVRealAttenuation").expect("realABVPrep(), realABVRealAttenuation");
......@@ -35,13 +35,10 @@ pub fn realABVPrep(realABVBuilder: &gtk::Builder) {
}
pub fn realABVFormatting(abvFloat: f64, attenuationFloat: f64) -> (String, String) {
let abvFormatted;
let attenuationFormatted;
let mut abvFormatted: String = String::from("");
let mut attenuationFormatted: String = String::from("Enter legimate amounts");
if abvFloat > 26.0 || abvFloat <= 0.0 {
abvFormatted = String::from("");
attenuationFormatted = String::from("Enter legimate amounts");
} else {
if abvFloat > 0.0 && abvFloat < 26.0 {
abvFormatted = format!("{:.2}%", abvFloat);
attenuationFormatted = format!("{:.2}%", attenuationFloat);
}
......
......@@ -30,22 +30,22 @@ pub struct spargeOutputStrings {
pub fn waterSpargePrep(waterSpargeBuilder: &gtk::Builder) {
let spargePreFermentVolume: gtk::Entry = waterSpargeBuilder.get_object("spargePreFermentVolume").expect("waterSpargePrep(), spargePreFermentVolume");
let spargePreFermentVolumeBuffer = spargePreFermentVolume.get_text().expect("waterSpargePrep(), spargePreFermentVolumeBuffer");
let spargePreFermentVolumeBuffer: String = spargePreFermentVolume.get_text().expect("waterSpargePrep(), spargePreFermentVolumeBuffer");
let spargeTotalGrain: gtk::Entry = waterSpargeBuilder.get_object("spargeTotalGrain").expect("waterSpargePrep(), spargeTotalGrain");
let spargeTotalGrainBuffer = spargeTotalGrain.get_text().expect("waterSpargePrep(), spargeTotalGrainBuffer");
let spargeTotalGrainBuffer: String = spargeTotalGrain.get_text().expect("waterSpargePrep(), spargeTotalGrainBuffer");
let spargeBoilTime: gtk::Entry = waterSpargeBuilder.get_object("spargeBoilTime").expect("waterSpargePrep(), spargeBoilTime");
let spargeBoilTimeBuffer = spargeBoilTime.get_text().expect("waterSpargePrep(), spargeBoilTimeBuffer");
let spargeBoilTimeBuffer: