diff --git a/src/file.jl b/src/file.jl index f5b2cd3..f0dfc8f 100644 --- a/src/file.jl +++ b/src/file.jl @@ -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