Repository navigation
TcxImportPlan
Up | Previous | Next | Русский
Below is the full source of the class in documentation form. The comments inside the block explain the purpose of the parts of the class, but they are not stored in the working file TcxImportPlan.java: the production code stays clean and the explanations live in the wiki.
package com.velitask.plugin.official.processing.plans;
import com.velitask.plugin.official.processing.compress.SameValueCompress;
import com.velitask.plugin.official.processing.filters.BadPointFilter;
import com.velitask.plugin.official.processing.filters.CyclingPowerBadPointFilter;
import com.velitask.plugin.official.processing.filters.HeartBadPointFilter;
import com.velitask.plugin.official.processing.filters.SlopeBadPointFilter;
import com.velitask.plugin.official.processing.gaps.ExplicitGaps;
import com.velitask.plugin.official.processing.gaps.UnchangedGaps;
import com.velitask.sdk.SensorType;
import com.velitask.sdk.scenario.ImportPlan;
import java.util.Map;
/* Import plan for TCX files. */
public final class TcxImportPlan extends ImportPlan {
/* Import format identifier. */
public static final String FORMAT_ID = "tcx";
public TcxImportPlan() {
super(FORMAT_ID);
}
@Override
protected void define() {
/* Coordinates: pauses from the file, then compression. */
sensor(SensorType.GEO)
.step(ExplicitGaps.NAME)
.step(SameValueCompress.NAME);
/* Distance from the file: a pause if the value did not change for longer than 1 s. */
sensor(SensorType.DISTANCE)
.step(UnchangedGaps.NAME, Map.of(UnchangedGaps.HOLD_SEC, 1), track(SensorType.GEO))
.step(SameValueCompress.NAME);
/* Elevation and speed: pauses from the file by the geo track. */
sensor(SensorType.ELEVATION)
.step(ExplicitGaps.NAME, track(SensorType.GEO))
.step(SameValueCompress.NAME);
sensor(SensorType.SPEED)
.step(ExplicitGaps.NAME, track(SensorType.GEO))
.step(SameValueCompress.NAME);
/* Heart rate: rejection outside 1..220 bpm. */
sensor(SensorType.HEART)
.step(HeartBadPointFilter.NAME,
Map.of(BadPointFilter.USE_RANGE, true, BadPointFilter.MIN, 1, BadPointFilter.MAX, 220))
.step(ExplicitGaps.NAME, track(SensorType.GEO))
.step(SameValueCompress.NAME);
sensor(SensorType.CADENC)
.step(ExplicitGaps.NAME, track(SensorType.GEO))
.step(SameValueCompress.NAME);
/* Power: spike rejection. */
sensor(SensorType.CYCLING_POWER)
.step(CyclingPowerBadPointFilter.NAME,
Map.of(BadPointFilter.WINDOW_SEC, 5, BadPointFilter.DEVIATION, 1000, BadPointFilter.FLOOR, 1500))
.step(ExplicitGaps.NAME, track(SensorType.GEO))
.step(SameValueCompress.NAME);
/* Computed distance and G-force: compression only. */
computed(SensorType.DISTANCE)
.step(SameValueCompress.NAME);
computed(SensorType.GFORCE)
.step(SameValueCompress.NAME);
/* Computed slope is off by default; when turned on, rejection outside -45..45 %. */
computed(SensorType.SLOPE).disabled()
.step(SlopeBadPointFilter.NAME,
Map.of(BadPointFilter.USE_RANGE, true, BadPointFilter.MIN, -45, BadPointFilter.MAX, 45))
.step(SameValueCompress.NAME);
}
}Import plan for TCX workout files: the track, distance, elevation, speed, heart rate, cadence and power from the file, plus computed distance, G-force and slope.
The plan processes no data itself. It tells the application which steps (formulas) to apply to each sensor of the source, in what order and with which parameter values. The steps themselves are in the packages processing/gaps, processing/filters and processing/compress, and the list of plans is collected by BuiltinScenarios. The title and description of the format in the import settings are the strings Plugin.ImportPlan.tcx.title ("TCX") and Plugin.ImportPlan.tcx.description.
Data. The format identifier is "tcx" (the FORMAT_ID constant), it is passed to the constructor of the base ImportPlan. The define() method declares the sensor scenarios in two ways: sensor(type) is a sensor that the source reads from the file, and computed(type) is a sensor that the application computes from others (the SensorType.GEO channel). .disabled() means the scenario is off by default, and the user can turn it on in the import settings. .step(name, values, bindings) adds a step: the name is the NAME of the step, Map.of(...) holds the parameter values, track(...) is the sensor that provides the geo track to a pause step, reference(...) is the reference sensor. A step without a Map takes the default values.
Most sensors use ExplicitGaps ("Pauses from the file"). The exception is the distance from the file: it uses UnchangedGaps ("Pauses by frozen value") with the time without changes of 1 s.
Settings. The step values below are taken from the plan code; the units are as in the step parameter description (speed in km/h, distances in metres, time in seconds, balance and slope in percent, acceleration in mm/s², rotation in °/s).
| Sensor | Steps and values |
|---|---|
Coordinates (GEO) |
"Pauses from the file"; "Data compression" |
Distance from the file (DISTANCE) |
"Pauses by frozen value": time without changes 1 s, track is GEO; "Data compression" |
Elevation (ELEVATION) |
"Pauses from the file" (track is GEO); "Data compression" |
Speed (SPEED) |
"Pauses from the file" (track is GEO); "Data compression" |
Heart rate (HEART) |
"Bad heart rate points": limit check on, 1..220; "Pauses from the file"; "Data compression" |
Cadence (CADENC) |
"Pauses from the file"; "Data compression" |
Power (CYCLING_POWER) |
"Bad power points": window 5 s, deviation 1000, lower threshold 1500; "Pauses from the file"; "Data compression" |
Distance, computed (computed DISTANCE) |
"Data compression" |
G-force, computed (computed GFORCE) |
"Data compression" |
Slope, computed (computed SLOPE), off |
"Bad slope points": limit check on, -45..45; "Data compression" |
Unlike FIT, the TCX plan has no scenarios for temperature, power balance and pedalling metrics.
Drawing. Not applicable: the plan only sets the order and the values of the processing.
- The TCX coordinates have no rejection step (
GeoBadPointFilter), unlike FIT, GoPro, DJI and DJI SRT. - The TCX speed has no bad point rejection, unlike FIT: only pauses and compression.
- The user can change the values and turn scenarios on or off; the plan sets only the default values.
- A public no-argument constructor is required: without it the user could not change the plan values in the settings. The class is
final.