Generation of textevents for ZWO files
This commit is contained in:
parent
cec481da4e
commit
78a1bed1f2
|
|
@ -0,0 +1,35 @@
|
|||
Name: Workout with comments
|
||||
|
||||
Warmup: 10:00 25%..75%
|
||||
# 0:10 Welcome to: #8
|
||||
# 6:00 Let's talk about today's workout
|
||||
# 6:10 We'll be doing 5 blocks of VO2max work
|
||||
# 6:20 Each block 2 minutes and 30 seconds
|
||||
# 6:30 30 seconds more than last time :)
|
||||
# 6:40 Finally we finish off with 10 minutes of threshold work
|
||||
# 6:50 Easy as that :)
|
||||
|
||||
Interval: 0:30 95% 95rpm
|
||||
# 0:00 Spin to 95 RPM if you're not already there
|
||||
|
||||
Rest: 0:30 50% 85rpm
|
||||
# 0:00 Rest a bit
|
||||
|
||||
Interval: 2:30 115% 105rpm
|
||||
# 0:00 Here we go!
|
||||
# 1:00 First minute done
|
||||
# 2:00 Just 30 seconds more
|
||||
# 2:20 Finish it!
|
||||
|
||||
Rest: 3:00 50% 85rpm
|
||||
# 0:00 Good!
|
||||
# 0:10 Rest for 3 minutes
|
||||
# 2:50 Ready for next round?
|
||||
|
||||
Cooldown: 7:30 90%..25%
|
||||
# 0:00 We'll now gradually decrease the power
|
||||
# 0:10 It's all downhill from here :)
|
||||
# 0:20 until you're cooled down
|
||||
# 7:10 Thanks for participating
|
||||
# 7:20 Until next time!
|
||||
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
"test:watch": "jest --watch",
|
||||
"test:1": "ts-node src/index.ts examples/threshold-pushing.txt",
|
||||
"test:2": "ts-node src/index.ts examples/darth-vader.txt",
|
||||
"test:comments": "ts-node src/index.ts examples/comments.txt",
|
||||
"test:stats:1": "ts-node src/index.ts --stats examples/threshold-pushing.txt",
|
||||
"test:stats:2": "ts-node src/index.ts --stats examples/darth-vader.txt",
|
||||
"format:js": "prettier --write src/"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
import * as xml from "xml";
|
||||
import { Interval, Workout } from "./ast";
|
||||
import { Interval, Workout, Comment } from "./ast";
|
||||
|
||||
// Zwift Workout XML generator
|
||||
|
||||
const generateTextEvents = (comments: Comment[]): xml.XmlObject[] => {
|
||||
return comments.map(({ offset, text }) => ({
|
||||
textevent: [{ _attr: { timeoffset: offset, message: text } }],
|
||||
}));
|
||||
};
|
||||
|
||||
const generateRangeInterval = (
|
||||
tagName: "Warmup" | "Cooldown",
|
||||
{ duration, intensity, cadence }: Interval,
|
||||
{ duration, intensity, cadence, comments }: Interval,
|
||||
): xml.XmlObject => {
|
||||
return {
|
||||
[tagName]: [
|
||||
|
|
@ -17,11 +23,12 @@ const generateRangeInterval = (
|
|||
...(cadence ? { Cadence: cadence } : {}),
|
||||
},
|
||||
},
|
||||
...generateTextEvents(comments),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
const generateSteadyStateInterval = ({ duration, intensity, cadence }: Interval): xml.XmlObject => {
|
||||
const generateSteadyStateInterval = ({ duration, intensity, cadence, comments }: Interval): xml.XmlObject => {
|
||||
return {
|
||||
SteadyState: [
|
||||
{
|
||||
|
|
@ -31,6 +38,7 @@ const generateSteadyStateInterval = ({ duration, intensity, cadence }: Interval)
|
|||
...(cadence ? { Cadence: cadence } : {}),
|
||||
},
|
||||
},
|
||||
...generateTextEvents(comments),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue