Integrate detectRepeats() with ZWO generation
This commit is contained in:
parent
be5b9a5146
commit
98f882f9b8
|
|
@ -21,17 +21,29 @@ Interval: 12:00 90rpm 90%
|
||||||
Rest: 4:00 85rpm 55%
|
Rest: 4:00 85rpm 55%
|
||||||
|
|
||||||
Interval: 1:00 60rpm 90%
|
Interval: 1:00 60rpm 90%
|
||||||
|
# 00:00 Start off at slow cadence
|
||||||
Interval: 1:00 90rpm 90%
|
Interval: 1:00 90rpm 90%
|
||||||
|
# 00:00 Now bump that cadence up
|
||||||
Interval: 1:00 60rpm 90%
|
Interval: 1:00 60rpm 90%
|
||||||
|
# 00:00 Back to 60 RPM
|
||||||
Interval: 1:00 90rpm 90%
|
Interval: 1:00 90rpm 90%
|
||||||
|
# 00:00 Back to normal cadence
|
||||||
Interval: 1:00 60rpm 90%
|
Interval: 1:00 60rpm 90%
|
||||||
|
# 00:00 Grinding...
|
||||||
Interval: 1:00 90rpm 90%
|
Interval: 1:00 90rpm 90%
|
||||||
|
# 00:00 Back to normal cadence
|
||||||
Interval: 1:00 60rpm 90%
|
Interval: 1:00 60rpm 90%
|
||||||
|
# 00:00 And grind at 60 RPM again
|
||||||
Interval: 1:00 90rpm 90%
|
Interval: 1:00 90rpm 90%
|
||||||
|
# 00:00 Back to 90 RPM
|
||||||
Interval: 1:00 60rpm 90%
|
Interval: 1:00 60rpm 90%
|
||||||
|
# 00:00 Lower it again to 60 RPM
|
||||||
Interval: 1:00 90rpm 90%
|
Interval: 1:00 90rpm 90%
|
||||||
|
# 00:00 Increase the cadence to 90 RPM
|
||||||
Interval: 1:00 60rpm 90%
|
Interval: 1:00 60rpm 90%
|
||||||
|
# 00:00 Last grinding minute
|
||||||
Interval: 1:00 90rpm 90%
|
Interval: 1:00 90rpm 90%
|
||||||
|
# 00:00 Last minute... be strong!
|
||||||
|
|
||||||
Rest: 4:00 85rpm 55%
|
Rest: 4:00 85rpm 55%
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import * as xml from "xml";
|
import * as xml from "xml";
|
||||||
import { Interval, Workout, Comment } from "./ast";
|
import { Interval, Workout, Comment } from "./ast";
|
||||||
|
import { detectRepeats, RepeatedInterval } from "./detectRepeats";
|
||||||
|
|
||||||
// Zwift Workout XML generator
|
// Zwift Workout XML generator
|
||||||
|
|
||||||
|
|
@ -43,7 +44,33 @@ const generateSteadyStateInterval = ({ duration, intensity, cadence, comments }:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateInterval = (interval: Interval): xml.XmlObject => {
|
const generateRepeatInterval = (repInterval: RepeatedInterval): xml.XmlObject => {
|
||||||
|
const [on, off] = repInterval.intervals;
|
||||||
|
return {
|
||||||
|
IntervalsT: [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
Repeat: repInterval.times,
|
||||||
|
|
||||||
|
OnDuration: on.duration.value,
|
||||||
|
OnPower: on.intensity.from,
|
||||||
|
...(on.cadence ? { Cadence: on.cadence } : {}),
|
||||||
|
|
||||||
|
OffDuration: off.duration.value,
|
||||||
|
OffPower: off.intensity.from,
|
||||||
|
...(off.cadence ? { CadenceResting: off.cadence } : {}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...generateTextEvents(repInterval.comments),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const generateInterval = (interval: Interval | RepeatedInterval): xml.XmlObject => {
|
||||||
|
if (interval.type === "repeat") {
|
||||||
|
return generateRepeatInterval(interval);
|
||||||
|
}
|
||||||
|
|
||||||
const { intensity } = interval;
|
const { intensity } = interval;
|
||||||
if (intensity.from < intensity.to) {
|
if (intensity.from < intensity.to) {
|
||||||
return generateRangeInterval("Warmup", interval);
|
return generateRangeInterval("Warmup", interval);
|
||||||
|
|
@ -62,7 +89,7 @@ export const generateZwo = ({ name, author, description, intervals }: Workout):
|
||||||
{ author: author },
|
{ author: author },
|
||||||
{ description: description },
|
{ description: description },
|
||||||
{ sportType: "bike" },
|
{ sportType: "bike" },
|
||||||
...intervals.map(generateInterval),
|
...detectRepeats(intervals).map(generateInterval),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ indent: " " },
|
{ indent: " " },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue