Sotre a mapping of the local message type to the global mesg type on the reader struct

main
Jacob Windle 2023-04-25 08:57:39 -04:00
parent 79c21af5dd
commit 720e7cb28b
1 changed files with 7 additions and 2 deletions

View File

@ -55,10 +55,11 @@ mutable struct FITFileReader
bytes_read::Int64
header::Union{FITHeader, Nothing}
body::Union{Vector{DataRecord}, Nothing}
mesg_map::Dict{Real, AbstractString}
end
blank_file(fp::AbstractString) = FITFileReader(fp, nothing, 0, nothing, nothing)
blank_file(fp::AbstractString) = FITFileReader(fp, nothing, 0, nothing, nothing, Dict())
blank_row() = DataRecord(nothing)
blank_header_byte() = RecordHeader(false, false, 0)
@ -140,9 +141,13 @@ function read_record_content!(f::FITFileReader, hdr::RecordHeader)::Union{Defini
def_header_developer_fields = read_bytes!(f, def_header_developer_flag * 3)
end
# Associate the global message type with this local message type.
global_mesg_type = get_mesg_num_string(byte_vec_to_int(def_header_bytes[3:4]))
f.mesg_map[hdr.local_mesg_type] = global_mesg_type
DefinitionBody(
def_header_bytes[2] == 0 ? "littleendian" : "bigendian",
get_mesg_num_string(byte_vec_to_int(def_header_bytes[3:4])),
global_mesg_type,
def_header_bytes[end]
)
end