Copyright | Copyright 2014-2015, Matt Giles |
---|---|
License | Modified BSD License (see LICENSE file) |
Maintainer | matt.w.giles@gmail.com |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
- data Fit = Fit {}
- data FitHeader = FH {
- fhSize :: !Word8
- fhProtocolVersion :: !Word8
- fhProfileVersion :: !Word16
- fhDataSize :: !Word32
- fhDataType :: ByteString
- fhCrc :: !(Maybe Word16)
- data Message
- msgLmt :: Message -> LocalMessageType
- data MessageDefinition = MessageDef {
- defLocalType :: !LocalMessageType
- defGlobalType :: !Int
- defArch :: !Arch
- defFields :: [FieldDef]
- data FieldDef = FieldDef {}
- data Field
- = SingletonField !Int Value
- | ArrayField !Int Array
- data Value
- data Array
- = EnumArray (Seq Word8)
- | SInt8Array (Seq Int8)
- | UInt8Array (Seq Word8)
- | SInt16Array (Seq Int16)
- | UInt16Array (Seq Word16)
- | SInt32Array (Seq Int32)
- | UInt32Array (Seq Word32)
- | Float32Array (Seq Float)
- | Float64Array (Seq Double)
- | UInt8ZArray (Seq Word8)
- | UInt16ZArray (Seq Word16)
- | UInt32ZArray (Seq Word32)
- | ByteArray (Seq Word8)
- data MessageHeader
- newtype LocalMessageType = LMT {}
- mkLocalMessageType :: (Integral a, Bits a) => a -> LocalMessageType
- unLocalMessageType :: Integral a => LocalMessageType -> a
- newtype TimeOffset = TO {}
- mkTimeOffset :: (Integral a, Bits a) => a -> TimeOffset
- newtype Timestamp = Timestamp {}
- data BaseType
- btSize :: BaseType -> Int
Documentation
A FIT file consists of a header and a collection of messages.
The FIT file header
FH | |
|
There are two kinds of FIT messages:
- Definition messages set the structure for messages of a particular local message type
- Data messages contain the actual information, according to the structure given by a definition message.
msgLmt :: Message -> LocalMessageType Source
data MessageDefinition Source
A MessageDefinition
for a local message type (LMT) determines how future data messages with
that LMT are decoded. LMTs can be re-used: a data message with LMT n
will use the most recent
message definition for LMT n
.
MessageDef | |
|
Defines the structure for a single field in a message
FieldDef | |
|
A single field in a data message, containing the field number and the value(s)
Singleton values. There is a Value constructor for each BaseType constructor. The wrapped
value in these constructors corresponds to the specific format used in the FIT file, for
example an enum
in FIT is stored as an 8-bit unsigned int (ie a Word8). The primary exception
to this is using Text
for string values.
EnumValue !Word8 | |
SInt8Value !Int8 | |
UInt8Value !Word8 | |
SInt16Value !Int16 | |
UInt16Value !Word16 | |
SInt32Value !Int32 | |
UInt32Value !Word32 | |
StringValue Text | A |
Float32Value !Float | |
Float64Value !Double | |
UInt8ZValue !Word8 | |
UInt16ZValue !Word16 | |
UInt32ZValue !Word32 | |
ByteValue !Word8 |
Array values use similar constructors to singleton values. However, there is no constructor for arrays of strings, which seem to be unused in FIT.
EnumArray (Seq Word8) | |
SInt8Array (Seq Int8) | |
UInt8Array (Seq Word8) | |
SInt16Array (Seq Int16) | |
UInt16Array (Seq Word16) | |
SInt32Array (Seq Int32) | |
UInt32Array (Seq Word32) | |
Float32Array (Seq Float) | |
Float64Array (Seq Double) | |
UInt8ZArray (Seq Word8) | |
UInt16ZArray (Seq Word16) | |
UInt32ZArray (Seq Word32) | |
ByteArray (Seq Word8) |
data MessageHeader Source
Each message has a header that primarily determines whether the message is a definition or data message. If the message uses a compressed timestamp header, the header also contains the compressed time offset.
newtype LocalMessageType Source
A local message type is a 4 bit unsigned integer
mkLocalMessageType :: (Integral a, Bits a) => a -> LocalMessageType Source
Only the lower 4 bits of the integer are used to construct a LocalMessageType
unLocalMessageType :: Integral a => LocalMessageType -> a Source
Unwrap a LocalMessageType
. The resulting integer will be between 0 and 15
mkTimeOffset :: (Integral a, Bits a) => a -> TimeOffset Source
Only the lower 5 bits of the number are used
The different types that FIT uses for field values