Class: Fit4Ruby::Monitoring_B
- Inherits:
-
FitDataRecord
- Object
- FitDataRecord
- Fit4Ruby::Monitoring_B
- Defined in:
- lib/fit4ruby/Monitoring_B.rb
Overview
The Monitoring_B object is a FIT file class. It’s a top-level object that holds all references to other FIT records that are part of the FIT file. Each of the objects it references are direct equivalents of the message record structures used in the FIT file.
Constant Summary
Constants inherited from FitDataRecord
Constants included from BDFieldNameTranslator
BDFieldNameTranslator::BD_DICT
Instance Attribute Summary collapse
-
#device_infos ⇒ Object
Returns the value of attribute device_infos.
-
#field_descriptions ⇒ Object
Returns the value of attribute field_descriptions.
-
#file_id ⇒ Object
Returns the value of attribute file_id.
-
#monitoring_infos ⇒ Object
Returns the value of attribute monitoring_infos.
-
#monitorings ⇒ Object
Returns the value of attribute monitorings.
-
#software ⇒ Object
Returns the value of attribute software.
Attributes inherited from FitDataRecord
Instance Method Summary collapse
-
#check ⇒ Object
Perform some basic logical checks on the object and all references sub objects.
-
#initialize(field_values = {}) ⇒ Monitoring_B
constructor
Create a new Monitoring_B object.
-
#new_fit_data_record(record_type, field_values = {}) ⇒ Object
Create a new FitDataRecord.
Methods inherited from FitDataRecord
#<=>, #==, #export, #get, #get_as, #get_unit_by_name, #set, #set_field_values, #write
Methods included from BDFieldNameTranslator
Methods included from Converters
#conversion_factor, #fit_time_to_time, #secsToDHMS, #secsToHM, #secsToHMS, #speedToPace, #time_to_fit_time
Constructor Details
#initialize(field_values = {}) ⇒ Monitoring_B
Create a new Monitoring_B object.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 34 def initialize(field_values = {}) super('activity') @num_sessions = 0 @file_id = FileId.new @field_descriptions = [] @device_infos = [] @softwares = nil @monitoring_infos = [] @monitorings = [] end |
Instance Attribute Details
#device_infos ⇒ Object
Returns the value of attribute device_infos.
28 29 30 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 28 def device_infos @device_infos end |
#field_descriptions ⇒ Object
Returns the value of attribute field_descriptions.
28 29 30 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 28 def field_descriptions @field_descriptions end |
#file_id ⇒ Object
Returns the value of attribute file_id.
28 29 30 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 28 def file_id @file_id end |
#monitoring_infos ⇒ Object
Returns the value of attribute monitoring_infos.
28 29 30 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 28 def monitoring_infos @monitoring_infos end |
#monitorings ⇒ Object
Returns the value of attribute monitorings.
28 29 30 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 28 def monitorings @monitorings end |
#software ⇒ Object
Returns the value of attribute software.
28 29 30 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 28 def software @software end |
Instance Method Details
#check ⇒ Object
Perform some basic logical checks on the object and all references sub objects. Any errors will be reported via the Log object.
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 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 48 def check = ts_16_offset = nil last_ts_16 = nil # The timestamp_16 is a 2 byte time stamp value that is used instead of # the 4 byte timestamp field for monitoring records that have # current_activity_type_intensity values with an activity type of 6. The # value seems to be in seconds, but the 0 value reference does not seem # to be included in the file. However, it can be approximated using the # surrounding timestamp values. @monitorings.each do |record| if last_ts_16 && ts_16_offset && record. && record. < last_ts_16 # Detect timestamp_16 wrap-arounds. timestamp_16 is a 16 bit value. # In case of a wrap-around we adjust the ts_16_offset accordingly. ts_16_offset += 2 ** 16 end if ts_16_offset # We have already found the offset. Adjust all timestamps according # to 'offset + timestamp_16' if record. record. = ts_16_offset + record. last_ts_16 = record. end else # We are still looking for the offset. if record. && # We have a previous timestamp and found the first record with a # timestamp_16 value set. We assume that the timestamp of this # record is one minute after the previously found timestamp. # That's just a guess. Who knows what the Garmin engineers were # thinking here? ts_16_offset = + 60 - record. record. = ts_16_offset + record. last_ts_16 = record. else # Just save the timestamp of the current record. = record. end end end end |
#new_fit_data_record(record_type, field_values = {}) ⇒ Object
Create a new FitDataRecord.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/fit4ruby/Monitoring_B.rb', line 97 def new_fit_data_record(record_type, field_values = {}) case record_type when 'file_id' @file_id = (record = FileId.new(field_values)) when 'software' @software = (record = Software.new(field_values)) when 'device_info' @device_infos << (record = DeviceInfo.new(field_values)) when 'monitoring_info' @monitoring_infos << (record = MonitoringInfo.new(field_values)) when 'monitoring' @monitorings << (record = Monitoring.new(field_values)) else record = nil end record end |