forked from adiesner/GarminPlugin
/
edge305Device.h
202 lines (157 loc) · 5 KB
/
edge305Device.h
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
#ifndef EDGE305DEVICE_H_INCLUDED
#define EDGE305DEVICE_H_INCLUDED
#define TIXML_USE_TICPP
#include "ticpp.h"
#include <string>
#include "messageBox.h"
#include "gpsDevice.h"
#include "garmin.h"
using namespace std;
class MessageBox;
class Edge305Device : public GpsDevice
{
public:
Edge305Device();
Edge305Device(string name);
virtual ~Edge305Device();
/**
* Starts a thread that tries to read the fitness data from a garmin device
* @return int returns 1 if successful otherwise 0
*/
int startReadFitnessData();
/**
* Returns the status of reading fitness data from the device
* @return int 0 = idle 1 = working 2 = waiting 3 = finished
*/
int finishReadFitnessData();
/**
* Gets the fitness data xml
* @return xml containing fitness data read from garmin device
*/
string getFitnessData();
/**
* Checks if a device is attached and returns the device name.
* If no device is present and empty string is returned
* @return string with device name
*/
static string getAttachedDeviceName();
string getDeviceDescription() const;
int startWriteToGps(string filename, string xml);
int finishWriteToGps();
void cancelWriteToGps();
int getTransferSucceeded();
void setStorageCommand(string cmd);
MessageBox * getMessage();
void userAnswered(const int answer);
bool isDeviceAvailable();
/**
* Starts reading the fitness data without points
* @return int returns 1 if successful otherwise 0
*/
virtual int startReadFITDirectory();
/**
* Starts reading the fitness data without points
* @return int returns 1 if successful otherwise 0
*/
virtual int startReadFitnessDirectory();
/**
* Checks if the read of the fitness directory finished
* @return 0 = idle 1 = working 2 = waiting 3 = finished
*/
virtual int finishReadFitnessDirectory();
/**
* Cancels the read of the fitness data
*/
virtual void cancelReadFitnessData();
virtual int startReadFitnessDetail(string id);
virtual int finishReadFitnessDetail();
virtual void cancelReadFitnessDetail();
protected:
virtual void doWork();
void readFitnessDataFromDevice(bool readTrackData, string fitnessDetailId);
/**
* Directory where this device stores its fitness data
*/
string fitnessDirectory;
string fitnessFileExtension;
/**
* Reads fitnessdata xml from a garmin device like Edge 305/Forerunner 305
* @return xml containing fitness data read from garmin device
*/
string readFitnessData(bool readTrackData, string fitnessDetailId);
/**
* Stores the data read from the device to speed up things
*/
garmin_data * fitnessdata;
private:
/**
* Prints an activity read from the garmin device
* @param run Garmin list of points describing the runs
* @param lap Garmin list of points describing the laps
* @param track Garmin list of points describing the tracks
* @param garmin device descriptor
* @return xml string that describes all activities provided by the given lists
*/
string printActivities(garmin_list * run, garmin_list * lap, garmin_list * track, const garmin_unit garmin, bool readTrackData, string fitnessDetailId);
/**
* Prints the fitness data header
* @return xml string
*/
string getFitnessDataHeader();
/**
* Prints the fitness data footer
* @return xml string
*/
string getFitnessDataFooter();
/**
* Prints the header of a run
* @param D1009 internal run format of garmintools
* @return xml string
*/
string getRunHeader(D1009 * runData) ;
/**
* Prints the footer of a run
* @return xml string
*/
string getRunFooter();
/**
* Prints the header of a lap
* @param D1011 internal lap format of garmintools
* @param firstLap if set to true an <ID>Time</ID> header is added
* @param printTrackData if <Track> should be outputted
* @return xml string
*/
string getLapHeader(D1011 * lapData, bool firstLap, bool printTrackData);
/**
* Prints the footer of a lap
* @param printTrackData set to true if you have track data
* @return xml string
*/
string getLapFooter(bool printTrackData);
/**
* Prints a time in the format 2007-04-20T23:55:01Z
* @param t timestamp
* @return string
*/
string print_dtime( uint32 t );
/**
* Prints a track point
* @param D304 internal track point format of garmintools
* @return xml string
*/
string getTrackPoint ( D304 * p);
/**
* Prints information about the device
* @param garmin device descriptor
* @return xml string
*/
string getCreator(const garmin_unit garmin);
/**
* Stores the fitnessData which was read from the device
*/
string fitnessDataTcdXml;
bool transferSuccessful;
static string filterDeviceName(string name);
string readFitnessDetailId;
};
#endif // EDGE305DEVICE_H_INCLUDED