update: log format

This commit is contained in:
Wataru Otsubo 2024-07-21 19:53:51 +09:00
parent eff62d7f09
commit 62a5393cf5
6 changed files with 126 additions and 116 deletions

View file

@ -120,8 +120,8 @@ impl FromStr for PsbId {
type Err = anyhow::Error; type Err = anyhow::Error;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
if !s.starts_with("PB") { if !s.starts_with("PS") {
return Err(anyhow!("Must prefixed with PB: {}", s)); return Err(anyhow!("Must prefixed with PS: got: {}", s));
} }
let num = s[2..].parse()?; let num = s[2..].parse()?;
// TODO: add validation // TODO: add validation
@ -137,13 +137,13 @@ impl FromStr for PsbId {
#[derive(Debug)] #[derive(Debug)]
struct MasterBoardResult { struct MasterBoardResult {
id: PsbId, id: PsbId,
qspif: u8,
qspip: u8, qspip: u8,
recov: u8, recov: u8,
power: u8,
clock: u8, clock: u8,
regac: u8,
asdtp: u8, asdtp: u8,
done: u8, reset: u16,
result: u8,
} }
/// Full result for a single QAQC run from a log file on JATHub master. /// 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"); trace!("Read all PBS assignments");
info!("{:?}", assignments); info!("{:?}", assignments);
// TODO: stricter validation for header?
if !lines if !lines
.next() .next()
.context("Invalid log format")?? .context("Invalid log format")??
@ -315,34 +316,34 @@ impl MasterLogResult {
let result = MasterBoardResult { let result = MasterBoardResult {
id: psbid, id: psbid,
qspif: parts
.get(1)
.map(|v| v.split_whitespace().next().unwrap().parse())
.context("Invalid qspif")??,
qspip: parts qspip: parts
.get(2) .get(1)
.map(|v| v.split_whitespace().next().unwrap().parse()) .map(|v| v.split_whitespace().next().unwrap().parse())
.context("Invalid qspip")??, .context("Invalid qspip")??,
recov: parts recov: parts
.get(3) .get(2)
.map(|v| v.split_whitespace().next().unwrap().parse()) .map(|v| v.split_whitespace().next().unwrap().parse())
.context("Invalid recov")??, .context("Invalid recov")??,
power: parts
.get(3)
.map(|v| v.split_whitespace().next().unwrap().parse())
.context("Invalid power")??,
clock: parts clock: parts
.get(4) .get(4)
.map(|v| v.split_whitespace().next().unwrap().parse()) .map(|v| v.split_whitespace().next().unwrap().parse())
.context("Invalid clock")??, .context("Invalid clock")??,
regac: parts asdtp: parts
.get(5) .get(5)
.map(|v| v.split_whitespace().next().unwrap().parse()) .map(|v| v.split_whitespace().next().unwrap().parse())
.context("Invalid regac")??, .context("Invalid asdtp")??,
asdtp: parts reset: parts
.get(6) .get(6)
.map(|v| v.split_whitespace().next().unwrap().parse()) .map(|v| v.split_whitespace().next().unwrap().parse())
.context("Invalid asdtp")??, .context("Invalid reset")??,
done: parts result: parts
.get(7) .get(7)
.map(|v| v.split_whitespace().next().unwrap().parse()) .map(|v| v.split_whitespace().next().unwrap().parse())
.context("Invalid done")??, .context("Invalid result")??,
}; };
match board_results.insert(pos, result) { match board_results.insert(pos, result) {
@ -378,12 +379,12 @@ pub struct PsbQaqcResult {
daughterboard_id: Option<u32>, daughterboard_id: Option<u32>,
#[serde_as(as = "DisplayFromStr")] #[serde_as(as = "DisplayFromStr")]
position: Position, position: Position,
qspif: u8,
qspip: u8, qspip: u8,
recov: u8, recov: u8,
power: u8,
clock: u8, clock: u8,
regac: u8,
asdtp: u8, asdtp: u8,
reset: u16,
qaqc_result: u32, qaqc_result: u32,
lvds_tx_skew: Option<u32>, lvds_tx_skew: Option<u32>,
ppl_lock_reset_count: Option<i32>, ppl_lock_reset_count: Option<i32>,
@ -397,7 +398,7 @@ pub struct PsbQaqcResult {
impl PsbQaqcResult { impl PsbQaqcResult {
/// Expand [`MasterLogResult`] to [`PsbQaqcResult`]. /// Expand [`MasterLogResult`] to [`PsbQaqcResult`].
/// Filling unavailable fileds with [`None`]s. /// Filling unavailable fields with [`None`]s.
pub fn from_masterlogresult(result: MasterLogResult) -> Vec<Self> { pub fn from_masterlogresult(result: MasterLogResult) -> Vec<Self> {
let mut converted = vec![]; let mut converted = vec![];
for (pos, boardresult) in result.board_results { for (pos, boardresult) in result.board_results {
@ -405,13 +406,13 @@ impl PsbQaqcResult {
motherboard_id: boardresult.id.id, motherboard_id: boardresult.id.id,
daughterboard_id: None, daughterboard_id: None,
position: pos, position: pos,
qspif: boardresult.qspif,
qspip: boardresult.qspip, qspip: boardresult.qspip,
recov: boardresult.recov, recov: boardresult.recov,
power: boardresult.power,
clock: boardresult.clock, clock: boardresult.clock,
regac: boardresult.regac,
asdtp: boardresult.asdtp, asdtp: boardresult.asdtp,
qaqc_result: boardresult.done.into(), reset: boardresult.reset,
qaqc_result: boardresult.result.into(),
lvds_tx_skew: None, lvds_tx_skew: None,
ppl_lock_reset_count: None, ppl_lock_reset_count: None,
timestamp: result.datetime, timestamp: result.datetime,
@ -557,7 +558,7 @@ mod test {
#[test] #[test]
fn parse_pos_id_line() { fn parse_pos_id_line() {
assert_eq!( 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 { Position {
major: PositionLayer::A, major: PositionLayer::A,
@ -568,7 +569,7 @@ mod test {
) )
); );
assert_eq!( 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 { Position {
major: PositionLayer::A, major: PositionLayer::A,
@ -579,7 +580,7 @@ mod test {
) )
); );
assert_ne!( 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 { Position {
major: PositionLayer::A, major: PositionLayer::A,

View file

@ -10,14 +10,23 @@ mod integrated_test {
let test_out_dir = assert_fs::TempDir::new()?; let test_out_dir = assert_fs::TempDir::new()?;
let test_out = PathBuf::new().join(&test_out_dir).join("out.csv"); let test_out = PathBuf::new().join(&test_out_dir).join("out.csv");
// 1st file
let mut cmd = Command::cargo_bin("psb-qaqc-parse")?; let mut cmd = Command::cargo_bin("psb-qaqc-parse")?;
cmd.current_dir("tests") cmd.current_dir("tests")
.arg("./example_logs/valid/20240620_083537.log") .arg("./example_logs/valid/20240720_171418.log")
.arg(test_out.as_path()) .arg(test_out.as_path())
.assert() .assert()
.success() .success()
.stdout(predicate::str::contains("Creating new file")); .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(()) Ok(())
} }
@ -28,7 +37,7 @@ mod integrated_test {
let mut cmd = Command::cargo_bin("psb-qaqc-parse")?; let mut cmd = Command::cargo_bin("psb-qaqc-parse")?;
cmd.current_dir("tests") cmd.current_dir("tests")
.arg("./example_logs/valid/20240620_093537.log") .arg("./example_logs/valid/20240720_171419.log")
.arg(test_out.as_path()) .arg(test_out.as_path())
.assert() .assert()
.success() .success()

View file

@ -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|
======================

View file

@ -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|
======================

View file

@ -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|
======================

View file

@ -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|
======================