fit4ruby 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,11 +18,23 @@ module Fit4Ruby
18
18
  message 0, 'file_id'
19
19
  field 0, 'enum', 'type', :dict => 'file'
20
20
  field 1, 'uint16', 'manufacturer', :dict => 'manufacturer'
21
- field 2, 'uint16', 'product', :dict => 'product'
21
+ alt_field 2, 'manufacturer' do
22
+ field :default, 'uint16', 'product'
23
+ field 'garmin', 'uint16', 'garmin_product', :dict => 'garmin_product'
24
+ end
22
25
  field 3, 'uint32z', 'serial_number'
23
26
  field 4, 'uint32', 'time_created', :type => 'date_time'
24
27
  field 5, 'uint16', 'number'
25
28
 
29
+ message 12, 'sport'
30
+ field 0, 'enum', 'sport', :dict => 'sport'
31
+ field 1, 'enum', 'sub_sport', :dict => 'sub_sport'
32
+ field 3, 'string', 'name'
33
+ field 4, 'uint16', 'undocumented_field_4'
34
+ field 5, 'enum', 'undocumented_field_5'
35
+ field 6, 'enum', 'undocumented_field_6'
36
+ field 10, 'uint8', 'undocumented_field_10', :array => true
37
+
26
38
  message 18, 'session'
27
39
  field 0, 'enum', 'event', :dict => 'event'
28
40
  field 1, 'enum', 'event_type', :dict => 'event_type'
@@ -34,15 +46,26 @@ module Fit4Ruby
34
46
  field 7, 'uint32', 'total_elapsed_time', :type => 'duration', :scale => 1000
35
47
  field 8, 'uint32', 'total_timer_time', :type => 'duration', :scale => 1000
36
48
  field 9, 'uint32', 'total_distance', :scale => 100, :unit => 'm'
37
- field 10, 'uint32', 'total_strides', :unit => 'strides'
49
+ alt_field 10, 'sport' do
50
+ field :default, 'uint32', 'total_cycles', :unit => 'cycles'
51
+ field [ 'running', 'walking' ], 'uint32', 'total_strides', :unit => 'strides'
52
+ end
38
53
  field 11, 'uint16', 'total_calories', :unit => 'kcal'
39
54
  field 13, 'uint16', 'total_fat_calories', :unit => 'kcal'
40
55
  field 14, 'uint16', 'avg_speed', :scale => 1000, :unit => 'm/s'
41
56
  field 15, 'uint16', 'max_speed', :scale => 1000, :unit => 'm/s'
42
57
  field 16, 'uint8', 'avg_heart_rate', :unit => 'bpm'
43
58
  field 17, 'uint8', 'max_heart_rate', :unit => 'bpm'
44
- field 18, 'uint8', 'avg_running_cadence', :unit => 'strides/min'
45
- field 19, 'uint8', 'max_running_cadence', :unit => 'strides/min'
59
+ alt_field 18, 'sport' do
60
+ field :default, 'uint8', 'avg_candence', :unit => 'rpm'
61
+ field 'running', 'uint8', 'avg_running_cadence', :unit => 'strides/min'
62
+ end
63
+ alt_field 19, 'sport' do
64
+ field :default, 'uint8', 'max_cadence', :unit => 'rpm'
65
+ field 'running', 'uint8', 'max_running_cadence', :unit => 'strides/min'
66
+ end
67
+ field 20, 'uint16', 'avg_power', :unit => 'watts'
68
+ field 21, 'uint16', 'max_power', :unit => 'watts'
46
69
  field 22, 'uint16', 'total_ascent', :unit => 'm'
47
70
  field 23, 'uint16', 'total_descent', :unit => 'm'
48
71
  field 24, 'uint8', 'total_training_effect', :scale => 10
@@ -54,13 +77,45 @@ module Fit4Ruby
54
77
  field 30, 'sint32', 'nec_long', :type => 'coordinate'
55
78
  field 31, 'sint32', 'swc_lat', :type => 'coordinate'
