spektrum-log 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b27ea4e4e0b71ec0ba1395c8d05ce04af0baaad
4
- data.tar.gz: 784d8e0e1f26c9d3555e702d3a2d226d65847c1f
3
+ metadata.gz: 54c5526710a152f84a57087a9e04b6b11bbff9de
4
+ data.tar.gz: fff8907b1912b94aa3f5d6b039023133f9e596f1
5
5
  SHA512:
6
- metadata.gz: 7c3dd04459dc87fe770a8384304c68e693a9d59522d17fe3032edda33b1bc91ade4dd3f6899c71e03df82a7d06fc2b1c68b14b063e7d35740d0c5517505f21da
7
- data.tar.gz: 3a38cb895d757d3bd04ca82f64d1f5e32c02b260e07f5ecb4ba4490fd58b53b131de5dcd0b8d4325545da6d8c2cc5abe33a15fbe10a500835adca74af55ca7fe
6
+ metadata.gz: ab81bcce78e95b0de66d204efe78a1821b95227f0f7980c02d0a35c226a680a0fbc99f216560bd0dc7fd360af5d62239c73a092cc9edd98fe2a2bae8e670a362
7
+ data.tar.gz: a1d9d3fab34d2c5250ec389a200c89ec762b97c78c46d63919f651c75b1ed32130f484c9d53825cabfbcfb145d285889717910afd8655bae74409590577c47d3
@@ -11,11 +11,11 @@ module Spektrum
11
11
  #
12
12
  # @param uri URI to file to read
13
13
  # @return [Spektrum::Log::File] loaded file if the file is a Spektrum log file, nil otherwise
14
- def self.spektrum? uri
14
+ def self.spektrum?(uri)
15
15
  File.new(uri) rescue nil
16
16
  end
17
17
 
18
- def initialize uri
18
+ def initialize(uri)
19
19
  headers = []
20
20
  headers_complete = false
21
21
  records = []
@@ -128,7 +128,7 @@ module Spektrum
128
128
 
129
129
  private
130
130
 
131
- def apply_default_file_options options
131
+ def apply_default_file_options(options)
132
132
  options = { :name => 'Spektrum TLM GPS Path' }.merge(options)
133
133
  options = { :description => 'Flight paths for GPS telemetry data' }.merge(options)
134
134
  options
@@ -229,14 +229,14 @@ module Spektrum
229
229
  @records.any? { |rec| rec.is_a?(type) && rec.valid? }
230
230
  end
231
231
 
232
- def apply_default_file_options options
232
+ def apply_default_file_options(options)
233
233
  options = { :name => 'Spektrum TLM GPS Path' }.merge(options)
234
234
  options = { :description => 'Flight paths for GPS telemetry data' }.merge(options)
235
235
  options = { :style_id => 'default-poly-style' }.merge(options)
236
236
  options
237
237
  end
238
238
 
239
- def apply_default_placemark_options options
239
+ def apply_default_placemark_options(options)
240
240
  options = { :altitude_mode => 'absolute' }.merge(options)
241
241
  options = { :extrude => true }.merge(options)
242
242
  options = { :name => "#{model_name} (#{duration.round(1)}s)" }.merge(options)
@@ -9,7 +9,7 @@ module Spektrum
9
9
  # Creates a new header.
10
10
  #
11
11
  # @param [String] raw_data string of data from the data file for this header
12
- def initialize raw_data
12
+ def initialize(raw_data)
13
13
  @raw_data = raw_data
14
14
  end
15
15
 
@@ -18,7 +18,7 @@ module Spektrum
18
18
  # Helper class to create the correct type of header for the given data.
19
19
  class Headers
20
20
 
21
- def self.create raw_data
21
+ def self.create(raw_data)
22
22
  Header.new(raw_data)
23
23
  end
24
24
 
@@ -6,7 +6,7 @@ module Spektrum
6
6
 
7
7
  attr_reader :timestamp
8
8
 
9
- def initialize timestamp, raw_data
9
+ def initialize(timestamp, raw_data)
10
10
  if raw_data.length != 16
11
11
  raise ArgumentError, "raw_data incorrectly sized (#{raw_data.length})"
12
12
  end
@@ -35,23 +35,23 @@ module Spektrum
35
35
 
36
36
  protected
37
37
 
38
- def byte_field range
38
+ def byte_field(range)
39
39
  @raw_data[range].unpack('C')[0]
40
40
  end
41
41
 
42
- def hex_byte_field range
42
+ def hex_byte_field(range)
43
43
  @raw_data[range].unpack('H*')[0].to_i
44
44
  end
45
45
 
46
- def hex_string_field range
46
+ def hex_string_field(range)
47
47
  @raw_data[range].unpack('H*')[0]
48
48
  end
49
49
 
50
- def two_byte_field range, endian = :big
50
+ def two_byte_field(range, endian = :big)
51
51
  @raw_data[range].unpack(endian == :big ? 'n' : 'v')[0]
52
52
  end
53
53
 
54
- def four_byte_field range, endian = :big
54
+ def four_byte_field(range, endian = :big)
55
55
  @raw_data[range].unpack(endian == :big ? 'N' : 'V')[0]
56
56
  end
57
57
 
@@ -59,7 +59,7 @@ module Spektrum
59
59
 
60
60
  class AltimeterRecord < Record
61
61
 
62
- def initialize timestamp, raw_data
62
+ def initialize(timestamp, raw_data)
63
63
  super timestamp, raw_data
64
64
  end
65
65
 
@@ -71,11 +71,11 @@ module Spektrum
71
71
 
72
72
  class BasicDataRecord < Record
