mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-06-08 05:55:42 +09:00
add(SlaveLogParser): test for full file (log)
- also added a test case (364_88_longrun)
This commit is contained in:
parent
3d4865c18f
commit
5ca921bcfc
4 changed files with 30366 additions and 12 deletions
|
@ -109,14 +109,14 @@ function parse_qspip_section!(lines::Base.Iterators.Stateful)
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
parse_power_section(lines::Base.Iterators.Stateful)
|
parse_power_section!(lines::Base.Iterators.Stateful)::PowerResult
|
||||||
|
|
||||||
Parse Power section of given stateful iterator of log.
|
Parse Power section of given stateful iterator of log.
|
||||||
|
|
||||||
# Args
|
# Args
|
||||||
- `lines`: Stateful iterator of slave log file lines
|
- `lines`: Stateful iterator of slave log file lines
|
||||||
"""
|
"""
|
||||||
function parse_power_section!(lines::Base.Iterators.Stateful)
|
function parse_power_section!(lines::Base.Iterators.Stateful)::PowerResult
|
||||||
line = popfirst!(lines)
|
line = popfirst!(lines)
|
||||||
result_3v3d = let
|
result_3v3d = let
|
||||||
m = match(r"^3V3D \[V\] = ([\d|\.]+)$", line)
|
m = match(r"^3V3D \[V\] = ([\d|\.]+)$", line)
|
||||||
|
@ -142,9 +142,7 @@ function parse_power_section!(lines::Base.Iterators.Stateful)
|
||||||
channelvals =
|
channelvals =
|
||||||
Iterators.map(1:16) do ch
|
Iterators.map(1:16) do ch
|
||||||
ch_s = @sprintf "%x" (ch - 1)
|
ch_s = @sprintf "%x" (ch - 1)
|
||||||
re = Regex(
|
re = Regex("channel $(ch_s): DAC \\[mV\\] = (\\d+), ADC \\[mV\\] = (\\d+)\$")
|
||||||
"channel $(ch_s): DAC \\[mV\\] = (\\d+), ADC \\[mV\\] = (\\d+)\$",
|
|
||||||
)
|
|
||||||
line = popfirst!(lines) # I'm not sure this mutating operation is called in sequence
|
line = popfirst!(lines) # I'm not sure this mutating operation is called in sequence
|
||||||
m = match(re, line)
|
m = match(re, line)
|
||||||
(dac = parse(Int64, m[1]), adc = parse(Int64, m[2]))
|
(dac = parse(Int64, m[1]), adc = parse(Int64, m[2]))
|
||||||
|
@ -200,14 +198,14 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
parse_asdtp_section(lines::Base.Iterators.Stateful)
|
parse_asdtp_section!(lines::Base.Iterators.Stateful)::AsdtpResult
|
||||||
|
|
||||||
Parse ASDTP section of given stateful iterator of log.
|
Parse ASDTP section of given stateful iterator of log.
|
||||||
|
|
||||||
# Args
|
# Args
|
||||||
- `lines`: Stateful iterator of slave log file lines
|
- `lines`: Stateful iterator of slave log file lines
|
||||||
"""
|
"""
|
||||||
function parse_asdtp_section!(lines::Base.Iterators.Stateful)
|
function parse_asdtp_section!(lines::Base.Iterators.Stateful)::AsdtpResult
|
||||||
line = popfirst!(lines)
|
line = popfirst!(lines)
|
||||||
result_reconfig_done = let
|
result_reconfig_done = let
|
||||||
m = match(r"^reconfig_done = (\d+)$", line)
|
m = match(r"^reconfig_done = (\d+)$", line)
|
||||||
|
@ -363,11 +361,13 @@ Main function to parse slave log file.
|
||||||
function parse_slavelog_file(filename::AbstractString)
|
function parse_slavelog_file(filename::AbstractString)
|
||||||
lines_iter = Iterators.Stateful(eachline(filename))
|
lines_iter = Iterators.Stateful(eachline(filename))
|
||||||
|
|
||||||
asdtp_results = Any[]
|
asdtp_results = AsdtpResult[]
|
||||||
|
power_results = PowerResult[]
|
||||||
|
|
||||||
mode::SlaveLogSection = MODE_NONE
|
mode::SlaveLogSection = MODE_NONE
|
||||||
# main loop
|
# main loop
|
||||||
while !isempty(lines_iter)
|
while !isempty(lines_iter)
|
||||||
|
# @info "section" mode
|
||||||
# each sections
|
# each sections
|
||||||
if mode == MODE_NONE
|
if mode == MODE_NONE
|
||||||
line = popfirst!(lines_iter)
|
line = popfirst!(lines_iter)
|
||||||
|
@ -376,7 +376,8 @@ function parse_slavelog_file(filename::AbstractString)
|
||||||
parse_qspip_section!(lines_iter)
|
parse_qspip_section!(lines_iter)
|
||||||
mode = MODE_NONE
|
mode = MODE_NONE
|
||||||
elseif mode == MODE_POWER
|
elseif mode == MODE_POWER
|
||||||
parse_power_section!(lines_iter)
|
result = parse_power_section!(lines_iter)
|
||||||
|
push!(power_results, result)
|
||||||
mode = MODE_NONE
|
mode = MODE_NONE
|
||||||
elseif mode == MODE_ASDTP
|
elseif mode == MODE_ASDTP
|
||||||
result = parse_asdtp_section!(lines_iter)
|
result = parse_asdtp_section!(lines_iter)
|
||||||
|
@ -388,8 +389,7 @@ function parse_slavelog_file(filename::AbstractString)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@info "Finished"
|
return (asdtp = asdtp_results, power = power_results)
|
||||||
return asdtp_results
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function eff99_count_map(asdtp_results)
|
function eff99_count_map(asdtp_results)
|
||||||
|
@ -406,4 +406,4 @@ function eff99_count_map(asdtp_results)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end # module SlaveLogParser
|
||||||
|
|
1
test/input/.gitignore
vendored
1
test/input/.gitignore
vendored
|
@ -8,3 +8,4 @@ slavelogs/main/*
|
||||||
!slavelogs/main/525_244.txt
|
!slavelogs/main/525_244.txt
|
||||||
!slavelogs/main/525_245_longrun.txt
|
!slavelogs/main/525_245_longrun.txt
|
||||||
!slavelogs/main/430_100.txt
|
!slavelogs/main/430_100.txt
|
||||||
|
!slavelogs/main/364_88_longrun.txt
|
||||||
|
|
30315
test/input/slavelogs/main/364_88_longrun.txt
Normal file
30315
test/input/slavelogs/main/364_88_longrun.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -98,6 +98,44 @@ true || include("../src/PSBoardDataBase.jl")
|
||||||
@test result.result_3v3a == 2.91
|
@test result.result_3v3a == 2.91
|
||||||
@test result.result_n3va == -3.01
|
@test result.result_n3va == -3.01
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@testset "Integrated" begin
|
||||||
|
result = PSBoardDataBase.SlaveLogParser.parse_slavelog_file(
|
||||||
|
"./input/slavelogs/main/430_100.txt",
|
||||||
|
)
|
||||||
|
@test result isa NamedTuple
|
||||||
|
@test result.asdtp |> length |> ==(1)
|
||||||
|
@test result.power |> length |> ==(1)
|
||||||
|
@test result.power[1].result_3v3d == 3.43
|
||||||
|
|
||||||
|
@test PSBoardDataBase.SlaveLogParser.parse_slavelog_file(
|
||||||
|
"./input/slavelogs/main/525_244.txt",
|
||||||
|
) isa NamedTuple
|
||||||
|
|
||||||
|
result = PSBoardDataBase.SlaveLogParser.parse_slavelog_file(
|
||||||
|
"./input/slavelogs/main/525_245_longrun.txt",
|
||||||
|
)
|
||||||
|
@test result isa NamedTuple
|
||||||
|
# @test result.asdtp |> length |> ==(100)
|
||||||
|
@test result.power |> length |> ==(0)
|
||||||
|
@info "" result.asdtp |> length result.power |> length
|
||||||
|
@test readlines("./input/slavelogs/main/525_245_longrun.txt") |>
|
||||||
|
filter(contains("=== Test Power Start ==")) |>
|
||||||
|
length |>
|
||||||
|
==(length(result.power))
|
||||||
|
|
||||||
|
result = PSBoardDataBase.SlaveLogParser.parse_slavelog_file(
|
||||||
|
"./input/slavelogs/main/364_88_longrun.txt",
|
||||||
|
)
|
||||||
|
@test result isa NamedTuple
|
||||||
|
@test result.asdtp |> length |> ==(100)
|
||||||
|
@test result.power |> length |> ==(0)
|
||||||
|
@info "" result.asdtp |> length result.power |> length
|
||||||
|
@test readlines("./input/slavelogs/main/364_88_longrun.txt") |>
|
||||||
|
filter(contains("=== Test Power Start ==")) |>
|
||||||
|
length |>
|
||||||
|
==(length(result.power))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Download data csv" begin
|
@testset "Download data csv" begin
|
||||||
|
|
Loading…
Add table
Reference in a new issue