spektrum-log 0.0.1
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 +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/data/1.TLM +0 -0
- data/data/2.TLM +0 -0
- data/data/3.TLM +0 -0
- data/data/4.TLM +0 -0
- data/lib/spektrum-log.rb +5 -0
- data/lib/spektrum-log/flight.rb +54 -0
- data/lib/spektrum-log/headers.rb +23 -0
- data/lib/spektrum-log/reader.rb +56 -0
- data/lib/spektrum-log/records.rb +231 -0
- data/lib/spektrum-log/version.rb +5 -0
- data/spec/flight_spec.rb +233 -0
- data/spec/reader_spec.rb +37 -0
- data/spec/spec_helper.rb +17 -0
- data/spektrum-log.gemspec +20 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80e40d14225d2fc99ad38744cbf85752aca4832b
|
4
|
+
data.tar.gz: a15dc90df0edd293bd38bfc852e596063e88ddb8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46d5b8afdaefe491852f77fbacc85cf48fb20a93ef33cd437e130ae324dd3c3391819f34a23beacdf129327da13735c27de8caef9a4dab046b1a9ceda24f822c
|
7
|
+
data.tar.gz: 4f46200e10324cf7024f440b1f8430265923aeb212b54c2539ec8716c477756efb0ca0a217ded1c98b08aea300243cdfe51dc571b396dcf2255a77f67e75b389
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Nick Veys
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Spektrum::Log [](https://travis-ci.org/code-lever/spektrum-log)
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
Research:
|
6
|
+
|
7
|
+
* http://www.rcgroups.com/forums/showthread.php?t=1726960
|
8
|
+
* http://www.rcgroups.com/forums/showthread.php?t=1725173
|
9
|
+
* http://www.rcgroups.com/forums/showthread.php?t=1725173&page=6#86 -- more refinement
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'spektrum-log'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install spektrum-log
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
TODO: Write usage instructions here
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/data/1.TLM
ADDED
Binary file
|
data/data/2.TLM
ADDED
Binary file
|
data/data/3.TLM
ADDED
Binary file
|
data/data/4.TLM
ADDED
Binary file
|
data/lib/spektrum-log.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
module Spektrum
|
2
|
+
module Log
|
3
|
+
|
4
|
+
class Flight
|
5
|
+
|
6
|
+
attr_reader :headers, :records
|
7
|
+
|
8
|
+
def initialize(headers, records)
|
9
|
+
@headers = headers
|
10
|
+
@records = records
|
11
|
+
end
|
12
|
+
|
13
|
+
def duration
|
14
|
+
@records.empty? ? 0 : @records.last.timestamp - @records.first.timestamp
|
15
|
+
end
|
16
|
+
|
17
|
+
def empty?
|
18
|
+
@records.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
def bind_type
|
22
|
+
case @headers.first.raw_data[2].unpack('C')[0]
|
23
|
+
when 0x01..0x02
|
24
|
+
'DSM2'
|
25
|
+
when 0x03..0x04
|
26
|
+
'DSMX'
|
27
|
+
else
|
28
|
+
'Unknown'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def model_name
|
33
|
+
@headers.first.raw_data[8..18].unpack('Z*')[0]
|
34
|
+
end
|
35
|
+
|
36
|
+
def model_number
|
37
|
+
@headers.first.raw_data[0].unpack('C')[0] + 1
|
38
|
+
end
|
39
|
+
|
40
|
+
def model_type
|
41
|
+
case @headers.first.raw_data[1].unpack('C')[0]
|
42
|
+
when 0x00
|
43
|
+
'Fixed Wing'
|
44
|
+
when 0x01
|
45
|
+
'Helicopter'
|
46
|
+
else
|
47
|
+
'Unknown'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Spektrum
|
2
|
+
module Log
|
3
|
+
|
4
|
+
class Header
|
5
|
+
|
6
|
+
attr_reader :raw_data
|
7
|
+
|
8
|
+
def initialize raw_data
|
9
|
+
@raw_data = raw_data
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
class Headers
|
15
|
+
|
16
|
+
def self.create raw_data
|
17
|
+
Header.new(raw_data)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Spektrum
|
2
|
+
module Log
|
3
|
+
|
4
|
+
class Reader
|
5
|
+
|
6
|
+
attr_reader :records, :flights
|
7
|
+
|
8
|
+
def initialize filename
|
9
|
+
headers = []
|
10
|
+
headers_complete = false
|
11
|
+
records = []
|
12
|
+
@flights = []
|
13
|
+
|
14
|
+
File.open(filename, 'rb') do |file|
|
15
|
+
loop do
|
16
|
+
first4 = file.read(4)
|
17
|
+
if first4.nil?
|
18
|
+
if headers_complete || !records.empty?
|
19
|
+
# we have records, this is a new entry
|
20
|
+
@flights << Flight.new(headers, records)
|
21
|
+
headers = []
|
22
|
+
records = []
|
23
|
+
end
|
24
|
+
break
|
25
|
+
end
|
26
|
+
|
27
|
+
first = first4.unpack('V')[0]
|
28
|
+
if 0xFFFFFFFF == first
|
29
|
+
|
30
|
+
if headers_complete || !records.empty?
|
31
|
+
# we have records, this is a new entry
|
32
|
+
@flights << Flight.new(headers, records)
|
33
|
+
headers = []
|
34
|
+
records = []
|
35
|
+
headers_complete = false
|
36
|
+
end
|
37
|
+
|
38
|
+
rest = file.read(32)
|
39
|
+
headers << Headers.create(rest)
|
40
|
+
|
41
|
+
headers_complete = rest.unpack('S')[0] == 0x1717
|
42
|
+
|
43
|
+
else
|
44
|
+
type = file.read(1).unpack('C')[0]
|
45
|
+
rest = file.read(15)
|
46
|
+
records << Records.create(type, first, rest)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
module Spektrum
|
2
|
+
module Log
|
3
|
+
|
4
|
+
class Record
|
5
|
+
|
6
|
+
attr_reader :timestamp
|
7
|
+
|
8
|
+
def initialize timestamp, raw_data
|
9
|
+
@timestamp = timestamp
|
10
|
+
@raw_data = raw_data
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def byte_field range
|
16
|
+
@raw_data[range].unpack('C')[0]
|
17
|
+
end
|
18
|
+
|
19
|
+
def hex_byte_field range
|
20
|
+
@raw_data[range].unpack('H*')[0].to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
def two_byte_field range, endian = :big
|
24
|
+
@raw_data[range].unpack(endian == :big ? 'n' : 'v')[0]
|
25
|
+
end
|
26
|
+
|
27
|
+
def four_byte_field range, endian = :big
|
28
|
+
@raw_data[range].unpack(endian == :big ? 'N' : 'V')[0]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
class AltimeterRecord < Record
|
34
|
+
|
35
|
+
def initialize timestamp, raw_data
|
36
|
+
super timestamp, raw_data
|
37
|
+
end
|
38
|
+
|
39
|
+
def altitude
|
40
|
+
two_byte_field(1..2)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
class FlightLogRecord < Record
|
46
|
+
|
47
|
+
def initialize timestamp, raw_data
|
48
|
+
super timestamp, raw_data
|
49
|
+
end
|
50
|
+
|
51
|
+
def receiver_voltage
|
52
|
+
volt = two_byte_field(13..14)
|
53
|
+
volt / 100.0
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
class GForceRecord < Record
|
59
|
+
|
60
|
+
def initialize timestamp, raw_data
|
61
|
+
super timestamp, raw_data
|
62
|
+
end
|
63
|
+
|
64
|
+
def x
|
65
|
+
x = two_byte_field(1..2)
|
66
|
+
x
|
67
|
+
end
|
68
|
+
|
69
|
+
def y
|
70
|
+
y = two_byte_field(3..4)
|
71
|
+
y
|
72
|
+
end
|
73
|
+
|
74
|
+
def z
|
75
|
+
z = two_byte_field(5..6)
|
76
|
+
z
|
77
|
+
end
|
78
|
+
|
79
|
+
def x_max
|
80
|
+
x = two_byte_field(7..8)
|
81
|
+
x
|
82
|
+
end
|
83
|
+
|
84
|
+
def y_max
|
85
|
+
y = two_byte_field(9..10)
|
86
|
+
y
|
87
|
+
end
|
88
|
+
|
89
|
+
def z_max
|
90
|
+
z = two_byte_field(11..12)
|
91
|
+
z
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
class GPSRecord1 < Record
|
97
|
+
|
98
|
+
def initialize timestamp, raw_data
|
99
|
+
super timestamp, raw_data
|
100
|
+
end
|
101
|
+
|
102
|
+
def altitude
|
103
|
+
alt = two_byte_field(1..2, :little)
|
104
|
+
alt
|
105
|
+
end
|
106
|
+
|
107
|
+
def latitude
|
108
|
+
a = byte_field(3) # 1/100 degree-second
|
109
|
+
b = byte_field(4) # degree-seconds
|
110
|
+
c = byte_field(5) # degree-minutes
|
111
|
+
d = byte_field(6) # degrees
|
112
|
+
[d, c, b, a]
|
113
|
+
end
|
114
|
+
|
115
|
+
def longitude
|
116
|
+
a = byte_field(7) # 1/100 degree-second
|
117
|
+
b = byte_field(8) # degree-seconds
|
118
|
+
c = byte_field(9) # degree-minutes
|
119
|
+
d = byte_field(10) # degrees
|
120
|
+
[d, c, b, a]
|
121
|
+
end
|
122
|
+
|
123
|
+
def heading
|
124
|
+
head = two_byte_field(11..12, :little)
|
125
|
+
head / 10.0
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
class GPSRecord2 < Record
|
131
|
+
|
132
|
+
def initialize timestamp, raw_data
|
133
|
+
super timestamp, raw_data
|
134
|
+
end
|
135
|
+
|
136
|
+
# :knots, :mph, :kph
|
137
|
+
def speed unit = :knots
|
138
|
+
speed = two_byte_field(1..2, :little)
|
139
|
+
speed = case unit
|
140
|
+
when :knots
|
141
|
+
speed / 10.0
|
142
|
+
when :mph
|
143
|
+
speed * 0.115
|
144
|
+
when :kph
|
145
|
+
speed * 0.185
|
146
|
+
end
|
147
|
+
speed.round(2)
|
148
|
+
end
|
149
|
+
|
150
|
+
def time
|
151
|
+
ax = hex_byte_field(3) # hundredths
|
152
|
+
bx = hex_byte_field(4) # seconds
|
153
|
+
cx = hex_byte_field(5) # minutes
|
154
|
+
dx = hex_byte_field(6) # hours
|
155
|
+
|
156
|
+
[dx, cx, bx + (ax / 100.0)] # hh:mm:ss.sss
|
157
|
+
end
|
158
|
+
|
159
|
+
def sats
|
160
|
+
sats = byte_field(7)
|
161
|
+
sats
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
class MysteryRecord < Record
|
167
|
+
|
168
|
+
def initialize timestamp, raw_data
|
169
|
+
super timestamp, raw_data
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
class SpeedRecord < Record
|
175
|
+
|
176
|
+
def initialize timestamp, raw_data
|
177
|
+
super timestamp, raw_data
|
178
|
+
end
|
179
|
+
|
180
|
+
def speed
|
181
|
+
speed = two_byte_field(1..2)
|
182
|
+
speed
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
class VoltsTemperatureRPMRecord < Record
|
188
|
+
|
189
|
+
def initialize timestamp, raw_data
|
190
|
+
super timestamp, raw_data
|
191
|
+
end
|
192
|
+
|
193
|
+
def rpms pole_count
|
194
|
+
rpm = two_byte_field(1..2)
|
195
|
+
rpm * pole_count
|
196
|
+
end
|
197
|
+
|
198
|
+
def voltage
|
199
|
+
volt = two_byte_field(3..4)
|
200
|
+
volt / 100.0
|
201
|
+
end
|
202
|
+
|
203
|
+
def temperature
|
204
|
+
temp = two_byte_field(5..6)
|
205
|
+
temp
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
class Records
|
211
|
+
|
212
|
+
@@types = {
|
213
|
+
0x11 => SpeedRecord,
|
214
|
+
0x12 => AltimeterRecord,
|
215
|
+
0x14 => GForceRecord,
|
216
|
+
0x16 => GPSRecord1,
|
217
|
+
0x17 => GPSRecord2,
|
218
|
+
0x7E => VoltsTemperatureRPMRecord,
|
219
|
+
0x7F => FlightLogRecord,
|
220
|
+
0xFE => VoltsTemperatureRPMRecord,
|
221
|
+
0xFF => FlightLogRecord,
|
222
|
+
}
|
223
|
+
|
224
|
+
def self.create type, timestamp, raw_data
|
225
|
+
@@types.fetch(type, MysteryRecord).new(timestamp, raw_data)
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
end
|
data/spec/flight_spec.rb
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spektrum::Log::Flight do
|
4
|
+
|
5
|
+
context 'data file 1.TLM' do
|
6
|
+
|
7
|
+
let(:reader) { Spektrum::Log::Reader.new(data_file('1.TLM')) }
|
8
|
+
|
9
|
+
context 'flight 1' do
|
10
|
+
|
11
|
+
subject { reader.flights[0] }
|
12
|
+
|
13
|
+
it { should have(4).headers }
|
14
|
+
|
15
|
+
it { should have(191).records }
|
16
|
+
|
17
|
+
its(:duration) { should eql(1148) }
|
18
|
+
|
19
|
+
its(:bind_type) { should eql('DSMX') }
|
20
|
+
|
21
|
+
its(:model_name) { should eql('Stinson') }
|
22
|
+
|
23
|
+
its(:model_number) { should eql(1) }
|
24
|
+
|
25
|
+
its(:model_type) { should eql('Fixed Wing') }
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'flight 2' do
|
30
|
+
|
31
|
+
subject { reader.flights[1] }
|
32
|
+
|
33
|
+
it { should have(4).headers }
|
34
|
+
|
35
|
+
it { should have(634).records }
|
36
|
+
|
37
|
+
its(:duration) { should eql(3798) }
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'flight 3' do
|
42
|
+
|
43
|
+
subject { reader.flights[2] }
|
44
|
+
|
45
|
+
it { should have(4).headers }
|
46
|
+
|
47
|
+
it { should have(641).records }
|
48
|
+
|
49
|
+
its(:duration) { should eql(3842) }
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'data file 2.TLM' do
|
56
|
+
|
57
|
+
let(:reader) { Spektrum::Log::Reader.new(data_file('2.TLM')) }
|
58
|
+
|
59
|
+
context 'flight 1' do
|
60
|
+
|
61
|
+
subject { reader.flights[0] }
|
62
|
+
|
63
|
+
it { should have(5).headers }
|
64
|
+
|
65
|
+
it { should have(260).records }
|
66
|
+
|
67
|
+
its(:duration) { should eql(570) }
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'data file 3.TLM' do
|
74
|
+
|
75
|
+
let(:reader) { Spektrum::Log::Reader.new(data_file('3.TLM')) }
|
76
|
+
|
77
|
+
context 'flight 1' do
|
78
|
+
|
79
|
+
subject { reader.flights[0] }
|
80
|
+
|
81
|
+
it { should have(5).headers }
|
82
|
+
|
83
|
+
it { should have(0).records }
|
84
|
+
|
85
|
+
its(:duration) { should eql(0) }
|
86
|
+
|
87
|
+
it { should be_empty }
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'flight 2' do
|
92
|
+
|
93
|
+
subject { reader.flights[1] }
|
94
|
+
|
95
|
+
it { should have(5).headers }
|
96
|
+
|
97
|
+
it { should have(0).records }
|
98
|
+
|
99
|
+
its(:duration) { should eql(0) }
|
100
|
+
|
101
|
+
it { should be_empty }
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'flight 3' do
|
106
|
+
|
107
|
+
subject { reader.flights[2] }
|
108
|
+
|
109
|
+
it { should have(5).headers }
|
110
|
+
|
111
|
+
it { should have(0).records }
|
112
|
+
|
113
|
+
its(:duration) { should eql(0) }
|
114
|
+
|
115
|
+
it { should be_empty }
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'flight 4' do
|
120
|
+
|
121
|
+
subject { reader.flights[3] }
|
122
|
+
|
123
|
+
it { should have(5).headers }
|
124
|
+
|
125
|
+
it { should have(0).records }
|
126
|
+
|
127
|
+
its(:duration) { should eql(0) }
|
128
|
+
|
129
|
+
it { should be_empty }
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'flight 5' do
|
134
|
+
|
135
|
+
subject { reader.flights[4] }
|
136
|
+
|
137
|
+
it { should have(5).headers }
|
138
|
+
|
139
|
+
it { should have(0).records }
|
140
|
+
|
141
|
+
its(:duration) { should eql(0) }
|
142
|
+
|
143
|
+
it { should be_empty }
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'flight 6' do
|
148
|
+
|
149
|
+
subject { reader.flights[5] }
|
150
|
+
|
151
|
+
it { should have(5).headers }
|
152
|
+
|
153
|
+
it { should have(0).records }
|
154
|
+
|
155
|
+
its(:duration) { should eql(0) }
|
156
|
+
|
157
|
+
it { should be_empty }
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'flight 7' do
|
162
|
+
|
163
|
+
subject { reader.flights[6] }
|
164
|
+
|
165
|
+
it { should have(5).headers }
|
166
|
+
|
167
|
+
it { should have(0).records }
|
168
|
+
|
169
|
+
its(:duration) { should eql(0) }
|
170
|
+
|
171
|
+
it { should be_empty }
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'flight 8' do
|
176
|
+
|
177
|
+
subject { reader.flights[7] }
|
178
|
+
|
179
|
+
it { should have(5).headers }
|
180
|
+
|
181
|
+
it { should have(0).records }
|
182
|
+
|
183
|
+
its(:duration) { should eql(0) }
|
184
|
+
|
185
|
+
it { should be_empty }
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'flight 9' do
|
190
|
+
|
191
|
+
subject { reader.flights[8] }
|
192
|
+
|
193
|
+
it { should have(5).headers }
|
194
|
+
|
195
|
+
it { should have(23155).records }
|
196
|
+
|
197
|
+
its(:duration) { should eql(148365) }
|
198
|
+
|
199
|
+
it { should_not be_empty }
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'data file 4.TLM' do
|
206
|
+
|
207
|
+
let(:reader) { Spektrum::Log::Reader.new(data_file('4.TLM')) }
|
208
|
+
|
209
|
+
context 'flight 1' do
|
210
|
+
|
211
|
+
subject { reader.flights[0] }
|
212
|
+
|
213
|
+
it { should have(5).headers }
|
214
|
+
|
215
|
+
it { should have(5440).records }
|
216
|
+
|
217
|
+
it { should_not be_empty }
|
218
|
+
|
219
|
+
its(:duration) { should eql(16325) }
|
220
|
+
|
221
|
+
its(:bind_type) { should eql('DSMX') }
|
222
|
+
|
223
|
+
its(:model_name) { should eql('Goblin 700') }
|
224
|
+
|
225
|
+
its(:model_number) { should eql(5) }
|
226
|
+
|
227
|
+
its(:model_type) { should eql('Helicopter') }
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
data/spec/reader_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spektrum::Log::Reader do
|
4
|
+
|
5
|
+
context 'data file 1.TLM' do
|
6
|
+
|
7
|
+
subject { Spektrum::Log::Reader.new(data_file('1.TLM')) }
|
8
|
+
|
9
|
+
it { should have(3).flights }
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'data file 2.TLM' do
|
14
|
+
|
15
|
+
subject { Spektrum::Log::Reader.new(data_file('2.TLM')) }
|
16
|
+
|
17
|
+
it { should have(312).flights }
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'data file 3.TLM' do
|
22
|
+
|
23
|
+
subject { Spektrum::Log::Reader.new(data_file('3.TLM')) }
|
24
|
+
|
25
|
+
it { should have(12).flights }
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'data file 4.TLM' do
|
30
|
+
|
31
|
+
subject { Spektrum::Log::Reader.new(data_file('4.TLM')) }
|
32
|
+
|
33
|
+
it { should have(1).flights }
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spektrum-log'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
5
|
+
config.run_all_when_everything_filtered = true
|
6
|
+
config.filter_run :focus
|
7
|
+
|
8
|
+
# Run specs in random order to surface order dependencies. If you find an
|
9
|
+
# order dependency and want to debug it, you can fix the order by providing
|
10
|
+
# the seed, which is printed after each run.
|
11
|
+
# --seed 1234
|
12
|
+
config.order = 'random'
|
13
|
+
end
|
14
|
+
|
15
|
+
def data_file(name)
|
16
|
+
"#{File.dirname(__FILE__)}/../data/#{name}"
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/spektrum-log/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Nick Veys"]
|
6
|
+
gem.email = ["nveys@aramisgroup.com"]
|
7
|
+
gem.description = %q{Read and interpret Spektrum TLM log files.}
|
8
|
+
gem.summary = %q{Spektrum TLM log file reader}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "spektrum-log"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Spektrum::Log::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rspec', '~> 2.12'
|
19
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spektrum-log
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Veys
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Read and interpret Spektrum TLM log files.
|
42
|
+
email:
|
43
|
+
- nveys@aramisgroup.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .rspec
|
50
|
+
- .travis.yml
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- data/1.TLM
|
56
|
+
- data/2.TLM
|
57
|
+
- data/3.TLM
|
58
|
+
- data/4.TLM
|
59
|
+
- lib/spektrum-log.rb
|
60
|
+
- lib/spektrum-log/flight.rb
|
61
|
+
- lib/spektrum-log/headers.rb
|
62
|
+
- lib/spektrum-log/reader.rb
|
63
|
+
- lib/spektrum-log/records.rb
|
64
|
+
- lib/spektrum-log/version.rb
|
65
|
+
- spec/flight_spec.rb
|
66
|
+
- spec/reader_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
- spektrum-log.gemspec
|
69
|
+
homepage: ''
|
70
|
+
licenses: []
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.0.3
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Spektrum TLM log file reader
|
92
|
+
test_files:
|
93
|
+
- spec/flight_spec.rb
|
94
|
+
- spec/reader_spec.rb
|
95
|
+
- spec/spec_helper.rb
|