rfbeam 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/.tool-versions +1 -1
- data/CHANGELOG.md +10 -1
- data/Gemfile.lock +1 -1
- data/README.md +29 -24
- data/lib/rfbeam/kld7/constants.rb +34 -28
- data/lib/rfbeam/kld7/radar_messages.rb +81 -0
- data/lib/rfbeam/kld7/radar_parameters.rb +390 -0
- data/lib/rfbeam/kld7/{connection.rb → serial_connection.rb} +1 -1
- data/lib/rfbeam/version.rb +1 -1
- data/lib/rfbeam.rb +3 -3
- data/rfbeam.gemspec +3 -3
- metadata +9 -9
- data/lib/rfbeam/kld7/app_commands.rb +0 -230
- data/lib/rfbeam/kld7/app_messages.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 139acc0d00964189f2eadbba6ed9c7b0e3f4b6c5104a757b2c1ab335d0e30c22
|
4
|
+
data.tar.gz: 86370312525afb17e493aa4b561a68b0f57dc48122f3ecd5f389c421c512cbe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76e49986de83640754506d935a5a46b0c74548fe96ac7fec03bff66efe048937eaf1dd1175ea25658e3cbdc3705f6f4744df56c969f584e9f3763629d37fbe0e
|
7
|
+
data.tar.gz: 0d032f953bca0658fb4edec3544925bd1fe675b759b1a9759a8cfbffea0abd76f7e1690bb9ae87df5d700a102d4c713f5bb858ca7a8b855d039c3ea448e94428
|
data/.rubocop.yml
CHANGED
@@ -2,10 +2,16 @@ inherit_from:
|
|
2
2
|
- node_modules/@prettier/plugin-ruby/rubocop.yml
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
TargetRubyVersion: 2
|
5
|
+
TargetRubyVersion: 3.2
|
6
6
|
|
7
7
|
Layout/LineLength:
|
8
8
|
Max: 120
|
9
9
|
|
10
|
+
Metrics/ModuleLength:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Max: 15
|
15
|
+
|
10
16
|
Documentation:
|
11
17
|
Enabled: false
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 3.2.1
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
## [0.3.
|
1
|
+
## [0.3.5] - 2023-4-1
|
2
|
+
|
3
|
+
- Updated Radar parameter accessors
|
4
|
+
- Added parameter setter arg validation and errors
|
5
|
+
|
6
|
+
## [0.3.4] - 2023-3-28
|
7
|
+
|
8
|
+
- Added a formatted option to pdat
|
9
|
+
|
10
|
+
## [0.3.2] - 2023-3-28
|
2
11
|
|
3
12
|
- Added setters for Parameter settings
|
4
13
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# Rfbeam
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
![Gem](https://img.shields.io/gem/v/rfbeam?color=green&label=version)
|
4
|
+
![Ruby](https://img.shields.io/static/v1?message=Ruby&color=red&logo=Ruby&logoColor=FFFFFF&label=v3.2.1)
|
5
|
+
![Ruby](https://img.shields.io/gitlab/license/robcarruthers/rfbeam?color=orange)
|
6
|
+
|
7
|
+
RfBeam is a simple, high-level interface for the RFBeam radar modules.
|
8
|
+
The user can query process and raw detection data and set the radar parameters for the sensor.
|
5
9
|
|
6
10
|
At this stage it only works on Linux and Mac with the K-LD7 module.
|
7
11
|
|
@@ -63,28 +67,29 @@ Returns a formatted String of all parameter settings. The only way to read param
|
|
63
67
|
|
64
68
|
radar.config
|
65
69
|
|
66
|
-
Software Version: K-LD7_APP-RFB-0103
|
67
|
-
Base Frequency:
|
68
|
-
|
69
|
-
|
70
|
-
Threshold
|
71
|
-
Tracking Filter Type:
|
72
|
-
Vibration Suppression:
|
73
|
-
Minimum Detection Distance: 0
|
74
|
-
Maximum Detection Distance:
|
75
|
-
Minimum Detection Angle: -
|
76
|
-
Maximum Detection Angle: 90°
|
77
|
-
|
78
|
-
Maximum Detection Speed: 100
|
79
|
-
Detection Direction:
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
Digital
|
84
|
-
Digital
|
85
|
-
|
86
|
-
|
87
|
-
Micro Detection
|
70
|
+
Software Version: K-LD7_APP-RFB-0103
|
71
|
+
Base Frequency: Low
|
72
|
+
Maximum Speed: 100km/h
|
73
|
+
Maximum Range: 100m
|
74
|
+
Threshold Offset: 30db
|
75
|
+
Tracking Filter Type: Long Visibility
|
76
|
+
Vibration Suppression: 16
|
77
|
+
Minimum Detection Distance: 0%
|
78
|
+
Maximum Detection Distance: 100%
|
79
|
+
Minimum Detection Angle: -10°
|
80
|
+
Maximum Detection Angle: 90°
|
81
|
+
Minimum Detection Speed: 0%
|
82
|
+
Maximum Detection Speed: 100%
|
83
|
+
Detection Direction: Both
|
84
|
+
Range Threshold: 10%
|
85
|
+
Angle Threshold: 0°
|
86
|
+
Speed Threshold: 50%
|
87
|
+
Digital Output 1: Direction
|
88
|
+
Digital Output 2: Angle
|
89
|
+
Digital Output 3: Range
|
90
|
+
Hold Time: 1s
|
91
|
+
Micro Detection Trigger: Off
|
92
|
+
Micro Detection Sensativity: 4
|
88
93
|
|
89
94
|
## Parameter setters
|
90
95
|
|
@@ -11,7 +11,7 @@ module RfBeam
|
|
11
11
|
3 => 'Invalid RPST version',
|
12
12
|
4 => 'Uart error (parity, framing, noise)',
|
13
13
|
5 => 'Sensor busy',
|
14
|
-
6 => 'Timeout error'
|
14
|
+
6 => 'Timeout error'
|
15
15
|
}.freeze
|
16
16
|
|
17
17
|
# The response delay was determined empirically and may need adjusting with baude rate
|
@@ -27,33 +27,39 @@ module RfBeam
|
|
27
27
|
angle: %w[Left Right],
|
28
28
|
direction: %w[Receding Approaching],
|
29
29
|
range: %w[Far Near],
|
30
|
-
speed: %w[Low High]
|
31
|
-
}
|
30
|
+
speed: %w[Low High]
|
31
|
+
}.freeze
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
33
|
+
Param = Data.define(:name, :grps_index, :description, :default, :units, :values) do |_param|
|
34
|
+
def initialize(name:, grps_index:, description: nil, default: nil, units: nil, values: [])
|
35
|
+
super(name:, grps_index:, description:, default:, units:, values:)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
RADAR_PARAMETERS = {
|
40
|
+
sw_version: Param.new(name: 'Software Version', grps_index: 2, default: 'K-LD7_APP-RFB-XXXX'),
|
41
|
+
base_frequency: Param.new( name: 'Base Frequency', grps_index: 3, description: '0 = Low, 1 = Middle, 2 = High', default: 1, values: ['Low', 'Middle', 'High'] ),
|
42
|
+
max_speed: Param.new( name: 'Maximum Speed', grps_index: 4, description: '0 = 12km/h, 1 = 25km/h, 2 = 50km/h, 3 = 100km/h', default: 1, units: 'km/h', values: ['12.5', '25', '50', '100'] ),
|
43
|
+
max_range: Param.new( name: 'Maximum Range', grps_index: 5, description: '0 = 5m, 1 = 10m, 2 = 30m, 3 = 100m', default: 1, values: %w[5m 10m 30m 100m] ),
|
44
|
+
threshhold_offset: Param.new( name: 'Threshold Offset', grps_index: 6, description: '10db - 60db', default: 30, units: 'db' ),
|
45
|
+
tracking_filter: Param.new( name: 'Tracking Filter Type', grps_index: 7, description: '0 = Standard, 2 = Fast Detection, 3 = Long Visibility', default: 0, values: ['standard', 'Fast Detection', 'Long Visibility'] ),
|
46
|
+
vibration_suppression: Param.new( name: 'Vibration Suppression', grps_index: 8, description: '0-16, 0 = No Suppression, 16 = High Suppression', default: 2 ),
|
47
|
+
min_detection_distance: Param.new( name: 'Minimum Detection Distance', grps_index: 9, description: '0 - 100% of range setting', default: 0, units: '%' ),
|
48
|
+
max_detection_distance: Param.new( name: 'Maximum Detection Distance', grps_index: 10, description: '0 - 100% of range setting', default: 50, units: '%' ),
|
49
|
+
min_detection_angle: Param.new( name: 'Minimum Detection Angle', grps_index: 11, description: '-90° - 90°', default: -90, units: '°' ),
|
50
|
+
max_detection_angle: Param.new( name: 'Maximum Detection Angle', grps_index: 12, description: '-90° - 90°', default: 90, units: '°' ),
|
51
|
+
min_detection_speed: Param.new( name: 'Minimum Detection Speed', grps_index: 13, description: '0 - 100% of speed setting', default: 0, units: '%' ),
|
52
|
+
max_detection_speed: Param.new( name: 'Maximum Detection Speed', grps_index: 14, description: '0 - 100% of speed setting', default: 100, units: '%' ),
|
53
|
+
detection_direction: Param.new( name: 'Detection Direction', grps_index: 15, description: '0 = Receding, 1 = Approaching, 2 = Both', default: 2, values: %w[Receding Approaching Both] ),
|
54
|
+
range_threshold: Param.new( name: 'Range Threshold', grps_index: 16, description: '0 - 100% of range setting', default: 10, units: '%' ),
|
55
|
+
angle_threshold: Param.new( name: 'Angle Threshold', grps_index: 17, description: '-90° - 90°', default: 0, units: '°' ),
|
56
|
+
speed_threshold: Param.new( name: 'Speed Threshold', grps_index: 18, description: '0 - 100% of speed setting', default: 50, units: '%' ),
|
57
|
+
digital_output1: Param.new( name: 'Digital Output 1', grps_index: 19, description: '0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection', default: 0, values: %w[Direction Angle Range Speed Micro] ),
|
58
|
+
digital_output2: Param.new( name: 'Digital Output 2', grps_index: 20, description: '0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection', default: 1, values: %w[Direction Angle Range Speed Micro] ),
|
59
|
+
digital_output3: Param.new( name: 'Digital Output 3', grps_index: 21, description: '0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection', default: 2, values: %w[Direction Angle Range Speed Micro] ),
|
60
|
+
hold_time: Param.new( name: 'Hold Time', grps_index: 22, description: '1 - 7200s', default: 1, units: 's' ),
|
61
|
+
micro_detection_retrigger: Param.new( name: 'Micro Detection Trigger', grps_index: 23, description: '0 = Off, 1 = Retrigger', default: 0, values: %w[Off Retrigger] ),
|
62
|
+
micro_detection_sensativity: Param.new( name: 'Micro Detection Sensativity', grps_index: 24, description: '0 - 9, 0 = Min, 9 = Max', default: 4 )
|
63
|
+
}.freeze
|
58
64
|
end
|
59
65
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module RfBeam
|
2
|
+
module KLD7
|
3
|
+
def detection?
|
4
|
+
data = ddat
|
5
|
+
(data[2] == 1)
|
6
|
+
end
|
7
|
+
|
8
|
+
def pdat(formatted: false)
|
9
|
+
request_frame_data(:pdat)
|
10
|
+
resp = read(102).unpack('a4LSssSSssSSssSSssSSssSSssSSssSSssSSssSSssS')
|
11
|
+
return resp unless formatted
|
12
|
+
|
13
|
+
target_count = resp[1].to_i / 8
|
14
|
+
return [] unless target_count > 0
|
15
|
+
|
16
|
+
resp.shift 2
|
17
|
+
resp.compact
|
18
|
+
detected_raw_targets = []
|
19
|
+
target_count.times { detected_raw_targets << format_raw_target_data(resp.shift(4)) }
|
20
|
+
detected_raw_targets
|
21
|
+
end
|
22
|
+
|
23
|
+
def tdat
|
24
|
+
request_frame_data(:tdat)
|
25
|
+
|
26
|
+
sleep 0.1
|
27
|
+
resp = read(16).unpack('a4LSssS')
|
28
|
+
return { dist: resp[2], speed: resp[3], angle: resp[4], mag: resp[5] } unless resp[1].zero?
|
29
|
+
end
|
30
|
+
|
31
|
+
def ddat
|
32
|
+
request_frame_data(:ddat)
|
33
|
+
|
34
|
+
read(14).unpack('a4LC6')
|
35
|
+
end
|
36
|
+
|
37
|
+
def config
|
38
|
+
puts formatted_grps(grps)
|
39
|
+
end
|
40
|
+
|
41
|
+
def formatted_parameter(param)
|
42
|
+
return unless PARAMETERS.include? param
|
43
|
+
|
44
|
+
param_data = PARAMETERS[param]
|
45
|
+
grps_data = grps
|
46
|
+
index = grps_data[param_data[:grps_index]]
|
47
|
+
param_data[:values][index]
|
48
|
+
end
|
49
|
+
|
50
|
+
# Get the radar parameter structure
|
51
|
+
def grps
|
52
|
+
command = ['GRPS', 0]
|
53
|
+
write command.pack('a4L')
|
54
|
+
check_response
|
55
|
+
read(50).unpack('a4LA19C8c2C4cCCCCSCC')
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def format_raw_target_data(array)
|
62
|
+
{ dist: array.shift, speed: array.shift, angle: array.shift, mag: array.shift }
|
63
|
+
end
|
64
|
+
|
65
|
+
def request_frame_data(type)
|
66
|
+
command = ['GNFD', 4, FRAME_DATA_TYPES[type]]
|
67
|
+
write command.pack('a4LL')
|
68
|
+
check_response
|
69
|
+
end
|
70
|
+
|
71
|
+
def formatted_grps(data)
|
72
|
+
output = "\n"
|
73
|
+
RADAR_PARAMETERS.each do |param|
|
74
|
+
param = param[1]
|
75
|
+
value = param.values.empty? ? data[param.grps_index] : param.values[data[param.grps_index].to_i]
|
76
|
+
output << "#{param.name}: #{value}#{param.units}\n"
|
77
|
+
end
|
78
|
+
output
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,390 @@
|
|
1
|
+
module RfBeam
|
2
|
+
module KLD7
|
3
|
+
|
4
|
+
# -----------------
|
5
|
+
# Base Frequency, 0 = low, 1 = middle (default), 2 = high
|
6
|
+
# -----------------
|
7
|
+
def base_frequency
|
8
|
+
query_parameter RADAR_PARAMETERS[:base_frequency].grps_index
|
9
|
+
end
|
10
|
+
alias rbfr base_frequency
|
11
|
+
|
12
|
+
def base_frequency=(frequency = 1)
|
13
|
+
value = case frequency
|
14
|
+
when 0, :low, 'low'
|
15
|
+
0
|
16
|
+
when 1, :middle, 'middle'
|
17
|
+
1
|
18
|
+
when 2, :high, 'high'
|
19
|
+
2
|
20
|
+
else
|
21
|
+
raise ArgumentError, "Invalid arg: '#{frequency}'"
|
22
|
+
end
|
23
|
+
set_parameter(:rbfr, value, :uint32)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias set_base_frequency base_frequency=
|
27
|
+
alias rbfr= base_frequency=
|
28
|
+
|
29
|
+
# -----------------
|
30
|
+
# Maximum Speed, 0 = 12.5km/h, 1 = 25km/h (default), 2 = 50km/h, 3 = 100km/h
|
31
|
+
# -----------------
|
32
|
+
def max_speed
|
33
|
+
query_parameter(RADAR_PARAMETERS[:max_speed].grps_index)
|
34
|
+
end
|
35
|
+
|
36
|
+
def max_speed=(speed = 1)
|
37
|
+
raise ArgumentError, "Invalid arg: '#{speed}'" unless (0..3).include?(speed)
|
38
|
+
raise ArgumentError, "Expected an Integer" unless speed.is_a?(Integer)
|
39
|
+
|
40
|
+
set_parameter :rspi, speed, :uint32
|
41
|
+
end
|
42
|
+
|
43
|
+
alias set_max_speed max_speed=
|
44
|
+
alias rspi max_speed=
|
45
|
+
|
46
|
+
# -----------------
|
47
|
+
# Maximum Range, 0 = 5m, 1 = 10m (default), 2 = 30m, 3 = 100m
|
48
|
+
# -----------------
|
49
|
+
def max_range
|
50
|
+
query_parameter(RADAR_PARAMETERS[:max_range].grps_index)
|
51
|
+
end
|
52
|
+
|
53
|
+
def max_range=(range = 1)
|
54
|
+
raise ArgumentError, "Invalid arg: '#{range}'" unless (0..3).include?(range)
|
55
|
+
|
56
|
+
set_parameter :rrai, range, :uint32
|
57
|
+
end
|
58
|
+
|
59
|
+
alias rrai= max_range=
|
60
|
+
alias set_max_range max_range=
|
61
|
+
|
62
|
+
# -----------------
|
63
|
+
# Threshold Offset, 10 - 60db, (default = 30)
|
64
|
+
# -----------------
|
65
|
+
def threshold_offset
|
66
|
+
query_parameter RADAR_PARAMETERS[:threshold_offset].grps_index
|
67
|
+
end
|
68
|
+
|
69
|
+
def threshold_offset=(offset = 30)
|
70
|
+
raise ArgumentError, "Invalid arg: '#{offset}'" unless (10..60).include?(offset)
|
71
|
+
raise ArgumentError, "Expected an Integer" unless range.is_a?(Integer)
|
72
|
+
|
73
|
+
set_parameter :thof, offset, :uint32
|
74
|
+
end
|
75
|
+
|
76
|
+
alias thof= threshold_offset=
|
77
|
+
alias set_threshold_offset threshold_offset=
|
78
|
+
|
79
|
+
# -----------------
|
80
|
+
# Tracking filter type, 0 = Standard (Default), 1 = Fast Tracking, 2 = Long visibility
|
81
|
+
# -----------------
|
82
|
+
def tracking_filter
|
83
|
+
query_parameter RADAR_PARAMETERS[:tracking_filter].grps_index
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_tracking_filter(type = 0)
|
87
|
+
raise ArgumentError, "Invalid arg: '#{type}'" unless (0..2).include?(type)
|
88
|
+
raise ArgumentError, "Expected an Integer" unless type.is_a?(Integer)
|
89
|
+
|
90
|
+
set_parameter :trft, type, :uint32
|
91
|
+
end
|
92
|
+
alias trtf set_tracking_filter
|
93
|
+
|
94
|
+
# -----------------
|
95
|
+
# Vibration suppression, 0 - 16, 0 = No Suppression, 16 = High Suppression, default = 2
|
96
|
+
# -----------------
|
97
|
+
def vibration_suppression
|
98
|
+
query_parameter RADAR_PARAMETERS[:vibration_suppression].grps_index
|
99
|
+
end
|
100
|
+
|
101
|
+
def vibration_suppression=(value = 2)
|
102
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..16).include?(value)
|
103
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
104
|
+
|
105
|
+
set_parameter :visu, value, :uint32
|
106
|
+
end
|
107
|
+
alias visu= vibration_suppression=
|
108
|
+
alias set_vibration_suppression vibration_suppression=
|
109
|
+
|
110
|
+
# -----------------
|
111
|
+
# Minimum Detection distance, 0 - 100% of Range setting, default = 0
|
112
|
+
# -----------------
|
113
|
+
def min_detection_distance
|
114
|
+
query_parameter RADAR_PARAMETERS[:min_detection_distance].grps_index
|
115
|
+
end
|
116
|
+
|
117
|
+
def min_detection_distance=(value = 0)
|
118
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..100).include?(value)
|
119
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
120
|
+
|
121
|
+
set_parameter :mira, value, :uint32
|
122
|
+
end
|
123
|
+
alias mira= min_detection_distance=
|
124
|
+
alias set_min_detection_distance min_detection_distance=
|
125
|
+
|
126
|
+
# -----------------
|
127
|
+
# Maximum Detection distance, 0 - 100% of Range setting, default = 50
|
128
|
+
# -----------------
|
129
|
+
def max_detection_distance
|
130
|
+
query_parameter RADAR_PARAMETERS[:min_detection_distance].grps_index
|
131
|
+
end
|
132
|
+
|
133
|
+
def max_detection_distance=(value = 50)
|
134
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..100).include?(value)
|
135
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
136
|
+
|
137
|
+
set_parameter :mara, value, :uint32
|
138
|
+
end
|
139
|
+
alias mara= max_detection_distance=
|
140
|
+
alias set_max_detection_distance max_detection_distance=
|
141
|
+
|
142
|
+
# -----------------
|
143
|
+
# Minimum Detection Angle, -90° - 90°, default = -90
|
144
|
+
# -----------------
|
145
|
+
def min_detection_angle
|
146
|
+
query_parameter RADAR_PARAMETERS[:min_detection_angle].grps_index
|
147
|
+
end
|
148
|
+
|
149
|
+
def min_detection_angle=(angle = -90)
|
150
|
+
raise ArgumentError, "Invalid arg: '#{angle}'" unless (-90..90).include?(angle)
|
151
|
+
raise ArgumentError, "Expected an Integer" unless angle.is_a?(Integer)
|
152
|
+
|
153
|
+
set_parameter :mian, angle, :int32
|
154
|
+
end
|
155
|
+
alias mian= min_detection_angle=
|
156
|
+
alias set_min_detection_angle min_detection_angle=
|
157
|
+
|
158
|
+
# -----------------
|
159
|
+
# Maximum Detection Angle, -90° - 90°, default = 90
|
160
|
+
# -----------------
|
161
|
+
def max_detection_angleq
|
162
|
+
query_parameter RADAR_PARAMETERS[:max_detection_angle].grps_index
|
163
|
+
end
|
164
|
+
|
165
|
+
def max_detection_angle=(angle = 90)
|
166
|
+
raise ArgumentError, "Invalid arg: '#{angle}'" unless (-90..90).include?(angle)
|
167
|
+
raise ArgumentError, "Expected an Integer" unless angle.is_a?(Integer)
|
168
|
+
|
169
|
+
set_parameter :maan, angle, :int32
|
170
|
+
end
|
171
|
+
alias maan= max_detection_angle=
|
172
|
+
alias set_max_detection_angle max_detection_angle=
|
173
|
+
|
174
|
+
# -----------------
|
175
|
+
# Minimum Detection Speed, 0 - 100% of Speed setting, default = 0
|
176
|
+
# -----------------
|
177
|
+
def min_detection_speed
|
178
|
+
query_parameter RADAR_PARAMETERS[:min_detection_angle].grps_index
|
179
|
+
end
|
180
|
+
|
181
|
+
def min_detection_speed=(speed = 0)
|
182
|
+
raise ArgumentError, "Invalid arg: '#{speed}'" unless (0..100).include?(speed)
|
183
|
+
raise ArgumentError, "Expected an Integer" unless speed.is_a?(Integer)
|
184
|
+
|
185
|
+
set_parameter :misp, speed, :uint32
|
186
|
+
end
|
187
|
+
alias misp= min_detection_speed=
|
188
|
+
alias set_min_detection_speed min_detection_speed=
|
189
|
+
|
190
|
+
# -----------------
|
191
|
+
# Maximum Detection Speed, 0 - 100% of Speed setting, default = 100
|
192
|
+
# -----------------
|
193
|
+
def max_detection_speed
|
194
|
+
query_parameter RADAR_PARAMETERS[:max_detection_speed].grps_index
|
195
|
+
end
|
196
|
+
|
197
|
+
def max_detection_speed=(speed = 100)
|
198
|
+
raise ArgumentError, "Invalid arg: '#{speed}'" unless (0..100).include?(speed)
|
199
|
+
raise ArgumentError, "Expected an Integer" unless speed.is_a?(Integer)
|
200
|
+
|
201
|
+
set_parameter :masp, speed, :uint32
|
202
|
+
end
|
203
|
+
alias masp= max_detection_speed=
|
204
|
+
alias set_max_detection_speed max_detection_speed=
|
205
|
+
|
206
|
+
# -----------------
|
207
|
+
# Detection Direction, 0 = Receding, 1 = Approaching, 2 = Both (default)
|
208
|
+
# -----------------
|
209
|
+
def detection_direction
|
210
|
+
query_parameter RADAR_PARAMETERS[:detection_direction].grps_index
|
211
|
+
end
|
212
|
+
|
213
|
+
def detection_direction=(direction = 2)
|
214
|
+
raise ArgumentError, "Invalid arg: '#{direction}'" unless (0..2).include?(direction)
|
215
|
+
raise ArgumentError, "Expected an Integer" unless direction.is_a?(Integer)
|
216
|
+
|
217
|
+
set_parameter :dedi, direction, :uint32
|
218
|
+
end
|
219
|
+
alias dedi= detection_direction=
|
220
|
+
alias set_detection_direction detection_direction=
|
221
|
+
|
222
|
+
# -----------------
|
223
|
+
# Range Threshold, 0 - 100% of Range setting, default = 10
|
224
|
+
# -----------------
|
225
|
+
def range_threshold
|
226
|
+
query_parameter RADAR_PARAMETERS[:range_threshold].grps_index
|
227
|
+
end
|
228
|
+
|
229
|
+
def range_threshold=(value = 10)
|
230
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..100).include?(value)
|
231
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
232
|
+
|
233
|
+
set_parameter :rath, value, :uint32
|
234
|
+
end
|
235
|
+
alias rath= range_threshold=
|
236
|
+
alias set_range_threshold range_threshold=
|
237
|
+
|
238
|
+
# -----------------
|
239
|
+
# Angle Threshold, -90° to 90°, default = 0
|
240
|
+
# -----------------
|
241
|
+
def angle_threshold
|
242
|
+
query_parameter RADAR_PARAMETERS[:angle_threshold].grps_index
|
243
|
+
end
|
244
|
+
|
245
|
+
def angle_threshold=(value = 0)
|
246
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (-90..90).include?(value)
|
247
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
248
|
+
|
249
|
+
set_parameter :anth, value, :int32
|
250
|
+
end
|
251
|
+
alias anth= angle_threshold=
|
252
|
+
alias set_angle_threshold angle_threshold=
|
253
|
+
|
254
|
+
# -----------------
|
255
|
+
# Speed Threshold, 0 - 100% of speed setting, default = 50
|
256
|
+
# -----------------
|
257
|
+
def speed_threshold
|
258
|
+
query_parameter RADAR_PARAMETERS[:speed_threshold].grps_index
|
259
|
+
end
|
260
|
+
|
261
|
+
def speed_threshold=(value = 50)
|
262
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..100).include?(value)
|
263
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
264
|
+
|
265
|
+
set_parameter :spth, value, :uint32
|
266
|
+
end
|
267
|
+
alias spth= angle_threshold=
|
268
|
+
alias set_speed_threshold angle_threshold=
|
269
|
+
|
270
|
+
# -----------------
|
271
|
+
# Digital output 1, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 0
|
272
|
+
# -----------------
|
273
|
+
def digital_output1
|
274
|
+
query_parameter RADAR_PARAMETERS[:digital_output1]grps_index
|
275
|
+
end
|
276
|
+
|
277
|
+
def digital_output1=(value = 0)
|
278
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..4).include?(value)
|
279
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
280
|
+
|
281
|
+
set_parameter :dig1, value, :uint32
|
282
|
+
end
|
283
|
+
alias dig1= digital_output1=
|
284
|
+
alias set_digital_output1 digital_output1=
|
285
|
+
|
286
|
+
# -----------------
|
287
|
+
# Digital output 2, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 1
|
288
|
+
# -----------------
|
289
|
+
def digital_output2
|
290
|
+
query_parameter RADAR_PARAMETERS[:digital_output2]grps_index
|
291
|
+
end
|
292
|
+
|
293
|
+
def digital_output2=(value = 1)
|
294
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..4).include?(value)
|
295
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
296
|
+
|
297
|
+
set_parameter :dig2, value, :uint32
|
298
|
+
end
|
299
|
+
alias dig2= set_digital_output2=
|
300
|
+
alias set_digital_output2 digital_output2=
|
301
|
+
|
302
|
+
# -----------------
|
303
|
+
# Digital output 3, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 2
|
304
|
+
# -----------------
|
305
|
+
def digital_output3
|
306
|
+
query_parameter RADAR_PARAMETERS[:digital_output3].grps_index
|
307
|
+
end
|
308
|
+
|
309
|
+
def digital_output3=(value = 2)
|
310
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..4).include?(value)
|
311
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
312
|
+
|
313
|
+
set_parameter :dig3, value, :uint32
|
314
|
+
end
|
315
|
+
alias dig3= digital_output3=
|
316
|
+
alias set_digital_output3 digital_output3=
|
317
|
+
|
318
|
+
# -----------------
|
319
|
+
# Hold Time, 1 - 7200s, default = 1
|
320
|
+
# -----------------
|
321
|
+
def hold_time
|
322
|
+
query_parameter RADAR_PARAMETERS[:hold_time].grps_index
|
323
|
+
end
|
324
|
+
|
325
|
+
def hold_time=(time = 1)
|
326
|
+
raise ArgumentError, "Invalid arg: '#{time}'" unless (1..7200).include?(time)
|
327
|
+
raise ArgumentError, "Expected an Integer" unless time.is_a?(Integer)
|
328
|
+
|
329
|
+
set_parameter :hold, time, :uint32
|
330
|
+
end
|
331
|
+
alias hold= hold_time=
|
332
|
+
alias set_hold_time hold_time=
|
333
|
+
|
334
|
+
# -----------------
|
335
|
+
# Micro Detection retrigger, 0 = Off (default), 1 = Retrigger
|
336
|
+
# -----------------
|
337
|
+
def micro_detection_retrigger
|
338
|
+
query_parameter RADAR_PARAMETERS[:set_micro_detection_retrigger].grps_index
|
339
|
+
end
|
340
|
+
|
341
|
+
def micro_detection_retrigger=(value = 0)
|
342
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..1).include?(value)
|
343
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
344
|
+
|
345
|
+
set_parameter :mide, value, :uint32
|
346
|
+
end
|
347
|
+
alias mide= micro_detection_retrigger=
|
348
|
+
alias set_micro_detection_retrigger micro_detection_retrigger=
|
349
|
+
|
350
|
+
# -----------------
|
351
|
+
# Micro Detection sensitivity, 0 - 9, 0 = Min, 9 = Max, default = 4
|
352
|
+
# -----------------
|
353
|
+
def micro_detection_sensitivity
|
354
|
+
query_parameter RADAR_PARAMETERS[:micro_detection_sensitivity].grps_index
|
355
|
+
end
|
356
|
+
|
357
|
+
def micro_detection_sensitivity=(value = 4)
|
358
|
+
raise ArgumentError, "Invalid arg: '#{value}'" unless (0..9).include?(value)
|
359
|
+
raise ArgumentError, "Expected an Integer" unless value.is_a?(Integer)
|
360
|
+
|
361
|
+
set_parameter :mids, value, :uint32
|
362
|
+
end
|
363
|
+
alias mids= micro_detection_sensitivty=
|
364
|
+
alias set_micro_detection_sensitivity micro_detection_sensitivty=
|
365
|
+
|
366
|
+
private
|
367
|
+
|
368
|
+
def query_parameter(index)
|
369
|
+
data = grps
|
370
|
+
data[index]
|
371
|
+
end
|
372
|
+
|
373
|
+
def set_parameter(header, value, return_type = :uint32)
|
374
|
+
return_type =
|
375
|
+
case return_type
|
376
|
+
when :uint32
|
377
|
+
'L'
|
378
|
+
when :int32
|
379
|
+
'l'
|
380
|
+
when :uint32
|
381
|
+
'S'
|
382
|
+
else
|
383
|
+
'L'
|
384
|
+
end
|
385
|
+
command = [header.upcase.to_s, 4, value]
|
386
|
+
write command.pack("a4L#{return_type}")
|
387
|
+
check_response
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
data/lib/rfbeam/version.rb
CHANGED
data/lib/rfbeam.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
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_relative 'rfbeam/version'
|
8
8
|
|
data/rfbeam.gemspec
CHANGED
@@ -8,11 +8,11 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['Rob Carruthers']
|
9
9
|
spec.email = ['robc@hey.com']
|
10
10
|
|
11
|
-
spec.summary = 'Ruby
|
12
|
-
spec.description = 'Currently only
|
11
|
+
spec.summary = 'Ruby API and CLI for RFBeam doplar radar modules'
|
12
|
+
spec.description = 'Currently only tested with K-LD7 on MacOS & Raspian (bullseye)'
|
13
13
|
spec.homepage = 'https://gitlab.com/robcarruthers/rfbeam'
|
14
14
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = '>= 2.
|
15
|
+
spec.required_ruby_version = '>= 3.2.1'
|
16
16
|
|
17
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
18
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfbeam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Carruthers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.2.1
|
55
|
-
description: Currently only
|
55
|
+
description: Currently only tested with K-LD7 on MacOS & Raspian (bullseye)
|
56
56
|
email:
|
57
57
|
- robc@hey.com
|
58
58
|
executables: []
|
@@ -69,10 +69,10 @@ files:
|
|
69
69
|
- README.md
|
70
70
|
- Rakefile
|
71
71
|
- lib/rfbeam.rb
|
72
|
-
- lib/rfbeam/kld7/app_commands.rb
|
73
|
-
- lib/rfbeam/kld7/app_messages.rb
|
74
|
-
- lib/rfbeam/kld7/connection.rb
|
75
72
|
- lib/rfbeam/kld7/constants.rb
|
73
|
+
- lib/rfbeam/kld7/radar_messages.rb
|
74
|
+
- lib/rfbeam/kld7/radar_parameters.rb
|
75
|
+
- lib/rfbeam/kld7/serial_connection.rb
|
76
76
|
- lib/rfbeam/version.rb
|
77
77
|
- node_modules/.bin/prettier
|
78
78
|
- node_modules/.yarn-integrity
|
@@ -178,15 +178,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
178
|
requirements:
|
179
179
|
- - ">="
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version: 2.
|
181
|
+
version: 3.2.1
|
182
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
184
|
- - ">="
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
rubygems_version: 3.
|
188
|
+
rubygems_version: 3.4.9
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
|
-
summary: Ruby
|
191
|
+
summary: Ruby API and CLI for RFBeam doplar radar modules
|
192
192
|
test_files: []
|
@@ -1,230 +0,0 @@
|
|
1
|
-
module RfBeam
|
2
|
-
module KLD7
|
3
|
-
|
4
|
-
def detection?
|
5
|
-
data = ddat
|
6
|
-
(data[2] == 1)
|
7
|
-
end
|
8
|
-
|
9
|
-
def config
|
10
|
-
puts formatted_grps(grps)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Get the radar parameter structure
|
14
|
-
def grps
|
15
|
-
command = ['GRPS', 0]
|
16
|
-
write command.pack('a4L')
|
17
|
-
check_response
|
18
|
-
read(50).unpack('a4LA19C8c2C4cCCCCSCC')
|
19
|
-
end
|
20
|
-
|
21
|
-
# Base Frequency, 0 = low, 1 = middle (default), 2 = high
|
22
|
-
def set_base_frequency(frequency = 1)
|
23
|
-
set_parameter(:rbfr, frequency, :uint8)
|
24
|
-
end
|
25
|
-
alias_method :rbfr, :set_base_frequency
|
26
|
-
|
27
|
-
# Maximum Speed, 0 = 12.5km/h, 1 = 25km/h (default), 2 = 50km/h, 3 = 100km/h
|
28
|
-
def set_max_speed(speed = 1)
|
29
|
-
set_parameter :rspi, speed, :uint8
|
30
|
-
end
|
31
|
-
alias_method :rspi, :set_max_speed
|
32
|
-
|
33
|
-
# Maximum Range, 0 = 5m, 1 = 10m (default), 2 = 30m, 3 = 100m
|
34
|
-
def set_max_range(range = 1)
|
35
|
-
set_parameter :rrai, range, :uint8
|
36
|
-
end
|
37
|
-
alias_method :rrai, :set_max_range
|
38
|
-
|
39
|
-
# Threshold Offset, 10 - 60db, (default = 30)
|
40
|
-
def set_threshold_offset(offset = 30)
|
41
|
-
range = 10..60
|
42
|
-
return false unless range.include?(offset)
|
43
|
-
|
44
|
-
set_parameter :thof, offset, :uint8
|
45
|
-
end
|
46
|
-
alias_method :thof, :set_threshold_offset
|
47
|
-
|
48
|
-
# Tracking filter type, 0 = Standard (Default), 1 = Fast Tracking, 2 = Long visibility
|
49
|
-
def set_tracking_filter(type = 0)
|
50
|
-
set_parameter :trft, type, :uint8
|
51
|
-
end
|
52
|
-
alias_method :trtf, :set_tracking_filter
|
53
|
-
|
54
|
-
# Vibration suppression, 0 - 16, 0 = No Suppression, 16 = High Suppression, default = 2
|
55
|
-
def set_vibration_suppression(value = 2)
|
56
|
-
set_parameter :visu, value, :uint8
|
57
|
-
end
|
58
|
-
alias_method :visu, :set_vibration_suppression
|
59
|
-
|
60
|
-
# Minimum Detection distance, 0 - 100% of Range setting, default = 0
|
61
|
-
def set_min_detection_distance(value = 0)
|
62
|
-
set_parameter :mira, value, :uint8
|
63
|
-
end
|
64
|
-
alias_method :mira, :set_min_detection_distance
|
65
|
-
|
66
|
-
# Maximum Detection distance, 0 - 100% of Range setting, default = 50
|
67
|
-
def set_max_detection_distance(value = 50)
|
68
|
-
set_parameter :mara, value, :uint8
|
69
|
-
end
|
70
|
-
alias_method :mara, :set_max_detection_distance
|
71
|
-
|
72
|
-
# Minimum Detection Angle, -90° - 90°, default = -90
|
73
|
-
def set_min_detection_angle(angle = -90)
|
74
|
-
set_parameter :mian, angle, :int8
|
75
|
-
end
|
76
|
-
alias_method :mian, :set_min_detection_distance
|
77
|
-
|
78
|
-
# Maximum Detection Angle, -90° - 90°, default = 90
|
79
|
-
def set_min_detection_angle(angle = 90)
|
80
|
-
set_parameter :maan, angle, :int8
|
81
|
-
end
|
82
|
-
alias_method :maan, :set_min_detection_angle
|
83
|
-
|
84
|
-
# Minimum Detection Speed, 0 - 100% of Speed setting, default = 0
|
85
|
-
def set_min_detection_speed(speed = 0)
|
86
|
-
set_parameter :misp, speed, :uint8
|
87
|
-
end
|
88
|
-
alias_method :misp, :set_min_detection_speed
|
89
|
-
|
90
|
-
# Maximum Detection Speed, 0 - 100% of Speed setting, default = 100
|
91
|
-
def set_max_detection_speed(speed = 100)
|
92
|
-
set_parameter :masp, speed, :uint8
|
93
|
-
end
|
94
|
-
alias_method :masp, :set_max_detection_speed
|
95
|
-
|
96
|
-
# Detection Direction, 0 = Receding, 1 = Approaching, 2 = Both (default)
|
97
|
-
def set_detection_direction(direction = 2)
|
98
|
-
set_parameter :dedi, direction, :uint8
|
99
|
-
end
|
100
|
-
alias_method :dedi, :set_detection_direction
|
101
|
-
|
102
|
-
# Range Threshold, 0 - 100% of Range setting, default = 10
|
103
|
-
def set_range_threshold(value = 10)
|
104
|
-
range = 0..100
|
105
|
-
return false unless range.include?(value)
|
106
|
-
|
107
|
-
set_parameter :rath, value, :uint8
|
108
|
-
end
|
109
|
-
alias_method :rath, :set_range_threshold
|
110
|
-
|
111
|
-
# Angle Threshold, -90° to 90°, default = 0
|
112
|
-
def set_range_threshold(value = 0)
|
113
|
-
range = -90..90
|
114
|
-
return false unless range.include?(value)
|
115
|
-
|
116
|
-
set_parameter :anth, value, :int8
|
117
|
-
end
|
118
|
-
alias_method :anth, :set_range_threshold
|
119
|
-
|
120
|
-
# Speed Threshold, 0 - 100% of speed setting, default = 50
|
121
|
-
def set_angle_threshold(value = 50)
|
122
|
-
range = 0..100
|
123
|
-
return false unless range.include?(value)
|
124
|
-
|
125
|
-
set_parameter :spth, value, :uint8
|
126
|
-
end
|
127
|
-
alias_method :spth, :set_angle_threshold
|
128
|
-
|
129
|
-
# Digital output 1, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 0
|
130
|
-
def set_dio_1(value = 0)
|
131
|
-
range = 0..4
|
132
|
-
return false unless range.include?(value)
|
133
|
-
|
134
|
-
set_parameter :dig1, value, :uint8
|
135
|
-
end
|
136
|
-
alias_method :dig1, :set_dio_1
|
137
|
-
|
138
|
-
# Digital output 2, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 1
|
139
|
-
def set_dio_2(value = 1)
|
140
|
-
range = 0..4
|
141
|
-
return false unless range.include?(value)
|
142
|
-
|
143
|
-
set_parameter :dig2, value, :uint8
|
144
|
-
end
|
145
|
-
alias_method :dig2, :set_dio_2
|
146
|
-
|
147
|
-
# Digital output 3, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 2
|
148
|
-
def set_dio_3(value = 2)
|
149
|
-
range = 0..4
|
150
|
-
return false unless range.include?(value)
|
151
|
-
|
152
|
-
set_parameter :dig3, value, :uint8
|
153
|
-
end
|
154
|
-
alias_method :dig3, :set_dio_3
|
155
|
-
|
156
|
-
# Hold Time, 1 - 7200s, default = 1
|
157
|
-
def set_hold_time(time = 1)
|
158
|
-
range = 1..7200
|
159
|
-
return false unless range.include?(time)
|
160
|
-
|
161
|
-
set_parameter :hold, time, :uint16
|
162
|
-
end
|
163
|
-
alias_method :hold, :set_hold_time
|
164
|
-
|
165
|
-
# Micro Detection retrigger, 0 = Off (default), 1 = Retrigger
|
166
|
-
def set_micro_detection_retrigger(value = 0)
|
167
|
-
return false unless (value == 0 || value == 1)
|
168
|
-
|
169
|
-
set_parameter :mide, value, :uint8
|
170
|
-
end
|
171
|
-
alias_method :mide, :set_micro_detection_retrigger
|
172
|
-
|
173
|
-
# Micro Detection sensitivity, 0 - 9, 0 = Min, 9 = Max, default = 4
|
174
|
-
def set_micro_detection_sensitivty(value = 4)
|
175
|
-
range = 0..9
|
176
|
-
return false unless range.include?(value)
|
177
|
-
|
178
|
-
set_parameter :mids, value, :uint8
|
179
|
-
end
|
180
|
-
alias_method :mids, :set_micro_detection_sensitivty
|
181
|
-
|
182
|
-
private
|
183
|
-
|
184
|
-
def set_parameter(header, value, return_type = :uint8)
|
185
|
-
return_type =
|
186
|
-
case return_type
|
187
|
-
when :uint8
|
188
|
-
'L'
|
189
|
-
when :int8
|
190
|
-
'c'
|
191
|
-
when :uint16
|
192
|
-
'S'
|
193
|
-
else
|
194
|
-
'L'
|
195
|
-
end
|
196
|
-
command = [header.upcase.to_s, 4, value]
|
197
|
-
write command.pack("a4L#{return_type}")
|
198
|
-
check_response
|
199
|
-
end
|
200
|
-
|
201
|
-
def formatted_grps(data)
|
202
|
-
output = "\n"
|
203
|
-
output << "Software Version: #{data[2]}\n"
|
204
|
-
output << "Base Frequency: #{PARAMETER_STRUCTURE[:base_frequency][data[3]]}\n"
|
205
|
-
output << "Max Speed: #{PARAMETER_STRUCTURE[:max_speed][data[4]]}\n"
|
206
|
-
output << "Max Range: #{PARAMETER_STRUCTURE[:max_range][data[5]]}\n"
|
207
|
-
output << "Threshold offset: #{data[6]}db\n"
|
208
|
-
output << "Tracking Filter Type: #{PARAMETER_STRUCTURE[:tracking_filter_type][data[7]]}\n"
|
209
|
-
output << "Vibration Suppression: #{data[8]} , (#{PARAMETER_STRUCTURE[:vibration_suppression]})\n"
|
210
|
-
output << "Minimum Detection Distance: #{data[9]} , (#{PARAMETER_STRUCTURE[:min_detection_distance]})\n"
|
211
|
-
output << "Maximum Detection Distance: #{data[10]} , (#{PARAMETER_STRUCTURE[:max_detection_distance]})\n"
|
212
|
-
output << "Minimum Detection Angle: #{data[11]}° , (#{PARAMETER_STRUCTURE[:min_detection_angle]})\n"
|
213
|
-
output << "Maximum Detection Angle: #{data[12]}° , (#{PARAMETER_STRUCTURE[:max_detection_angle]})\n"
|
214
|
-
output << "Minimum Detection Speed: #{data[13]} , (#{PARAMETER_STRUCTURE[:min_detection_speed]})\n"
|
215
|
-
output << "Maximum Detection Speed: #{data[14]} , (#{PARAMETER_STRUCTURE[:max_detection_speed]})\n"
|
216
|
-
output << "Detection Direction: #{PARAMETER_STRUCTURE[:detection_direction][data[15]]}\n"
|
217
|
-
output << "Range Threshold: #{data[16]}%, (#{PARAMETER_STRUCTURE[:range_threshold]})\n"
|
218
|
-
output << "Angle Threshold: #{data[17]}°, (#{PARAMETER_STRUCTURE[:angle_threshold]})\n"
|
219
|
-
output << "Speed Threshold: #{data[18]}%, (#{PARAMETER_STRUCTURE[:speed_threshold]})\n"
|
220
|
-
output << "Digital output 1: #{PARAMETER_STRUCTURE[:digital_output_1][data[19]]}\n"
|
221
|
-
output << "Digital output 2: #{PARAMETER_STRUCTURE[:digital_output_2][data[20]]}\n"
|
222
|
-
output << "Digital output 3: #{PARAMETER_STRUCTURE[:digital_output_3][data[21]]}\n"
|
223
|
-
output << "Hold time: #{data[22]}sec\n"
|
224
|
-
output << "Micro Detection Retrigger: #{PARAMETER_STRUCTURE[:micro_detection_trigger][data[23]]}\n"
|
225
|
-
output << "Micro Detection Sensitivity: #{data[24]} (#{PARAMETER_STRUCTURE[:micro_detection_sensitivity]})"
|
226
|
-
|
227
|
-
output
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module RfBeam
|
2
|
-
module KLD7
|
3
|
-
def detection?
|
4
|
-
data = ddat
|
5
|
-
(data[2] == 1)
|
6
|
-
end
|
7
|
-
|
8
|
-
def pdat
|
9
|
-
request_frame_data(:pdat)
|
10
|
-
sleep 0.1
|
11
|
-
|
12
|
-
resp = read(102).unpack('a4LSssSSssS')
|
13
|
-
resp
|
14
|
-
end
|
15
|
-
|
16
|
-
def tdat
|
17
|
-
request_frame_data(:tdat)
|
18
|
-
|
19
|
-
sleep 0.1
|
20
|
-
resp = read(16).unpack('a4LSssS')
|
21
|
-
return { dist: resp[2], speed: resp[3], angle: resp[4], mag: resp[5] } unless resp[1].zero?
|
22
|
-
end
|
23
|
-
|
24
|
-
def ddat
|
25
|
-
request_frame_data(:ddat)
|
26
|
-
|
27
|
-
resp = read(14).unpack('a4LC6')
|
28
|
-
return resp
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def request_frame_data(type)
|
34
|
-
command = ['GNFD', 4, FRAME_DATA_TYPES[type]]
|
35
|
-
write command.pack('a4LL')
|
36
|
-
check_response
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|