PSBoardDataBase/examples/pllld_count.jl

264 lines
8.5 KiB
Julia

### A Pluto.jl notebook ###
# v0.20.3
using Markdown
using InteractiveUtils
# ╔═╡ 635dcf78-b6b3-11ef-3a04-f5b7c43ed12d
begin
using Pkg
Pkg.activate("..")
using PSBoardDataBase
using SQLite
using DataFrames
using CSV
using CairoMakie
using FHist
using LinearAlgebra
using Printf
using PlutoUI
end
# ╔═╡ 3fccbdca-9856-4122-8597-9f267f90d390
md"""
# 説明
第6回 PS-Board QAQC キャンペーンの11_27のファームウェアを使った100回試験において、PLLLD fail countの数の分布の調査
"""
# ╔═╡ 3e844f3d-0017-41ae-9632-ae0f7e2b03f7
TableOfContents()
# ╔═╡ 26954da1-0820-490d-aa3e-79fd3603d28a
md"""
# データベース読み込み
"""
# ╔═╡ a36886af-ff32-4f4f-a20f-f83bc333b8fd
db = SQLite.DB("../psboard_qaqc.db")
# ╔═╡ df5087be-18de-4714-b6d8-4ab54271b1fb
SQLite.tables(db)
# ╔═╡ 56d8896a-40e3-46e3-aa28-82f89476743b
qaqc_runs = DBInterface.execute(db, "select * from qaqc_runs") |> DataFrame
# ╔═╡ 08032250-5893-445c-8662-459e5636ba81
qaqc_extra_run_results =
DBInterface.execute(db, "select * from qaqc_extra_run_results") |> DataFrame
# ╔═╡ 013948ff-ccde-4222-862b-7ecda62fd7f1
qaqc_extra_run_campaign_6 = let
runids_campaign_6 = filter(:campaign_id => x -> (!ismissing(x) && x == 6), qaqc_runs).id
filter(:runid => in(runids_campaign_6), qaqc_extra_run_results)
end
# ╔═╡ 0282181f-2607-43b6-8456-813c2636dabf
md"""
# 解析
"""
# ╔═╡ ecb09aa6-7f2e-4ef7-a081-348a219272e0
md"""
## PLLLD fail count
"""
# ╔═╡ 41da581f-0cdf-40f3-a1f8-bf1bd7f8835b
map(eachrow(qaqc_extra_run_campaign_6)) do row
logfilename = "$(row.psboard_id)_$(row.runid)_longrun.txt"
logfile = joinpath("../test/input/slavelogs/main/", logfilename)
!ispath(logfile) && begin
@info "file $(logfile) not found"
return missing
end
slave_result = PSBoardDataBase.SlaveLogParser.parse_slavelog_file(logfile)
map(slave_result.asdtp) do asdtp_result
asdtp_result.pllld_fail_counter
end
end
# ╔═╡ 34ae2948-bb5a-4086-beb1-cfb77593d678
df_pllld_counts_camp6 = combine(
groupby(qaqc_extra_run_campaign_6, :id),
AsTable([:psboard_id, :runid]) =>
(
sdf -> begin
@assert nrow(sdf) == 1
logfilename = "$(sdf.psboard_id[1])_$(sdf.runid[1])_longrun.txt"
logfile = joinpath("../test/input/slavelogs/main/", logfilename)
!ispath(logfile) && begin
@warn "logfile $(logfile) not found"
return []
end
slave_result =
PSBoardDataBase.SlaveLogParser.parse_slavelog_file(logfile)
return map(slave_result.asdtp) do asdtp_result
(
psboard_id = sdf.psboard_id[1],
runid = sdf.runid[1],
pllld_count = asdtp_result.pllld_fail_counter + 1,
reset_failed_though_reconfig_done = let
asdtp_result.reconfig_done_2 == 0 &&
asdtp_result.pllld_fail_counter == 10
end,
)
end
end
) => [:psboard_id, :runid, :pllld_count, :reset_failed_though_reconfig_done],
)
# ╔═╡ c084b8f4-dbc2-497b-9132-7e4bd4fd3874
sort(df_pllld_counts_camp6, :pllld_count, rev = true)
# ╔═╡ 6d85cc29-0d02-43b4-8a50-57f003e4686b
let
df = combine(groupby(df_pllld_counts_camp6, :id), nrow)
sort!(df, :nrow)
end
# ╔═╡ e95447c1-a8e2-4a46-9320-e1a88d9e34da
unique(df_pllld_counts_camp6.psboard_id) |> sort
# ╔═╡ 0433bbe4-1f71-4cf7-96ec-ac9c70170feb
stephist(df_pllld_counts_camp6.pllld_count)
# ╔═╡ f04d5c95-7308-4129-ba95-49da2e142d5d
let
h1 = Hist1D(df_pllld_counts_camp6.pllld_count; binedges = 1:1:10, overflow = false)
h1 = normalize(h1)
fig = Figure()
ax = Axis(
fig[1, 1],
yscale = log10,
xlabel = "Number of resets before PLL lock",
ylabel = "fraction",
title = "PLLLD count ratios of 6th QAQC 100 test results",
)
stephist!(ax, h1, label = "pllld fail count")
errorbars!(ax, h1)
text!(
ax,
bincenters(h1),
bincounts(h1),
text = [@sprintf "%.4g" r for r in bincounts(h1)],
)
axislegend(position = :rt)
Label(
fig[1, 1],
"""
n = $(nentries(h1))
$(length(unique(df_pllld_counts_camp6.psboard_id))) PS-Boards
""",
tellwidth = false,
tellheight = false,
halign = :right,
padding = (20, 20, 20, 20),
)
save("pllld_fail_counts.svg", fig)
fig
end
# ╔═╡ 650482e5-9b79-4304-aa5a-2b7c9a377013
md"""
## "reconfig_done = 0なのにresetしていない" の数
"""
# ╔═╡ 4b9c0bd8-b17a-4933-8d6e-2da884fc4b5e
combine(
groupby(df_pllld_counts_camp6, :id),
AsTable(:) =>
(
sdf -> begin
@assert allequal(sdf.psboard_id)
@assert allequal(sdf.runid)
(
reset_failed_though_reconfig_done = count(
sdf.reset_failed_though_reconfig_done,
),
psboard_id = first(sdf.psboard_id),
runid = first(sdf.runid),
)
end
) => [:reset_failed_though_reconfig_done, :psboard_id, :runid],
)
# ╔═╡ a0baf37c-8b05-49c1-a6a4-027f3404f8b4
df_reset_failed_though_reconfig_done = combine(
groupby(qaqc_extra_run_results, :id),
AsTable([:psboard_id, :runid]) =>
(
sdf -> begin
@assert nrow(sdf) == 1
logfilename = "$(sdf.psboard_id[1])_$(sdf.runid[1])_longrun.txt"
logfile = joinpath("../test/input/slavelogs/main/", logfilename)
!ispath(logfile) && begin
@warn "logfile $(logfile) not found"
return (
psboard_id = sdf.psboard_id[1],
runid = sdf.runid[1],
reset_failed_though_reconfig_done = missing,
)
end
if sdf.runid[1] == 99
@info "skipping runid 99 since it is not exactly 100 run"
return (
psboard_id = sdf.psboard_id[1],
runid = sdf.runid[1],
reset_failed_though_reconfig_done = missing,
)
end
slave_result =
PSBoardDataBase.SlaveLogParser.parse_slavelog_file(logfile)
return (
psboard_id = sdf.psboard_id[1],
runid = sdf.runid[1],
reset_failed_though_reconfig_done = count(
slave_result.asdtp,
) do asdtp_result
asdtp_result.reconfig_done_2 == 0 &&
asdtp_result.pllld_fail_counter == 10
end,
)
end
) => [:psboard_id, :runid, :reset_failed_though_reconfig_done],
)
# ╔═╡ 14519d45-a6a9-4ba1-a4f2-9597d1335b2c
let
df_compare = outerjoin(
df_reset_failed_though_reconfig_done,
select(qaqc_extra_run_results, [:id, :reset_failed_though_reconfig_done]),
on = :id,
renamecols = "_old" => "_new",
)
end
# ╔═╡ dfeb3900-539f-4d8d-8103-edb67cf4e890
#CSV.write("reset_failed_though_reconfig_done.csv", df_reset_failed_though_reconfig_done)
# ╔═╡ Cell order:
# ╠═3fccbdca-9856-4122-8597-9f267f90d390
# ╠═635dcf78-b6b3-11ef-3a04-f5b7c43ed12d
# ╠═3e844f3d-0017-41ae-9632-ae0f7e2b03f7
# ╟─26954da1-0820-490d-aa3e-79fd3603d28a
# ╠═a36886af-ff32-4f4f-a20f-f83bc333b8fd
# ╠═df5087be-18de-4714-b6d8-4ab54271b1fb
# ╠═56d8896a-40e3-46e3-aa28-82f89476743b
# ╠═08032250-5893-445c-8662-459e5636ba81
# ╠═013948ff-ccde-4222-862b-7ecda62fd7f1
# ╟─0282181f-2607-43b6-8456-813c2636dabf
# ╟─ecb09aa6-7f2e-4ef7-a081-348a219272e0
# ╠═41da581f-0cdf-40f3-a1f8-bf1bd7f8835b
# ╠═34ae2948-bb5a-4086-beb1-cfb77593d678
# ╠═c084b8f4-dbc2-497b-9132-7e4bd4fd3874
# ╠═6d85cc29-0d02-43b4-8a50-57f003e4686b
# ╠═e95447c1-a8e2-4a46-9320-e1a88d9e34da
# ╠═0433bbe4-1f71-4cf7-96ec-ac9c70170feb
# ╠═f04d5c95-7308-4129-ba95-49da2e142d5d
# ╟─650482e5-9b79-4304-aa5a-2b7c9a377013
# ╠═4b9c0bd8-b17a-4933-8d6e-2da884fc4b5e
# ╠═a0baf37c-8b05-49c1-a6a4-027f3404f8b4
# ╠═14519d45-a6a9-4ba1-a4f2-9597d1335b2c
# ╠═dfeb3900-539f-4d8d-8103-edb67cf4e890