| 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 |
#ifndef GLOBALSATSPORT_H_INCLUDED_ |
| 38 |
#define GLOBALSATSPORT_H_INCLUDED_ |
| 39 |
|
| 40 |
#include <cstdint> |
| 41 |
|
| 42 |
#include <QList> |
| 43 |
#include <QString> |
| 44 |
#include <QTimeZone> |
| 45 |
#include <QVector> |
| 46 |
|
| 47 |
#include "defs.h" |
| 48 |
#include "format.h" |
| 49 |
#include "gbfile.h" |
| 50 |
#include "option.h" |
| 51 |
|
| 52 |
|
| 53 |
class GlobalsatSportFormat : public Format |
| 54 |
{ |
| 55 |
public: |
| 56 |
QVector<arglist_t>* get_args() override |
| 57 |
{ |
| 58 |
return &globalsat_args; |
| 59 |
} |
| 60 |
|
| 61 |
ff_type get_type() const override |
| 62 |
{ |
| 63 |
return ff_type_serial; |
| 64 |
} |
| 65 |
|
| 66 |
QVector<ff_cap> get_cap() const override |
| 67 |
{ |
| 68 |
return { |
| 69 |
ff_cap_none, |
| 70 |
ff_cap_read, |
| 71 |
ff_cap_none, |
| 72 |
}; |
| 73 |
} |
| 74 |
|
| 75 |
void rd_init(const QString& fname) override; |
| 76 |
void read() override; |
| 77 |
void rd_deinit() override; |
| 78 |
|
| 79 |
private: |
| 80 |
|
| 81 |
enum globalsat_commands_e { |
| 82 |
CommandWhoAmI = 0xBF, |
| 83 |
CommandGetSystemInformation = 0x85, |
| 84 |
CommandGetSystemConfiguration = 0x86, |
| 85 |
|
| 86 |
CommandSetSystemConfiguration = 0x96, |
| 87 |
CommandSetSystemInformation = 0x98, |
| 88 |
CommandGetScreenshot = 0x83, |
| 89 |
|
| 90 |
CommandGetWaypoints = 0x77, |
| 91 |
CommandSendWaypoint = 0x76, |
| 92 |
CommandDeleteWaypoints = 0x75, |
| 93 |
|
| 94 |
CommandSendRoute = 0x93, |
| 95 |
CommandDeleteAllRoutes = 0x97, |
| 96 |
|
| 97 |
CommandGetTrackFileHeaders = 0x78, |
| 98 |
CommandGetTrackFileSections = 0x80, |
| 99 |
CommandGetNextTrackSection = 0x81, |
| 100 |
|
| 101 |
CommandId_FINISH = 0x8A, |
| 102 |
CommandSendTrackStart = 0x90, |
| 103 |
CommandSendTrackSection = 0x91, |
| 104 |
|
| 105 |
HeaderTypeLaps = 0xAA, |
| 106 |
HeaderTypeTrackPoints = 0x55, |
| 107 |
|
| 108 |
ResponseInsufficientMemory = 0x95, |
| 109 |
ResponseResendTrackSection = 0x92, |
| 110 |
ResponseSendTrackFinish = 0x9A |
| 111 |
}; |
| 112 |
|
| 113 |
struct gh_date { |
| 114 |
uint8_t Year; |
| 115 |
uint8_t Month; |
| 116 |
uint8_t Day; |
| 117 |
}; |
| 118 |
|
| 119 |
struct gh_time { |
| 120 |
uint8_t Hour; |
| 121 |
uint8_t Minute; |
| 122 |
uint8_t Second; |
| 123 |
}; |
| 124 |
|
| 125 |
struct gh_trainheader { |
| 126 |
gh_date dateStart; |
| 127 |
gh_time timeStart; |
| 128 |
uint32_t TotalPoint; |
| 129 |
uint32_t TotalTime; |
| 130 |
uint32_t TotalDistance; |
| 131 |
uint16_t LapCnts; |
| 132 |
union { |
| 133 |
uint32_t Index; |
| 134 |
uint32_t StartPt; |
| 135 |
} gh_ptrec; |
| 136 |
union { |
| 137 |
uint32_t LapIndex; |
| 138 |
uint32_t EndPt; |
| 139 |
} gh_laprec; |
| 140 |
uint8_t DataType; |
| 141 |
}; |
| 142 |
|
| 143 |
struct gh_db_train { |
| 144 |
gh_date dateStart; |
| 145 |
gh_time timeStart; |
| 146 |
uint32_t TotalPoint; |
| 147 |
uint32_t TotalTime; |
| 148 |
uint32_t TotalDistance; |
| 149 |
uint16_t LapCnts; |
| 150 |
union { |
| 151 |
uint32_t Index; |
| 152 |
uint32_t StartPt; |
| 153 |
} gh_ptrec; |
| 154 |
union { |
| 155 |
uint32_t LapIndex; |
| 156 |
uint32_t EndPt; |
| 157 |
} gh_laprec; |
| 158 |
uint8_t MultiSport; |
| 159 |
uint16_t Calory; |
| 160 |
uint32_t MaxSpeed; |
| 161 |
uint8_t MaxHeart; |
| 162 |
uint8_t AvgHeart; |
| 163 |
|
| 164 |
uint16_t Ascent; |
| 165 |
uint16_t Descent; |
| 166 |
|
| 167 |
int16_t MinAlti; |
| 168 |
int16_t MaxAlti; |
| 169 |
uint16_t AvgCadns; |
| 170 |
uint16_t BestCadns; |
| 171 |
uint16_t AvgPower; |
| 172 |
uint16_t MaxPower; |
| 173 |
uint8_t Sport1; |
| 174 |
uint8_t Sport2; |
| 175 |
uint8_t Sport3; |
| 176 |
uint8_t Sport4; |
| 177 |
uint8_t Sport5; |
| 178 |
}; |
| 179 |
|
| 180 |
struct gh_db_lap { |
| 181 |
uint32_t AccruedTime; |
| 182 |
uint32_t TotalTime; |
| 183 |
uint32_t TotalDistance; |
| 184 |
uint16_t Calory; |
| 185 |
uint32_t MaxSpeed; |
| 186 |
uint8_t MaxHeart; |
| 187 |
uint8_t AvgHeart; |
| 188 |
int16_t MinAlti; |
| 189 |
int16_t MaxAlti; |
| 190 |
uint16_t AvgCadns; |
| 191 |
uint16_t BestCadns; |
| 192 |
uint16_t AvgPower; |
| 193 |
uint16_t MaxPower; |
| 194 |
uint8_t MultiSportIndex; |
| 195 |
uint32_t StartPt; |
| 196 |
uint32_t EndPt; |
| 197 |
}; |
| 198 |
|
| 199 |
struct gh_recpoint { |
| 200 |
uint32_t Latitude; |
| 201 |
uint32_t Longitude; |
| 202 |
int16_t Altitude; |
| 203 |
uint32_t Speed; |
| 204 |
uint8_t HeartRate; |
| 205 |
uint32_t IntervalTime; |
| 206 |
uint16_t Cadence; |
| 207 |
uint16_t PwrCadence; |
| 208 |
uint16_t Power; |
| 209 |
}; |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
void serial_init(const char* fname); |
| 214 |
void serial_deinit(); |
| 215 |
int serial_recv_byte() const; |
| 216 |
void serial_write_byte(uint8_t byte); |
| 217 |
int recv_byte(); |
| 218 |
void write_byte(uint8_t byte); |
| 219 |
void globalsat_write_package(uint8_t* payload, uint32_t size); |
| 220 |
uint8_t* globalsat_read_package(int* out_length, uint8_t* out_DeviceCommand); |
| 221 |
void globalsat_send_simple(uint8_t command); |
| 222 |
void globalsat_probe_device(); |
| 223 |
void waypoint_read(); |
| 224 |
void track_read(); |
| 225 |
static void route_read(); |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
void* serial_handle{nullptr}; |
| 230 |
bool isSizeSwapped{false}; |
| 231 |
|
| 232 |
OptionBool showlist; |
| 233 |
|
| 234 |
OptionString opt_dump_file; |
| 235 |
OptionBool opt_input_dump_file; |
| 236 |
OptionString opt_timezone; |
| 237 |
gbfile* dumpfile{nullptr}; |
| 238 |
gbfile* in_file{nullptr}; |
| 239 |
QTimeZone* timezn{nullptr}; |
| 240 |
|
| 241 |
QVector<arglist_t> globalsat_args = { |
| 242 |
{"showlist", &showlist, "list tracks", nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr}, |
| 243 |
{"dump-file", &opt_dump_file, "Dump raw data to this file", nullptr, ARGTYPE_OUTFILE, ARG_NOMINMAX, nullptr}, |
| 244 |
{"input-is-dump-file", &opt_input_dump_file, "Dump raw data to this file", nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr}, |
| 245 |
{"timezone", &opt_timezone, "Time zone ID", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, |
| 246 |
}; |
| 247 |
}; |
| 248 |
#endif |