diff --git a/src/cli_struct.rs b/src/cli_struct.rs index e69de29..26ea107 100644 --- a/src/cli_struct.rs +++ b/src/cli_struct.rs @@ -0,0 +1,37 @@ +use clap::Parser; + + +#[derive(Parser, Debug)] +pub struct CliArgs { + /// IP address of the controller + #[arg(short, long)] + pub ip_string: String, + + /// the address to find the load device (HP606n) on the GPIB bus + #[arg(short, long)] + pub gpib_addr: u8, + + /// the current to draw from the battery in Amps + #[arg(short='d', long)] + pub discharge_current: f64, + + /// the range for the current sensor on the machine. this differs on different machines, + /// so check which range best matches your discharge current. + /// This field is the index of the range, so for the 6063B which has ranges [0, 1A] and [0, 10A], + /// you would enter `0` for discharge currents less than 1A, and `1` otherwise + #[arg(short='c', long, default_value_t = 1u8)] + pub current_range: u8, + + /// the voltage to stop discharging the battery. + #[arg(short='v', long, default_value_t = 0f64)] + pub cutoff_voltage: f64, + + /// path and name for the output file + #[arg(short='p', long)] + pub output_file: String, + + /// number of times to check the voltage per minute. + /// This affects cutoff voltage checks if set too low. + #[arg(short='r', long)] + pub polling_rate: f64 +} \ No newline at end of file diff --git a/src/errors.rs b/src/errors.rs index e69de29..93ea6a6 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -0,0 +1,33 @@ +use std::net::AddrParseError; +use std::num::{ParseFloatError, ParseIntError}; +use std::string::FromUtf8Error; +use std::time::SystemTimeError; +use prologix_gpib_ethernet_controller_manager::errors::GpibControllerError; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum BatTestError { + #[error("Error trying to send or receive data: {0}")] + TcpIoError(#[from] std::io::Error), + #[error("reqwest error: {0}")] + ReqwestError(#[from] reqwest::Error), + #[error("error parsing integer from a string: {0}")] + ParseIntError(#[from] ParseIntError), + #[error("error parsing string from TCPStream: {0}")] + ParseStringError(#[from] FromUtf8Error), + #[error("error parsing Ip address: {0}")] + ParseIpAddressError(#[from] AddrParseError), + #[error("error in GPIB controller library: {0}")] + ControllerLibraryError(#[from] GpibControllerError), + #[error("error in CSV library: {0}")] + CsvError(#[from] csv::Error), + #[error("error parsing Float: {0}")] + ParseFloatError(#[from] ParseFloatError), + #[error("error with system time: {0}")] + SystemTimeError(#[from] SystemTimeError), + #[error("Error converting path to string")] + PathToStringError, + #[error("Error converting scientific notation string to float")] + SciNotParseError + +} \ No newline at end of file