56
79
  field 32, 'sint32', 'swc_long', :type => 'coordinate'
80
+ field 33, 'uint16', 'undefined_value_33'
81
+ field 34, 'uint16', 'normalized_power', :unit => 'watts'
82
+ field 35, 'uint16', 'training_stress_score', :scale => 10, :unit => 'tss'
83
+ field 36, 'uint16', 'intensity_factor', :scale => 1000, :unit => 'if'
84
+ field 37, 'uint16', 'left_right_balance', :dict => 'left_right_balance_100'
85
+ field 41, 'uint32', 'avg_stroke_count', :scale => 10, :unit => 'strokes/lap'
86
+ field 42, 'uint16', 'avg_stroke_distance', :scale => 100, :unit => 'm'
87
+ field 43, 'enum', 'swim_stroke', :dict => 'swim_stroke'
88
+ field 44, 'uint16', 'pool_length', :scale => 100, :unit => 'm'
89
+ field 45, 'uint16', 'undefined_value_45'
90
+ field 46, 'enum', 'pool_length_unit', :dict => 'display_measure'
91
+ field 47, 'uint16', 'num_active_length', :unit => 'lengths'
92
+ field 48, 'uint32', 'total_work', :unit => 'J'
93
+ field 57, 'sint8', 'avg_temperature', :unit => 'C'
94
+ field 58, 'sint8', 'max_temperature', :unit => 'C'
95
+ field 65, 'uint32', 'time_in_hr_zone', :array => true, :scale => 1000, :unit => 's'
96
+ field 68, 'uint32', 'time_in_power_zone', :array => true, :scale => 1000, :unit => 's'
97
+ field 78, 'uint32', 'undocumented_field_78'
98
+ field 79, 'uint16', 'undocumented_field_79'
99
+ field 80, 'uint16', 'undocumented_field_80'
57
100
  field 81, 'enum', 'undocumented_field_81'
58
101
  field 89, 'uint16', 'avg_vertical_oscillation', :scale => 10, :unit => 'mm'
59
102
  field 90, 'uint16', 'avg_stance_time_percent', :scale => 100, :unit => 'percent'
60
103
  field 91, 'uint16', 'avg_stance_time', :scale => 10, :unit => 'ms'
61
- field 92, 'uint8', 'avg_fraction_cadence', :scale => 128
62
- field 93, 'uint8', 'max_fractional_cadence', :scale => 128
63
- field 94, 'uint8', 'total_fractional_cycles', :scale => 128
104
+ field 92, 'uint8', 'avg_fractional_cadence', :scale => 128, :unit => 'rpm'
105
+ field 93, 'uint8', 'max_fractional_cadence', :scale => 128, :unit => 'rpm'
106
+ field 94, 'uint8', 'total_fractional_cycles', :scale => 128, :unit => 'cycles'
107
+ field 95, 'uint16', 'avg_total_hemoglobin_conc', :array => true, :scale => 100, :unit => 'g/dL'
108
+ field 96, 'uint16', 'min_total_hemoglobin_conc', :array => true, :scale => 100, :unit => 'g/dL'
109
+ field 97, 'uint16', 'max_total_hemoglobin_conc', :array => true, :scale => 100, :unit => 'g/dL'
110
+ field 101, 'uint8', 'avg_left_torque_effectiveness', :scale => 2, :unit => 'percent'
111
+ field 102, 'uint8', 'avg_right_torque_effectiveness', :scale => 2, :unit => 'percent'
112
+ field 103, 'uint8', 'avg_left_pedal_smoothness', :scale => 2, :unit => 'percent'
113
+ field 104, 'uint8', 'avg_right_pedal_smoothness', :scale => 2, :unit => 'percent'
114
+ field 105, 'uint8', 'avg_combined_pedal_smoothness', :scale => 2, :unit => 'percent'
115
+ field 107, 'uint16', 'undefined_value_107'
116
+ field 108, 'uint16', 'undefined_value_108'
117
+ field 109, 'uint8', 'undefined_value_109'
118
+ field 110, 'string', 'undefined_value_110'
64
119
  field 253, 'uint32', 'timestamp', :type => 'date_time'
