add support for quanity
This commit is contained in:
+53
-14
@@ -1,3 +1,5 @@
|
||||
pub mod pdf;
|
||||
|
||||
use clap::{Parser, ValueEnum};
|
||||
use colored::*;
|
||||
|
||||
@@ -45,6 +47,10 @@ struct Args {
|
||||
/// Control terminal color output
|
||||
#[arg(long, default_value = "auto")]
|
||||
color: ColorChoice,
|
||||
|
||||
/// Number of casts to make simultaneously
|
||||
#[arg(short = 'n', long, default_value_t = 1)]
|
||||
quantity: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -57,7 +63,7 @@ fn main() {
|
||||
ColorChoice::Auto => {} // Respects standard stream capabilities (default)
|
||||
}
|
||||
|
||||
// Determine density and target wet weight
|
||||
// Determine density and target wet weight for a SINGLE cast
|
||||
let density = args.density.or_else(|| {
|
||||
if (args.concentration - DEFAULT_CONCENTRATION).abs() < f64::EPSILON {
|
||||
Some(DEFAULT_DENSITY)
|
||||
@@ -65,9 +71,11 @@ fn main() {
|
||||
None
|
||||
}
|
||||
});
|
||||
let target_wet_weight = density.map(|d| (args.volume / 1000.0) * d);
|
||||
|
||||
let (plaster_nominal, water_nominal) = match target_wet_weight {
|
||||
let single_wet_weight = density.map(|d| (args.volume / 1000.0) * d);
|
||||
let total_wet_weight = single_wet_weight.map(|w| w * args.quantity as f64);
|
||||
|
||||
let (plaster_total, water_total) = match total_wet_weight {
|
||||
Some(wet_weight) => {
|
||||
let plaster = wet_weight / (1.0 + (args.concentration / PERCENT));
|
||||
let water = plaster * (args.concentration / PERCENT);
|
||||
@@ -79,9 +87,13 @@ fn main() {
|
||||
// Output Header
|
||||
println!("--- Plaster Calculation Parameters ---");
|
||||
println!(
|
||||
"Volume: {}ml",
|
||||
"Volume (per cast): {}ml",
|
||||
format!("{}", args.volume).color(COLOR_PARAM).bold()
|
||||
);
|
||||
println!(
|
||||
"Quantity: {}",
|
||||
format!("{}", args.quantity).color(COLOR_PARAM).bold()
|
||||
);
|
||||
println!(
|
||||
"Concentration: {}g water per 100g plaster",
|
||||
format!("{}", args.concentration).color(COLOR_PARAM).bold()
|
||||
@@ -94,22 +106,37 @@ fn main() {
|
||||
println!("--------------------------------------");
|
||||
|
||||
// Output Mixing Amounts and Target Weights
|
||||
if let (Some(p_nom), Some(w_nom)) = (plaster_nominal, water_nominal) {
|
||||
let p_slack = p_nom * (1.0 + SLACK);
|
||||
let w_slack = w_nom * (1.0 + SLACK);
|
||||
let dry_weight = p_nom * DRY_WEIGHT_MULTIPLIER;
|
||||
if let (Some(p_tot), Some(w_tot)) = (plaster_total, water_total) {
|
||||
let p_slack = p_tot * (1.0 + SLACK);
|
||||
let w_slack = w_tot * (1.0 + SLACK);
|
||||
|
||||
let single_plaster = p_tot / args.quantity as f64;
|
||||
let single_dry_weight = single_plaster * DRY_WEIGHT_MULTIPLIER;
|
||||
let total_dry_weight = single_dry_weight * args.quantity as f64;
|
||||
|
||||
if args.quantity > 1 {
|
||||
println!("Combined Mixing Amounts (for {} casts):", args.quantity);
|
||||
println!(" Nominal Total:");
|
||||
} else {
|
||||
println!("Mixing Amounts:");
|
||||
println!(" Nominal:");
|
||||
}
|
||||
|
||||
println!(
|
||||
" Plaster: {}g",
|
||||
format!("{:.1}", p_nom).color(COLOR_PLASTER)
|
||||
format!("{:.1}", p_tot).color(COLOR_PLASTER)
|
||||
);
|
||||
println!(
|
||||
" Water: {}g",
|
||||
format!("{:.1}", w_nom).color(COLOR_WATER)
|
||||
format!("{:.1}", w_tot).color(COLOR_WATER)
|
||||
);
|
||||
|
||||
if args.quantity > 1 {
|
||||
println!(" {:2}% Slack Total:", SLACK * PERCENT);
|
||||
} else {
|
||||
println!(" {:2}% Slack:", SLACK * PERCENT);
|
||||
}
|
||||
|
||||
println!(
|
||||
" Plaster: {}g",
|
||||
format!("{:.1}", p_slack).color(COLOR_PLASTER).bold()
|
||||
@@ -120,16 +147,28 @@ fn main() {
|
||||
);
|
||||
|
||||
println!("\nTarget Weights:");
|
||||
if args.quantity > 1 {
|
||||
println!(" Individual Cast:");
|
||||
}
|
||||
println!(
|
||||
" Wet Cast: {}g",
|
||||
format!("{:.1}", target_wet_weight.unwrap())
|
||||
.color(COLOR_TARGET)
|
||||
.bold()
|
||||
format!("{:.1}", single_wet_weight.unwrap()).color(COLOR_TARGET).bold()
|
||||
);
|
||||
println!(
|
||||
" Dry Cast: {}g",
|
||||
format!("{:.1}", dry_weight).color(COLOR_TARGET).bold()
|
||||
format!("{:.1}", single_dry_weight).color(COLOR_TARGET).bold()
|
||||
);
|
||||
if args.quantity > 1 {
|
||||
println!(" Total Batch:");
|
||||
println!(
|
||||
" Wet Cast: {}g",
|
||||
format!("{:.1}", total_wet_weight.unwrap()).color(COLOR_TARGET)
|
||||
);
|
||||
println!(
|
||||
" Dry Cast: {}g",
|
||||
format!("{:.1}", total_dry_weight).color(COLOR_TARGET)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
println!("{}",
|
||||
"Target weights and mixing amounts cannot be calculated. Please specify a density with `-d` for any non-70 concentration.".red()
|
||||
|
||||
Reference in New Issue
Block a user