update: add QAQC runid for master log parsing

- for master version v0.2.0
This commit is contained in:
Wataru Otsubo 2024-07-23 14:41:08 +09:00
parent b927f5923e
commit 84d321ec30
5 changed files with 55 additions and 19 deletions

View file

@ -175,6 +175,7 @@ pub struct PsbQaqcResult {
pll_lock_reset: u16,
qaqc_result: u32,
lvds_tx_skew: Option<u32>,
runid: u32,
timestamp: DateTime<Utc>,
qaqc_log_file: String,
shiftscript_ver: Version,
@ -203,6 +204,7 @@ impl PsbQaqcResult {
pll_lock_reset: boardresult.reset,
qaqc_result: boardresult.result.into(),
lvds_tx_skew: None,
runid: result.runid,
timestamp: result.datetime,
qaqc_log_file: result.filename.clone(),
shiftscript_ver: result.version.clone(),

View file

@ -29,6 +29,7 @@ pub struct MasterBoardResult {
pub struct MasterLogResult {
pub version: Version,
pub datetime: DateTime<Utc>,
pub runid: u32,
pub shifter: String,
pub board_results: BTreeMap<Position, MasterBoardResult>,
pub filename: String,
@ -43,6 +44,15 @@ fn extract_version(line: &str) -> Result<Version> {
.parse()?)
}
/// Get runid.
fn extract_runid_line(line: &str) -> Result<u32> {
let re = Regex::new(r"^QAQC runid: (\d+)$").unwrap();
let caps = re.captures(line).unwrap();
trace!("Regex {:?}", caps);
let runid = u32::from_str(caps.get(1).unwrap().into())?;
Ok(runid)
}
/// Get shifters from shifter line
fn extract_shifter_line(line: &str) -> Result<String> {
let re = Regex::new(r"^Shifters: (.+)$").unwrap();
@ -81,6 +91,13 @@ impl MasterLogResult {
.to_utc()
};
let runid: u32 = {
let line = lines
.next()
.context("Invalid log format(no runid line)")??;
extract_runid_line(&line)?
};
let shifter = {
let line = lines
.next()
@ -238,6 +255,7 @@ impl MasterLogResult {
Ok(MasterLogResult {
version,
datetime,
runid,
shifter,
board_results,
filename,
@ -249,6 +267,8 @@ impl MasterLogResult {
mod test {
use semver::Version;
use crate::masterlog::extract_runid_line;
use super::{Position, PositionLayer, PsbId};
use super::{extract_position_id, extract_shifter_line, extract_version};
@ -261,6 +281,18 @@ mod test {
)
}
#[test]
fn parse_runid_line() {
assert_eq!(
extract_runid_line("QAQC runid: 7").unwrap(),
7
);
assert_eq!(
extract_runid_line("QAQC runid: 12345").unwrap(),
12345
);
}
#[test]
fn parse_shifter_line() {
assert_eq!(extract_shifter_line("Shifters: foo").unwrap(), "foo");

View file

@ -18,7 +18,7 @@ mod integrated_test {
let mut cmd = Command::cargo_bin("psb-qaqc")?;
cmd.current_dir("tests")
.arg("add-master-log")
.arg("./example_logs/valid/20240720_171418.log")
.arg("./example_logs/valid/7.log")
.arg(test_out.as_path())
.assert()
.success()
@ -34,7 +34,7 @@ mod integrated_test {
line
.unwrap()
.contains(
"8866,,A-0-0,0,1,1,0,1,8,1,,2024-07-20T17:15:46Z,20240720_171418.log,0.1.0,alice,,,,"
"8866,,A-0-0,0,1,1,0,1,8,1,,7,2024-07-20T17:15:46Z,7.log,0.1.0,alice,,,,"
)
}));
}
@ -43,7 +43,7 @@ mod integrated_test {
let mut cmd = Command::cargo_bin("psb-qaqc")?;
cmd.current_dir("tests")
.arg("add-master-log")
.arg("./example_logs/valid/20240720_171418.log")
.arg("./example_logs/valid/7.log")
.arg(test_out.as_path())
.assert()
.success();
@ -67,7 +67,7 @@ mod integrated_test {
let mut cmd = Command::cargo_bin("psb-qaqc")?;
cmd.current_dir("tests")
.arg("add-master-log")
.arg("./example_logs/valid/20240720_171419.log")
.arg("./example_logs/valid/84.log")
.arg(test_out.as_path())
.assert()
.success()

View file

@ -1,6 +1,7 @@
Shift script: 0.1.0
----------------------
Date: 2024-07-20T17:15:46+0000
QAQC runid: 7
Shifters: alice
----------------------
PBS Assignment:

View file

@ -1,23 +1,24 @@
Shift script: 0.1.0
----------------------
Date: 2024-07-20T17:15:46+0000
Date: 2024-07-20T17:15:47+0000
QAQC runid: 84
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
Position / assigned-ID : A-0-0 / PS008867
Position / assigned-ID : A-1-0 / PS008868
Position / assigned-ID : A-0-2 / PS008869
Position / assigned-ID : A-1-2 / PS008810
Position / assigned-ID : A-0-3 / PS008811
Position / assigned-ID : A-1-3 / PS008812
Position / assigned-ID : A-0-4 / PS008813
Position / assigned-ID : A-1-4 / PS008814
Position / assigned-ID : A-1-5 / PS008815
Position / assigned-ID : A-0-6 / PS008816
Position / assigned-ID : A-1-6 / PS008817
Position / assigned-ID : A-0-7 / PS008818
Position / assigned-ID : A-0-8 / PS008819
Position / assigned-ID : A-1-8 / PS008820
======================
QAQC status| QSPIp | Recov | Power | Clock | ASDTP | Reset | Result |
----------------------------------------------------------------------