73
73
 
74
- def initialize timestamp, raw_data
74
+ def initialize(timestamp, raw_data)
75
75
  super timestamp, raw_data
76
76
  end
77
77
 
78
- def rpm pole_count
78
+ def rpm(pole_count)
79
79
  raw_rpm * pole_count
80
80
  end
81
81
 
@@ -98,7 +98,7 @@ module Spektrum
98
98
  raw_voltage != 0xFFFF
99
99
  end
100
100
 
101
- def temperature unit = :f
101
+ def temperature(unit = :f)
102
102
  @temperature ||= two_byte_field(6..7)
103
103
  case unit
104
104
  when :f
@@ -128,7 +128,7 @@ module Spektrum
128
128
 
129
129
  class FlightLogRecord < Record
130
130
 
131
- def initialize timestamp, raw_data
131
+ def initialize(timestamp, raw_data)
132
132
  super timestamp, raw_data
133
133
  end
134
134
 
@@ -157,7 +157,7 @@ module Spektrum
157
157
 
158
158
  class GForceRecord < Record
159
159
 
160
- def initialize timestamp, raw_data
160
+ def initialize(timestamp, raw_data)
161
161
  super timestamp, raw_data
162
162
  end
163
163
 
@@ -189,7 +189,7 @@ module Spektrum
189
189
 
190
190
  class GPSRecord1 < Record
191
191
 
192
- def initialize timestamp, raw_data
192
+ def initialize(timestamp, raw_data)
193
193
  super timestamp, raw_data
194
194
  end
195
195
 
@@ -198,7 +198,7 @@ module Spektrum
198
198
  # @param unit one of :feet, :meters to define desired unit
199
199
  # @return [Float] altitude in the desired unit
200
200
  # @note This conversion has been verified via Spektrum STi
201
- def altitude unit = :feet
201
+ def altitude(unit = :feet)
202
202
  @altitude ||= (hex_byte_field(3) * 100) + hex_byte_field(2)
203
203
  case unit
204
204
  when :feet
@@ -272,7 +272,7 @@ module Spektrum
272
272
  multiplier * convert_latlon([hundreds, elements].flatten)
273
273
  end
274
274
 
275
- def convert_latlon elts
275
+ def convert_latlon(elts)
276
276
  raise ArgumentError unless elts.length == 5
277
277
  elts[0] * 100 + elts[1].to_i + ("#{elts[2]}.#{elts[3]}#{elts[4]}".to_f / 60.0)
278
278
  end
@@ -281,7 +281,7 @@ module Spektrum
281
281
 
282
282
  class GPSRecord2 < Record
283
283
 
284
- def initialize timestamp, raw_data
284
+ def initialize(timestamp, raw_data)
285
285
  super timestamp, raw_data
286
286
  end
287
287
 
@@ -290,7 +290,7 @@ module Spektrum
290
290
  # @param unit one of :knots, :mph, :kph to define desired unit
291
291
  # @return [Float] speed in the desired unit
292
292
  # @note This conversion has been verified via Spektrum STi
293
- def speed unit = :knots
293
+ def speed(unit = :knots)
294
294
  @speed ||= (hex_byte_field(3) * 100) + hex_byte_field(2)
295
295
  case unit
296
296
  when :knots
@@ -310,7 +310,7 @@ module Spektrum
310
310
  # @note This conversion has been verified via Spektrum STi
311
311
  def time
312
312
  elements = 7.downto(4).map { |i| hex_byte_field(i) }
313
- @time ||= "%.2i:%.2i:%.2i.%.2i" % elements
313
+ @time ||= '%.2i:%.2i:%.2i.%.2i' % elements
314
314
  end
315
315
 
316
316
  # Gets the number of satellites current visible and in-use.
@@ -325,7 +325,7 @@ module Spektrum
325
325
 
326
326
  class SpeedRecord < Record
327
327
 
328
- def initialize timestamp, raw_data
328
+ def initialize(timestamp, raw_data)
329
329
  super timestamp, raw_data
330
330
  end
331
331
 
@@ -351,7 +351,7 @@ module Spektrum
351
351
 
352
352
  class MysteryRecord < Record
353
353
 
354
- def initialize timestamp, raw_data
354
+ def initialize(timestamp, raw_data)
355
355
  super timestamp, raw_data
356
356
  end
357
357
 
@@ -371,7 +371,7 @@ module Spektrum
371
371
  0xFF => FlightLogRecord,
372
372
  }
373
373
 
374
- def self.create type, timestamp, raw_data
374
+ def self.create(type, timestamp, raw_data)
375
375
  @@types.fetch(type, MysteryRecord).new(timestamp, raw_data)
376
376
  end
377
377
 
@@ -1,5 +1,5 @@
1
1
  module Spektrum
2
2
  module Log
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
data/spektrum-log.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["nick@codelever.com"]
11
11
  spec.description = %q{Read and interpret Spektrum TLM log files.}
12
12
  spec.summary = %q{Spektrum TLM log file reader}
13
- spec.homepage = ""
13
+ spec.homepage = "http://github.com/code-lever/spektrum-log"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spektrum-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-15 00:00:00.000000000 Z
11
+ date: 2013-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -190,7 +190,7 @@ files:
190
190
  - spec/spec_helper.rb
191
191
  - spec/speed_record_spec.rb
192
192
  - spektrum-log.gemspec
193
- homepage: ''
193
+ homepage: http://github.com/code-lever/spektrum-log
194
194
  licenses:
195
195
  - MIT
196
196
  metadata: {}
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.0.3
213
+ rubygems_version: 2.0.6
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Spektrum TLM log file reader