Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwrath1223 committed Dec 18, 2023
1 parent c257d7c commit 9053e57
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/cli_struct.rs
Original file line number Diff line number Diff line change
@@ -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
}
33 changes: 33 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -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

}

0 comments on commit 9053e57

Please sign in to comment.