@@ -266,17 +266,21 @@ def GenericRecordYielder(self, header, data, record_type):
266
266
for x in xrange (header [1 ]):
267
267
yield record_type .Create (data , x )
268
268
269
- def ParsePage (self , header , data ):
270
- record_type = constants .RECORD_TYPES [ord (header [2 ])]
271
- revision = int (header [3 ])
272
- generic_parser_map = {
269
+ PARSER_MAP = {
273
270
'USER_EVENT_DATA' : database_records .EventRecord ,
274
271
'METER_DATA' : database_records .MeterRecord ,
275
272
'CAL_SET' : database_records .Calibration ,
273
+ # 'CAL_SET': database_records.Calibration,
276
274
'INSERTION_TIME' : database_records .InsertionRecord ,
277
275
'EGV_DATA' : database_records .EGVRecord ,
278
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
284
xml_parsed = ['PC_SOFTWARE_PARAMETER' , 'MANUFACTURING_DATA' ]
281
285
if record_type in generic_parser_map :
282
286
return self .GenericRecordYielder (header , data ,
@@ -310,6 +314,20 @@ def ReadRecords(self, record_type):
310
314
records .extend (self .ReadDatabasePage (record_type , x ))
311
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
332
if __name__ == '__main__' :
315
333
Dexcom .LocateAndDownload ()
0 commit comments