From 49e91906f861071bfe497b3942bde3e156b09226 Mon Sep 17 00:00:00 2001 From: Manu Le Guirriec <eleguirriec@km3net.de> Date: Wed, 17 Apr 2024 13:52:44 +0000 Subject: [PATCH] Create DAQSummaryslice object --- src/controlhost.jl | 1 + src/daq.jl | 37 +++++++++++++++++++++++++++++++++++++ src/exports.jl | 1 + src/types.jl | 10 ++++++++++ 4 files changed, 49 insertions(+) diff --git a/src/controlhost.jl b/src/controlhost.jl index 0d55d006..a5f00c45 100644 --- a/src/controlhost.jl +++ b/src/controlhost.jl @@ -100,6 +100,7 @@ struct CHClient{T} end CHTag(::Type{T}) where T = error("No controlhost tag defined for type '$(T)'") CHTag(::Type{DAQEvent}) = CHTag("IO_EVT") +CHTag(::Type{DAQSummaryslice}) = CHTag("IO_SUM") CHClient(ip::IPv4, port::Integer, tags::Vector{CHTag}) = CHClient{CHMessage}(ip, port, tags) CHClient{T}(ip::IPv4, port::Integer) where T = CHClient{T}(ip, port, [CHTag(T)]) Base.eltype(::CHClient{T}) where T = T diff --git a/src/daq.jl b/src/daq.jl index d2f9981f..2b6f530d 100644 --- a/src/daq.jl +++ b/src/daq.jl @@ -1,4 +1,5 @@ # Online DAQ readout +using StaticArrays function Base.read(s::IO, ::Type{T}; legacy=false) where T<:DAQEvent length = read(s, Int32) @@ -52,3 +53,39 @@ function Base.read(s::IO, ::Type{T}; legacy=false) where T<:DAQEvent T(header, snapshot_hits, triggered_hits) end + + +function Base.read(s::IO, ::Type{T}; legacy=false) where T<:DAQSummaryslice + length = read(s, Int32) + type = read(s, Int32) + version = Int16(0) + !legacy && (version = read(s, Int16)) + + detector_id = read(s, Int32) + run_id = read(s, Int32) + frame_index = read(s, Int32) + utc_seconds = read(s, UInt32) + utc_16nanosecondcycles = read(s, UInt32) # 16ns ticks + + header = SummarysliceHeader( + detector_id, + run_id, + frame_index, + UTCExtended(utc_seconds, utc_16nanosecondcycles) + ) + n_frames = read(s, Int32) + summary_frames = Vector{SummaryFrame}() + sizehint!(summary_frames, n_frames) + @inbounds for i ∈ 1:n_frames + dom_id = read(s, Int32) + daq = read(s, UInt32) + status = read(s,UInt32) + fifo = read(s,UInt32) + status3 = read(s,UInt32) + status4 = read(s,UInt32) + rates = @SVector [read(s,UInt8) for i ∈ 1:31] + push!(summary_frames, SummaryFrame(dom_id, daq, status, fifo, status3, status4, rates)) + end + + T(header, summary_frames) +end diff --git a/src/exports.jl b/src/exports.jl index a4b7b646..dfd35e56 100644 --- a/src/exports.jl +++ b/src/exports.jl @@ -44,6 +44,7 @@ ROOTFile, # Online dataformat DAQEvent, +DAQSummaryslice, EventHeader, SnapshotHit, SummaryFrame, diff --git a/src/types.jl b/src/types.jl index 7cb51ff1..efb969cc 100644 --- a/src/types.jl +++ b/src/types.jl @@ -205,3 +205,13 @@ struct DAQEvent snapshot_hits::Vector{SnapshotHit} triggered_hits::Vector{TriggeredHit} end + +""" + +DAQSummaryslice from JLigier + +""" +struct DAQSummaryslice + header::SummarysliceHeader + summary_frames::Vector{SummaryFrame} +end -- GitLab