def __init__(self, data): super(FileName, self).__init__(data) self.parent_dir = fields.Field(br(self.content, 0, 7)) self.file_creation_time = fields.Field( br(self.content, 8, 15) ) self.file_modification_time = fields.Field( br(self.content, 16, 23) ) self.mft_modification_time = fields.Field( br(self.content, 24, 31) ) self.file_access_time = fields.Field( br(self.content, 32, 39) ) self.allocated_size = fields.Field( br(self.content, 40, 47) ) self.actual_size = fields.Field( br(self.content, 48, 55) ) self.content_flags = fields.Field(br(self.content, 56, 59)) self.reparse_value = fields.Field(br(self.content, 60, 63)) self.name_length = fields.Field(br(self.content, 64, 64)) # FIXME: FIND OUT WHAT NAMESPACE IS FOR self.namespace = fields.Field(br(self.content, 65, 65)) self.name = fields.StringField( self.content[66:self.content_size.value] )
def __deserialize(self, dictionary): cls = None if '__type__' in dictionary: mod_name = dictionary['__type__']['module'] cls_name = dictionary['__type__']['class'] mod = import_module(mod_name) cls = getattr(mod, cls_name) del dictionary['__type__'] deserialized = dict() for key, value in dictionary.items(): if type(value) == dict: deserialized[key] = fields.ObjectField(self.deserialize(value)) elif type(value) == list: deserialized[key] = fields.ListField( [self.deserialize(v) for v in value]) elif type(value) == int: deserialized[key] = fields.IntegerField(value) elif type(value) == float: deserialized[key] = fields.FloatField(value) else: deserialized[key] = fields.StringField(value) if cls: return fields.ObjectField(cls(**deserialized)) else: return deserialized
def __init__(self, data): self.raw = data self.signature = fields.StringField(br(data, 0, 3)) self.fixup_array_offset = fields.BaseField(br(data, 4, 5)) self.fixup_array_entries = fields.BaseField(br(data, 6, 7)) self.lsn = fields.BaseField(br(data, 8, 15)) self.sequence = fields.BaseField(br(data, 16, 17)) self.link_count = fields.BaseField(br(data, 18, 19)) self.attribute_offset = fields.BaseField(br(data, 20, 21)) self.flags = fields.MftFlagsField(br(data, 22, 23)) self.used_size = fields.BaseField(br(data, 24, 27)) self.allocated_size = fields.BaseField(br(data, 28, 31)) self.file_ref = fields.BaseField(br(data, 32, 39)) self.next_attr_id = fields.BaseField(br(data, 40, 41)) self.attributes_and_fixups = data[42:]
class Shoe(models.Model): color = fields.StringField() size = fields.StringField() material = fields.StringField() cordon = fields.ObjectField()
class Cordon(models.Model): material = fields.StringField() color = fields.StringField()
class MyModelStub(Model): id = fields.StringField(primary_key=True) choice_mto_field = fields.ManyToOneField(TargetModelStub, on_delete=None, choices=[1, 2])
class TargetModelStub(Model): primary_key_choice_field = fields.StringField(primary_key=True, choices=[1, 2, 3]) ordinary_field = fields.StringField()
class DefinitionMessageData(object): """Structured data for decoding a FIT file definition message.""" known_messages = { MessageType.file_id : { 0 : fields.FileField('type'), 1 : fields.ManufacturerField(), 2 : fields.ProductField(), 3 : fields.Field('serial_number'), 4 : fields.TimestampField('time_created'), 5 : fields.Field('number'), 7 : fields.StringField('product_name') }, MessageType.capabilities : {}, MessageType.device_settings : { 0 : fields.Field('active_time_zone'), 1 : fields.Field('utc_offset'), 2 : fields.TimeSField('time_offset'), 4 : fields.TimeModeField(), 5 : fields.TimeHourField('time_zone_offset'), 12 : fields.BacklightModeField(), 35 : fields.SwitchField('switch_35'), 36 : fields.BoolField('activity_tracker_enabled'), 38 : fields.SwitchField('switch_38'), 39 : fields.TimestampField('clock_time'), 40 : fields.Field('pages_enabled'), 41 : fields.SwitchField('switch_41'), 42 : fields.SwitchField('switch_42'), 43 : fields.SwitchField('switch_43'), 44 : fields.SwitchField('switch_44'), 45 : fields.SwitchField('switch_45'), 46 : fields.BoolField('move_alert_enabled'), 47 : fields.DateModeField(), 48 : fields.SwitchField('switch_48'), 49 : fields.SwitchField('switch_49'), 52 : fields.SwitchField('switch_52'), 53 : fields.SwitchField('switch_53'), 55 : fields.DisplayOrientationField('display_orientation'), 56 : fields.SideField(), 57 : fields.Field('default_page'), 58 : fields.Field('autosync_min_steps'), 59 : fields.Field('autosync_min_time'), 64 : fields.SwitchField('switch_64'), 65 : fields.SwitchField('switch_65'), 68 : fields.SwitchField('switch_68'), 80 : fields.BoolField('lactate_threshold_autodetect_enabled'), 81 : fields.SwitchField('switch_81'), 82 : fields.SwitchField('switch_82'), 83 : fields.SwitchField('switch_83'), 84 : fields.SwitchField('switch_84'), 85 : fields.SwitchField('switch_85'), 86 : fields.BoolField('ble_auto_upload_enabled'), 87 : fields.SwitchField('switch_87'), 89 : fields.AutoSyncFrequencyField(), 90 : fields.AutoActivityDetectField(), 94 : fields.Field('number_of_screens'), 95 : fields.DisplayOrientationField('smart_notification_display_orientation'), 107 : fields.SwitchField('switch_107'), 108 : fields.SwitchField('switch_108'), 109 : fields.SwitchField('switch_109'), 110 : fields.SwitchField('switch_110'), 111 : fields.SwitchField('switch_111'), 112 : fields.SwitchField('switch_112'), 126 : fields.SwitchField('switch_126'), 127 : fields.SwitchField('switch_127'), 128 : fields.SwitchField('switch_128'), 133 : fields.SwitchField('switch_133'), 134 : fields.SwitchField('tap_interface'), 141 : fields.SwitchField('switch_141'), }, MessageType.user_profile : { 1 : fields.GenderField(), 2 : fields.Field('age'), 3 : fields.HeightField(), 4 : fields.WeightField(), 5 : fields.LanguageField(), 6 : fields.DisplayMeasureField('elev_setting'), 7 : fields.DisplayMeasureField('weight_setting'), 8 : fields.HeartRateField('resting_heart_rate'), 9 : fields.HeartRateField('default_max_running_heart_rate'), 10 : fields.HeartRateField('default_max_biking_heart_rate'), 11 : fields.HeartRateField('default_max_heart_rate'), 12 : fields.DisplayHeartField('hr_setting'), 13 : fields.DisplayMeasureField('speed_setting'), 14 : fields.DisplayMeasureField('dist_setting'), 16 : fields.PowerField('power_setting'), 17 : fields.ActivityClassField('activity_class'), 18 : fields.DisplayPositionField('position_setting'), 21 : fields.DisplayMeasureField('temperature_setting'), 22 : fields.Field('local_id'), 23 : fields.Field('global_id'), 28 : fields.TimeOfDayField('wake_time'), 29 : fields.TimeOfDayField('sleep_time'), 30 : fields.DisplayMeasureField('height_setting'), 31 : fields.EnhancedDistanceMetersField('user_running_step_length'), 32 : fields.EnhancedDistanceMetersField('user_walking_step_length'), 35 : fields.TimestampField('ts_35'), 41 : fields.TimestampField('ts_41'), 47 : fields.DisplayMeasureField('depth_setting'), 49 : fields.Field('dive_count'), }, MessageType.hrm_profile : { 0 : fields.BoolField('enabled'), 1 : fields.Field('hrm_ant_id'), 2 : fields.BoolField('log_hrv'), 3 : fields.Field('hrm_ant_id_trans_type'), }, MessageType.sdm_profile : {}, MessageType.bike_profile : { 0 : fields.StringField('name'), 1 : fields.SportField(), 2 : fields.SubSportField(), 3 : fields.DistanceCentimetersToMetersField('odometer'), 4 : fields.Field('bike_spd_ant_id'), 5 : fields.Field('bike_cad_ant_id'), 6 : fields.Field('bike_spdcad_ant_id'), 7 : fields.Field('bike_power_ant_id'), 8 : fields.DistanceMillimetersToMetersField('custom_wheelsize'), 9 : fields.DistanceMillimetersToMetersField('auto_wheelsize'), 10 : fields.WeightField('bike_weight'), 11 : fields.PercentField('power_cal_factor'), 12 : fields.BoolField('auto_wheel_cal'), 13 : fields.BoolField('auto_power_zero'), 14 : fields.Field('id'), 15 : fields.BoolField('spd_enabled'), 16 : fields.BoolField('cad_enabled'), 17 : fields.BoolField('spdcad_enabled'), 18 : fields.BoolField('power_enabled'), 19 : fields.DistanceMillimetersToMetersField('crank_length'), 20 : fields.BoolField('enabled'), 21 : fields.Field('bike_spd_ant_id_trans_type'), 22 : fields.Field('bike_cad_ant_id_trans_type'), 23 : fields.Field('bike_spdcad_ant_id_trans_type'), 24 : fields.Field('bike_power_ant_id_trans_type'), 37 : fields.Field('odometer_rollover'), }, MessageType.zones_target : { 1 : fields.Field('max_heart_rate'), 2 : fields.Field('threshold_heart_rate'), 3 : fields.Field('functional_threshold_power'), 5 : fields.HeartRateZoneCalcField(), 7 : fields.PowerCalcField() }, MessageType.hr_zone : { 1 : fields.HeartRateField('high_bpm'), 2 : fields.StringField('name'), }, MessageType.power_zone : { 1 : fields.PowerField('high_value'), 2 : fields.StringField('name'), }, MessageType.met_zone : {}, MessageType.sport : { 0 : fields.SportField(), 1 : fields.SubSportField(), 3 : fields.StringField('name'), }, MessageType.unknown_13 : { 5 : fields.PosField('position_5'), 6 : fields.PosField('position_6'), }, MessageType.unknown_14 : { 10 : fields.Field('sequence'), }, MessageType.goal : { 0 : fields.SportField(), 1 : fields.SubSportField(), 2 : fields.TimestampField('start_time'), 3 : fields.TimestampField('end_time'), 4 : fields.GoalTypeField('type'), 5 : fields.Field('value'), 6 : fields.BoolField('repeat'), 7 : fields.GoalValueField(), 8 : fields.GoalRecurrenceField('recurrence'), 9 : fields.Field('recurrence_value'), 10 : fields.BoolField('enabled'), 11 : fields.GoalSourceField('source') }, MessageType.session : { 0 : fields.EventField(), 1 : fields.EventTypeField(), 2 : fields.TimestampField('start_time'), 3 : fields.LatiitudeField('start_position_lat'), 4 : fields.LongitudeField('start_position_long'), 5 : fields.SportField(), 6 : fields.SubSportField(), 7 : fields.TimeMsField('total_elapsed_time'), 8 : fields.TimeMsField('total_timer_time'), 9 : fields.DistanceCentimetersToKmsField('total_distance'), 10 : fields.SportBasedCyclesField('total_cycles'), 11 : fields.CaloriesField('total_calories'), 13 : fields.CaloriesField('total_fat_calories'), 14 : fields.SpeedMpsField('avg_speed'), 15 : fields.SpeedMpsField('max_speed'), 16 : fields.HeartRateField('avg_heart_rate'), 17 : fields.HeartRateField('max_heart_rate'), 18 : fields.CadenceField('avg_cadence'), 19 : fields.CadenceField('max_cadence'), 20 : fields.PowerField('avg_power'), 21 : fields.PowerField('max_power'), 22 : fields.DistanceMetersField('total_ascent'), 23 : fields.DistanceMetersField('total_descent'), 24 : fields.TrainingeffectField('total_training_effect'), 25 : fields.Field('first_lap_index'), 26 : fields.Field('num_laps'), 27 : fields.Field('event_group'), 28 : fields.SessionTriggerField(), 29 : fields.LatiitudeField('nec_lat'), 30 : fields.LongitudeField('nec_long'), 31 : fields.LatiitudeField('swc_lat'), 32 : fields.LongitudeField('swc_long'), 33 : fields.Field('length_count'), 34 : fields.PowerField('normalized_power'), 35 : fields.TrainingeffectField('training_stress_score'), 36 : fields.Field('intensity_factor'), 37 : fields.LeftRightBalanceField('left_right_balance'), 38 : fields.LatiitudeField('end_position_lat'), 39 : fields.LongitudeField('end_position_long'), 41 : fields.Field('avg_stroke_count'), 42 : fields.DistanceCentimetersToMetersField('avg_stroke_distance'), 43 : fields.Field('swim_stroke'), 44 : fields.DistanceMetersField('pool_length'), 45 : fields.PowerField('threshold_power'), 46 : fields.DisplayMeasureField('pool_length_unit'), 47 : fields.Field('num_active_lengths'), 48 : fields.WorkField('total_work'), 49 : fields.EnhancedAltitudeField('avg_altitude'), 50 : fields.EnhancedAltitudeField('max_altitude'), 51 : fields.DistanceMetersField('gps_accuracy'), 52 : fields.PercentField('avg_grade'), 53 : fields.PercentField('avg_pos_grade'), 54 : fields.PercentField('avg_neg_grade'), 55 : fields.PercentField('max_pos_grade'), 56 : fields.PercentField('max_neg_grade'), 57 : fields.TemperatureField('avg_temperature'), 58 : fields.TemperatureField('max_temperature'), 59 : fields.TimeMsField('total_moving_time'), 60 : fields.SpeedMpsField('avg_pos_vertical_speed'), 61 : fields.SpeedMpsField('avg_neg_vertical_speed'), 62 : fields.SpeedMpsField('max_pos_vertical_speed'), 63 : fields.SpeedMpsField('max_neg_vertical_speed'), 64 : fields.HeartRateField('min_heart_rate'), 65 : fields.TimeMsField('time_in_hr_zone'), 66 : fields.TimeMsField('time_in_speed_zone'), 67 : fields.TimeMsField('time_in_cadence_zone'), 68 : fields.TimeMsField('time_in_power_zone'), 69 : fields.TimeMsField('avg_lap_time'), 70 : fields.Field('best_lap_index'), 71 : fields.EnhancedAltitudeField('min_altitude'), 78 : fields.Field('total_swim_time'), 79 : fields.Field('average_stroke'), 80 : fields.Field('swolf'), 82 : fields.Field('player_score'), 83 : fields.Field('opponent_score'), 84 : fields.StringField('opponent_name'), 85 : fields.Field('stroke_count'), 86 : fields.Field('zone_count'), 87 : fields.SpeedMpsField('max_ball_speed'), 88 : fields.SpeedMpsField('avg_ball_speed'), 89 : fields.DistanceMillimetersField('avg_vertical_oscillation'), 90 : fields.PercentField('avg_stance_time_percent'), 91 : fields.TimeMsField('avg_stance_time', 10.0), 92 : fields.FractionalCadenceField('avg_fractional_cadence'), 93 : fields.FractionalCadenceField('max_fractional_cadence'), 94 : fields.FractionalCyclesField('total_fractional_cycles'), 95 : fields.Field('avg_total_hemoglobin_conc'), 96 : fields.Field('min_total_hemoglobin_conc'), 97 : fields.Field('max_total_hemoglobin_conc'), 98 : fields.PercentField('avg_saturated_hemoglobin_percent'), 99 : fields.PercentField('min_saturated_hemoglobin_percent'), 100 : fields.PercentField('max_saturated_hemoglobin_percent'), 101 : fields.BytePercentField('avg_left_torque_effectiveness'), 102 : fields.BytePercentField('avg_right_torque_effectiveness'), 103 : fields.BytePercentField('avg_left_pedal_smoothness'), 104 : fields.BytePercentField('avg_right_pedal_smoothness'), 105 : fields.BytePercentField('avg_combined_pedal_smoothness'), 110 : fields.StringField('sport_name'), 111 : fields.Field('sport_index'), 112 : fields.TimeMsField('time_standing'), 113 : fields.Field('stand_count'), 114 : fields.Field('avg_left_pco'), 115 : fields.Field('avg_right_pco'), 116 : fields.Field('avg_left_power_phase'), 117 : fields.Field('avg_left_power_phase_peak'), 118 : fields.Field('avg_right_power_phase'), 119 : fields.Field('avg_right_power_phase_peak'), 120 : fields.PowerField('avg_power_position'), 121 : fields.PowerField('max_power_position'), 122 : fields.CadenceField('avg_cadence_position'), 123 : fields.CadenceField('max_cadence_position'), 124 : fields.SpeedMpsField('enhanced_avg_speed'), 125 : fields.SpeedMpsField('enhanced_max_speed'), 126 : fields.EnhancedAltitudeField('enhanced_avg_altitude'), 127 : fields.EnhancedAltitudeField('enhanced_min_altitude'), 128 : fields.EnhancedAltitudeField('enhanced_max_altitude'), 129 : fields.PowerField('avg_lev_motor_power'), 130 : fields.PowerField('max_lev_motor_power'), 131 : fields.BytePercentField('lev_battery_consumption'), 132 : fields.PercentField('avg_vertical_ratio'), 133 : fields.PercentField('avg_stance_time_balance'), 134 : fields.DistanceMillimetersField('avg_step_length'), 137 : fields.TrainingeffectField('total_anaerobic_training_effect'), 139 : fields.SpeedMpsField('avg_vam'), }, MessageType.lap : { 0 : fields.EventField(), 1 : fields.EventTypeField(), 2 : fields.TimestampField('start_time'), 3 : fields.LatiitudeField('start_position_lat'), 4 : fields.LongitudeField('start_position_long'), 5 : fields.LatiitudeField('end_position_lat'), 6 : fields.LongitudeField('end_position_long'), 7 : fields.TimeMsField('total_elapsed_time'), 8 : fields.TimeMsField('total_timer_time'), 9 : fields.DistanceCentimetersToKmsField('total_distance'), 10 : fields.SportBasedCyclesField('total_cycles'), 11 : fields.CaloriesField('total_calories'), 12 : fields.CaloriesField('total_fat_calories'), 13 : fields.SpeedMpsField('avg_speed'), 14 : fields.SpeedMpsField('max_speed'), 15 : fields.Field('avg_heart_rate'), 16 : fields.Field('max_heart_rate'), 17 : fields.Field('avg_cadence'), 18 : fields.Field('max_cadence'), 19 : fields.Field('avg_power'), 20 : fields.Field('max_power'), 21 : fields.DistanceMetersField('total_ascent'), 22 : fields.DistanceMetersField('total_descent'), 24 : fields.LapTriggerField(), 25 : fields.SportField(), 26 : fields.Field('event_group'), 27 : fields.PosField('unknown_lat_27'), 28 : fields.PosField('unknown_long_28'), 29 : fields.PosField('unknown_lat_29'), 30 : fields.PosField('unknown_long_30'), 32 : fields.Field('num_lengths'), 33 : fields.PowerField('normalized_power'), 34 : fields.LeftRightBalanceField('left_right_balance'), 35 : fields.Field('first_length_index'), 37 : fields.DistanceCentimetersToMetersField('avg_stroke_distance'), 38 : fields.Field('swim_stroke'), 39 : fields.SubSportField(), 40 : fields.Field('num_active_lengths'), 41 : fields.WorkField('total_work'), 42 : fields.EnhancedAltitudeField('avg_altitude'), 43 : fields.EnhancedAltitudeField('max_altitude'), 44 : fields.DistanceMetersField('gps_accuracy'), 45 : fields.PercentField('avg_grade'), 46 : fields.PercentField('avg_pos_grade'), 47 : fields.PercentField('avg_neg_grade'), 48 : fields.PercentField('max_pos_grade'), 49 : fields.PercentField('max_neg_grade'), 50 : fields.TemperatureField('avg_temperature'), 51 : fields.TemperatureField('max_temperature'), 52 : fields.TimeMsField('total_moving_time'), 53 : fields.SpeedMpsField('avg_pos_vertical_speed'), 54 : fields.SpeedMpsField('avg_neg_vertical_speed'), 55 : fields.SpeedMpsField('max_pos_vertical_speed'), 56 : fields.SpeedMpsField('max_neg_vertical_speed'), 57 : fields.TimeMsField('time_in_hr_zone'), 58 : fields.TimeMsField('time_in_speed_zone'), 59 : fields.TimeMsField('time_in_cadence_zone'), 60 : fields.TimeMsField('time_in_power_zone'), 61 : fields.Field('repetition_num'), 62 : fields.EnhancedAltitudeField('min_altitude'), 63 : fields.HeartRateField('min_heart_rate'), 70 : fields.Field('swim_time'), 71 : fields.MessageIndexField('wkt_step_index'), 72 : fields.Field('average_stroke'), 73 : fields.Field('swolf'), 74 : fields.Field('opponent_score'), 75 : fields.Field('stroke_count'), 76 : fields.Field('zone_count'), 77 : fields.DistanceMillimetersField('avg_vertical_oscillation'), 78 : fields.PercentField('avg_stance_time_percent'), 79 : fields.TimeMsField('avg_stance_time', 10.0), 80 : fields.FractionalCadenceField('avg_fractional_cadence'), 81 : fields.FractionalCadenceField('max_fractional_cadence'), 82 : fields.FractionalCyclesField('total_fractional_cycles'), 83 : fields.Field('player_score'), 84 : fields.Field('avg_total_hemoglobin_conc'), 85 : fields.Field('min_total_hemoglobin_conc'), 86 : fields.Field('max_total_hemoglobin_conc'), 87 : fields.PercentField('avg_saturated_hemoglobin_percent'), 88 : fields.PercentField('min_saturated_hemoglobin_percent'), 89 : fields.PercentField('max_saturated_hemoglobin_percent'), 91 : fields.BytePercentField('avg_left_torque_effectiveness'), 92 : fields.BytePercentField('avg_right_torque_effectiveness'), 93 : fields.BytePercentField('avg_left_pedal_smoothness'), 94 : fields.BytePercentField('avg_right_pedal_smoothness'), 95 : fields.BytePercentField('avg_combined_pedal_smoothness'), 98 : fields.TimeMsField('time_standing'), 99 : fields.Field('stand_count'), 100 : fields.Field('avg_left_pco'), 101 : fields.Field('avg_right_pco'), 102 : fields.Field('avg_left_power_phase'), 103 : fields.Field('avg_left_power_phase_peak'), 104 : fields.Field('avg_right_power_phase'), 105 : fields.Field('avg_right_power_phase_peak'), 106 : fields.PowerField('avg_power_position'), 107 : fields.PowerField('max_power_position'), 108 : fields.CadenceField('avg_cadence_position'), 109 : fields.CadenceField('max_cadence_position'), 110 : fields.SpeedMpsField('enhanced_avg_speed'), 111 : fields.SpeedMpsField('enhanced_max_speed'), 112 : fields.EnhancedAltitudeField('enhanced_avg_altitude'), 113 : fields.EnhancedAltitudeField('enhanced_min_altitude'), 114 : fields.EnhancedAltitudeField('enhanced_max_altitude'), 115 : fields.PowerField('avg_lev_motor_power'), 116 : fields.PowerField('max_lev_motor_power'), 117 : fields.BytePercentField('lev_battery_consumption'), 118 : fields.PercentField('avg_vertical_ratio', 100.0), 119 : fields.PercentField('avg_stance_time_balance'), 120 : fields.DistanceMillimetersField('avg_step_length'), 121 : fields.SpeedMpsField('avg_vam'), }, MessageType.record : { 0 : fields.LatiitudeField('position_lat'), 1 : fields.LongitudeField('position_long'), 2 : fields.AltitudeField(), 3 : fields.HeartRateField('heart_rate'), 4 : fields.Field('cadence'), 5 : fields.DistanceCentimetersToKmsField('distance'), 6 : fields.SpeedMpsField('speed'), 7 : fields.PowerField(), 8 : fields.Field('compressed_speed_distance'), 9 : fields.PercentField('grade'), 10 : fields.Field('resistance'), 11 : fields.TimeMsField('time_from_course'), 12 : fields.DistanceMetersField('cycle_length', scale=100), 13 : fields.TemperatureField('temperature'), 17 : fields.SpeedMpsField('speed_1s'), 18 : fields.ActivityBasedCyclesField(), 19 : fields.ActivityBasedCyclesField('total_cycles'), 28 : fields.Field('compressed_accumulated_power'), 29 : fields.Field('accumulated_power'), 30 : fields.LeftRightBalanceField('left_right_balance'), 31 : fields.DistanceMetersField('gps_accuracy'), 32 : fields.SpeedMpsField('vertical_speed'), 33 : fields.CaloriesField('calories'), 39 : fields.DistanceMillimetersField('avg_vertical_oscillation'), 40 : fields.PercentField('stance_time_percent'), 41 : fields.TimeMsField('stance_time', 10.0), 42 : fields.ActivityTypeField(), 43 : fields.BytePercentField('left_torque_effectiveness'), 44 : fields.BytePercentField('right_torque_effectiveness'), 45 : fields.BytePercentField('left_pedal_smoothness'), 46 : fields.BytePercentField('right_pedal_smoothness'), 47 : fields.BytePercentField('combined_pedal_smoothness'), 48 : fields.Field('time128'), 49 : fields.Field('stroke_type'), 50 : fields.Field('zone'), 51 : fields.Field('ball_speed'), 52 : fields.Field('cadence256'), 53 : fields.Field('fractional_cadence'), 54 : fields.Field('total_hemoglobin_conc'), 55 : fields.Field('total_hemoglobin_conc_min'), 56 : fields.Field('total_hemoglobin_conc_max'), 57 : fields.PercentField('saturated_hemoglobin_percent'), 58 : fields.PercentField('saturated_hemoglobin_percent_min'), 59 : fields.PercentField('saturated_hemoglobin_percent_max'), 62 : fields.Field('device_index'), 67 : fields.Field('left_pco'), 68 : fields.Field('right_pco'), 69 : fields.Field('left_power_phase'), 70 : fields.Field('left_power_phase_peak'), 71 : fields.Field('right_power_phase'), 72 : fields.Field('right_power_phase_peak'), 73 : fields.SpeedMpsField('enhanced_speed'), 78 : fields.EnhancedAltitudeField('enhanced_altitude'), 83 : fields.PercentField('vertical_ratio', 100.0), 84 : fields.PercentField('stance_time_balance'), 85 : fields.DistanceMillimetersField('step_length'), }, MessageType.event : { 0 : fields.EventField('event'), 1 : fields.EventTypeField(), 2 : fields.Field('data16'), 3 : fields.Field('data'), 4 : fields.Field('event_group'), 7 : fields.Field('score'), 8 : fields.Field('opponent_score'), 9 : fields.Field('front_gear_num'), 10 : fields.Field('front_gear'), 11 : fields.Field('rear_gear_num'), 12 : fields.Field('rear_gear'), 13 : fields.Field('device_index'), 15 : fields.TimestampField('ts_15'), }, MessageType.source : {}, MessageType.device_info : { 0 : fields.Field('device_index'), 1 : fields.DeviceType(), 2 : fields.ManufacturerField(), 3 : fields.Field('serial_number'), 4 : fields.ProductField(), 5 : fields.VersionField('software_version'), 6 : fields.Field('hardware_version'), 7 : fields.TimeMsField('cum_operating_time', 1000.0), 10 : fields.BatteryVoltageField('battery_voltage'), 11 : fields.BatteryStatusField(), 15 : fields.Field('ant_related'), # only found on ant devices? 18 : fields.BodyLocationField('sensor_position'), 19 : fields.StringField('descriptor'), 20 : fields.Field('ant_transmission_type'), 21 : fields.Field('ant_device_number'), 22 : fields.AntNetworkField(), 24 : fields.Field('sensor_id'), 25 : fields.SourceTypeField(), 27 : fields.StringField('product_name'), }, MessageType.unknown_24 : { 2 : fields.BytesField('data'), }, MessageType.workout : { 6 : fields.Field('num_valid_steps'), 8 : fields.StringField('wkt_name'), }, MessageType.workout_step : {}, MessageType.schedule : {}, MessageType.location : {}, MessageType.weight_scale : { 0 : fields.WeightField(), 1 : fields.PercentField('percent_fat'), 2 : fields.PercentField('percent_hydration'), 3 : fields.WeightField('visceral_fat_mass'), 4 : fields.WeightField('bone_mass'), 5 : fields.WeightField('muscle_mass'), 7 : fields.Field('basal_met'), 8 : fields.Field('physique_rating'), 9 : fields.Field('active_met'), 10 : fields.Field('metabolic_age'), 11 : fields.Field('visceral_fat_rating'), 12 : fields.Field('user_profile_index') }, MessageType.course : {}, MessageType.course_point : {}, MessageType.totals : { 0 : fields.TimeSField('timer_time'), 1 : fields.DistanceMetersField('distance'), 2 : fields.CaloriesField('calories'), 3 : fields.SportField(), 4 : fields.TimeSField('elapsed_time'), 5 : fields.Field('sessions'), 6 : fields.TimeSField('active_time'), 9 : fields.Field('sport_index'), }, MessageType.activity : { 0 : fields.TimeMsField('total_timer_time'), 1 : fields.Field('num_sessions'), 2 : fields.ActivityField(), 3 : fields.EventField(), 4 : fields.EventTypeField(), 5 : fields.TimestampField('local_timestamp', False), 6 : fields.Field('event_group'), }, MessageType.software : { 3 : fields.VersionField('version') }, MessageType.file_capabilities : {}, MessageType.mesg_capabilities : {}, MessageType.field_capabilities : {}, MessageType.file_creator : { 0 : fields.VersionField('software_version'), 1 : fields.VersionField('hardware_version'), 2 : fields.BytesField('data') }, MessageType.blood_pressure : {}, MessageType.speed_zone : {}, MessageType.monitoring : { 0 : fields.Field('device_index'), 1 : fields.CaloriesField('calories'), 2 : fields.DistanceCentimetersToMetersField(), 3 : fields.ActivityBasedCyclesField(), 4 : fields.TimeMsField('cum_active_time'), 5 : fields.ActivityTypeField(), 6 : fields.Field('activity_subtype'), 7 : fields.Field('activity_level'), 14 : fields.TemperatureField('temperature_min'), 15 : fields.TemperatureField('temperature_max'), 19 : fields.ActiveCaloriesField(), 24 : fields.ActivityTypeIntensityField('current_activity_type_intensity'), 26 : fields.TimeSField('timestamp_16'), 27 : fields.HeartRateField('heart_rate'), 29 : fields.TimeMinField('duration'), 31 : fields.DistanceMillimetersToMetersField('ascent'), 32 : fields.DistanceMillimetersToMetersField('descent'), 33 : fields.TimeMinField('moderate_activity_time'), 34 : fields.TimeMinField('vigorous_activity_time'), 35 : fields.DistanceMillimetersToMetersField('cum_ascent'), 36 : fields.DistanceMillimetersToMetersField('cum_descent') }, MessageType.training_file : { 0 : fields.FileField('type'), 1 : fields.ManufacturerField(), 2 : fields.ProductField(), 3 : fields.Field('serial_number'), 4 : fields.TimestampField('time_created'), }, # timestamp, serial_number, creation_time, product_ID, session_style MessageType.hrv : { 0 : fields.TimeMsField('time'), }, MessageType.ant_rx : {}, MessageType.ant_tx : {}, MessageType.ant_channel_id : {}, MessageType.length : {}, MessageType.monitoring_info : { 0 : fields.TimestampField('local_timestamp', False), 1 : fields.ActivityTypeField(), 3 : fields.CyclesDistanceField(), 4 : fields.CyclesCaloriesField(), 5 : fields.CaloriesDayField('resting_metabolic_rate') }, MessageType.battery : { 0 : fields.TimeMinField('remaining_mins'), 2 : fields.PercentField('charge') }, MessageType.pad : {}, MessageType.slave_device : {}, MessageType.personal_record : { 0 : fields.PersonalRecordTypeField(), 1 : fields.SportField(), 2 : fields.DistanceCentimetersToMetersField('record_distance'), 3 : fields.DistanceCentimetersToMetersField('record_distance2'), 4 : fields.DistanceCentimetersToMetersField('actual_distance'), 5 : fields.PersonalRecordField() }, MessageType.connectivity : { 0 : fields.BoolField('bluetooth_enabled'), 1 : fields.BoolField('bluetooth_le_enabled'), 2 : fields.BoolField('ant_enabled'), 3 : fields.StringField('name'), 4 : fields.BoolField('live_tracking_enabled'), 5 : fields.BoolField('weather_conditions_enabled'), 6 : fields.BoolField('weather_alerts_enabled'), 7 : fields.BoolField('auto_activity_upload_enabled'), 8 : fields.BoolField('course_download_enabled'), 9 : fields.BoolField('workout_download_enabled'), 10 : fields.BoolField('gps_ephemeris_download_enabled'), 11 : fields.BoolField('incident_detection_enabled'), 12 : fields.BoolField('grouptrack_enabled'), }, MessageType.weather_conditions : {}, MessageType.weather_alert : {}, MessageType.cadence_zone : {}, MessageType.hr : {}, MessageType.unknown_140 : { 21 : fields.PosField('position_21'), 24 : fields.PosField('position_24'), }, MessageType.unknown_141 : { 1 : fields.TimestampField('ts_1', False), 2 : fields.TimestampField('ts_2', False), 4 : fields.PosField('position_4'), 5 : fields.PosField('position_5'), }, MessageType.segment_lap : {}, MessageType.memo_glob : {}, MessageType.sensor : { 0 : fields.Field('sensor_id'), 2 : fields.StringField('name'), 10 : fields.DistanceMillimetersToMetersField('manual_wheelsize'), 11 : fields.NumberField('calibration_factor', 10.0), 21 : fields.DistanceMillimetersToMetersField('auto_wheelsize'), 32 : fields.ProductField(), 33 : fields.ManufacturerField(), 34 : fields.VersionField('software_version'), 50 : fields.BytesField('ble_id') }, MessageType.segment_id : {}, MessageType.segment_leaderboard_entry : {}, MessageType.segment_point : {}, MessageType.segment_file : {}, MessageType.workout_session : {}, MessageType.watchface_settings : { 0 : fields.WatchFaceModeField('mode'), 1 : fields.Field('layout'), }, MessageType.gps_metadata : {}, MessageType.camera_event : {}, MessageType.timestamp_correlation : {}, MessageType.gyroscope_data : {}, MessageType.accelerometer_data : {}, MessageType.three_d_sensor_calibration : {}, MessageType.video_frame : {}, MessageType.obdii_data : {}, MessageType.nmea_sentence : {}, MessageType.aviation_attitude : {}, MessageType.video : {}, MessageType.video_title : {}, MessageType.video_description : {}, MessageType.video_clip : {}, MessageType.ohr_settings : { 0 : fields.SwitchField('enabled'), }, MessageType.exd_screen_configuration : {}, MessageType.exd_data_field_configuration : {}, MessageType.exd_data_concept_configuration : {}, MessageType.field_description : { 0 : fields.Field('developer_data_index'), 1 : fields.Field('field_definition_number'), 2 : fields.FitBaseTypeField('fit_base_type_id'), 3 : fields.StringField('field_name'), 4 : fields.Field('array'), 5 : fields.StringField('components'), 6 : fields.Field('scale'), 7 : fields.Field('offset'), 8 : fields.StringField('units'), 9 : fields.StringField('bits'), 10 : fields.StringField('accumulate'), 13 : fields.FitBaseUnitField('fit_base_unit_id'), 14 : fields.Field('native_message_num'), 15 : fields.Field('native_field_num') }, MessageType.dev_data_id : { 0 : fields.Field('developer_id'), 1 : fields.BytesField('application_id'), 2 : fields.ManufacturerField(), 3 : fields.Field('developer_data_index'), 4 : fields.Field('application_version') }, MessageType.magnetometer_data : {}, MessageType.barometer_data : {}, MessageType.one_d_sensor_calibration : {}, MessageType.set : {}, MessageType.stress_level : { 0 : fields.Field('stress_level_value'), 1 : fields.TimestampField('stress_level_time', False), }, MessageType.unknown_233 : { 2 : fields.BytesField('unknown_2'), }, MessageType.local_time : { 0 : fields.TimestampField('local_timestamp', False) }, MessageType.dive_settings : {}, MessageType.dive_gas : {}, MessageType.dive_alarm : {}, MessageType.exercise_title : {}, MessageType.dive_summary : {}, # Names and types for this message are guesses MessageType.start : { 2 : fields.TimestampField('local_timestamp', False), }, # Names and types for this message are guesses MessageType.data : { 0 : fields.BytesField('data'), }, # Names and types for this message are guesses MessageType.end : {}, MessageType.unknown_284 : { 1 : fields.TimestampField('ts_1', True), }, MessageType.mfg_range_min : {}, MessageType.mfg_range_max : {}, } reserved_field_indexes = { 250 : fields.Field('part_index'), 253 : fields.TimestampField(), 254 : fields.MessageIndexField('message_index') } @classmethod def get_message_definition(cls, message_type): """Given a message number, return a message definition.""" return cls.known_messages.get(message_type, {})