Begin body reading code
This commit is contained in:
+3
-5
@@ -1,11 +1,9 @@
|
|||||||
module FIT
|
module FIT
|
||||||
export greet_package
|
export read_file
|
||||||
export read_header, FITHeader
|
|
||||||
|
|
||||||
include("functions.jl")
|
include("file.jl")
|
||||||
include("header.jl")
|
|
||||||
|
|
||||||
using .header
|
using .file
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
"""
|
||||||
|
read the body of the FIT file.
|
||||||
|
"""
|
||||||
|
module body
|
||||||
|
|
||||||
|
# TODO: Why do this?
|
||||||
|
import Base.show
|
||||||
|
|
||||||
|
export RecordHeader, read_row
|
||||||
|
|
||||||
|
include("mesg_num.jl")
|
||||||
|
using .mesg_num
|
||||||
|
|
||||||
|
struct DefinitionMessage end
|
||||||
|
struct DataMessage end
|
||||||
|
|
||||||
|
"""
|
||||||
|
RecordHeader
|
||||||
|
|
||||||
|
The byte that corresponds to the type of message that this record holds.
|
||||||
|
"""
|
||||||
|
struct RecordHeader
|
||||||
|
definition_message::Bool
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
read_row(f::io)
|
||||||
|
|
||||||
|
Read a row of the file at a time. Parse the row into a data or def message.
|
||||||
|
TODO: Endianness matters here. Need to resolve endianness with the architecture bit.
|
||||||
|
"""
|
||||||
|
function read_row(f::IO)
|
||||||
|
header_byte = read(f, 1; all=false)[1]
|
||||||
|
println(bitstring(header_byte))
|
||||||
|
|
||||||
|
# The message byte is 7
|
||||||
|
RecordHeader(Bool(parse(Int64, bitstring(header_byte)[2])))
|
||||||
|
end
|
||||||
|
|
||||||
|
function read_header_byte(f::Core.IO)
|
||||||
|
end
|
||||||
|
|
||||||
|
function show(io::IO, header::RecordHeader)
|
||||||
|
println(io, header.definition_message ? "DefinitionMessage" : "DataMessage")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
module file
|
||||||
|
|
||||||
|
export FITFile, read_file
|
||||||
|
|
||||||
|
include("header.jl")
|
||||||
|
include("body.jl")
|
||||||
|
|
||||||
|
using .header
|
||||||
|
using .body
|
||||||
|
|
||||||
|
struct FITFile
|
||||||
|
header::FITHeader
|
||||||
|
body::RecordHeader
|
||||||
|
end
|
||||||
|
|
||||||
|
function read_file(filepath::AbstractString)::FITFile
|
||||||
|
open(filepath, "r") do f
|
||||||
|
header = read_header(f)
|
||||||
|
body = read_row(f)
|
||||||
|
FITFile(header, body)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
function greet_package()
|
|
||||||
print("Hello package")
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user