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 ¶
- func SortMessagesByTimestamp(messages []proto.Message)
- func ToMesgs[S []E, E ToMesg](messages *[]proto.Message, options *mesgdef.Options, mesgNum typedef.MesgNum, ...)
- type Activity
- type ActivitySummary
- type BloodPressure
- type Course
- type Device
- type File
- type FileSets
- type Goals
- type Listener
- type MonitoringAB
- type MonitoringDaily
- type Option
- type Schedules
- type Segment
- type SegmentList
- type Settings
- type Sport
- type ToMesg
- type Totals
- type Weight
- type Workout
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 // required fields: type, manufacturer, product, serial_number, time_created // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription // Required Messages Activity *mesgdef.Activity // required fields: timestamp, num_sessions, type, event, event_type Sessions []*mesgdef.Session // required fields: timestamp, start_time, total_elapsed_time, sport, event, event_type Laps []*mesgdef.Lap // required fields: timestamp, event, event_type Records []*mesgdef.Record // required fields: timestamp // Optional Messages UserProfile *mesgdef.UserProfile DeviceInfos []*mesgdef.DeviceInfo // required fields: timestamp Events []*mesgdef.Event Lengths []*mesgdef.Length // required fields: timestamp, event, event_type SegmentLap []*mesgdef.SegmentLap ZonesTargets []*mesgdef.ZonesTarget Workouts []*mesgdef.Workout WorkoutSteps []*mesgdef.WorkoutStep HRs []*mesgdef.Hr HRVs []*mesgdef.Hrv // required fields: time 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 ¶
NewActivity creates new Activity File.
type ActivitySummary ¶ added in v0.8.0
type ActivitySummary struct { FileId mesgdef.FileId // required fields: type, manufacturer, product, serial_number, time_created // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription Activity *mesgdef.Activity Sessions []*mesgdef.Session Laps []*mesgdef.Lap }
ActivitySummary is a compact version of the activity file and contain only activity, session and lap messages
func NewActivitySummary ¶ added in v0.8.0
func NewActivitySummary(mesgs ...proto.Message) *ActivitySummary
NewActivitySummary creates new ActivitySummary File.
func (*ActivitySummary) Add ¶ added in v0.8.0
func (f *ActivitySummary) Add(mesg proto.Message)
Add adds mesg to the ActivitySummary.
type BloodPressure ¶ added in v0.8.0
type BloodPressure struct { FileId mesgdef.FileId // required fields: type, manufacturer, product, serial_number // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription UserProfile *mesgdef.UserProfile BloodPressures []*mesgdef.BloodPressure DeviceInfos []*mesgdef.DeviceInfo }
BloodPressure files contain time-stamped discrete measurement data of blood pressure.
func NewBloodPressure ¶ added in v0.8.0
func NewBloodPressure(mesgs ...proto.Message) *BloodPressure
NewBloodPressure creates new BloodPressure File.
func (*BloodPressure) Add ¶ added in v0.8.0
func (f *BloodPressure) Add(mesg proto.Message)
Add adds mesg to the BloodPressure.
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 Device ¶ added in v0.8.0
type Device struct { FileId mesgdef.FileId // required fields: type, manufacturer, product, serial_number // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription Softwares []*mesgdef.Software Capabilities []*mesgdef.Capabilities FileCapabilities []*mesgdef.FileCapabilities MesgCapabilities []*mesgdef.MesgCapabilities FieldCapabilities []*mesgdef.FieldCapabilities }
Device files contain information about a device’s file structure/capabilities.
type File ¶
type File interface { // Add adds message into file structure. Add(mesg proto.Message) // ToFIT converts file back to proto.FIT structure. ToFIT(options *mesgdef.Options) 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. This alias is created for documentation purpose.
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 Goals ¶ added in v0.8.0
type Goals struct { FileId mesgdef.FileId // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription Goals []*mesgdef.Goal }
Goals files allow a user to communicate their exercise/health goals.
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 MonitoringAB ¶ added in v0.8.0
type MonitoringAB struct { FileId mesgdef.FileId // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription MonitoringInfo *mesgdef.MonitoringInfo Monitorings []*mesgdef.Monitoring DeviceInfos []*mesgdef.DeviceInfo }
MonitoringAB (Monitoring A and Monitoring B) files are used to store data that is logged over varying time intervals. The two monitoring file formats are identical apart from supporting different conventions for file_id.number and the start of accumulating data values.
The FIT file_id.type = 15 for a monitoring_a file and the FIT file_id.type = 32 for a monitoring_b file
func NewMonitoringAB ¶ added in v0.8.0
func NewMonitoringAB(mesgs ...proto.Message) *MonitoringAB
NewMonitoringAB creates new MonitoringAB File.
func (*MonitoringAB) Add ¶ added in v0.8.0
func (f *MonitoringAB) Add(mesg proto.Message)
Add adds mesg to the MonitoringAB.
type MonitoringDaily ¶ added in v0.8.0
type MonitoringDaily struct { FileId mesgdef.FileId // required fields: type, manufacturer, product, serial_number, time_created, number // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription MonitoringInfo *mesgdef.MonitoringInfo Monitorings []*mesgdef.Monitoring // required fields: timestamp DeviceInfos []*mesgdef.DeviceInfo }
MonitoringDaily files follow the same format as monitoring files, however data is logged at 24 hour time intervals.
func NewMonitoringDaily ¶ added in v0.8.0
func NewMonitoringDaily(mesgs ...proto.Message) *MonitoringDaily
NewMonitoringDaily creates new MonitoringDaily File.
func (*MonitoringDaily) Add ¶ added in v0.8.0
func (f *MonitoringDaily) Add(mesg proto.Message)
Add adds mesg to the MonitoringDaily.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithChannelBuffer ¶
WithChannelBuffer sets the size of buffered channel, default is 128.
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 Schedules ¶ added in v0.8.0
type Schedules struct { FileId mesgdef.FileId // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription Schedules []*mesgdef.Schedule }
Schedules files are used to schedule a user’s workouts and may contain multiple schedule messages each representing the start time of a workout.
func NewSchedules ¶ added in v0.8.0
NewSchedules creates new Schedules File.
type Segment ¶ added in v0.8.0
type Segment struct { FileId mesgdef.FileId // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription SegmentId *mesgdef.SegmentId SegmentLeaderboardEntry *mesgdef.SegmentLeaderboardEntry SegmentLap *mesgdef.SegmentLap SegmentPoints []*mesgdef.SegmentPoint }
Segment files contain data defining a route and timing information to gauge progress against previous performances or other users
func NewSegment ¶ added in v0.8.0
NewSegment creates new Segment File.
type SegmentList ¶ added in v0.8.0
type SegmentList struct { FileId mesgdef.FileId // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription FileCreator *mesgdef.FileCreator SegmentFiles []*mesgdef.SegmentFile }
SegmentList files maintain a list of available segments on the device.
func NewSegmentList ¶ added in v0.8.0
func NewSegmentList(mesgs ...proto.Message) *SegmentList
NewSegmentList creates new SegmentList File.
func (*SegmentList) Add ¶ added in v0.8.0
func (f *SegmentList) Add(mesg proto.Message)
Add adds mesg to the SegmentList.
type Settings ¶ added in v0.8.0
type Settings struct { FileId mesgdef.FileId // required fields: type, manufacturer, product, serial_number // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription UserProfiles []*mesgdef.UserProfile HrmProfiles []*mesgdef.HrmProfile SdmProfiles []*mesgdef.SdmProfile BikeProfiles []*mesgdef.BikeProfile DeviceSettings []*mesgdef.DeviceSettings }
Settings files contain user and device information in the form of profiles.
func NewSettings ¶ added in v0.8.0
NewSettings creates new Settings File.
type Sport ¶ added in v0.8.0
type Sport struct { FileId mesgdef.FileId // required fields: type, manufacturer, product, serial_number // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription ZonesTargets []*mesgdef.ZonesTarget Sport *mesgdef.Sport HrZones []*mesgdef.HrZone PowerZones []*mesgdef.PowerZone MetZones []*mesgdef.MetZone SpeedZones []*mesgdef.SpeedZone CadenceZones []*mesgdef.CadenceZone }
Sport files contain information about the user’s desired target zones.
type ToMesg ¶ added in v0.4.0
ToMesg is a type constraint to retrieve all mesgdef structures which implement ToMesg method.
type Totals ¶ added in v0.8.0
type Totals struct { FileId mesgdef.FileId // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription Totals []*mesgdef.Totals }
Totals files are used to summarize a user’s activities and may contain multiple totals messages each representing summaries of a different activity type/sport
type Weight ¶ added in v0.8.0
type Weight struct { FileId mesgdef.FileId // required fields: type, manufacturer, product, serial_number // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription UserProfile *mesgdef.UserProfile WeightScales []*mesgdef.WeightScale DeviceInfos []*mesgdef.DeviceInfo }
Weight contains time-stamped discrete measurement data of weight.
type Workout ¶ added in v0.2.0
type Workout struct { FileId mesgdef.FileId // required fields: type, manufacturer, product, serial_number, time_created // Developer Data Lookup DeveloperDataIds []*mesgdef.DeveloperDataId FieldDescriptions []*mesgdef.FieldDescription // Required Messages Workout *mesgdef.Workout // required fields: num_valid_steps WorkoutSteps []*mesgdef.WorkoutStep // required fields: message_index, duration_type, target_type UnrelatedMessages []proto.Message }
Workout is a file contains instructions for performing a structured activity.
ref: https://developer.garmin.com/fit/file-types/workout/
func NewWorkout ¶ added in v0.2.0
NewWorkout creates new Workout File.