rfbeam 0.3.4 → 0.4.0
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/.rubocop.yml +7 -1
- data/CHANGELOG.md +11 -1
- data/Gemfile +10 -0
- data/Gemfile.lock +28 -1
- data/README.md +29 -24
- data/exe/rfbeam +5 -0
- data/lib/rfbeam/cli.rb +130 -0
- data/lib/rfbeam/kld7/constants.rb +34 -54
- data/lib/rfbeam/kld7/radar_messages.rb +94 -0
- data/lib/rfbeam/kld7/radar_parameters.rb +399 -0
- data/lib/rfbeam/kld7/{connection.rb → serial_connection.rb} +0 -2
- data/lib/rfbeam/kld7/streamer.rb +75 -0
- data/lib/rfbeam/version.rb +1 -1
- data/lib/rfbeam.rb +7 -4
- data/output.csv +257 -0
- metadata +11 -6
- data/lib/rfbeam/kld7/app_commands.rb +0 -201
- data/lib/rfbeam/kld7/app_messages.rb +0 -100
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
module RfBeam
|
|
2
|
+
module KLD7
|
|
3
|
+
|
|
4
|
+
# -----------------
|
|
5
|
+
# Software Version, 'K-LD7_APP-RFB-XXXX'
|
|
6
|
+
# -----------------
|
|
7
|
+
def sw_version
|
|
8
|
+
query_parameter RADAR_PARAMETERS[:sw_version].grps_index
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# -----------------
|
|
12
|
+
# Base Frequency, 0 = low, 1 = middle (default), 2 = high
|
|
13
|
+
# -----------------
|
|
14
|
+
def base_frequency
|
|
15
|
+
query_parameter RADAR_PARAMETERS[:base_frequency].grps_index
|
|
16
|
+
end
|
|
17
|
+
alias rbfr base_frequency
|
|
18
|
+
|
|
19
|
+
def base_frequency=(frequency = 1)
|
|
20
|
+
value = case frequency
|
|
21
|
+
when 0, :low, 'low'
|
|
22
|
+
0
|
|
23
|
+
when 1, :middle, 'middle'
|
|
24
|
+
1
|
|
25
|
+
when 2, :high, 'high'
|
|
26
|
+
2
|
|
27
|
+
else
|
|
28
|
+
raise ArgumentError, "Invalid arg: '#{frequency}'"
|
|
29
|
+
end
|
|
30
|
+
set_parameter(:rbfr, value, :uint32)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
alias set_base_frequency base_frequency=
|
|
34
|
+
alias rbfr= base_frequency=
|
|
35
|
+
|
|
36
|
+
# -----------------
|
|
37
|
+
# Maximum Speed, 0 = 12.5km/h, 1 = 25km/h (default), 2 = 50km/h, 3 = 100km/h
|
|
38
|
+
# -----------------
|
|
39
|
+
def max_speed
|
|
40
|
+
query_parameter(RADAR_PARAMETERS[:max_speed].grps_index)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def max_speed=(speed = 1)
|
|
44
|
+
raise ArgumentError, "Invalid arg: '#{speed}'" unless (0..3).include?(speed)
|
|
45
|
+
raise ArgumentError, "Expected an Integer" unless speed.is_a?(Integer)
|
|
46
|
+
|
|
47
|
+
set_parameter :rspi, speed, :uint32
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
alias set_max_speed max_speed=
|
|
51
|
+
alias rspi max_speed=
|
|
52
|
+
|
|
53
|
+
# -----------------
|
|
54
|
+
# Maximum Range, 0 = 5m, 1 = 10m (default), 2 = 30m, 3 = 100m
|
|
55
|
+
# -----------------
|
|
56
|
+
def max_range
|
|
57
|
+
query_parameter(RADAR_PARAMETERS[:max_range].grps_index)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def max_range=(range = 1)
|
|
61
|
+
raise ArgumentError, "Invalid arg: '#{range}'" unless (0..3).include?(range)
|
|
62
|
+
raise ArgumentError, "Expected an Integer" unless range.is_a?(Integer)
|
|
63
|
+
|
|
64
|
+
set_parameter :rrai, range, :uint32
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
alias rrai= max_range=
|
|
68
|
+
alias set_max_range max_range=
|
|
69
|
+
|
|
70
|
+
# -----------------
|
|
71
|
+
# Threshold Offset, 10 - 60db, (default = 30)
|
|
72
|
+
# -----------------
|
|
73
|
+
def threshold_offset
|
|
74
|
+
query_parameter RADAR_PARAMETERS[:threshold_offset].grps_index
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def threshold_offset=(offset = 30)
|
|
78
|
+
raise ArgumentError, "Invalid arg: '#{offset}'" unless (10..60).include?(offset)
|
|
79
|
+
raise ArgumentError, "Expected an Integer" unless offset.is_a?(Integer)
|
|
80
|
+
|
|
81
|
+
set_parameter :thof, offset, :uint32
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
alias thof= threshold_offset=
|
|
85
|
+
alias set_threshold_offset threshold_offset=
|
|
86
|
+
|
|
87
|
+
# -----------------
|
|
88
|
+
# Tracking filter type, 0 = Standard (Default), 1 = Fast Tracking, 2 = Long visibility
|
|
89
|
+
# -----------------
|
|
90
|
+
def tracking_filter
|
|
91
|
+
query_parameter RADAR_PARAMETERS[:tracking_filter].grps_index
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def tracking_filter=(type = 0)
|
|
95
|
+
raise ArgumentError, "Invalid arg: '#{type}'" unless (0..2).include?(type)
|
|
96
|
+
raise ArgumentError, "Expected an Integer" unless type.is_a?(Integer)
|
|
97
|
+
|
|
98
|
+
set_parameter :trft, type, :uint32
|
|
99
|
+
end
|
|
100
|
+
alias trtf= tracking_filter=
|
|
101
|
+
alias set_tracking_filter tracking_filter=
|
|
102
|
+
|
|
103
|
+
# -----------------
|
|
104
|
+
# Vibration suppression, 0 - 16, 0 = No Suppression, 16 = High Suppression, default = 2
|
|
105
|
+
# -----------------
|
|
106
|
+
def vibration_suppression
|
|
107
|
+
query_parameter RADAR_PARAMETERS[:vibration_suppression].grps_index
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def vibration_suppression=(value = 2)
|
|
111
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..16).include?(value)
|
|
112
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
113
|
+
|
|
114
|
+
set_parameter :visu, value, :uint32
|
|
115
|
+
end
|
|
116
|
+
alias visu= vibration_suppression=
|
|
117
|
+
alias set_vibration_suppression vibration_suppression=
|
|
118
|
+
|
|
119
|
+
# -----------------
|
|
120
|
+
# Minimum Detection distance, 0 - 100% of Range setting, default = 0
|
|
121
|
+
# -----------------
|
|
122
|
+
def min_detection_distance
|
|
123
|
+
query_parameter RADAR_PARAMETERS[:min_detection_distance].grps_index
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def min_detection_distance=(value = 0)
|
|
127
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..100).include?(value)
|
|
128
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
129
|
+
|
|
130
|
+
set_parameter :mira, value, :uint32
|
|
131
|
+
end
|
|
132
|
+
alias mira= min_detection_distance=
|
|
133
|
+
alias set_min_detection_distance min_detection_distance=
|
|
134
|
+
|
|
135
|
+
# -----------------
|
|
136
|
+
# Maximum Detection distance, 0 - 100% of Range setting, default = 50
|
|
137
|
+
# -----------------
|
|
138
|
+
def max_detection_distance
|
|
139
|
+
query_parameter RADAR_PARAMETERS[:min_detection_distance].grps_index
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def max_detection_distance=(value = 50)
|
|
143
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..100).include?(value)
|
|
144
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
145
|
+
|
|
146
|
+
set_parameter :mara, value, :uint32
|
|
147
|
+
end
|
|
148
|
+
alias mara= max_detection_distance=
|
|
149
|
+
alias set_max_detection_distance max_detection_distance=
|
|
150
|
+
|
|
151
|
+
# -----------------
|
|
152
|
+
# Minimum Detection Angle, -90° - 90°, default = -90
|
|
153
|
+
# -----------------
|
|
154
|
+
def min_detection_angle
|
|
155
|
+
query_parameter RADAR_PARAMETERS[:min_detection_angle].grps_index
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def min_detection_angle=(angle = -90)
|
|
159
|
+
raise ArgumentError, "Invalid arg: '#{angle}'" unless (-90..90).include?(angle)
|
|
160
|
+
raise ArgumentError, "Expected an Integer" unless angle.is_a?(Integer)
|
|
161
|
+
|
|
162
|
+
set_parameter :mian, angle, :int32
|
|
163
|
+
end
|
|
164
|
+
alias mian= min_detection_angle=
|
|
165
|
+
alias set_min_detection_angle min_detection_angle=
|
|
166
|
+
|
|
167
|
+
# -----------------
|
|
168
|
+
# Maximum Detection Angle, -90° - 90°, default = 90
|
|
169
|
+
# -----------------
|
|
170
|
+
def max_detection_angleq
|
|
171
|
+
query_parameter RADAR_PARAMETERS[:max_detection_angle].grps_index
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def max_detection_angle=(angle = 90)
|
|
175
|
+
raise ArgumentError, "Invalid arg: '#{angle}'" unless (-90..90).include?(angle)
|
|
176
|
+
raise ArgumentError, "Expected an Integer" unless angle.is_a?(Integer)
|
|
177
|
+
|
|
178
|
+
set_parameter :maan, angle, :int32
|
|
179
|
+
end
|
|
180
|
+
alias maan= max_detection_angle=
|
|
181
|
+
alias set_max_detection_angle max_detection_angle=
|
|
182
|
+
|
|
183
|
+
# -----------------
|
|
184
|
+
# Minimum Detection Speed, 0 - 100% of Speed setting, default = 0
|
|
185
|
+
# -----------------
|
|
186
|
+
def min_detection_speed
|
|
187
|
+
query_parameter RADAR_PARAMETERS[:min_detection_angle].grps_index
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def min_detection_speed=(speed = 0)
|
|
191
|
+
raise ArgumentError, "Invalid arg: '#{speed}'" unless (0..100).include?(speed)
|
|
192
|
+
raise ArgumentError, "Expected an Integer" unless speed.is_a?(Integer)
|
|
193
|
+
|
|
194
|
+
set_parameter :misp, speed, :uint32
|
|
195
|
+
end
|
|
196
|
+
alias misp= min_detection_speed=
|
|
197
|
+
alias set_min_detection_speed min_detection_speed=
|
|
198
|
+
|
|
199
|
+
# -----------------
|
|
200
|
+
# Maximum Detection Speed, 0 - 100% of Speed setting, default = 100
|
|
201
|
+
# -----------------
|
|
202
|
+
def max_detection_speed
|
|
203
|
+
query_parameter RADAR_PARAMETERS[:max_detection_speed].grps_index
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def max_detection_speed=(speed = 100)
|
|
207
|
+
raise ArgumentError, "Invalid arg: '#{speed}'" unless (0..100).include?(speed)
|
|
208
|
+
raise ArgumentError, "Expected an Integer" unless speed.is_a?(Integer)
|
|
209
|
+
|
|
210
|
+
set_parameter :masp, speed, :uint32
|
|
211
|
+
end
|
|
212
|
+
alias masp= max_detection_speed=
|
|
213
|
+
alias set_max_detection_speed max_detection_speed=
|
|
214
|
+
|
|
215
|
+
# -----------------
|
|
216
|
+
# Detection Direction, 0 = Receding, 1 = Approaching, 2 = Both (default)
|
|
217
|
+
# -----------------
|
|
218
|
+
def detection_direction
|
|
219
|
+
query_parameter RADAR_PARAMETERS[:detection_direction].grps_index
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def detection_direction=(direction = 2)
|
|
223
|
+
raise ArgumentError, "Invalid arg: '#{direction}'" unless (0..2).include?(direction)
|
|
224
|
+
raise ArgumentError, "Expected an Integer" unless direction.is_a?(Integer)
|
|
225
|
+
|
|
226
|
+
set_parameter :dedi, direction, :uint32
|
|
227
|
+
end
|
|
228
|
+
alias dedi= detection_direction=
|
|
229
|
+
alias set_detection_direction detection_direction=
|
|
230
|
+
|
|
231
|
+
# -----------------
|
|
232
|
+
# Range Threshold, 0 - 100% of Range setting, default = 10
|
|
233
|
+
# -----------------
|
|
234
|
+
def range_threshold
|
|
235
|
+
query_parameter RADAR_PARAMETERS[:range_threshold].grps_index
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def range_threshold=(value = 10)
|
|
239
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..100).include?(value)
|
|
240
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
241
|
+
|
|
242
|
+
set_parameter :rath, value, :uint32
|
|
243
|
+
end
|
|
244
|
+
alias rath= range_threshold=
|
|
245
|
+
alias set_range_threshold range_threshold=
|
|
246
|
+
|
|
247
|
+
# -----------------
|
|
248
|
+
# Angle Threshold, -90° to 90°, default = 0
|
|
249
|
+
# -----------------
|
|
250
|
+
def angle_threshold
|
|
251
|
+
query_parameter RADAR_PARAMETERS[:angle_threshold].grps_index
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def angle_threshold=(value = 0)
|
|
255
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (-90..90).include?(value)
|
|
256
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
257
|
+
|
|
258
|
+
set_parameter :anth, value, :int32
|
|
259
|
+
end
|
|
260
|
+
alias anth= angle_threshold=
|
|
261
|
+
alias set_angle_threshold angle_threshold=
|
|
262
|
+
|
|
263
|
+
# -----------------
|
|
264
|
+
# Speed Threshold, 0 - 100% of speed setting, default = 50
|
|
265
|
+
# -----------------
|
|
266
|
+
def speed_threshold
|
|
267
|
+
query_parameter RADAR_PARAMETERS[:speed_threshold].grps_index
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def speed_threshold=(value = 50)
|
|
271
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..100).include?(value)
|
|
272
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
273
|
+
|
|
274
|
+
set_parameter :spth, value, :uint32
|
|
275
|
+
end
|
|
276
|
+
alias spth= angle_threshold=
|
|
277
|
+
alias set_speed_threshold angle_threshold=
|
|
278
|
+
|
|
279
|
+
# -----------------
|
|
280
|
+
# Digital output 1, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 0
|
|
281
|
+
# -----------------
|
|
282
|
+
def digital_output1
|
|
283
|
+
query_parameter RADAR_PARAMETERS[:digital_output1].grps_index
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def digital_output1=(value = 0)
|
|
287
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..4).include?(value)
|
|
288
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
289
|
+
|
|
290
|
+
set_parameter :dig1, value, :uint32
|
|
291
|
+
end
|
|
292
|
+
alias dig1= digital_output1=
|
|
293
|
+
alias set_digital_output1 digital_output1=
|
|
294
|
+
|
|
295
|
+
# -----------------
|
|
296
|
+
# Digital output 2, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 1
|
|
297
|
+
# -----------------
|
|
298
|
+
def digital_output2
|
|
299
|
+
query_parameter RADAR_PARAMETERS[:digital_output2].grps_index
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def digital_output2=(value = 1)
|
|
303
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..4).include?(value)
|
|
304
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
305
|
+
|
|
306
|
+
set_parameter :dig2, value, :uint32
|
|
307
|
+
end
|
|
308
|
+
alias dig2= digital_output2=
|
|
309
|
+
alias set_digital_output2 digital_output2=
|
|
310
|
+
|
|
311
|
+
# -----------------
|
|
312
|
+
# Digital output 3, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 2
|
|
313
|
+
# -----------------
|
|
314
|
+
def digital_output3
|
|
315
|
+
query_parameter RADAR_PARAMETERS[:digital_output3].grps_index
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def digital_output3=(value = 2)
|
|
319
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..4).include?(value)
|
|
320
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
321
|
+
|
|
322
|
+
set_parameter :dig3, value, :uint32
|
|
323
|
+
end
|
|
324
|
+
alias dig3= digital_output3=
|
|
325
|
+
alias set_digital_output3 digital_output3=
|
|
326
|
+
|
|
327
|
+
# -----------------
|
|
328
|
+
# Hold Time, 1 - 7200s, default = 1
|
|
329
|
+
# -----------------
|
|
330
|
+
def hold_time
|
|
331
|
+
query_parameter RADAR_PARAMETERS[:hold_time].grps_index
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def hold_time=(time = 1)
|
|
335
|
+
raise ArgumentError, "Invalid arg: '#{time}'" unless (1..7200).include?(time)
|
|
336
|
+
raise ArgumentError, "Expected an Integer" unless time.is_a?(Integer)
|
|
337
|
+
|
|
338
|
+
set_parameter :hold, time, :uint32
|
|
339
|
+
end
|
|
340
|
+
alias hold= hold_time=
|
|
341
|
+
alias set_hold_time hold_time=
|
|
342
|
+
|
|
343
|
+
# -----------------
|
|
344
|
+
# Micro Detection retrigger, 0 = Off (default), 1 = Retrigger
|
|
345
|
+
# -----------------
|
|
346
|
+
def micro_detection_retrigger
|
|
347
|
+
query_parameter RADAR_PARAMETERS[:set_micro_detection_retrigger].grps_index
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def micro_detection_retrigger=(value = 0)
|
|
351
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..1).include?(value)
|
|
352
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
353
|
+
|
|
354
|
+
set_parameter :mide, value, :uint32
|
|
355
|
+
end
|
|
356
|
+
alias mide= micro_detection_retrigger=
|
|
357
|
+
alias set_micro_detection_retrigger micro_detection_retrigger=
|
|
358
|
+
|
|
359
|
+
# -----------------
|
|
360
|
+
# Micro Detection sensitivity, 0 - 9, 0 = Min, 9 = Max, default = 4
|
|
361
|
+
# -----------------
|
|
362
|
+
def micro_detection_sensitivity
|
|
363
|
+
query_parameter RADAR_PARAMETERS[:micro_detection_sensitivity].grps_index
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
def micro_detection_sensitivity=(value = 4)
|
|
367
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..9).include?(value)
|
|
368
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
|
369
|
+
|
|
370
|
+
set_parameter :mids, value, :uint32
|
|
371
|
+
end
|
|
372
|
+
alias mids= micro_detection_sensitivity=
|
|
373
|
+
alias set_micro_detection_sensitivity micro_detection_sensitivity=
|
|
374
|
+
|
|
375
|
+
private
|
|
376
|
+
|
|
377
|
+
def query_parameter(index)
|
|
378
|
+
data = grps
|
|
379
|
+
data[index]
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
def set_parameter(header, value, return_type = :uint32)
|
|
383
|
+
return_type =
|
|
384
|
+
case return_type
|
|
385
|
+
when :uint32
|
|
386
|
+
'L'
|
|
387
|
+
when :int32
|
|
388
|
+
'l'
|
|
389
|
+
when :uint32
|
|
390
|
+
'S'
|
|
391
|
+
else
|
|
392
|
+
'L'
|
|
393
|
+
end
|
|
394
|
+
command = [header.upcase.to_s, 4, value]
|
|
395
|
+
write command.pack("a4L#{return_type}")
|
|
396
|
+
check_response
|
|
397
|
+
end
|
|
398
|
+
end
|
|
399
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# rubocop:disable all
|
|
2
|
+
require 'unicode_plot'
|
|
3
|
+
require 'io/console'
|
|
4
|
+
require "stringio"
|
|
5
|
+
require 'tty-screen'
|
|
6
|
+
|
|
7
|
+
module RfBeam
|
|
8
|
+
module KLD7
|
|
9
|
+
class Streamer
|
|
10
|
+
attr_accessor :radar
|
|
11
|
+
|
|
12
|
+
def initialize(radar)
|
|
13
|
+
@radar = radar
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def monitor_keypress
|
|
17
|
+
loop do
|
|
18
|
+
key = STDIN.getch
|
|
19
|
+
if key.downcase == "q"
|
|
20
|
+
@stop_streaming = true
|
|
21
|
+
break
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def rfft
|
|
27
|
+
out = StringIO.new
|
|
28
|
+
def out.tty?
|
|
29
|
+
true
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Thread.new { monitor_keypress }
|
|
33
|
+
|
|
34
|
+
loop do
|
|
35
|
+
out.truncate(0)
|
|
36
|
+
|
|
37
|
+
plot = rfft_plot(@radar)
|
|
38
|
+
plot.render(out)
|
|
39
|
+
|
|
40
|
+
lines = out.string.lines
|
|
41
|
+
lines.each { |line| $stdout.print "\r#{line}" }
|
|
42
|
+
$stdout.print "\e[0J"
|
|
43
|
+
$stdout.flush
|
|
44
|
+
break if @stop_streaming
|
|
45
|
+
|
|
46
|
+
n = lines.count
|
|
47
|
+
$stdout.print "\e[#{n}F"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def plot_data(data)
|
|
54
|
+
{ x: Array(-128...128), series1: data.shift(256).map { |value| value / 100 }, series2: data.shift(256).map { |value| value.to_i / 100 } }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def rfft_plot(radar)
|
|
58
|
+
width = TTY::Screen.width * 0.65
|
|
59
|
+
data = plot_data(radar.rfft)
|
|
60
|
+
plot = UnicodePlot.lineplot(
|
|
61
|
+
data[:x],
|
|
62
|
+
data[:series1],
|
|
63
|
+
name: 'IF1/2 Averaged',
|
|
64
|
+
title: 'Raw FFT',
|
|
65
|
+
height: 25,
|
|
66
|
+
width: width,
|
|
67
|
+
xlabel: "Speed (km/h)",
|
|
68
|
+
ylabel: 'Signal (db)', xlim: [-128, 128],
|
|
69
|
+
ylim: [0, 100])
|
|
70
|
+
UnicodePlot.lineplot!(plot, data[:x], data[:series2], name: "Threshold")
|
|
71
|
+
plot
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
data/lib/rfbeam/version.rb
CHANGED
data/lib/rfbeam.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'rfbeam/kld7/
|
|
4
|
-
require 'rfbeam/kld7/
|
|
5
|
-
require 'rfbeam/kld7/
|
|
3
|
+
require 'rfbeam/kld7/radar_parameters'
|
|
4
|
+
require 'rfbeam/kld7/radar_messages'
|
|
5
|
+
require 'rfbeam/kld7/serial_connection'
|
|
6
6
|
require 'rfbeam/kld7/constants'
|
|
7
|
-
|
|
7
|
+
require 'rfbeam/kld7/streamer'
|
|
8
|
+
require 'rfbeam/version'
|
|
9
|
+
require 'rfbeam/cli'
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
module RfBeam
|
|
10
13
|
class Error < StandardError
|