65
120
  field 254, 'uint16', 'message_index'
66
121
 
@@ -75,34 +130,65 @@ module Fit4Ruby
75
130
  field 7, 'uint32', 'total_elapsed_time', :type => 'duration', :scale => 1000
76
131
  field 8, 'uint32', 'total_timer_time', :type => 'duration', :scale => 1000
77
132
  field 9, 'uint32', 'total_distance', :scale => 100, :unit => 'm'
78
- field 10, 'uint32', 'total_strides', :unit => 'strides'
133
+ field 25, 'enum', 'sport', :dict => 'sport'
134
+ alt_field 10, 'sport' do
135
+ field :default, 'uint32', 'total_cycles', :unit => 'cycles'
136
+ field [ 'running', 'walking' ], 'uint32', 'total_strides', :unit => 'strides'
137
+ end
79
138
  field 11, 'uint16', 'total_calories', :unit => 'kcal'
80
139
  field 12, 'uint16', 'total_fat_calories', :unit => 'kcal'
81
140
  field 13, 'uint16', 'avg_speed', :scale => 1000, :unit => 'm/s'
82
141
  field 14, 'uint16', 'max_speed', :scale => 1000, :unit => 'm/s'
83
142
  field 15, 'uint8', 'avg_heart_rate', :unit => 'bpm'
84
143
  field 16, 'uint8', 'max_heart_rate', :unit => 'bpm'
85
- field 17, 'uint8', 'avg_running_cadence', :unit => 'strides'
86
- field 18, 'uint8', 'max_running_cadence', :unit => 'strides'
144
+ alt_field 17, 'sport' do
145
+ field :default, 'uint8', 'avg_candence', :unit => 'rpm'
146
+ field 'running', 'uint8', 'avg_running_cadence', :unit => 'strides/min'
147
+ end
148
+ alt_field 18, 'sport' do
149
+ field :default, 'uint8', 'max_cadence', :unit => 'rpm'
150
+ field 'running', 'uint8', 'max_running_cadence', :unit => 'strides/min'
151
+ end
152
+ field 19, 'uint16', 'avg_power', :unit => 'watts'
153
+ field 20, 'uint16', 'max_power', :unit => 'watts'
87
154
  field 21, 'uint16', 'total_ascent', :unit => 'm'
88
155
  field 22, 'uint16', 'total_descent', :unit => 'm'
89
156
  field 23, 'enum', 'intensity', :dict => 'intensity'
90
157
  field 24, 'enum', 'lap_trigger', :dict => 'lap_trigger'
91
- field 25, 'enum', 'sport', :dict => 'sport'
92
158
  field 26, 'uint8', 'event_group'
93
159
  field 27, 'sint32', 'nec_lat', :type => 'coordinate'
94
160
  field 28, 'sint32', 'nec_long', :type => 'coordinate'
95
161
  field 29, 'sint32', 'swc_lat', :type => 'coordinate'
96
162
  field 30, 'sint32', 'swc_long', :type => 'coordinate'
163
+ field 32, 'uint16', 'num_length', :unit => 'lengths'
164
+ field 33, 'uint16', 'normalized_power', :unit => 'watts'
165
+ field 34, 'uint16', 'left_right_balance', :dict => 'left_right_balance_100'
166
+ field 35, 'uint16', 'first_length_index'
167
+ field 37, 'uint16', 'avg_stroke_distance', :scale => 100, :unit => 'm'
168
+ field 38, 'enum', 'swim_stroke', :dict => 'swim_stroke'
97
169
  field 39, 'enum', 'sub_sport', :dict => 'sub_sport'
170
+ field 40, 'uint16', 'num_active_length', :unit => 'lengths'
171
+ field 41, 'uint32', 'total_work', :scale => 'J'
172
+ field 57, 'uint32', 'time_in_hr_zone', :array => true, :scale => 1000, :unit => 's'
173
+ field 60, 'uint32', 'avg_pos_vertical_speed', :scale => 1000, :unit => 'm/s'
174
+ field 70, 'uint32', 'undefined_value_70'
98
175
  field 71, 'uint16', 'wkt_step_index'
