mirror of
https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess.git
synced 2024-11-22 07:10:18 +09:00
new: get run information from skew log file name
This commit is contained in:
parent
73a169c68f
commit
059283fab3
2 changed files with 39 additions and 0 deletions
|
@ -45,6 +45,9 @@ pub enum Commands {
|
||||||
csvfile: PathBuf,
|
csvfile: PathBuf,
|
||||||
},
|
},
|
||||||
/// Get LVDS TX skew from slave log _clk file.
|
/// Get LVDS TX skew from slave log _clk file.
|
||||||
|
///
|
||||||
|
/// PSB ID is extracted from `logfile` name and the corresponding QAQC run is retrieved by
|
||||||
|
/// searching the n-th run with the same PSB ID in chronological order.
|
||||||
AddSkew {
|
AddSkew {
|
||||||
/// Slave _clk log file.
|
/// Slave _clk log file.
|
||||||
logfile: PathBuf,
|
logfile: PathBuf,
|
||||||
|
|
36
src/skew.rs
36
src/skew.rs
|
@ -6,6 +6,27 @@ use std::{
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::PsbId;
|
||||||
|
|
||||||
|
/// Extract PsbId and runid from filename.
|
||||||
|
///
|
||||||
|
/// format:
|
||||||
|
/// `PSBID_RUNID_clk.txt`
|
||||||
|
pub fn get_psbid_from_clklogfile(path: PathBuf) -> Result<(PsbId, u32)> {
|
||||||
|
let filename = path
|
||||||
|
.file_stem()
|
||||||
|
.context("path is not a file")?
|
||||||
|
.to_str()
|
||||||
|
.context("Invalid utf-8")?;
|
||||||
|
let mut parts = filename.split('_');
|
||||||
|
let psbid: PsbId = {
|
||||||
|
let id: u32 = parts.next().context("No psbid")?.parse()?;
|
||||||
|
PsbId::new(id)
|
||||||
|
};
|
||||||
|
let runid = parts.next().context("No run id")?.parse()?;
|
||||||
|
Ok((psbid, runid))
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_single_line(l: String) -> Result<(f64, u32, u32)> {
|
fn parse_single_line(l: String) -> Result<(f64, u32, u32)> {
|
||||||
let mut splitted = l.split_whitespace();
|
let mut splitted = l.split_whitespace();
|
||||||
let delay: f64 = splitted.next().context("No value found")?.parse()?;
|
let delay: f64 = splitted.next().context("No value found")?.parse()?;
|
||||||
|
@ -38,7 +59,22 @@ pub fn parse_count_file(filename: PathBuf) -> Result<f64> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
use crate::{skew::get_psbid_from_clklogfile, PsbId};
|
||||||
|
|
||||||
use super::parse_counts;
|
use super::parse_counts;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_psbid_from_clklog() {
|
||||||
|
assert_eq!(
|
||||||
|
get_psbid_from_clklogfile("120_1234.log".into()).unwrap(),
|
||||||
|
(PsbId::new(1020), 1234)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
get_psbid_from_clklogfile("1024_124.log".into()).unwrap(),
|
||||||
|
(PsbId::new(1024), 124)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_counts1() {
|
fn test_parse_counts1() {
|
||||||
let file = "
|
let file = "
|
||||||
|
|
Loading…
Reference in a new issue