Merge branch 'add-version-and-skew' into 'main'

Add version info and skew for positions to the database

See merge request wotsubo/PSBoardDataBase!1397
This commit is contained in:
Wataru Otsubo 2024-09-30 08:02:16 +02:00
commit 187f49a0ce
6 changed files with 85 additions and 6 deletions

View file

@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Add `versions` table to store versoin information of converter(this software)
- Add `skew` columnt to `qaqc_positions` table
## [0.1.0]
### Added

View file

@ -20,6 +20,7 @@ include("import_data.jl")
runlist_csv::AbstractString,
dispatch_csv::AbstractString,
hundred_csv::AbstractString,
jathubs_csv::AbstractString,
masterlog_dir::AbstractString,
)
@ -31,6 +32,7 @@ Create database at `dbpath` and import data from CSV and master log files.
- `runlist_csv`: CSV of run lists exported from the Google sheets database
- `dispatch_csv`: CSV of dispatch lists exported from the Google sheets database
- `hundred_csv`: CSV of 100 tests results exported from the Google sheets database
- `jathubs_csv`: CSV for jathub list used in QAQC. Used to add skew.
- `masterlog_dir`: path to the directory (`log`) where all JATHub master log is stored
"""
function create_database_from_exported_csvs(
@ -39,6 +41,7 @@ function create_database_from_exported_csvs(
runlist_csv::AbstractString,
dispatch_csv::AbstractString,
hundred_csv::AbstractString,
jathubs_csv::AbstractString,
masterlog_dir::AbstractString,
)
db = create_database(dbpath)
@ -48,7 +51,7 @@ function create_database_from_exported_csvs(
extra_100test_result_df = CSV.read(hundred_csv, DataFrame)
insert_qaqc_campaign_id(db)
insert_qaqc_positions(db)
insert_qaqc_positions(db, jathubs_csv)
add_psboard_ids(db, single_result_df)
add_qaqc_runlist_from_runlist(db, runlist_table)

View file

@ -1,3 +1,20 @@
"""
insert_version_info(db::SQLite.DB)
Insert version information of this software as string.
"""
function insert_version_info(db::SQLite.DB)
stmt = DBInterface.prepare(
db,
sql"""
INSERT INTO versions VALUES (:converter)
""",
)
DBInterface.execute(stmt, (; converter = pkgversion(@__MODULE__) |> string))
nothing
end
"""
insert_qaqc_campaign_id(db::SQLite.DB)
@ -28,11 +45,18 @@ function insert_qaqc_campaign_id(db::SQLite.DB)
end
"""
insert_qaqc_positions(db::SQLite.DB)
insert_qaqc_positions(db::SQLite.DB, jathub_db_table::DataFrame)
Fill qaqc_positions table in `db`.
Argument `jathub_db_table` is for skew for each positions.
"""
function insert_qaqc_positions(db::SQLite.DB)
function insert_qaqc_positions(db::SQLite.DB, jathub_db_table::DataFrame)
dropmissing!(jathub_db_table, :psb_position)
transform!(
jathub_db_table,
Symbol("立ち上がり [ns]") => ByRow(Float64) => Symbol("立ち上がり [ns]"),
)
stmt = DBInterface.prepare(
db,
sql"""
@ -41,7 +65,8 @@ function insert_qaqc_positions(db::SQLite.DB)
:id,
:name,
:station,
:position
:position,
:rising_ns
)
""",
)
@ -52,6 +77,12 @@ function insert_qaqc_positions(db::SQLite.DB)
name = ["B-$i-$j" for i in 0:1 for j in 1:9],
station = [fill(0, 9); fill(1, 9)],
position = [collect(1:9); collect(1:9)],
rising_ns = [
filter(
:psb_position => (s -> !ismissing(s) && s == "B-$i-$j"),
jathub_db_table,
).var"立ち上がり [ns]" |> first for i in 0:1 for j in 1:9
],
),
)

View file