99
176
  field 72, 'enum', 'undocumented_field_72'
177
+ field 73, 'uint16', 'undefined_value_73'
100
178
  field 77, 'uint16', 'avg_vertical_oscillation', :scale => 10, :unit => 'mm'
101
179
  field 78, 'uint16', 'avg_stance_time_percent', :scale => 100, :unit => 'percent'
102
180
  field 79, 'uint16', 'avg_stance_time', :scale => 10, :unit => 'ms'
103
181
  field 80, 'uint8', 'avg_fractional_cadence', :scale => 128
104
182
  field 81, 'uint8', 'max_fractional_cadence', :scale => 128
105
183
  field 82, 'uint8', 'total_fractional_cycles', :scale => 128
184
+ field 90, 'uint16', 'undefined_value_90'
185
+ field 91, 'uint8', 'avg_left_torque_effectiveness', :scale => 2, :unit => 'percent'
186
+ field 92, 'uint8', 'avg_right_torque_effectiveness', :scale => 2, :unit => 'percent'
187
+ field 93, 'uint8', 'avg_left_pedal_smoothness', :scale => 2, :unit => 'percent'
188
+ field 94, 'uint8', 'avg_right_pedal_smoothness', :scale => 2, :unit => 'percent'
189
+ field 95, 'uint8', 'avg_combined_pedal_smoothness', :scale => 2, :unit => 'percent'
190
+ field 96, 'uint16', 'undefined_value_96'
191
+ field 97, 'uint16', 'undefined_value_97'
106
192
  field 253, 'uint32', 'timestamp', :type => 'date_time'
107
193
  field 254, 'uint16', 'message_index'
108
194
 
@@ -118,14 +204,24 @@ module Fit4Ruby
118
204
  field 40, 'uint16', 'stance_time_percent', :scale => 100, :unit => 'percent'
119
205
  field 41, 'uint16', 'stance_time', :scale => 10, :unit => 'ms'
120
206
  field 42, 'enum', 'activity_type', :dict => 'activity_type'
121
- field 53, 'uint8', 'fractional_cadence', :scale => 128 # Just a guess
207
+ field 53, 'uint8', 'fractional_cadence', :scale => 128
208
+ field 61, 'uint16', 'undefined_value_61'
209
+ field 66, 'sint16', 'undefined_value_66'
122
210
  field 253, 'uint32', 'timestamp', :type => 'date_time'
123
211
 
124
212
  message 21, 'event'
125
213
  field 0, 'enum', 'event', :dict => 'event'
126
214
  field 1, 'enum', 'event_type', :dict => 'event_type'
127
215
  field 2, 'uint16', 'data16'
128
- field 3, 'uint32', 'data'
216
+ alt_field 3, 'event' do
217
+ field :default, 'uint32', 'data'
218
+ field 'timer', 'enum', 'timer_trigger', :dict => 'timer_trigger'
219
+ field 'course_point', 'enum', 'message_index', :dict => 'message_index'
220
+ field 'battery', 'uint16', 'battery_level', :scale => 1000, :unit => 'V'
221
+ field 'recovery_hr', 'uint32', 'recovery_hr', :unit => 'bpm'
222
+ field 'recovery_time', 'uint32', 'recovery_time', :unit => 'min'
223
+ field 'vo2max', 'uint32', 'vo2max'
224
+ end
129
225
  field 4, 'uint8', 'event_group'
130
226
  field 253, 'uint32', 'timestamp', :type => 'date_time'
131
227
 
@@ -138,6 +234,8 @@ module Fit4Ruby
138
234
  field 3, 'uint8', 'Satellite 4'
139
235
  field 4, 'uint8', 'Satellite 5'
140
236
  field 5, 'enum', 'lock_status'
