forked from difcareer/010templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TacxTemplate.bt
executable file
·426 lines (400 loc) · 10.8 KB
/
TacxTemplate.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
//-----------------------------------
//--- 010 Editor v2.0 Binary Template
//
// File: Tacx Total Template.bt
// Author: Nestor Matas
// Revision: 1.0
// Purpose: Defines a template for
// parsing All Tacx files PGMF CAF IMF RLV MRLV.
//-----------------------------------
// Define structures used in Tacx files
typedef struct {
WORD FileFingerprint;
WORD FileVersion;
DWORD BlockCount;
} HEADER;
typedef struct {
WORD BlockFingerprint; //Identifies the data to follow
WORD BlockVersion; //A 3 digit number indicating the block version, e.g. 100 or 110
DWORD RecordCount; //Number of records in the block
DWORD RecordSize; //Size of each record in the block
} INFOBLOCK;
typedef struct {
DWORD CheckSum;
CHAR CourseName[34];
DWORD WattSlopePulse; //0 = Watt program, 1 = Slope program, 2 = Pulse (HR) program
DWORD TimeDist; //0 = Time based program, 1 = distance based program
DOUBLE TotalTimeDist; //Total time (in seconds) or distance (in metres) of complete program
DOUBLE EnergyCons;
FLOAT AltitudeStart;
DWORD BrakeCategory;
} GENERALINFO;
typedef struct {
FLOAT DurationDistance; //Seconds or metres, depending on program type
FLOAT PulseSlopeWatts; //Pulse, slope or watts data, depending on program type
FLOAT RollingFriction; // Usually 4.0
} PROGRAM;
typedef struct {
FLOAT Start; //Start of route section (time (s) or distance (m), depending on program type)
FLOAT End; //End of route section (time (s) or distance (m), depending on program type)
CHAR CourseSegmentName[66];
CHAR TextFile[522];
} COURSEINFO;
typedef struct{
CHAR VideoFileName[522];// Location of the RLV AVI file
FLOAT FrameRate; // Video frame rate
FLOAT OrgRunWeight;
INT FrameOffset;
} RLVINFO;
typedef struct{
UINT16 Year;
UINT16 Month;
UINT16 DayOfWeek;
UINT16 DayOfMonth;
UINT16 Hour;
UINT16 Minute;
UINT16 Second;
UINT16 Millisecond;
FLOAT RecordInterval;// secs
DOUBLE Distance;//m
DOUBLE Duration; //s
INT32 CoolDownCount;
UINT32 NotFinished;//0 = ride completed, 1 = ride not completed
BYTE HRMin; //bpm
BYTE HRMax; //bpm
CHAR Feeling[42];
CHAR Temperature[22]; //deg C
UINT16 VendorID;
UINT16 BrakeType; //Brake type. i-Magic 6402, Fortius 6466, Cosmos 6514, Fortagic (Fortius Multiplayer) 6450
UINT32 SerialNo; //
UINT32 DriverVersion; //The format of the version number is part1.part2.part3 where part1 = (DriverVersion & 0xFF0000) >> 16, part2 = (DriverVersion & 0xFF00) >> 8 and part3 = DriverVersion & 0xFF
UINT16 TrainerYear;//Trainer year of manufacture
BYTE TrainerMonth;
BYTE TrainerDay;
UINT32 BrakeSerialNo;
UINT32 BrakeVersion;
UINT16 BrakeYear;
BYTE BrakeMonth;
BYTE BrakeDay;
INT16 CalibrationX10; //Divide by 10 to get calibration value
BYTE ScaleFactor;
BYTE Reserved_1;
UINT32 Reserved_2;
FLOAT CA; //VR parameters
FLOAT Ccw;//VR parameters
FLOAT Crho;//VR parameters
FLOAT Crr;//VR parameters
FLOAT CeffBike;//VR parameters
FLOAT CeffCyclist;//VR parameters
FLOAT Slope;//VR parameters
INT16 AirSpeedAbs;//VR parameters
BYTE BikeMass;//VR parameters
BYTE CyclistWeight;//VR parameters
FLOAT VirtSpeedAccelFactor;//VR parameters
UINT32 Reserved_3;
UINT32 Reserved_4;
INT32 LazyMode;
INT32 VRParamExt;
INT32 RLVFlags;
} RIDEINFO_100;
typedef struct{
UINT16 Year;
UINT16 Month;
UINT16 DayOfWeek;
UINT16 DayOfMonth;
UINT16 Hour;
UINT16 Minute;
UINT16 Second;
UINT16 Millisecond;
FLOAT RecordInterval;// secs
DOUBLE Distance;//m
DOUBLE Duration; //s
INT32 CoolDownCount;
UINT32 NotFinished;//0 = ride completed, 1 = ride not completed
BYTE HRMin; //bpm
BYTE HRMax; //bpm
CHAR Feeling[42];
CHAR Temperature[22]; //deg C
UINT16 VendorID;
UINT16 BrakeType; //Brake type. i-Magic 6402, Fortius 6466, Cosmos 6514, Fortagic (Fortius Multiplayer) 6450
UINT32 SerialNo; //
UINT32 DriverVersion; //The format of the version number is part1.part2.part3 where part1 = (DriverVersion & 0xFF0000) >> 16, part2 = (DriverVersion & 0xFF00) >> 8 and part3 = DriverVersion & 0xFF
UINT16 TrainerYear;//Trainer year of manufacture
BYTE TrainerMonth;
BYTE TrainerDay;
UINT32 BrakeSerialNo;
UINT32 BrakeVersion;
UINT16 BrakeYear;
BYTE BrakeMonth;
BYTE BrakeDay;
INT16 CalibrationX10; //Divide by 10 to get calibration value
BYTE ScaleFactor;
BYTE Reserved_1;
UINT32 Reserved_2;
FLOAT CA; //VR parameters
FLOAT Ccw;//VR parameters
FLOAT Crho;//VR parameters
FLOAT Crr;//VR parameters
FLOAT CeffBike;//VR parameters
FLOAT CeffCyclist;//VR parameters
FLOAT Slope;//VR parameters
INT16 AirSpeedAbs;//VR parameters
BYTE BikeMass;//VR parameters
BYTE CyclistWeight;//VR parameters
FLOAT VirtSpeedAccelFactor;//VR parameters
UINT32 Reserved_3;
UINT32 Reserved_4;
INT32 RLVSlopeAdjustmentPercent;
INT32 VRParamExt;
INT32 RLVFlags;
CHAR CourseName[34];
} RIDEINFO_110;
typedef struct{
CHAR Team[34];
CHAR RiderName[34];
FLOAT Weight; //kg
BYTE Gender; // 0 = female, 1 = male for VR, reversed for Catalyst
FLOAT Height;// cm
UINT BirthYear;// UInt32
BYTE BirthMonth;
BYTE BirthDay;
BYTE HRMax;//bpm
BYTE HRRest;//bpm
BYTE HRAThreshold;
BYTE HRZone1;
BYTE HRZone2;
BYTE HRZone3;
BYTE HRZone4;
BYTE HRZone5;
CHAR Email[522];
CHAR Country[66];
CHAR Remarks[522];
} RIDERINFO;
typedef struct{
FLOAT Distance;
BYTE HR;
BYTE Cadence;
UINT16 PowerX10;//Divide by 10 to get actual power in watts
UINT16 SpeedX10;//Divide by 10 to get actual speed in km/h
} RIDEDATA;
typedef struct{
UINT CRC32;
CHAR SegmentName[66];
CHAR InfoFile[522];
DOUBLE Distance;
INT32 PrgCnt;
} RLV_MULTICOURSE;
typedef struct{
UINT32 CRC32;
CHAR ProgName[34];
INT32 PrgIdx;
DOUBLE DistTimeBeg;
DOUBLE DistTimeEnd;
CHAR Name[66];
CHAR InfoFil[522];
INT32 LapCount;
} RLV_MULTISECT;
typedef struct{
UINT32 FrameNumber;
FLOAT DistancePerFrame;
} RLV_FRAMEDISTANCE;
typedef struct{
INT32 Frame; // Frame number
INT32 Cmd;
} RLV_INFOBOX;
typedef struct{
DWORD CheckSum;
CHAR CourseName[34];
CHAR Terrain[34];
FLOAT RecordInterval;
DOUBLE CourseDistance;
DOUBLE RunTime;//Total run time of pilot route
INT32 CoolDownCount;
INT32 RunFlags;
INT32 BrakeType;
} GENERAL_INFO_VR;
typedef struct{
FLOAT X; //x co-ordinate on 3D map
FLOAT Y; //y co-ordinate on 3D map (and height in metres)
FLOAT Z; //z co-ordinate on 3D map
FLOAT Alpha;//Horizontal alignment of rider at each coordinate
FLOAT Beta; //Declination of rider at each coordinate
FLOAT Gamma;
BYTE HeartRate;
BYTE Cadence;
INT16 PowerX10;
INT16 SpeedX10;
FLOAT TerrainAngle;
FLOAT ForkAngle; // < -100 = crash
} COURSE_DATA_VR;
typedef struct{
CHAR CourseName[34];
CHAR Terrain[34];
UINT16 Year;
UINT16 Month;
UINT16 DayOfWeek;
UINT16 DayOfMonth;
UINT16 Hour;
UINT16 Minute;
UINT16 Second;
UINT16 Millisecond;
FLOAT RecordInterval;// secs
DOUBLE Distance;//m
DOUBLE Duration; //s
INT32 CoolDownCount;
UINT32 NotFinished;//0 = ride completed, 1 = ride not completed
BYTE HRMin; //bpm
BYTE HRMax; //bpm
CHAR Feeling[42];
CHAR Temperature[22]; //deg C
UINT16 VendorID;
UINT16 BrakeType; //Brake type. i-Magic 6402, Fortius 6466, Cosmos 6514, Fortagic (Fortius Multiplayer) 6450
UINT32 SerialNo; //
UINT32 DriverVersion; //The format of the version number is part1.part2.part3 where part1 = (DriverVersion & 0xFF0000) >> 16, part2 = (DriverVersion & 0xFF00) >> 8 and part3 = DriverVersion & 0xFF
UINT16 TrainerYear;//Trainer year of manufacture
BYTE TrainerMonth;
BYTE TrainerDay;
UINT32 BrakeSerialNo;
UINT32 BrakeVersion;
UINT16 BrakeYear;
BYTE BrakeMonth;
BYTE BrakeDay;
INT16 CalibrationX10; //Divide by 10 to get calibration value
BYTE ScaleFactor;
BYTE Reserved_1;
UINT32 Reserved_2;
FLOAT CA; //VR parameters
FLOAT Ccw;//VR parameters
FLOAT Crho;//VR parameters
FLOAT Crr;//VR parameters
FLOAT CeffBike;//VR parameters
FLOAT CeffCyclist;//VR parameters
FLOAT Slope;//VR parameters
INT16 AirSpeedAbs;//VR parameters
BYTE BikeMass;//VR parameters
BYTE CyclistWeight;//VR parameters
FLOAT VirtSpeedAccelFactor;//VR parameters
UINT32 Reserved_3;
UINT32 Reserved_4;
INT32 LazyMode;
INT32 VRParamExt;
INT32 CollisionsOn;
FLOAT WindStrength;//0 = none, 12 = low, 24 = middle, 36 = high
FLOAT WindDirection;// -180 < x <= 180 (north = 0)
FLOAT ScaleFactor2;
INT32 CrashTimesCount;
} RIDEINFO_VR;
typedef struct{
FLOAT X; //x co-ordinate on 3D map
FLOAT Y; //y co-ordinate on 3D map (and height in metres)
FLOAT Z; //z co-ordinate on 3D map
FLOAT Alpha; //Horizontal alignment of rider at each co-ordinate
FLOAT Beta; //Declination of rider at each co-ordinate
FLOAT Gamma;
BYTE HR;//bpm Heart rate
BYTE Cadence;//rpm
UINT16 PowerX10;//watts x 10
UINT16 SpeedX10;//km/h x 10
FLOAT TerrainAngle;//Vertical alignment of rider at each co-ordinate
FLOAT ForkAngle;//< -100 = crash
} RIDEDATA_VR;
typedef struct{
UINT32 LapTime; //ms Cumulative
} LAPDATA;
// Define the headers
LittleEndian();
HEADER head;
// Check for header
if( head.FileFingerprint != 4000
&& head.FileFingerprint != 3000
&& head.FileFingerprint != 2000
&& head.FileFingerprint != 1000 )
{
Warning( "File is not a Tacx file. Template stopped." );
return -1;
}
local int i;
for (i=0; i<head.BlockCount;i++)
{
INFOBLOCK blk;
if( blk.BlockFingerprint == 1010 )
{
GENERALINFO ginfo[blk.RecordCount];
}
else if( blk.BlockFingerprint == 2040 )
{
COURSEINFO courseinfo[blk.RecordCount];
}
else if( blk.BlockFingerprint == 1020 )
{
PROGRAM pdata[blk.RecordCount];
}
else if( blk.BlockFingerprint == 210 )
{
RIDERINFO rinfo;
}
else if( blk.BlockFingerprint == 2010 )
{
RLVINFO rlvinfo;
}
else if( blk.BlockFingerprint == 3010 )
{
if(blk.BlockVersion == 100)
RIDEINFO_100 rideinfo;
else if(blk.BlockVersion == 110)
RIDEINFO_110 rideinfo;
}
else if( blk.BlockFingerprint == 120 )
{
char notes[blk.RecordCount*blk.RecordSize];
}
else if( blk.BlockFingerprint == 3020 )
{
RIDEDATA ride[blk.RecordCount];
}
else if( blk.BlockFingerprint == 6010 )
{
RLV_MULTICOURSE rlvmcourse;
}
else if( blk.BlockFingerprint == 6020 )
{
RLV_MULTISECT rlvmsect;
}
else if( blk.BlockFingerprint == 130 )
{
DOUBLE unkown_130;
}
else if( blk.BlockFingerprint == 2020 )
{
RLV_FRAMEDISTANCE rlvfd[blk.RecordCount];
}
else if( blk.BlockFingerprint == 2030 )
{
RLV_INFOBOX iboxes[blk.RecordCount];
}
else if( blk.BlockFingerprint == 4010 )
{
GENERAL_INFO_VR ginfovr[blk.RecordCount];
}
else if( blk.BlockFingerprint == 4020 )
{
COURSE_DATA_VR cdatavr[blk.RecordCount];
}
else if( blk.BlockFingerprint == 4030 )
{
RIDEINFO_VR rinfovr[blk.RecordCount];
}
else if( blk.BlockFingerprint == 110 )
{
LAPDATA lapdata[blk.RecordCount];
}
else if( blk.BlockFingerprint == 4040)
{
RIDEDATA_VR ridedata_vr[blk.RecordCount];
}
else
{
Warning( "Unknown Block Fingerprint");
return -1;
}
}