diff --git a/src/main.rs b/src/main.rs index 2d70f5f..b821d3f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -120,8 +120,8 @@ impl FromStr for PsbId { type Err = anyhow::Error; fn from_str(s: &str) -> std::result::Result { - if !s.starts_with("PB") { - return Err(anyhow!("Must prefixed with PB: {}", s)); + if !s.starts_with("PS") { + return Err(anyhow!("Must prefixed with PS: got: {}", s)); } let num = s[2..].parse()?; // TODO: add validation @@ -137,13 +137,13 @@ impl FromStr for PsbId { #[derive(Debug)] struct MasterBoardResult { id: PsbId, - qspif: u8, qspip: u8, recov: u8, + power: u8, clock: u8, - regac: u8, asdtp: u8, - done: u8, + reset: u16, + result: u8, } /// Full result for a single QAQC run from a log file on JATHub master. @@ -244,6 +244,7 @@ impl MasterLogResult { trace!("Read all PBS assignments"); info!("{:?}", assignments); + // TODO: stricter validation for header? if !lines .next() .context("Invalid log format")?? @@ -315,34 +316,34 @@ impl MasterLogResult { let result = MasterBoardResult { id: psbid, - qspif: parts - .get(1) - .map(|v| v.split_whitespace().next().unwrap().parse()) - .context("Invalid qspif")??, qspip: parts - .get(2) + .get(1) .map(|v| v.split_whitespace().next().unwrap().parse()) .context("Invalid qspip")??, recov: parts - .get(3) + .get(2) .map(|v| v.split_whitespace().next().unwrap().parse()) .context("Invalid recov")??, + power: parts + .get(3) + .map(|v| v.split_whitespace().next().unwrap().parse()) + .context("Invalid power")??, clock: parts .get(4) .map(|v| v.split_whitespace().next().unwrap().parse()) .context("Invalid clock")??, - regac: parts + asdtp: parts .get(5) .map(|v| v.split_whitespace().next().unwrap().parse()) - .context("Invalid regac")??, - asdtp: parts + .context("Invalid asdtp")??, + reset: parts .get(6) .map(|v| v.split_whitespace().next().unwrap().parse()) - .context("Invalid asdtp")??, - done: parts + .context("Invalid reset")??, + result: parts .get(7) .map(|v| v.split_whitespace().next().unwrap().parse()) - .context("Invalid done")??, + .context("Invalid result")??, }; match board_results.insert(pos, result) { @@ -378,12 +379,12 @@ pub struct PsbQaqcResult { daughterboard_id: Option, #[serde_as(as = "DisplayFromStr")] position: Position, - qspif: u8, qspip: u8, recov: u8, + power: u8, clock: u8, - regac: u8, asdtp: u8, + reset: u16, qaqc_result: u32, lvds_tx_skew: Option, ppl_lock_reset_count: Option, @@ -397,7 +398,7 @@ pub struct PsbQaqcResult { impl PsbQaqcResult { /// Expand [`MasterLogResult`] to [`PsbQaqcResult`]. - /// Filling unavailable fileds with [`None`]s. + /// Filling unavailable fields with [`None`]s. pub fn from_masterlogresult(result: MasterLogResult) -> Vec { let mut converted = vec![]; for (pos, boardresult) in result.board_results { @@ -405,13 +406,13 @@ impl PsbQaqcResult { motherboard_id: boardresult.id.id, daughterboard_id: None, position: pos, - qspif: boardresult.qspif, qspip: boardresult.qspip, recov: boardresult.recov, + power: boardresult.power, clock: boardresult.clock, - regac: boardresult.regac, asdtp: boardresult.asdtp, - qaqc_result: boardresult.done.into(), + reset: boardresult.reset, + qaqc_result: boardresult.result.into(), lvds_tx_skew: None, ppl_lock_reset_count: None, timestamp: result.datetime, @@ -557,7 +558,7 @@ mod test { #[test] fn parse_pos_id_line() { assert_eq!( - extract_position_id("Position / assigned-ID : A-0-0 / PB0004").unwrap(), + extract_position_id("Position / assigned-ID : A-0-0 / PS0004").unwrap(), ( Position { major: PositionLayer::A, @@ -568,7 +569,7 @@ mod test { ) ); assert_eq!( - extract_position_id("Position / assigned-ID : A-1-7 / PB0108").unwrap(), + extract_position_id("Position / assigned-ID : A-1-7 / PS0108").unwrap(), ( Position { major: PositionLayer::A, @@ -579,7 +580,7 @@ mod test { ) ); assert_ne!( - extract_position_id("Position / assigned-ID : A-1-7 / PB0108").unwrap(), + extract_position_id("Position / assigned-ID : A-1-7 / PS0108").unwrap(), ( Position { major: PositionLayer::A, diff --git a/tests/cli.rs b/tests/cli.rs index 32bccbf..e998e39 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -10,14 +10,23 @@ mod integrated_test { let test_out_dir = assert_fs::TempDir::new()?; let test_out = PathBuf::new().join(&test_out_dir).join("out.csv"); + // 1st file let mut cmd = Command::cargo_bin("psb-qaqc-parse")?; cmd.current_dir("tests") - .arg("./example_logs/valid/20240620_083537.log") + .arg("./example_logs/valid/20240720_171418.log") .arg(test_out.as_path()) .assert() .success() .stdout(predicate::str::contains("Creating new file")); + // 2nd file + let mut cmd = Command::cargo_bin("psb-qaqc-parse")?; + cmd.current_dir("tests") + .arg("./example_logs/valid/20240720_171418.log") + .arg(test_out.as_path()) + .assert() + .success(); + Ok(()) } @@ -28,7 +37,7 @@ mod integrated_test { let mut cmd = Command::cargo_bin("psb-qaqc-parse")?; cmd.current_dir("tests") - .arg("./example_logs/valid/20240620_093537.log") + .arg("./example_logs/valid/20240720_171419.log") .arg(test_out.as_path()) .assert() .success() diff --git a/tests/example_logs/valid/20240620_083537.log b/tests/example_logs/valid/20240620_083537.log deleted file mode 100644 index 2e0e7db..0000000 --- a/tests/example_logs/valid/20240620_083537.log +++ /dev/null @@ -1,48 +0,0 @@ -Shift script: 0.0.0 ----------------------- -Date: 2024-06-20T08:42:01+0000 -Shifters: Alice ----------------------- -PBS Assignment: -Position / assigned-ID : A-0-0 / PB0004 -Position / assigned-ID : A-1-0 / PB0004 -Position / assigned-ID : A-0-1 / PB0004 -Position / assigned-ID : A-1-1 / PB0004 -Position / assigned-ID : A-0-2 / PB0004 -Position / assigned-ID : A-1-2 / PB0004 -Position / assigned-ID : A-0-3 / PB0004 -Position / assigned-ID : A-1-3 / PB0004 -Position / assigned-ID : A-0-4 / PB0004 -Position / assigned-ID : A-1-4 / PB0004 -Position / assigned-ID : A-0-5 / PB0004 -Position / assigned-ID : A-1-5 / PB0004 -Position / assigned-ID : A-0-6 / PB0004 -Position / assigned-ID : A-1-6 / PB0004 -Position / assigned-ID : A-0-7 / PB0004 -Position / assigned-ID : A-1-7 / PB0004 -Position / assigned-ID : A-0-8 / PB0004 -Position / assigned-ID : A-1-8 / PB0004 -====================== - QAQC status| QSPIf | QSPIp | Recov | Clock | RegAc | ASDTP | DONE | - ----------------------------------------------------------------------- - Station0 - JATHub_ 1| 0| 1| 1| 0| 1| 1| 1| - JATHub_ 2| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 3| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 4| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 5| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 6| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 7| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 8| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 9| 0| 0| 1| 0| 1| 1| 1| - Station1 - JATHub_11| 0| 0| 1| 1| 1| 1| 1| - JATHub_12| 0| 0| 1| 1| 1| 1| 1| - JATHub_13| 0| 0| 1| 1| 1| 1| 1| - JATHub_14| 0| 0| 1| 1| 1| 1| 1| - JATHub_15| 0| 0| 1| 1| 1| 1| 1| - JATHub_16| 0| 0| 1| 1| 1| 1| 1| - JATHub_17| 0| 0| 1| 1| 1| 2| 1| - JATHub_18| 0| 0| 1| 1| 1| 1| 1| - JATHub_19| 0| 0| 0| 0| 0| 0| 0| -====================== diff --git a/tests/example_logs/valid/20240620_093537.log b/tests/example_logs/valid/20240620_093537.log deleted file mode 100644 index fbe7d1f..0000000 --- a/tests/example_logs/valid/20240620_093537.log +++ /dev/null @@ -1,40 +0,0 @@ -Shift script: 0.0.0 ----------------------- -Date: 2024-06-20T09:42:01+0000 -Shifters: Alice ----------------------- -PBS Assignment: -Position / assigned-ID : A-0-0 / PB0004 -Position / assigned-ID : A-1-0 / PB0004 -Position / assigned-ID : A-0-1 / PB0004 -Position / assigned-ID : A-1-1 / PB0004 -Position / assigned-ID : A-0-4 / PB0004 -Position / assigned-ID : A-1-4 / PB0004 -Position / assigned-ID : A-0-5 / PB0004 -Position / assigned-ID : A-1-5 / PB0004 -Position / assigned-ID : A-0-6 / PB0004 -Position / assigned-ID : A-1-6 / PB0004 -Position / assigned-ID : A-0-7 / PB0004 -Position / assigned-ID : A-1-7 / PB0004 -Position / assigned-ID : A-0-8 / PB0004 -Position / assigned-ID : A-1-8 / PB0004 -====================== - QAQC status| QSPIf | QSPIp | Recov | Clock | RegAc | ASDTP | DONE | - ----------------------------------------------------------------------- - Station0 - JATHub_ 1| 0| 1| 1| 0| 1| 1| 1| - JATHub_ 2| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 5| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 6| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 7| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 8| 0| 0| 1| 0| 1| 1| 1| - JATHub_ 9| 0| 0| 1| 0| 1| 1| 1| - Station1 - JATHub_11| 0| 0| 1| 1| 1| 1| 1| - JATHub_12| 0| 0| 1| 1| 1| 1| 1| - JATHub_15| 0| 0| 1| 1| 1| 1| 1| - JATHub_16| 0| 0| 1| 1| 1| 1| 1| - JATHub_17| 0| 0| 1| 1| 1| 2| 1| - JATHub_18| 0| 0| 1| 1| 1| 1| 1| - JATHub_19| 0| 0| 0| 0| 0| 0| 0| -====================== diff --git a/tests/example_logs/valid/20240720_171418.log b/tests/example_logs/valid/20240720_171418.log new file mode 100644 index 0000000..4600537 --- /dev/null +++ b/tests/example_logs/valid/20240720_171418.log @@ -0,0 +1,48 @@ +Shift script: 0.1.0 +---------------------- +Date: 2024-07-20T17:15:46+0000 +Shifters: alice +---------------------- +PBS Assignment: +Position / assigned-ID : A-0-0 / PS008866 +Position / assigned-ID : A-1-0 / PS008866 +Position / assigned-ID : A-0-1 / PS008866 +Position / assigned-ID : A-1-1 / PS008866 +Position / assigned-ID : A-0-2 / PS008866 +Position / assigned-ID : A-1-2 / PS008866 +Position / assigned-ID : A-0-3 / PS008866 +Position / assigned-ID : A-1-3 / PS008866 +Position / assigned-ID : A-0-4 / PS008866 +Position / assigned-ID : A-1-4 / PS008866 +Position / assigned-ID : A-0-5 / PS008866 +Position / assigned-ID : A-1-5 / PS008866 +Position / assigned-ID : A-0-6 / PS008866 +Position / assigned-ID : A-1-6 / PS008866 +Position / assigned-ID : A-0-7 / PS008866 +Position / assigned-ID : A-1-7 / PS008866 +Position / assigned-ID : A-0-8 / PS008866 +Position / assigned-ID : A-1-8 / PS008866 +====================== + QAQC status| QSPIp | Recov | Power | Clock | ASDTP | Reset | Result | + ---------------------------------------------------------------------- + Station0 + JATHub_ 1| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 2| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 3| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 4| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 5| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 6| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 7| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 8| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 9| 0| 1| 1| 0| 1| 8| 1| + Station1 + JATHub_11| 2| 3| 1| 1| 2| 13| 1| + JATHub_12| 3| 3| 1| 1| 1| 5| 1| + JATHub_13| 0| 1| 1| 1| 2| 13| 1| + JATHub_14| 2| 2| 1| 0| 3| 13| 1| + JATHub_15| 2| 3| 1| 0| 0| 5| 0| + JATHub_16| 1| 1| 2| 3| 3| 14| 3| + JATHub_17| 1| 0| 2| 2| 1| 2| 2| + JATHub_18| 2| 2| 3| 3| 1| 5| 1| + JATHub_19| 0| 3| 0| 0| 0| 7| 2| +====================== diff --git a/tests/example_logs/valid/20240720_171419.log b/tests/example_logs/valid/20240720_171419.log new file mode 100644 index 0000000..81b9e16 --- /dev/null +++ b/tests/example_logs/valid/20240720_171419.log @@ -0,0 +1,40 @@ +Shift script: 0.1.0 +---------------------- +Date: 2024-07-20T17:15:46+0000 +Shifters: alice +---------------------- +PBS Assignment: +Position / assigned-ID : A-0-0 / PS008866 +Position / assigned-ID : A-1-0 / PS008866 +Position / assigned-ID : A-0-2 / PS008866 +Position / assigned-ID : A-1-2 / PS008866 +Position / assigned-ID : A-0-3 / PS008866 +Position / assigned-ID : A-1-3 / PS008866 +Position / assigned-ID : A-0-4 / PS008866 +Position / assigned-ID : A-1-4 / PS008866 +Position / assigned-ID : A-1-5 / PS008866 +Position / assigned-ID : A-0-6 / PS008866 +Position / assigned-ID : A-1-6 / PS008866 +Position / assigned-ID : A-0-7 / PS008866 +Position / assigned-ID : A-0-8 / PS008866 +Position / assigned-ID : A-1-8 / PS008866 +====================== + QAQC status| QSPIp | Recov | Power | Clock | ASDTP | Reset | Result | + ---------------------------------------------------------------------- + Station0 + JATHub_ 1| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 3| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 4| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 5| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 7| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 8| 0| 1| 1| 0| 1| 8| 1| + JATHub_ 9| 0| 1| 1| 0| 1| 8| 1| + Station1 + JATHub_11| 2| 3| 1| 1| 2| 13| 1| + JATHub_13| 0| 1| 1| 1| 2| 13| 1| + JATHub_14| 2| 2| 1| 0| 3| 13| 1| + JATHub_15| 2| 3| 1| 0| 0| 5| 0| + JATHub_16| 1| 1| 2| 3| 3| 14| 3| + JATHub_17| 1| 0| 2| 2| 1| 2| 2| + JATHub_19| 0| 3| 0| 0| 0| 7| 2| +======================