237
+ field 6, 'uint8', 'undocumented_field_6' # First found in FR920XT
238
+ field 14, 'uint8', 'undocumented_field_14' # First found in FR920XT
141
239
  field 253, 'uint32', 'timestamp', :type => 'date_time'
142
240
 
143
241
  message 23, 'device_info'
@@ -145,7 +243,10 @@ module Fit4Ruby
145
243
  field 1, 'uint8', 'device_type', :dict => 'device_type'
146
244
  field 2, 'uint16', 'manufacturer', :dict => 'manufacturer'
147
245
  field 3, 'uint32z', 'serial_number'
148
- field 4, 'uint16', 'product', :dict => 'product'
246
+ alt_field 4, 'manufacturer' do
247
+ field :default, 'uint16', 'product'
248
+ field 'garmin', 'uint16', 'garmin_product', :dict => 'garmin_product'
249
+ end
149
250
  field 5, 'uint16', 'software_version', :scale => 100
150
251
  field 6, 'uint8', 'hardware_version'
151
252
  field 7, 'uint32', 'cum_operating_time', :type => 'duration'
@@ -155,11 +256,11 @@ module Fit4Ruby
155
256
  field 11, 'uint8', 'battery_status', :dict => 'battery_status'
156
257
  field 15, 'uint32', 'rx_packets_ok' # just a guess
157
258
  field 16, 'uint32', 'rx_packets_err' # just a guess
158
- field 20, 'uint8z', 'undocumented_field_20'
159
- field 21, 'uint16z', 'undocumented_field_21'
160
- field 22, 'enum', 'undocumented_field_22'
259
+ field 20, 'uint8z', 'ant_transmission_type'
260
+ field 21, 'uint16z', 'ant_device_number'
261
+ field 22, 'enum', 'ant_network', :dict => 'ant_network'
161
262
  field 23, 'uint8', 'undocumented_field_23'
162
- field 25, 'enum', 'undocumented_field_25'
263
+ field 25, 'enum', 'source_type', :dict => 'source_type'
163
264
  field 253, 'uint32', 'timestamp', :type => 'date_time'
164
265
 
165
266
  message 33, 'totals'
@@ -187,6 +288,20 @@ module Fit4Ruby
187
288
  field 0, 'uint16', 'software_version'
188
289
  field 1, 'uint8', 'hardware_version'
189
290
 
291
+ message 72, 'training_file'
292
+ field 0, 'enum', 'type'
293
+ field 1, 'uint16', 'manufacturer', :dict => 'manufacturer'
294
+ alt_field 2, 'manufacturer' do
295
+ field :default, 'uint16', 'product'
296
+ field 'garmin', 'uint16', 'garmin_product', :dict => 'garmin_product'
297
+ end
298
+ field 3, 'uint32z', 'serial_number'
299
+ field 4, 'uint32', 'time_created', :type => 'date_time'
300
+ field 253, 'uint32', 'timestamp', :type => 'date_time'
301
+
302
+ message 78, 'hrv'
303
+ field 0, 'uint16', 'time', :array => true, :scale => 1000, :unit => 's'
304
+
190
305
  # Not part of the official ANT SDK doc
191
306
  message 79, 'user_profile'
192
307
  field 0, 'uint16', 'undocumented_field_0' # seems to strongly correlate with vo2max
@@ -228,6 +343,8 @@ module Fit4Ruby
228
343
  field 8, 'uint8', 'undocumented_field_8'
229
344
  field 9, 'uint16', 'recovery_time', :scale => 60, :unit => 'hours'
230
345
  field 10, 'uint16', 'undocumented_field_10' # always seems to be 340
346
+ field 11, 'enum', 'undocumented_field_11'
347
+ field 12, 'enum', 'undocumented_field_12'
231
348
  field 253, 'uint32', 'timestamp', :type => 'date_time'
232
349
 
233
350
  # Not part of the official ANT SDK doc
@@ -1,4 +1,4 @@
1
1
  module Fit4Ruby
