diff options
Diffstat (limited to 'dexcom_reader/readdata.py')
-rw-r--r-- | dexcom_reader/readdata.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/dexcom_reader/readdata.py b/dexcom_reader/readdata.py index 5e91499..0f20e71 100644 --- a/dexcom_reader/readdata.py +++ b/dexcom_reader/readdata.py | |||
@@ -266,17 +266,21 @@ class Dexcom(object): | |||
266 | for x in xrange(header[1]): | 266 | for x in xrange(header[1]): |
267 | yield record_type.Create(data, x) | 267 | yield record_type.Create(data, x) |
268 | 268 | ||
269 | def ParsePage(self, header, data): | 269 | PARSER_MAP = { |
270 | record_type = constants.RECORD_TYPES[ord(header[2])] | ||
271 | revision = int(header[3]) | ||
272 | generic_parser_map = { | ||
273 | 'USER_EVENT_DATA': database_records.EventRecord, | 270 | 'USER_EVENT_DATA': database_records.EventRecord, |
274 | 'METER_DATA': database_records.MeterRecord, | 271 | 'METER_DATA': database_records.MeterRecord, |
275 | 'CAL_SET': database_records.Calibration, | 272 | 'CAL_SET': database_records.Calibration, |
273 | # 'CAL_SET': database_records.Calibration, | ||
276 | 'INSERTION_TIME': database_records.InsertionRecord, | 274 | 'INSERTION_TIME': database_records.InsertionRecord, |
277 | 'EGV_DATA': database_records.EGVRecord, | 275 | 'EGV_DATA': database_records.EGVRecord, |
278 | 'SENSOR_DATA': database_records.SensorRecord, | 276 | 'SENSOR_DATA': database_records.SensorRecord, |
279 | } | 277 | } |
278 | def ParsePage(self, header, data): | ||
279 | record_type = constants.RECORD_TYPES[ord(header[2])] | ||
280 | revision = int(header[3]) | ||
281 | generic_parser_map = self.PARSER_MAP | ||
282 | if revision < 2 and record_type == 'CAL_SET': | ||
283 | generic_parser_map.update(CAL_SET=database_records.LegacyCalibration) | ||
280 | xml_parsed = ['PC_SOFTWARE_PARAMETER', 'MANUFACTURING_DATA'] | 284 | xml_parsed = ['PC_SOFTWARE_PARAMETER', 'MANUFACTURING_DATA'] |
281 | if record_type in generic_parser_map: | 285 | if record_type in generic_parser_map: |
282 | return self.GenericRecordYielder(header, data, | 286 | return self.GenericRecordYielder(header, data, |
@@ -310,6 +314,20 @@ class Dexcom(object): | |||
310 | records.extend(self.ReadDatabasePage(record_type, x)) | 314 | records.extend(self.ReadDatabasePage(record_type, x)) |
311 | return records | 315 | return records |
312 | 316 | ||
317 | class DexcomG5 (Dexcom): | ||
318 | PARSER_MAP = { | ||
319 | 'USER_EVENT_DATA': database_records.EventRecord, | ||
320 | 'METER_DATA': database_records.G5MeterRecord, | ||
321 | 'CAL_SET': database_records.Calibration, | ||
322 | 'INSERTION_TIME': database_records.G5InsertionRecord, | ||
323 | 'EGV_DATA': database_records.G5EGVRecord, | ||
324 | 'SENSOR_DATA': database_records.SensorRecord, | ||
325 | } | ||
326 | |||
327 | def GetDevice (port, G5=False): | ||
328 | if G5: | ||
329 | return DexcomG5(port) | ||
330 | return Dexcom(port) | ||
313 | 331 | ||
314 | if __name__ == '__main__': | 332 | if __name__ == '__main__': |
315 | Dexcom.LocateAndDownload() | 333 | Dexcom.LocateAndDownload() |