Skip to content

Workout decoders, for cycling apps. Currently supports zwo and fit files under a common interface

License

Notifications You must be signed in to change notification settings

michallaskowski/WorkoutDecoders

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WorkoutDecoders

About the project

A common interface for (currently) two decoders:

  • zwo files (xml format)
  • fit files (binary format)

that allow to create a common model of a workout. See Sources/WorkoutDecoderBase/WorkoutDecoding.swift for model definitions.

Models are easy to use:

  • intervals are flattened
  • messages' time offset are normalized with respect to the beginning of the training

Built with

Getting started

To use the decoders in your project, add this Swift Package in your project. You can choose individual decoders, or a common facade WorkoutDecoders.

Usage

See tests for example of decoding workouts. Workout definitions may be using both absolute and FTP relative values, but for simplicity workouts are decoded to contain only FTP relative values. That's why FTP is needed for FIT file decoding.

let decoder = WorkoutDecoder(userFtp: 200)
let file = Bundle.module.url(forResource: "workout", withExtension: "fit")!
do {
  let data = try Data(contentsOf: file)
  let workout = try decoder.decodeWorkout(fileFormat: "fit", data: data)
  // use workout
} catch {
  // handle decoding errors
}

Roadmap

  1. Need to add a test for FIT file decoding. Will need to find a file that I can publish, or find a tool to create one.
  2. Potential support for FIT notes as messages.

For an app I am developing, ZWO and FIT file support is enough. MRC, ERG or other file support could be added if needed, but preferably by providing a PR :)
Workout model could be extended if there is also a need for that.

Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

About

Workout decoders, for cycling apps. Currently supports zwo and fit files under a common interface

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages