88 |
andreas |
1 |
/***************************************************************************
|
119 |
andreas |
2 |
* Copyright (C) 2007, 2008 by Andreas Theofilu *
|
|
|
3 |
* andreas@theosys.at *
|
88 |
andreas |
4 |
* *
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
6 |
* it under the terms of the GNU General Public License as published by *
|
|
|
7 |
* the Free Software Foundation version 3 of the License. *
|
|
|
8 |
* *
|
|
|
9 |
* This program is distributed in the hope that it will be useful, *
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
12 |
* GNU General Public License for more details. *
|
|
|
13 |
* *
|
|
|
14 |
* You should have received a copy of the GNU General Public License *
|
|
|
15 |
* along with this program; if not, write to the *
|
|
|
16 |
* Free Software Foundation, Inc., *
|
|
|
17 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
18 |
***************************************************************************/
|
|
|
19 |
|
|
|
20 |
#ifndef _DISASSEMBLE_H
|
|
|
21 |
#define _DISASSEMBLE_H
|
|
|
22 |
|
104 |
andreas |
23 |
#define DEG_2_RAD 0.0174532925199432957692369076848861271L
|
|
|
24 |
|
88 |
andreas |
25 |
typedef struct
|
|
|
26 |
{
|
|
|
27 |
int type;
|
|
|
28 |
char ident[7]; /* identifier */
|
|
|
29 |
position_type posn; /* position */
|
|
|
30 |
char cmnt[41]; /* comment */
|
|
|
31 |
float32 dst; /* proximity distance (meters) */
|
|
|
32 |
uint8 smbl; /* symbol id */
|
|
|
33 |
uint8 dspl; /* display option */
|
|
|
34 |
char * wpt_ident; /* null-terminated string */
|
|
|
35 |
char * lnk_ident; /* null-terminated string */
|
|
|
36 |
uint8 wpt_class; /* class */
|
|
|
37 |
unsigned char subclass[21]; /* subclass */
|
|
|
38 |
uint8 color; /* waypoint color */
|
|
|
39 |
uint8 attr; /* attributes (see below) 1 */
|
|
|
40 |
float32 alt; /* altitude in meters 4 */
|
|
|
41 |
float32 dpth; /* depth in meters 4 */
|
|
|
42 |
char state[3]; /* state 2 */
|
|
|
43 |
char cc[3]; /* country code 2 */
|
|
|
44 |
char * identity; /* variable length string 1-51 */
|
|
|
45 |
char * comment; /* waypoint user comment 1-51 */
|
|
|
46 |
char * facility; /* facility name 1-31 */
|
|
|
47 |
char * city; /* city name 1-25 */
|
|
|
48 |
char * addr; /* address number 1-51 */
|
|
|
49 |
char * cross_road; /* intersecting road label 1-51 */
|
|
|
50 |
uint8 dtyp; /* data packet type (0x01 for D109) 1 */
|
|
|
51 |
uint8 dspl_color; /* display & color (see below) 1 */
|
|
|
52 |
uint32 ete; /* outbound link ete in seconds 4 */
|
|
|
53 |
float32 temp; /* temperature 4 */
|
|
|
54 |
time_type time; /* timestamp 4 */
|
|
|
55 |
sint16 idx; /* proximity index */
|
|
|
56 |
} WAYPOINT;
|
|
|
57 |
|
|
|
58 |
typedef struct
|
|
|
59 |
{
|
|
|
60 |
char name[18]; /* category name */
|
|
|
61 |
} WPCATEGORY;
|
|
|
62 |
|
|
|
63 |
typedef struct
|
|
|
64 |
{
|
|
|
65 |
int type;
|
|
|
66 |
uint8 nmbr; /* route number */
|
|
|
67 |
char cmnt[21]; /* comment */
|
|
|
68 |
char * rte_ident; /* null-terminated string */
|
|
|
69 |
} ROUTE;
|
|
|
70 |
|
|
|
71 |
typedef struct
|
|
|
72 |
{
|
|
|
73 |
int type;
|
|
|
74 |
uint16 klasse; /* link class; see below */
|
|
|
75 |
uint8 subclass[20]; /* sublcass */
|
|
|
76 |
char * ident; /* variable length string */
|
|
|
77 |
} ROUTE_LINK;
|
|
|
78 |
|
|
|
79 |
typedef struct
|
|
|
80 |
{
|
|
|
81 |
int type;
|
|
|
82 |
position_type posn; /* position */
|
|
|
83 |
uint32 time; /* time */
|
|
|
84 |
bool new_trk; /* new track segment? */
|
|
|
85 |
float32 alt; /* altitude in meters */
|
|
|
86 |
float32 dpth; /* depth in meters */
|
|
|
87 |
float32 temp;
|
|
|
88 |
uint8 heart_rate;
|
|
|
89 |
float32 distance;
|
|
|
90 |
uint8 cadence;
|
|
|
91 |
bool sensor;
|
|
|
92 |
} POINT;
|
|
|
93 |
|
|
|
94 |
typedef struct POINT_NODE
|
|
|
95 |
{
|
|
|
96 |
int number;
|
|
|
97 |
POINT *point;
|
|
|
98 |
POINT_NODE *next;
|
|
|
99 |
} POINT_NODE;
|
|
|
100 |
|
|
|
101 |
typedef struct
|
|
|
102 |
{
|
|
|
103 |
int type;
|
|
|
104 |
bool dspl; /* display on the map? */
|
|
|
105 |
uint8 color; /* color (same as D108) */
|
|
|
106 |
char * trk_ident; /* null-terminated string */
|
|
|
107 |
uint16 index; /* unique among all tracks received from device */
|
|
|
108 |
} TRACK;
|
|
|
109 |
|
|
|
110 |
typedef struct
|
|
|
111 |
{
|
|
|
112 |
int type;
|
|
|
113 |
sint16 wn; /* week number (weeks) */
|
|
|
114 |
float32 toa; /* almanac data reference time (s) */
|
|
|
115 |
float32 af0; /* clock correction coefficient (s) */
|
|
|
116 |
float32 af1; /* clock correction coefficient (s/s) */
|
|
|
117 |
float32 e; /* eccentricity (-) */
|
|
|
118 |
float32 sqrta; /* square root of semi-major axis (a) (m**1/2) */
|
|
|
119 |
float32 m0; /* mean anomaly at reference time (r) */
|
|
|
120 |
float32 w; /* argument of perigee (r) */
|
|
|
121 |
float32 omg0; /* right ascension (r) */
|
|
|
122 |
float32 odot; /* rate of right ascension (r/s) */
|
|
|
123 |
float32 i; /* inclination angle (r) */
|
|
|
124 |
uint8 hlth; /* almanac health */
|
|
|
125 |
char svid; /* satellite id */
|
|
|
126 |
} ALMANAC;
|
|
|
127 |
|
|
|
128 |
typedef struct
|
|
|
129 |
{
|
|
|
130 |
uint8 month; /* month (1-12) */
|
|
|
131 |
uint8 day; /* day (1-31) */
|
|
|
132 |
uint16 year; /* year (1990 means 1990) */
|
|
|
133 |
sint16 hour; /* hour (0-23) */
|
|
|
134 |
uint8 minute; /* minute (0-59) */
|
|
|
135 |
uint8 second; /* second (0-59) */
|
|
|
136 |
} DATETIME;
|
|
|
137 |
|
|
|
138 |
typedef struct
|
|
|
139 |
{
|
|
|
140 |
int type;
|
|
|
141 |
time_type takeoff_time;
|
|
|
142 |
time_type landing_time;
|
|
|
143 |
position_type takeoff_posn;
|
|
|
144 |
position_type landing_posn;
|
|
|
145 |
uint32 night_time;
|
|
|
146 |
uint32 num_landings;
|
|
|
147 |
float32 max_speed;
|
|
|
148 |
float32 max_alt;
|
|
|
149 |
float32 distance;
|
|
|
150 |
bool cross_country_flag;
|
|
|
151 |
char * departure_name;
|
|
|
152 |
char * departure_ident;
|
|
|
153 |
char * arrival_name;
|
|
|
154 |
char * arrival_ident;
|
|
|
155 |
char * ac_id;
|
|
|
156 |
} FLIGHTBOOK;
|
|
|
157 |
|
|
|
158 |
typedef struct
|
|
|
159 |
{
|
|
|
160 |
float32 alt; /* alt above WGS 84 ellipsoid (m) */
|
|
|
161 |
float32 epe; /* est. position error, 2 sigma (m) */
|
|
|
162 |
float32 eph; /* epe, but horizontal only (meters) */
|
|
|
163 |
float32 epv; /* epe, but vertical only (meters) */
|
|
|
164 |
sint16 fix; /* type of position fix */
|
|
|
165 |
float64 tow; /* time of week (seconds) */
|
|
|
166 |
radian_position_type posn; /* latitude and longitude (radians) */
|
|
|
167 |
float32 east; /* velocity east (meters/second) */
|
|
|
168 |
float32 north; /* velocity north (meters/second) */
|
|
|
169 |
float32 up; /* velocity up (meters/second) */
|
|
|
170 |
float32 msl_hght; /* ht. of WGS 84 ellipsoid above MSL (m) */
|
|
|
171 |
sint16 leap_scnds; /* diff between GPS and UTC (seconds) */
|
|
|
172 |
sint32 wn_days; /* week number days */
|
|
|
173 |
} PVT;
|
|
|
174 |
|
|
|
175 |
typedef struct
|
|
|
176 |
{
|
|
|
177 |
int type;
|
|
|
178 |
uint32 start_time;
|
|
|
179 |
uint32 total_time; /* In hundredths of a second */
|
|
|
180 |
float32 total_distance; /* In meters */
|
|
|
181 |
position_type begin; /* Invalid if lat and lon are 0x7fffffff */
|
|
|
182 |
position_type end; /* Invalid if lat and lon are 0x7fffffff */
|
|
|
183 |
uint16 calories;
|
|
|
184 |
uint8 track_index; /* See below */
|
|
|
185 |
uint32 index;
|
|
|
186 |
float32 max_speed;
|
|
|
187 |
uint8 avg_heart_rate;
|
|
|
188 |
uint8 max_heart_rate;
|
|
|
189 |
uint8 intensity;
|
|
|
190 |
uint8 avg_cadence;
|
|
|
191 |
uint8 trigger_method;
|
|
|
192 |
} LAP;
|
|
|
193 |
|
|
|
194 |
typedef struct LAP_NODE
|
|
|
195 |
{
|
|
|
196 |
LAP *lap;
|
|
|
197 |
LAP_NODE *next;
|
|
|
198 |
} LAP_NODE;
|
|
|
199 |
|
|
|
200 |
typedef struct
|
|
|
201 |
{
|
|
|
202 |
int type;
|
|
|
203 |
uint32 num_valid_steps;
|
|
|
204 |
struct {
|
|
|
205 |
char custom_name[17];
|
|
|
206 |
float32 target_custom_zone_low;
|
|
|
207 |
float32 target_custom_zone_high;
|
|
|
208 |
uint16 duration_value;
|
|
|
209 |
uint8 intensity;
|
|
|
210 |
uint8 duration_type;
|
|
|
211 |
uint8 target_type;
|
|
|
212 |
uint8 target_value;
|
|
|
213 |
} steps[20];
|
|
|
214 |
char name[17];
|
|
|
215 |
uint8 sport_type;
|
|
|
216 |
char workout_name[17];
|
|
|
217 |
time_type day;
|
|
|
218 |
uint32 max_workouts;
|
|
|
219 |
uint32 max_unscheduled_workouts;
|
|
|
220 |
uint32 max_occurrences;
|
|
|
221 |
} WORKOUT;
|
|
|
222 |
|
|
|
223 |
typedef struct
|
|
|
224 |
{
|
|
|
225 |
int type;
|
|
|
226 |
uint32 track_index;
|
|
|
227 |
uint32 first_lap_index;
|
|
|
228 |
uint32 last_lap_index;
|
|
|
229 |
uint8 sport_type;
|
|
|
230 |
uint8 program_type;
|
|
|
231 |
uint8 multisport;
|
|
|
232 |
struct {
|
|
|
233 |
uint32 time;
|
|
|
234 |
float32 distance;
|
|
|
235 |
} virtual_partner;
|
|
|
236 |
WORKOUT workout;
|
|
|
237 |
} RUN;
|
|
|
238 |
|
|
|
239 |
typedef struct RUN_NODE
|
|
|
240 |
{
|
|
|
241 |
RUN *run;
|
|
|
242 |
RUN_NODE *next;
|
|
|
243 |
} RUN_NODE;
|
|
|
244 |
|
|
|
245 |
typedef struct
|
|
|
246 |
{
|
|
|
247 |
int type;
|
|
|
248 |
struct {
|
|
|
249 |
struct {
|
|
|
250 |
uint8 low_heart_rate;
|
|
|
251 |
uint8 high_heart_rate;
|
|
|
252 |
} heart_rate_zones[5];
|
|
|
253 |
struct {
|
|
|
254 |
float32 low_speed;
|
|
|
255 |
float32 high_speed;
|
|
|
256 |
char name[17];
|
|
|
257 |
} speed_zones[10];
|
|
|
258 |
float32 gear_weight;
|
|
|
259 |
uint8 max_heart_rate;
|
|
|
260 |
} activities[3];
|
|
|
261 |
float32 weight;
|
|
|
262 |
uint16 birth_year;
|
|
|
263 |
uint8 birth_month;
|
|
|
264 |
uint8 birth_day;
|
|
|
265 |
uint8 gender;
|
|
|
266 |
} FITNESS;
|
|
|
267 |
|
|
|
268 |
typedef struct
|
|
|
269 |
{
|
|
|
270 |
int type;
|
|
|
271 |
uint16 index;
|
|
|
272 |
char course_name[17];
|
|
|
273 |
uint16 track_index;
|
|
|
274 |
uint16 course_index;
|
|
|
275 |
uint16 lap_index;
|
|
|
276 |
uint32 total_time;
|
|
|
277 |
float32 total_dist;
|
|
|
278 |
position_type begin;
|
|
|
279 |
position_type end;
|
|
|
280 |
uint8 avg_heart_rate;
|
|
|
281 |
uint8 max_heart_rate;
|
|
|
282 |
uint8 intensity;
|
|
|
283 |
uint8 avg_cadence;
|
|
|
284 |
time_type track_point_time;
|
|
|
285 |
uint8 point_type;
|
|
|
286 |
uint32 max_courses;
|
|
|
287 |
uint32 max_course_laps;
|
|
|
288 |
uint32 max_course_pnt;
|
|
|
289 |
uint32 max_course_trk_pnt;
|
|
|
290 |
} COURSE;
|
|
|
291 |
|
|
|
292 |
class disassemble
|
|
|
293 |
{
|
|
|
294 |
public:
|
|
|
295 |
disassemble();
|
|
|
296 |
~disassemble();
|
|
|
297 |
void destroy();
|
|
|
298 |
void garmin_print_data (garmin_data *d);
|
|
|
299 |
|
|
|
300 |
LAP_NODE *addLap ();
|
|
|
301 |
LAP_NODE *getLapNode () { return lap_node; }
|
|
|
302 |
LAP *getLap(int index);
|
223 |
andreas |
303 |
LAP *getLapT(uint32 time);
|
88 |
andreas |
304 |
|
|
|
305 |
RUN_NODE *addRun ();
|
|
|
306 |
RUN_NODE *getRunNode () { return run_node; }
|
|
|
307 |
|
|
|
308 |
POINT_NODE *addPoint();
|
|
|
309 |
POINT_NODE *getPointNode() { return point_node; }
|
|
|
310 |
POINT *getPoint(int number);
|
|
|
311 |
POINT *getPoint(uint32 time);
|
|
|
312 |
|
248 |
andreas |
313 |
double getTotalDistance() { return totalDistance; }
|
|
|
314 |
long getTotalTime() { return totalTime; }
|
|
|
315 |
double getAvgHR() { return avgHR; }
|
|
|
316 |
double getAvgSpeed() { return avgSpeed; }
|
|
|
317 |
double getMaxSpeed() { return maxSpeed; }
|
|
|
318 |
double getAvgCadence() { return avgCadence; }
|
|
|
319 |
double getAscend() { return ascend; }
|
|
|
320 |
double getDescend() { return descend; }
|
|
|
321 |
|
104 |
andreas |
322 |
double CalcRad(double lat);
|
|
|
323 |
double earth_distance(double lat1, double lon1, double lat2, double lon2);
|
|
|
324 |
|
88 |
andreas |
325 |
protected:
|
|
|
326 |
void garmin_print_dlist (garmin_list *l);
|
|
|
327 |
char *garmin_print_dtime (uint32 t);
|
|
|
328 |
void garmin_print_dpos (position_type *pos, double *lat, double *lon);
|
|
|
329 |
char *garmin_print_float32 (float32 f, char *ret);
|
|
|
330 |
char *garmin_print_float64 (float64 f, char *ret);
|
|
|
331 |
char *garmin_print_dfloat32 (float32 f, char *ret);
|
|
|
332 |
char *garmin_print_ddist (uint32 dur, char *ret);
|
|
|
333 |
|
|
|
334 |
private:
|
|
|
335 |
void garmin_print_d100 (D100 *x);
|
|
|
336 |
void garmin_print_d101 (D101 *x);
|
|
|
337 |
void garmin_print_d102 (D102 *x);
|
|
|
338 |
void garmin_print_d103 (D103 *x);
|
|
|
339 |
void garmin_print_d104 (D104 *x);
|
|
|
340 |
void garmin_print_d105 (D105 *x);
|
|
|
341 |
void garmin_print_d106 (D106 *x);
|
|
|
342 |
void garmin_print_d107 (D107 *x);
|
|
|
343 |
void garmin_print_d108 (D108 *x);
|
|
|
344 |
void garmin_print_d109 (D109 *x);
|
|
|
345 |
void garmin_print_d110 (D110 *x);
|
|
|
346 |
void garmin_print_d120 (D120 *x);
|
|
|
347 |
void garmin_print_d150 (D150 *x);
|
|
|
348 |
void garmin_print_d151 (D151 *x);
|
|
|
349 |
void garmin_print_d152 (D152 *x);
|
|
|
350 |
void garmin_print_d154 (D154 *x);
|
|
|
351 |
void garmin_print_d155 (D155 *x);
|
|
|
352 |
void garmin_print_d200 (D200 *x);
|
|
|
353 |
void garmin_print_d201 (D201 *x);
|
|
|
354 |
void garmin_print_d202 (D202 *x);
|
|
|
355 |
void garmin_print_d210 (D210 *x);
|
|
|
356 |
void garmin_print_d300 (D300 *p);
|
|
|
357 |
void garmin_print_d301 (D301 *p);
|
|
|
358 |
void garmin_print_d302 (D302 *p);
|
|
|
359 |
void garmin_print_d303 (D303 *p);
|
|
|
360 |
void garmin_print_d304 (D304 *p);
|
|
|
361 |
void garmin_print_d310 (D310 *x);
|
|
|
362 |
void garmin_print_d311 (D311 *h);
|
|
|
363 |
void garmin_print_d312 (D312 *h);
|
|
|
364 |
void garmin_print_d400 (D400 *x);
|
|
|
365 |
void garmin_print_d403 (D403 *x);
|
|
|
366 |
void garmin_print_d450 (D450 *x);
|
|
|
367 |
void garmin_print_d500 (D500 *x);
|
|
|
368 |
void garmin_print_d501 (D501 *x);
|
|
|
369 |
void garmin_print_d550 (D550 *x);
|
|
|
370 |
void garmin_print_d551 (D551 *x);
|
|
|
371 |
void garmin_print_d600 (D600 *x);
|
|
|
372 |
void garmin_print_d650 (D650 *x);
|
|
|
373 |
void garmin_print_d700 (D700 *x);
|
|
|
374 |
void garmin_print_d800 (D800 *x);
|
|
|
375 |
void garmin_print_d906 (D906 *x);
|
|
|
376 |
void garmin_print_d1000 (D1000 *x);
|
|
|
377 |
void garmin_print_d1001 (D1001 *x);
|
|
|
378 |
void garmin_print_d1002 (D1002 *x);
|
|
|
379 |
void garmin_print_d1003 (D1003 *x);
|
|
|
380 |
void garmin_print_d1004 (D1004 *d);
|
|
|
381 |
void garmin_print_d1005 (D1005 *limits);
|
|
|
382 |
void garmin_print_d1006 (D1006 *x);
|
|
|
383 |
void garmin_print_d1007 (D1007 *x);
|
|
|
384 |
void garmin_print_d1008 (D1008 *w);
|
|
|
385 |
void garmin_print_d1009 (D1009 *x);
|
|
|
386 |
void garmin_print_d1010 (D1010 *x);
|
|
|
387 |
void garmin_print_d1011 (D1011 *x);
|
|
|
388 |
void garmin_print_d1012 (D1012 *x);
|
|
|
389 |
void garmin_print_d1013 (D1013 *x);
|
|
|
390 |
void garmin_print_d1015 (D1015 *x);
|
|
|
391 |
|
|
|
392 |
private:
|
|
|
393 |
WAYPOINT waypoint;
|
|
|
394 |
WPCATEGORY wpcategory;
|
|
|
395 |
int route_header;
|
|
|
396 |
ROUTE route;
|
|
|
397 |
ROUTE_LINK route_link;
|
|
|
398 |
POINT point;
|
|
|
399 |
POINT_NODE *point_node;
|
|
|
400 |
TRACK track;
|
|
|
401 |
ALMANAC almanac;
|
|
|
402 |
DATETIME datetime;
|
|
|
403 |
FLIGHTBOOK flightbook;
|
|
|
404 |
radian_position_type rpt;
|
|
|
405 |
PVT pvt;
|
|
|
406 |
LAP lap;
|
|
|
407 |
LAP_NODE *lap_node;
|
|
|
408 |
RUN run;
|
|
|
409 |
RUN_NODE *run_node;
|
|
|
410 |
WORKOUT workout;
|
|
|
411 |
FITNESS fitness;
|
|
|
412 |
COURSE course;
|
248 |
andreas |
413 |
|
|
|
414 |
double totalDistance; // Distance in meters
|
|
|
415 |
long totalTime; // Time in seconds
|
|
|
416 |
double avgHR; // Heart rate in beats per minute
|
|
|
417 |
double avgSpeed; // Speed in km per hour
|
|
|
418 |
double maxSpeed; // Speed in km per hour
|
|
|
419 |
int avgCadence; // Cadence
|
|
|
420 |
double ascend; // Height in meters
|
|
|
421 |
double descend; // Height (downhill) in meters
|
88 |
andreas |
422 |
};
|
|
|
423 |
|
|
|
424 |
#endif
|