new(SlaveLogParser): power section parser

This commit is contained in:
Wataru Otsubo 2024-10-29 18:02:01 +09:00
parent ccbcac3c16
commit f325051a08
2 changed files with 87 additions and 29 deletions

View file

@ -1,6 +1,7 @@
module SlaveLogParser
using StaticArrays
using Printf
using AutoHashEquals
const HEADER_QSPIP_START = "=============== Test QAPIp Start ==============="
@ -28,6 +29,7 @@ struct PowerResult
result_3v3a::Float64
result_n3va::Float64
fpga_temp::Float64
channelvals::SVector{16, @NamedTuple{dac::Int64, adc::Int64}}
result::Bool
end
@ -112,8 +114,52 @@ Parse Power section of given stateful iterator of log.
- `lines`: Stateful iterator of slave log file lines
"""
function parse_power_section!(lines::Base.Iterators.Stateful)
# TODO
nothing
line = popfirst!(lines)
result_3v3d = let
m = match(r"^3V3D \[V\] = ([\d|\.]+)$", line)
parse(Float64, m[1])
end
line = popfirst!(lines)
result_3v3a = let
m = match(r"^3V3A \[V\] = ([\d|\.]+)$", line)
parse(Float64, m[1])
end
line = popfirst!(lines)
result_n3va = let
m = match(r"^-3VA \[V\] = ([-|\d|\.]+)$", line)
parse(Float64, m[1])
end
line = popfirst!(lines)
fpga_temp = let
m = match(r"^FPGA Temprature \[C\] = ([\d|\.]+)$", line)
parse(Float64, m[1])
end
line = popfirst!(lines)
line = popfirst!(lines)
channelvals =
Iterators.map(1:16) do ch
ch_s = @sprintf "%x" (ch - 1)
re = Regex(
"channel $(ch_s): DAC \\[mV\\] = (\\d+), ADC \\[mV\\] = (\\d+)\$",
)
line = popfirst!(lines) # I'm not sure this mutating operation is called in sequence
m = match(re, line)
@info "" m line
(dac = parse(Int64, m[1]), adc = parse(Int64, m[2]))
end |>
Tuple |>
SVector
line = popfirst!(lines)
result = let
m = match(r"^Test Power Reseult = (\d)$", line)
if m[1] == "1"
true
else
false
end
end
PowerResult(result_3v3d, result_3v3a, result_n3va, fpga_temp, channelvals, result)
end
"""

View file

@ -47,6 +47,7 @@ true || include("../src/PSBoardDataBase.jl")
end
@testset "Slave Log parser" begin
@testset "AsdtpResult" begin
lines = Iterators.Stateful(
Iterators.drop(eachline("./input/slavelogs/main/430_100.txt"), 2280),
)
@ -56,7 +57,10 @@ true || include("../src/PSBoardDataBase.jl")
1,
0,
true,
fill(PSBoardDataBase.SlaveLogParser.AsdtpMeasurement.(fill((0, 1, 0), 32)), 8),
fill(
PSBoardDataBase.SlaveLogParser.AsdtpMeasurement.(fill((0, 1, 0), 32)),
8,
),
0,
1,
1,
@ -69,7 +73,7 @@ true || include("../src/PSBoardDataBase.jl")
0x0,
MVector((0x1001, 0x2001, 0x3001, 0x4001, 0x5001, 0x6001, 0x7001, 0x8001)),
)
@info "pass"
lines = Iterators.Stateful(
Iterators.drop(eachline("./input/slavelogs/main/525_244.txt"), 2280),
)
@ -77,6 +81,14 @@ true || include("../src/PSBoardDataBase.jl")
@test result_asdtp.reconfig_done == 0
end
@testset "Power" begin
lines = Iterators.Stateful(
Iterators.drop(eachline("./input/slavelogs/main/430_100.txt"), 1915),
)
PSBoardDataBase.SlaveLogParser.parse_power_section!(lines)
end
end
@testset "Download data csv" begin
out = tempname()
@test CSV.read(