@ -1,3 +1,7 @@
CREATE TABLE versions (
converter TEXT
);
CREATE TABLE ps_boards (
id INTEGER NOT NULL PRIMARY KEY,
daughterboard_id INTEGER
@ -89,7 +93,8 @@ CREATE TABLE qaqc_positions (
id INTEGER NOT NULL PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
station INTEGER NOT NULL,
position INTEGER NOT NULL
position INTEGER NOT NULL,
rising_ns NUMERIC NOT NULL
);
CREATE VIEW qaqc_single_run_table

View file

@ -0,0 +1,21 @@
station,slot,jathub_sn,psb_position,,試験 run number,立ち上がり [ns],skew [ns]
0,0,121,,,,,
0,1,171,B-0-1,with UART,135,12.32142857,0.000
0,2,123,B-0-2,,137,12.55357143,0.232
0,3,124,B-0-3,,139,12.32142857,0.000
0,4,66,B-0-4,,141,13.17857143,0.857
0,5,126,B-0-5,,143,13.30357143,0.982
0,6,127,B-0-6,,145,13.91071429,1.589
0,7,128,B-0-7,,147,13.57142857,1.250
0,8,129,B-0-8,,149,12.26785714,-0.054
0,9,67,B-0-9,,151,14.03571429,1.714
1,0,131,,,,,
1,1,166,B-1-1,with SiTCP,136,11.85714286,-0.464
1,2,133,B-1-2,,138,12.01785714,-0.304
1,3,134,B-1-3,,140,12.67857143,0.357
1,4,135,B-1-4,,142,13.66071429,1.339
1,5,132,B-1-5,,144,13.48214286,1.161
1,6,137,B-1-6,,146,11.92857143,-0.393
1,7,138,B-1-7,,148,12.07142857,-0.250
1,8,139,B-1-8,,150,12.46428571,0.143
1,9,140,B-1-9,,152,12.30357143,-0.018
1 station slot jathub_sn psb_position 試験 run number 立ち上がり [ns] skew [ns]
2 0 0 121
3 0 1 171 B-0-1 with UART 135 12.32142857 0.000
4 0 2 123 B-0-2 137 12.55357143 0.232
5 0 3 124 B-0-3 139 12.32142857 0.000
6 0 4 66 B-0-4 141 13.17857143 0.857
7 0 5 126 B-0-5 143 13.30357143 0.982
8 0 6 127 B-0-6 145 13.91071429 1.589
9 0 7 128 B-0-7 147 13.57142857 1.250
10 0 8 129 B-0-8 149 12.26785714 -0.054
11 0 9 67 B-0-9 151 14.03571429 1.714
12 1 0 131
13 1 1 166 B-1-1 with SiTCP 136 11.85714286 -0.464
14 1 2 133 B-1-2 138 12.01785714 -0.304
15 1 3 134 B-1-3 140 12.67857143 0.357
16 1 4 135 B-1-4 142 13.66071429 1.339
17 1 5 132 B-1-5 144 13.48214286 1.161
18 1 6 137 B-1-6 146 11.92857143 -0.393
19 1 7 138 B-1-7 148 12.07142857 -0.250
20 1 8 139 B-1-8 150 12.46428571 0.143
21 1 9 140 B-1-9 152 12.30357143 -0.018

View file

@ -1,6 +1,7 @@
using Test
using PSBoardDataBase
using CSV, DataFrames
using SQLite, DBInterface
using Dates
true || include("../src/PSBoardDataBase.jl")
@ -34,8 +35,21 @@ true || include("../src/PSBoardDataBase.jl")
db = PSBoardDataBase.create_database(dbpath)
@info "" db
@test PSBoardDataBase.insert_version_info(db) |> isnothing
let stmt
stmt = DBInterface.prepare(
db,
sql"""
SELECT * FROM versions
""",
)
result = DBInterface.execute(stmt) |> DataFrame
@test nrow(result) |> ==(1)
end
@test PSBoardDataBase.insert_qaqc_campaign_id(db) |> isnothing
@test PSBoardDataBase.insert_qaqc_positions(db) |> isnothing
jathub_list_df = CSV.read("input/PS board QAQC Data Base - JATHub db.csv", DataFrame)
@test PSBoardDataBase.insert_qaqc_positions(db, jathub_list_df) |> isnothing
single_result_df =
CSV.read("input/PS board QAQC Data Base - 本番1回試験・追加検証試験.csv", DataFrame)