mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-06-08 05:55:42 +09:00
new(SlaveLogParser): power section parser
This commit is contained in:
parent
ccbcac3c16
commit
f325051a08
2 changed files with 87 additions and 29 deletions
|
@ -1,6 +1,7 @@
|
||||||
module SlaveLogParser
|
module SlaveLogParser
|
||||||
|
|
||||||
using StaticArrays
|
using StaticArrays
|
||||||
|
using Printf
|
||||||
using AutoHashEquals
|
using AutoHashEquals
|
||||||
|
|
||||||
const HEADER_QSPIP_START = "=============== Test QAPIp Start ==============="
|
const HEADER_QSPIP_START = "=============== Test QAPIp Start ==============="
|
||||||
|
@ -28,6 +29,7 @@ struct PowerResult
|
||||||
result_3v3a::Float64
|
result_3v3a::Float64
|
||||||
result_n3va::Float64
|
result_n3va::Float64
|
||||||
fpga_temp::Float64
|
fpga_temp::Float64
|
||||||
|
channelvals::SVector{16, @NamedTuple{dac::Int64, adc::Int64}}
|
||||||
|
|
||||||
result::Bool
|
result::Bool
|
||||||
end
|
end
|
||||||
|
@ -112,8 +114,52 @@ Parse Power section of given stateful iterator of log.
|
||||||
- `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)
|
||||||
# TODO
|
line = popfirst!(lines)
|
||||||
nothing
|
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
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -47,34 +47,46 @@ true || include("../src/PSBoardDataBase.jl")
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Slave Log parser" begin
|
@testset "Slave Log parser" begin
|
||||||
lines = Iterators.Stateful(
|
@testset "AsdtpResult" begin
|
||||||
Iterators.drop(eachline("./input/slavelogs/main/430_100.txt"), 2280),
|
lines = Iterators.Stateful(
|
||||||
)
|
Iterators.drop(eachline("./input/slavelogs/main/430_100.txt"), 2280),
|
||||||
result_asdtp = PSBoardDataBase.SlaveLogParser.parse_asdtp_section!(lines)
|
)
|
||||||
|
result_asdtp = PSBoardDataBase.SlaveLogParser.parse_asdtp_section!(lines)
|
||||||
|
|
||||||
@test result_asdtp == PSBoardDataBase.SlaveLogParser.AsdtpResult(
|
@test result_asdtp == PSBoardDataBase.SlaveLogParser.AsdtpResult(
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
fill(PSBoardDataBase.SlaveLogParser.AsdtpMeasurement.(fill((0, 1, 0), 32)), 8),
|
fill(
|
||||||
0,
|
PSBoardDataBase.SlaveLogParser.AsdtpMeasurement.(fill((0, 1, 0), 32)),
|
||||||
1,
|
8,
|
||||||
1,
|
),
|
||||||
0,
|
0,
|
||||||
0x1,
|
1,
|
||||||
0x1,
|
1,
|
||||||
0xff,
|
0,
|
||||||
0x0,
|
0x1,
|
||||||
0x0,
|
0x1,
|
||||||
0x0,
|
0xff,
|
||||||
MVector((0x1001, 0x2001, 0x3001, 0x4001, 0x5001, 0x6001, 0x7001, 0x8001)),
|
0x0,
|
||||||
)
|
0x0,
|
||||||
@info "pass"
|
0x0,
|
||||||
lines = Iterators.Stateful(
|
MVector((0x1001, 0x2001, 0x3001, 0x4001, 0x5001, 0x6001, 0x7001, 0x8001)),
|
||||||
Iterators.drop(eachline("./input/slavelogs/main/525_244.txt"), 2280),
|
)
|
||||||
)
|
|
||||||
result_asdtp = PSBoardDataBase.SlaveLogParser.parse_asdtp_section!(lines)
|
lines = Iterators.Stateful(
|
||||||
@test result_asdtp.reconfig_done == 0
|
Iterators.drop(eachline("./input/slavelogs/main/525_244.txt"), 2280),
|
||||||
|
)
|
||||||
|
result_asdtp = PSBoardDataBase.SlaveLogParser.parse_asdtp_section!(lines)
|
||||||
|
@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
|
end
|
||||||
|
|
||||||
@testset "Download data csv" begin
|
@testset "Download data csv" begin
|
||||||
|
|
Loading…
Add table
Reference in a new issue