Documentation
¶
Overview ¶
Package filedef contains the implementation of known common file types and its listener to convert decoded FIT file into the desired common file type as soon as the message is decoded.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortMessagesByTimestamp ¶ added in v0.2.0
SortMessagesByTimestamp sorts messages by timestamp only if the message has timestamp field. When a message has no timestamp field, its order will not be changed.
Types ¶
type Activity ¶
type Activity struct { FileId mesgdef.FileId // must have mesg // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription // Required Messages Activity *mesgdef.Activity Sessions []*mesgdef.Session Laps []*mesgdef.Lap Records []*mesgdef.Record // Optional Messages UserProfile *mesgdef.UserProfile DeviceInfos []*mesgdef.DeviceInfo Events []*mesgdef.Event Lengths []*mesgdef.Length SegmentLap []*mesgdef.SegmentLap ZonesTargets []*mesgdef.ZonesTarget Workouts []*mesgdef.Workout WorkoutSteps []*mesgdef.WorkoutStep HRs []*mesgdef.Hr HRVs []*mesgdef.Hrv UnrelatedMessages []proto.Message }
Activity is a common file type that most wearable device or cycling computer uses to record activities.
Please note since we group the same mesgdef types in slices, we lose the arrival order of the messages. But for messages that have timestamp, we can reconstruct the messages by timestamp order.
ref: https://developer.garmin.com/fit/file-types/activity/
func NewActivity ¶
type Course ¶ added in v0.2.0
type Course struct { FileId mesgdef.FileId // must have mesg // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription // Required Messages Course *mesgdef.Course Lap *mesgdef.Lap Records []*mesgdef.Record Events []*mesgdef.Event // Optional Messages CoursePoints []*mesgdef.CoursePoint UnrelatedMessages []proto.Message }
Course is a common file type used as points of courses to assist with on- and off-road navigation, to provide turn by turn directions, or with virtual training applications to simulate real-world activities.
Please note since we group the same mesgdef types in slices, we lose the arrival order of the messages. But for messages that have timestamp, we can reconstruct the messages by timestamp order.
type File ¶
type File interface { // Add adds message into file structure. Add(mesg proto.Message) // ToFit converts file back to proto.Fit structure. ToFit(fac mesgdef.Factory) proto.Fit }
File is an interface for defining common type file, any defined common file type should implement the following methods to be able to work with Listener (and other building block in filedef package).
type FileSets ¶ added in v0.2.0
FileSets is a set of file type mapped to a function to create that File.
func PredefinedFileSet ¶ added in v0.2.0
func PredefinedFileSet() FileSets
PredefinedFileSet is a list of default filesets used in listener, it's exported so user can append their own types and register it as an option.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is Message Listener.
func (*Listener) Close ¶ added in v0.2.0
func (l *Listener) Close()
Close closes channel and wait until all messages is consumed.
func (*Listener) File ¶
File returns the resulting file after the a single decode process is completed. If we the current decoded result is not listed in fileSets, nil will be returned, it's recommended to use switch type assertion to check. This will reset fields used by listener and the listener is ready to be used for next chained FIT file.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithChannelBuffer ¶
WithChannelBuffer sets the size of buffered channel, default is 1000.
func WithFileSets ¶ added in v0.2.0
WithFileSets sets what kind of file listener should listen to, when we encounter a file type that is not listed in fileset, that file type will be skipped. This will replace the default filesets registered in listener, if you intend to append your own file types, please call PredefinedFileSet() and add your file types.
type ToMesg ¶ added in v0.4.0
ToMesg is a type constraint to retrieve all mesgdef structures which implement ToMesg method.
type Workout ¶ added in v0.2.0
type Workout struct { FileId mesgdef.FileId // must have mesg // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription // Required Messages Workout *mesgdef.Workout WorkoutSteps []*mesgdef.WorkoutStep UnrelatedMessages []proto.Message }
Workout is a file contains instructions for performing a structured activity.
ref: https://developer.garmin.com/fit/file-types/workout/