spektrum-log 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ module Spektrum
22
22
  #
23
23
  # @return [Float] duration of the flight, in seconds
24
24
  def duration
25
- @duration ||= ((@records.empty? ? 0.0 : @records.last.timestamp - @records.first.timestamp) / 256.0)
25
+ @duration ||= ((@records.empty? ? 0.0 : @records.last.timestamp - @records.first.timestamp) / 1000.0)
26
26
  end
27
27
 
28
28
  # Determines if this flight has any data. Models without telemetry
@@ -159,11 +159,7 @@ module Spektrum
159
159
  end
160
160
 
161
161
  def latitude_elements
162
- a = hex_byte_field(6) # degrees
163
- b = hex_byte_field(5) # degree-minutes
164
- c = hex_byte_field(4) # degree-minutes / 10
165
- d = hex_byte_field(3) # degree-minutes / 1000
166
- [a, b, c, d]
162
+ 6.downto(3).map { |i| hex_byte_field(i) }
167
163
  end
168
164
 
169
165
  def latitude
@@ -171,11 +167,7 @@ module Spektrum
171
167
  end
172
168
 
173
169
  def longitude_elements
174
- a = hex_byte_field(10) # degrees
175
- b = hex_byte_field(9) # degree-minutes
176
- c = hex_byte_field(8) # degree-minutes / 10
177
- d = hex_byte_field(7) # degree-minutes / 1000
178
- [a, b, c, d]
170
+ 10.downto(7).map { |i| hex_byte_field(i) }
179
171
  end
180
172
 
181
173
  def longitude
@@ -220,16 +212,12 @@ module Spektrum
220
212
  end
221
213
 
222
214
  def time
223
- ax = hex_byte_field(3) # hundredths
224
- bx = hex_byte_field(4) # seconds
225
- cx = hex_byte_field(5) # minutes
226
- dx = hex_byte_field(6) # hours
227
-
228
- [dx, cx, bx + (ax / 100.0)] # hh:mm:ss.sss
215
+ t = 3.upto(6).map { |i| hex_byte_field(i).to_s.rjust(2, '0') }
216
+ @time ||= "#{t[3]}:#{t[2]}:#{t[1]}.#{t[0]}"
229
217
  end
230
218
 
231
- def sats
232
- @sats ||= byte_field(7)
219
+ def satellites
220
+ @satellites ||= hex_byte_field(7)
233
221
  end
234
222
 
235
223
  end
@@ -1,5 +1,5 @@
1
1
  module Spektrum
2
2
  module Log
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
data/spec/flight_spec.rb CHANGED
@@ -14,7 +14,7 @@ describe Spektrum::Log::Flight do
14
14
 
15
15
  it { should have(191).records }
16
16
 
17
- its(:duration) { should be_within(0.1).of(4.5) }
17
+ its(:duration) { should be_within(0.1).of(1.1) }
18
18
 
19
19
  its(:bind_type) { should eql('DSMX') }
20
20
 
@@ -38,7 +38,7 @@ describe Spektrum::Log::Flight do
38
38
 
39
39
  it { should have(634).records }
40
40
 
41
- its(:duration) { should be_within(0.1).of(14.8) }
41
+ its(:duration) { should be_within(0.1).of(3.8) }
42
42
 
43
43
  its(:gps1_records?) { should be_true }
44
44
 
@@ -54,7 +54,7 @@ describe Spektrum::Log::Flight do
54
54
 
55
55
  it { should have(641).records }
56
56
 
57
- its(:duration) { should be_within(0.1).of(15.0) }
57
+ its(:duration) { should be_within(0.1).of(3.8) }
58
58
 
59
59
  its(:gps1_records?) { should be_true }
60
60
 
@@ -78,7 +78,7 @@ describe Spektrum::Log::Flight do
78
78
 
79
79
  it { should_not be_empty }
80
80
 
81
- its(:duration) { should be_within(0.1).of(2.2) }
81
+ its(:duration) { should be_within(0.1).of(0.6) }
82
82
 
83
83
  its(:bind_type) { should eql('DSMX') }
84
84
 
@@ -216,7 +216,7 @@ describe Spektrum::Log::Flight do
216
216
 
217
217
  it { should have(23155).records }
218
218
 
219
- its(:duration) { should be_within(0.1).of(579.5) }
219
+ its(:duration) { should be_within(1).of(148) }
220
220
 
221
221
  it { should_not be_empty }
222
222
 
@@ -238,7 +238,7 @@ describe Spektrum::Log::Flight do
238
238
 
239
239
  it { should_not be_empty }
240
240
 
241
- its(:duration) { should be_within(0.1).of(63.7) }
241
+ its(:duration) { should be_within(0.1).of(16.3) }
242
242
 
243
243
  its(:bind_type) { should eql('DSMX') }
244
244
 
@@ -274,6 +274,8 @@ describe Spektrum::Log::Flight do
274
274
 
275
275
  subject { reader.flights[0] }
276
276
 
277
+ its(:duration) { should be_within(1).of(179) }
278
+
277
279
  its(:gps1_records?) { should be_true }
278
280
 
279
281
  its(:gps2_records?) { should be_true }
@@ -286,6 +288,8 @@ describe Spektrum::Log::Flight do
286
288
 
287
289
  subject { reader.flights[1] }
288
290
 
291
+ its(:duration) { should be_within(1).of(188) }
292
+
289
293
  its(:gps1_records?) { should be_true }
290
294
 
291
295
  its(:gps2_records?) { should be_true }
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spektrum::Log::GPSRecord2 do
4
+
5
+ let(:timestamp) { 0x0002C8D5 }
6
+
7
+ let(:raw_data) { ["00500000184412110018099909073B"].pack('H*') }
8
+
9
+ subject { Spektrum::Log::GPSRecord2.new(timestamp, raw_data) }
10
+
11
+ its(:timestamp) { should eql(0x0002C8D5) }
12
+
13
+ its(:satellites) { should eql(11) }
14
+
15
+ its(:time) { should eq('12:44:18.00') }
16
+
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spektrum-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-18 00:00:00.000000000 Z
12
+ date: 2013-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: awesome_print
@@ -184,6 +184,7 @@ files:
184
184
  - spec/flight_log_record_spec.rb
185
185
  - spec/flight_spec.rb
186
186
  - spec/gps_record1_spec.rb
187
+ - spec/gps_record2_spec.rb
187
188
  - spec/reader_spec.rb
188
189
  - spec/spec_helper.rb
189
190
  - spektrum-log.gemspec
@@ -217,5 +218,6 @@ test_files:
217
218
  - spec/flight_log_record_spec.rb
218
219
  - spec/flight_spec.rb
219
220
  - spec/gps_record1_spec.rb
221
+ - spec/gps_record2_spec.rb
220
222
  - spec/reader_spec.rb
221
223
  - spec/spec_helper.rb