2
2
  # The version number of the library.
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
data/spec/FitFile_spec.rb CHANGED
@@ -16,14 +16,15 @@ describe Fit4Ruby do
16
16
 
17
17
  before(:each) do
18
18
  a = Fit4Ruby::Activity.new
19
- a.total_timer_time = 30 * 60
19
+ a.total_timer_time = 30 * 60.0
20
20
  a.new_user_profile({ :age => 33, :height => 1.78, :weight => 73.0,
21
21
  :gender => 'male', :activity_class => 4.0,
22
22
  :max_hr => 178 })
23
23
 
24
24
  a.new_event({ :event => 'timer', :event_type => 'start_time' })
25
- a.new_device_info({ :device_index => 0 })
26
- a.new_device_info({ :device_index => 1, :battery_status => 'ok' })
25
+ a.new_device_info({ :device_index => 0, :manufacturer => 'garmin' })
26
+ a.new_device_info({ :device_index => 1, :manufacturer => 'garmin',
27
+ :battery_status => 'ok' })
27
28
  ts = Time.now
28
29
  0.upto(a.total_timer_time / 60) do |mins|
29
30
  ts += 60
@@ -44,24 +45,26 @@ describe Fit4Ruby do
44
45
  })
45
46
 
46
47
  if mins > 0 && mins % 5 == 0
47
- a.new_lap({ :timestamp => ts })
48
+ a.new_lap({ :timestamp => ts, :sport => 'running',
49
+ :total_cycles => 195 })
48
50
  end
49
51
  end
50
- a.new_session({ :timestamp => ts })
52
+ a.new_session({ :timestamp => ts, :sport => 'running' })
51
53
  a.new_event({ :timestamp => ts, :event => 'recovery_time',
52
54
  :event_type => 'marker',
53
- :data => 2160 })
55
+ :recovery_time => 2160 })
54
56
  a.new_event({ :timestamp => ts, :event => 'vo2max',
55
- :event_type => 'marker', :data => 52 })
57
+ :event_type => 'marker', :vo2max => 52 })
56
58
  a.new_event({ :timestamp => ts, :event => 'timer',
57
59
  :event_type => 'stop_all' })
58
- a.new_device_info({ :timestamp => ts, :device_index => 0 })
60
+ a.new_device_info({ :timestamp => ts, :device_index => 0,
61
+ :manufacturer => 'garmin' })
59
62
  ts += 1
60
- a.new_device_info({ :timestamp => ts, :device_index => 1,
61
- :battery_status => 'low' })
63
+ a.new_device_info({ :timestamp => ts, :manufacturer => 'garmin',
64
+ :device_index => 1, :battery_status => 'low' })
62
65
  ts += 120
63
66
  a.new_event({ :timestamp => ts, :event => 'recovery_hr',
64
- :event_type => 'marker', :data => 132 })
67
+ :event_type => 'marker', :recovery_hr => 132 })
65
68
 
66
69
  a.aggregate
67
70
 
@@ -74,10 +77,11 @@ describe Fit4Ruby do
74
77
  File.delete(fit_file) if File.exists?(fit_file)
75
78
  Fit4Ruby.write(fit_file, @activity)
76
79
  File.exists?(fit_file).should be_true
80
+ puts File.absolute_path(fit_file)
77
81
 
78
82
  b = Fit4Ruby.read(fit_file)
79
83
  b.should == @activity
80
- #File.delete(fit_file)
84
+ File.delete(fit_file)
81
85
  end
82
86
 
83
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fit4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schlaeger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-03 00:00:00.000000000 Z
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -92,6 +92,7 @@ files:
92
92
  - lib/fit4ruby/FitDefinition.rb
93
93
  - lib/fit4ruby/FitDefinitionField.rb
94
94
  - lib/fit4ruby/FitFile.rb
95
+ - lib/fit4ruby/FitFileEntity.rb
95
96
  - lib/fit4ruby/FitFilter.rb
96
97
  - lib/fit4ruby/FitHeader.rb
97
98
  - lib/fit4ruby/FitMessageIdMapper.rb