fit4ruby 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fit4ruby/Activity.rb +14 -0
- data/lib/fit4ruby/FitFileEntity.rb +4 -0
- data/lib/fit4ruby/FitMessageRecord.rb +1 -1
- data/lib/fit4ruby/GlobalFitDictionaries.rb +42 -0
- data/lib/fit4ruby/GlobalFitMessage.rb +6 -0
- data/lib/fit4ruby/GlobalFitMessages.rb +88 -11
- data/lib/fit4ruby/Lap.rb +1 -1
- data/lib/fit4ruby/Monitoring.rb +27 -0
- data/lib/fit4ruby/MonitoringInfo.rb +27 -0
- data/lib/fit4ruby/Monitoring_B.rb +78 -0
- data/lib/fit4ruby/Record.rb +4 -0
- data/lib/fit4ruby/Software.rb +27 -0
- data/lib/fit4ruby/version.rb +1 -1
- data/spec/FitFile_spec.rb +6 -6
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cf519ee70f6b6337d1954ae6073ffa16e268953
|
4
|
+
data.tar.gz: e823bcb9ea3857f7900e4e3e08a4bb97a057145a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a92c584b15630e0cdd8c0d18ceed90214f84413df8246776c15a69f3ed685768015e2f9be70f9dd62cda5f12fb459022203fe8d55f3d34d117f07914e4530272
|
7
|
+
data.tar.gz: 3b11fec1a502086756ff02a3d206aa64350ce0be86245bc71bbaf816d402c20b0dd0917635996368331de0ddda211786042b93e6ead52e762a1005727ddd39f7
|
data/lib/fit4ruby/Activity.rb
CHANGED
@@ -95,6 +95,20 @@ module Fit4Ruby
|
|
95
95
|
speed / @sessions.length
|
96
96
|
end
|
97
97
|
|
98
|
+
# Return the heart rate when the activity recording was last stopped.
|
99
|
+
def ending_hr
|
100
|
+
@records.empty? ? nil : @records[-1].heart_rate
|
101
|
+
end
|
102
|
+
|
103
|
+
# Return the measured recovery heart rate.
|
104
|
+
def recovery_hr
|
105
|
+
@events.each do |e|
|
106
|
+
return e.recovery_hr if e.event == 'recovery_hr'
|
107
|
+
end
|
108
|
+
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
|
98
112
|
# Returns the predicted recovery time needed after this activity.
|
99
113
|
# @return recovery time in seconds.
|
100
114
|
def recovery_time
|
@@ -11,6 +11,7 @@
|
|
11
11
|
#
|
12
12
|
|
13
13
|
require 'fit4ruby/Activity'
|
14
|
+
require 'fit4ruby/Monitoring_B'
|
14
15
|
|
15
16
|
module Fit4Ruby
|
16
17
|
|
@@ -43,6 +44,9 @@ module Fit4Ruby
|
|
43
44
|
when 4, 'activity'
|
44
45
|
@top_level_record = Activity.new
|
45
46
|
@type = 'activity'
|
47
|
+
when 32, 'monitoring_b'
|
48
|
+
@top_level_record = Monitoring_B.new
|
49
|
+
@type = 'monitoring_b'
|
46
50
|
else
|
47
51
|
Log.error "Unsupported FIT file type #{type}"
|
48
52
|
return nil
|
@@ -72,7 +72,7 @@ module Fit4Ruby
|
|
72
72
|
end
|
73
73
|
|
74
74
|
field_name, field_def = get_field_name_and_global_def(field, obj)
|
75
|
-
obj.set(field_name, field.to_machine(value)) if obj
|
75
|
+
obj.set(field_name, v = (field_def || field).to_machine(value)) if obj
|
76
76
|
|
77
77
|
if filter && fields_dump &&
|
78
78
|
(filter.field_names.nil? ||
|
@@ -26,6 +26,33 @@ module Fit4Ruby
|
|
26
26
|
entry 6, 'walking'
|
27
27
|
entry 254, 'all'
|
28
28
|
|
29
|
+
dict 'activity_level'
|
30
|
+
entry 0, 'low'
|
31
|
+
entry 1, 'medium'
|
32
|
+
entry 2, 'high'
|
33
|
+
|
34
|
+
dict 'activity_subtype'
|
35
|
+
entry 0, 'generic'
|
36
|
+
entry 1, 'treadmill'
|
37
|
+
entry 2, 'street'
|
38
|
+
entry 3, 'trail'
|
39
|
+
entry 4, 'track'
|
40
|
+
entry 5, 'spin'
|
41
|
+
entry 6, 'indoor_cycling'
|
42
|
+
entry 7, 'road'
|
43
|
+
entry 8, 'mountain'
|
44
|
+
entry 9, 'downhill'
|
45
|
+
entry 10, 'recumbent'
|
46
|
+
entry 11, 'cyclocross'
|
47
|
+
entry 12, 'hand_cycling'
|
48
|
+
entry 13, 'track_cycling'
|
49
|
+
entry 14, 'indoor_rowing'
|
50
|
+
entry 15, 'elliptical'
|
51
|
+
entry 16, 'stair_climbing'
|
52
|
+
entry 17, 'lap_swimming'
|
53
|
+
entry 18, 'open_water'
|
54
|
+
entry 254, 'all'
|
55
|
+
|
29
56
|
dict 'ant_network'
|
30
57
|
entry 0, 'public'
|
31
58
|
entry 1, 'antplus'
|
@@ -141,6 +168,16 @@ module Fit4Ruby
|
|
141
168
|
entry 1930, 'fr220_japan'
|
142
169
|
entry 1931, 'fr220_china'
|
143
170
|
entry 1967, 'fenix2'
|
171
|
+
entry 1988, 'epix'
|
172
|
+
entry 2050, 'fenix3'
|
173
|
+
entry 2072, 'fr620_russia'
|
174
|
+
entry 2073, 'fr220_russia'
|
175
|
+
entry 2130, 'fr920xt_taiwan'
|
176
|
+
entry 2131, 'fr920xt_china'
|
177
|
+
entry 2132, 'fr920xt_japan'
|
178
|
+
entry 2173, 'fr620_taiwan'
|
179
|
+
entry 2188, 'fenix3_china'
|
180
|
+
entry 2189, 'fenix3_twn'
|
144
181
|
entry 10007, 'sdm4'
|
145
182
|
entry 20119, 'training_center'
|
146
183
|
entry 65532, 'android_antplus_plugin'
|
@@ -258,6 +295,11 @@ module Fit4Ruby
|
|
258
295
|
entry 255, 'development'
|
259
296
|
entry 5759, 'actigraphcorp'
|
260
297
|
|
298
|
+
dict 'message_index'
|
299
|
+
entry 0x0FFF, 'mask'
|
300
|
+
entry 0x7000, 'reserved'
|
301
|
+
entry 0x8000, 'selected'
|
302
|
+
|
261
303
|
dict 'session_trigger'
|
262
304
|
entry 0, 'activity_end'
|
263
305
|
entry 1, 'manual'
|
@@ -75,6 +75,12 @@ module Fit4Ruby
|
|
75
75
|
value = fit_time_to_time(value).strftime("%Y-%m-%d %H:%M:%S")
|
76
76
|
when 'duration'
|
77
77
|
value = secsToDHMS(value)
|
78
|
+
when 'activity_intensity'
|
79
|
+
# Activity monitoring data contains a byte value that consists of 5
|
80
|
+
# bit for the activity type and 3 bit for the intensity. Activty 0x8
|
81
|
+
# is resting. Instead if value + unit we return activity type +
|
82
|
+
# intensity here.
|
83
|
+
return [ value & 0x1F, (value >> 5) & 0x7 ]
|
78
84
|
end
|
79
85
|
[ value, @opts[:unit] ]
|
80
86
|
end
|
@@ -25,6 +25,7 @@ module Fit4Ruby
|
|
25
25
|
field 3, 'uint32z', 'serial_number'
|
26
26
|
field 4, 'uint32', 'time_created', :type => 'date_time'
|
27
27
|
field 5, 'uint16', 'number'
|
28
|
+
field 6, 'uint16', 'undocumented_field_6'
|
28
29
|
|
29
30
|
message 12, 'sport'
|
30
31
|
field 0, 'enum', 'sport', :dict => 'sport'
|
@@ -34,6 +35,7 @@ module Fit4Ruby
|
|
34
35
|
field 5, 'enum', 'undocumented_field_5'
|
35
36
|
field 6, 'enum', 'undocumented_field_6'
|
36
37
|
field 10, 'uint8', 'undocumented_field_10', :array => true
|
38
|
+
field 11, 'enum', 'undocumented_field_11'
|
37
39
|
|
38
40
|
message 18, 'session'
|
39
41
|
field 0, 'enum', 'event', :dict => 'event'
|
@@ -116,6 +118,18 @@ module Fit4Ruby
|
|
116
118
|
field 108, 'uint16', 'undefined_value_108'
|
117
119
|
field 109, 'uint8', 'undefined_value_109'
|
118
120
|
field 110, 'string', 'undefined_value_110'
|
121
|
+
field 112, 'uint32', 'time_standing', :scale => 1000, :unit => 's'
|
122
|
+
field 113, 'uint16', 'stand_count'
|
123
|
+
field 114, 'sint8', 'avg_left_pco', :unit => 'mm'
|
124
|
+
field 115, 'sint8', 'avg_right_pco', :unit => 'mm'
|
125
|
+
field 116, 'uint8', 'avg_left_power_phase', :array => true, :unit => 'degrees'
|
126
|
+
field 117, 'uint8', 'avg_left_power_phase_peak', :array => true, :unit => 'degrees'
|
127
|
+
field 118, 'uint8', 'avg_right_power_phase', :array => true, :unit => 'degrees'
|
128
|
+
field 119, 'uint8', 'avg_right_power_phase_peak', :array => true, :unit => 'degrees'
|
129
|
+
field 120, 'uint16', 'avg_power_position', :array => true, :unit => 'watts'
|
130
|
+
field 121, 'uint16', 'max_power_position', :array => true, :unit => 'watts'
|
131
|
+
field 122, 'uint8', 'avg_cadence_position', :array => true, :unit => 'rpm'
|
132
|
+
field 123, 'uint8', 'max_cadence_position', :array => true, :unit => 'rpm'
|
119
133
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
120
134
|
field 254, 'uint16', 'message_index'
|
121
135
|
|
@@ -189,6 +203,18 @@ module Fit4Ruby
|
|
189
203
|
field 95, 'uint8', 'avg_combined_pedal_smoothness', :scale => 2, :unit => 'percent'
|
190
204
|
field 96, 'uint16', 'undefined_value_96'
|
191
205
|
field 97, 'uint16', 'undefined_value_97'
|
206
|
+
field 98, 'uint32', 'time_standing', :scale => 1000, :unit => 's'
|
207
|
+
field 99, 'uint16', 'stand_count'
|
208
|
+
field 100, 'sint8', 'avg_left_pco', :unit => 'mm'
|
209
|
+
field 101, 'sint8', 'avg_right_pco', :unit => 'mm'
|
210
|
+
field 102, 'uint8', 'avg_left_power_phase', :array => true, :unit => 'degrees'
|
211
|
+
field 103, 'uint8', 'avg_left_power_phase_peak', :array => true, :unit => 'degrees'
|
212
|
+
field 104, 'uint8', 'avg_right_power_phase', :array => true, :unit => 'degrees'
|
213
|
+
field 105, 'uint8', 'avg_right_power_phase_peak', :array => true, :unit => 'degrees'
|
214
|
+
field 106, 'uint16', 'avg_power_position', :array => true, :unit => 'watts'
|
215
|
+
field 107, 'uint16', 'max_power_position', :array => true, :unit => 'watts'
|
216
|
+
field 108, 'uint8', 'avg_cadence_position', :array => true, :unit => 'rpm'
|
217
|
+
field 109, 'uint8', 'max_cadence_position', :array => true, :unit => 'rpm'
|
192
218
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
193
219
|
field 254, 'uint16', 'message_index'
|
194
220
|
|
@@ -200,6 +226,8 @@ module Fit4Ruby
|
|
200
226
|
field 4, 'uint8', 'cadence', :unit => 'rpm'
|
201
227
|
field 5, 'uint32', 'distance', :scale => 100, :unit => 'm'
|
202
228
|
field 6, 'uint16', 'speed', :scale => 1000, :unit => 'm/s'
|
229
|
+
field 7, 'uint16', 'power', :unit => 'watts'
|
230
|
+
field 13, 'sint8', 'temperature', :unit => 'C'
|
203
231
|
field 39, 'uint16', 'vertical_oscillation', :scale => 10, :unit => 'mm'
|
204
232
|
field 40, 'uint16', 'stance_time_percent', :scale => 100, :unit => 'percent'
|
205
233
|
field 41, 'uint16', 'stance_time', :scale => 10, :unit => 'ms'
|
@@ -225,15 +253,14 @@ module Fit4Ruby
|
|
225
253
|
field 4, 'uint8', 'event_group'
|
226
254
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
227
255
|
|
228
|
-
# Possibly the
|
229
|
-
|
230
|
-
|
231
|
-
field
|
232
|
-
field
|
233
|
-
field
|
234
|
-
field
|
235
|
-
field
|
236
|
-
field 5, 'enum', 'lock_status'
|
256
|
+
# Possibly the status of the sensors; Not documented in FIT SDK
|
257
|
+
message 22, 'sensor_status'
|
258
|
+
field 0, 'uint8', 'undocumented_field_0' # 1 - 5 or no value seen
|
259
|
+
field 1, 'uint8', 'undocumented_field_1' # Always identical to field 0
|
260
|
+
field 2, 'uint8', 'undocumented_field_2' # 1 - 5 or no value seen
|
261
|
+
field 3, 'uint8', 'undocumented_field_3' # 1, 3, 5 or no value seen
|
262
|
+
field 4, 'uint8', 'undocumented_field_4' # 1 - 3 or no value seen
|
263
|
+
field 5, 'enum', 'undocumented_field_5' # 0 or 3 seen
|
237
264
|
field 6, 'uint8', 'undocumented_field_6' # First found in FR920XT
|
238
265
|
field 14, 'uint8', 'undocumented_field_14' # First found in FR920XT
|
239
266
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
@@ -245,7 +272,7 @@ module Fit4Ruby
|
|
245
272
|
field 3, 'uint32z', 'serial_number'
|
246
273
|
alt_field 4, 'manufacturer' do
|
247
274
|
field :default, 'uint16', 'product'
|
248
|
-
field 'garmin', 'uint16', 'garmin_product', :dict => 'garmin_product'
|
275
|
+
field [ 'garmin', 'dynastream', 'dynastream_oem' ], 'uint16', 'garmin_product', :dict => 'garmin_product'
|
249
276
|
end
|
250
277
|
field 5, 'uint16', 'software_version', :scale => 100
|
251
278
|
field 6, 'uint8', 'hardware_version'
|
@@ -263,6 +290,18 @@ module Fit4Ruby
|
|
263
290
|
field 25, 'enum', 'source_type', :dict => 'source_type'
|
264
291
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
265
292
|
|
293
|
+
# Message 29 is just a guess. It's not officially documented.
|
294
|
+
# Found in LCTNS.FIT on Fenix 3
|
295
|
+
message 29, 'location'
|
296
|
+
field 0, 'string', 'name'
|
297
|
+
field 1, 'sint32', 'position_lat', :type => 'coordinate'
|
298
|
+
field 2, 'sint32', 'position_long', :type => 'coordinate'
|
299
|
+
field 3, 'uint16', 'undocumented_field_3'
|
300
|
+
field 4, 'uint16', 'altitude', :scale => 5, :offset => 500, :unit => 'm'
|
301
|
+
field 5, 'uint16', 'undocumented_field_5'
|
302
|
+
field 253, 'uint32', 'undocumented_field_253'
|
303
|
+
field 254, 'uint16', 'location_index'
|
304
|
+
|
266
305
|
message 33, 'totals'
|
267
306
|
field 0, 'uint32', 'timer_time', :unit => 's'
|
268
307
|
field 1, 'uint32', 'distance', :unit => 'm'
|
@@ -284,9 +323,37 @@ module Fit4Ruby
|
|
284
323
|
field 6, 'uint8', 'event_group'
|
285
324
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
286
325
|
|
326
|
+
message 35, 'software'
|
327
|
+
field 3, 'uint16', 'version', :scale => 100
|
328
|
+
field 5, 'string', 'part_number'
|
329
|
+
|
287
330
|
message 49, 'file_creator'
|
288
331
|
field 0, 'uint16', 'software_version'
|
289
332
|
field 1, 'uint8', 'hardware_version'
|
333
|
+
field 254, 'uint16', 'message_index', :dict => 'message_index'
|
334
|
+
|
335
|
+
message 55, 'monitoring'
|
336
|
+
field 0, 'enum', 'device_index'
|
337
|
+
field 1, 'uint16', 'calories', :unit => 'kcal'
|
338
|
+
field 2, 'uint32', 'distance', :scale => 100, :unit => 'm'
|
339
|
+
field 5, 'enum', 'activity_type'
|
340
|
+
alt_field 3, 'activity_type' do
|
341
|
+
field :default, 'uint32', 'cycles', :scale => 2, :unit => 'cycles'
|
342
|
+
field [ 'walking', 'running' ], 'uint32', 'steps', :unit => 'steps'
|
343
|
+
field [ 'cycling', 'swimming' ], 'uint32', 'strokes', :scale => 2, :unit => 'strokes'
|
344
|
+
end
|
345
|
+
field 4, 'uint32', 'active_time', :scale => 1000, :unit => 's'
|
346
|
+
field 6, 'enum', 'activity_sub_type'
|
347
|
+
field 7, 'enum', 'activity_level'
|
348
|
+
field 8, 'uint16', 'distance_16', :scale => 0.1, :unit => 'km'
|
349
|
+
field 9, 'uint16', 'cycles_16', :scale => 0.5, :unit => 'cycles'
|
350
|
+
field 10, 'uint16', 'active_time_16', :unit => 's'
|
351
|
+
field 11, 'uint16', 'local_timestamp'
|
352
|
+
field 19, 'uint16', 'active_calories', :unit => 'kcal'
|
353
|
+
field 24, 'byte', 'current_activity_type_intensity', :type => 'activity_intensity'
|
354
|
+
field 26, 'uint16', 'timestamp16', :unit => 's'
|
355
|
+
field 29, 'uint16', 'duration_min', :unit => 'min'
|
356
|
+
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
290
357
|
|
291
358
|
message 72, 'training_file'
|
292
359
|
field 0, 'enum', 'type'
|
@@ -316,10 +383,20 @@ module Fit4Ruby
|
|
316
383
|
field 9, 'uint16', 'undocumented_field_9' # maybe activity measurement
|
317
384
|
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
318
385
|
|
386
|
+
message 103, 'monitoring_info'
|
387
|
+
field 0, 'uint32', 'local_time', :type => 'date_time'
|
388
|
+
field 1, 'enum', 'activity_type', :array => true, :dict => 'activity_type'
|
389
|
+
field 3, 'uint16', 'cycles_to_distance', :array => true, :scale => 5000, :unit => 'm/cycle'
|
390
|
+
field 4, 'uint16', 'cycle_to_calories', :array => true, :scale => 5000, :unit => 'kcal/cycle'
|
391
|
+
field 5, 'uint16', 'resting_metabolic_rate', :unit => 'kcal/day'
|
392
|
+
# Just a guess, not officially documented
|
393
|
+
field 7, 'uint32', 'goal_cycles', :array => true
|
394
|
+
field 253, 'uint32', 'timestamp', :type => 'date_time'
|
395
|
+
|
319
396
|
# Not part of the official ANT SDK doc
|
320
397
|
message 113, 'personal_records'
|
321
398
|
field 0, 'uint16', 'longest_distance'
|
322
|
-
field 1, 'enum', '
|
399
|
+
field 1, 'enum', 'sport', :dict => 'sport'
|
323
400
|
field 2, 'uint32', 'distance', :scale => 100, :unit => 'm'
|
324
401
|
# If longest_distance is 1, field 3 is the distance, not a duration!
|
325
402
|
field 3, 'uint32', 'duration', :scale => 1000, :type => 'duration'
|
data/lib/fit4ruby/Lap.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# = Monitoring.rb -- Fit4Ruby - FIT file processing library for Ruby
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015 by Chris Schlaeger <cs@taskjuggler.org>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of version 2 of the GNU General Public License as
|
10
|
+
# published by the Free Software Foundation.
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'fit4ruby/FitDataRecord'
|
14
|
+
|
15
|
+
module Fit4Ruby
|
16
|
+
|
17
|
+
class Monitoring < FitDataRecord
|
18
|
+
|
19
|
+
def initialize(field_values = {})
|
20
|
+
super('monitoring')
|
21
|
+
set_field_values(field_values)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# = MonitoringInfo.rb -- Fit4Ruby - FIT file processing library for Ruby
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015 by Chris Schlaeger <cs@taskjuggler.org>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of version 2 of the GNU General Public License as
|
10
|
+
# published by the Free Software Foundation.
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'fit4ruby/FitDataRecord'
|
14
|
+
|
15
|
+
module Fit4Ruby
|
16
|
+
|
17
|
+
class MonitoringInfo < FitDataRecord
|
18
|
+
|
19
|
+
def initialize(field_values = {})
|
20
|
+
super('monitoring_info')
|
21
|
+
set_field_values(field_values)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# = Monitoring_B.rb -- Fit4Ruby - FIT file processing library for Ruby
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015 by Chris Schlaeger <cs@taskjuggler.org>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of version 2 of the GNU General Public License as
|
10
|
+
# published by the Free Software Foundation.
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'fit4ruby/FitDataRecord'
|
14
|
+
require 'fit4ruby/FileId'
|
15
|
+
require 'fit4ruby/DeviceInfo'
|
16
|
+
require 'fit4ruby/Software'
|
17
|
+
require 'fit4ruby/MonitoringInfo'
|
18
|
+
require 'fit4ruby/Monitoring'
|
19
|
+
|
20
|
+
module Fit4Ruby
|
21
|
+
|
22
|
+
# The Monitoring_B object is a FIT file class. It's a top-level object that
|
23
|
+
# holds all references to other FIT records that are part of the FIT file.
|
24
|
+
# Each of the objects it references are direct equivalents of the message
|
25
|
+
# record structures used in the FIT file.
|
26
|
+
class Monitoring_B < FitDataRecord
|
27
|
+
|
28
|
+
attr_accessor :file_id, :device_infos, :software, :monitoring_infos,
|
29
|
+
:monitorings
|
30
|
+
|
31
|
+
# Create a new Monitoring_B object.
|
32
|
+
# @param field_values [Hash] A Hash that provides initial values for
|
33
|
+
# certain fields of the FitDataRecord.
|
34
|
+
def initialize(field_values = {})
|
35
|
+
super('activity')
|
36
|
+
@num_sessions = 0
|
37
|
+
|
38
|
+
@file_id = FileId.new
|
39
|
+
@device_infos = []
|
40
|
+
@softwares = nil
|
41
|
+
@monitoring_infos = []
|
42
|
+
@monitorings = []
|
43
|
+
end
|
44
|
+
|
45
|
+
# Perform some basic logical checks on the object and all references sub
|
46
|
+
# objects. Any errors will be reported via the Log object.
|
47
|
+
def check
|
48
|
+
end
|
49
|
+
|
50
|
+
# Create a new FitDataRecord.
|
51
|
+
# @param record_type [String] Type that identifies the FitDataRecord
|
52
|
+
# derived class to create.
|
53
|
+
# @param field_values [Hash] A Hash that provides initial values for
|
54
|
+
# certain fields of the FitDataRecord.
|
55
|
+
# @return FitDataRecord
|
56
|
+
def new_fit_data_record(record_type, field_values = {})
|
57
|
+
case record_type
|
58
|
+
when 'file_id'
|
59
|
+
@file_id = (record = FileId.new(field_values))
|
60
|
+
when 'software'
|
61
|
+
@software = (record = Software.new(field_values))
|
62
|
+
when 'device_info'
|
63
|
+
@device_infos << (record = DeviceInfo.new(field_values))
|
64
|
+
when 'monitoring_info'
|
65
|
+
@monitoring_infos << (record = MonitoringInfo.new(field_values))
|
66
|
+
when 'monitoring'
|
67
|
+
@monitorings << (record = Monitoring.new(field_values))
|
68
|
+
else
|
69
|
+
record = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
record
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
data/lib/fit4ruby/Record.rb
CHANGED
@@ -40,7 +40,11 @@ module Fit4Ruby
|
|
40
40
|
|
41
41
|
# Convert the 'speed' field into a running pace. The pace is measured in
|
42
42
|
# minutes per Kilometer.
|
43
|
+
# @return [Float or nil] pace for this Record in m/s or nil if not
|
44
|
+
# available.
|
43
45
|
def pace
|
46
|
+
return nil unless @speed
|
47
|
+
|
44
48
|
1000.0 / (@speed * 60.0)
|
45
49
|
end
|
46
50
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# = Software.rb -- Fit4Ruby - FIT file processing library for Ruby
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015 by Chris Schlaeger <cs@taskjuggler.org>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of version 2 of the GNU General Public License as
|
10
|
+
# published by the Free Software Foundation.
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'fit4ruby/FitDataRecord'
|
14
|
+
|
15
|
+
module Fit4Ruby
|
16
|
+
|
17
|
+
class Software < FitDataRecord
|
18
|
+
|
19
|
+
def initialize(field_values = {})
|
20
|
+
super('software')
|
21
|
+
set_field_values(field_values)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
data/lib/fit4ruby/version.rb
CHANGED
data/spec/FitFile_spec.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# = FitFile_spec.rb -- Fit4Ruby - FIT file processing library for Ruby
|
5
5
|
#
|
6
|
-
# Copyright (c) 2014 by Chris Schlaeger <cs@taskjuggler.org>
|
6
|
+
# Copyright (c) 2014, 2015 by Chris Schlaeger <cs@taskjuggler.org>
|
7
7
|
#
|
8
8
|
# This program is free software; you can redistribute it and/or modify
|
9
9
|
# it under the terms of version 2 of the GNU General Public License as
|
@@ -22,8 +22,8 @@ describe Fit4Ruby do
|
|
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, :manufacturer => '
|
26
|
-
a.new_device_info({ :device_index => 1, :manufacturer => '
|
25
|
+
a.new_device_info({ :device_index => 0, :manufacturer => 'development' })
|
26
|
+
a.new_device_info({ :device_index => 1, :manufacturer => 'development',
|
27
27
|
:battery_status => 'ok' })
|
28
28
|
ts = Time.now
|
29
29
|
0.upto(a.total_timer_time / 60) do |mins|
|
@@ -58,9 +58,9 @@ describe Fit4Ruby do
|
|
58
58
|
a.new_event({ :timestamp => ts, :event => 'timer',
|
59
59
|
:event_type => 'stop_all' })
|
60
60
|
a.new_device_info({ :timestamp => ts, :device_index => 0,
|
61
|
-
:manufacturer => '
|
61
|
+
:manufacturer => 'development' })
|
62
62
|
ts += 1
|
63
|
-
a.new_device_info({ :timestamp => ts, :manufacturer => '
|
63
|
+
a.new_device_info({ :timestamp => ts, :manufacturer => 'development',
|
64
64
|
:device_index => 1, :battery_status => 'low' })
|
65
65
|
ts += 120
|
66
66
|
a.new_event({ :timestamp => ts, :event => 'recovery_hr',
|
@@ -71,7 +71,7 @@ describe Fit4Ruby do
|
|
71
71
|
@activity = a
|
72
72
|
end
|
73
73
|
|
74
|
-
it 'should write
|
74
|
+
it 'should write an Activity FIT file and read it back' do
|
75
75
|
fit_file = 'test.fit'
|
76
76
|
|
77
77
|
File.delete(fit_file) if File.exists?(fit_file)
|
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
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schlaeger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -105,10 +105,14 @@ files:
|
|
105
105
|
- lib/fit4ruby/GlobalFitMessages.rb
|
106
106
|
- lib/fit4ruby/Lap.rb
|
107
107
|
- lib/fit4ruby/Log.rb
|
108
|
+
- lib/fit4ruby/Monitoring.rb
|
109
|
+
- lib/fit4ruby/MonitoringInfo.rb
|
110
|
+
- lib/fit4ruby/Monitoring_B.rb
|
108
111
|
- lib/fit4ruby/PersonalRecords.rb
|
109
112
|
- lib/fit4ruby/Record.rb
|
110
113
|
- lib/fit4ruby/RecordAggregator.rb
|
111
114
|
- lib/fit4ruby/Session.rb
|
115
|
+
- lib/fit4ruby/Software.rb
|
112
116
|
- lib/fit4ruby/UserProfile.rb
|
113
117
|
- lib/fit4ruby/version.rb
|
114
118
|
- spec/FitFile_spec.rb
|