rsmp 0.1.11 → 0.1.21
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/.gitignore +1 -0
- data/Gemfile.lock +50 -52
- data/README.md +7 -1
- data/config/site.yaml +2 -2
- data/config/tlc.yaml +44 -0
- data/documentation/classes_and_modules.md +65 -0
- data/documentation/message_distribution.md +23 -0
- data/lib/rsmp.rb +10 -5
- data/lib/rsmp/archive.rb +16 -18
- data/lib/rsmp/cli.rb +15 -5
- data/lib/rsmp/collector.rb +90 -0
- data/lib/rsmp/component.rb +12 -2
- data/lib/rsmp/{site_base.rb → components.rb} +8 -6
- data/lib/rsmp/error.rb +10 -1
- data/lib/rsmp/listener.rb +33 -0
- data/lib/rsmp/logger.rb +3 -3
- data/lib/rsmp/{base.rb → logging.rb} +2 -2
- data/lib/rsmp/message.rb +25 -2
- data/lib/rsmp/node.rb +37 -12
- data/lib/rsmp/notifier.rb +24 -0
- data/lib/rsmp/proxy.rb +65 -45
- data/lib/rsmp/site.rb +12 -5
- data/lib/rsmp/site_proxy.rb +91 -65
- data/lib/rsmp/site_proxy_wait.rb +181 -0
- data/lib/rsmp/supervisor.rb +7 -6
- data/lib/rsmp/supervisor_proxy.rb +84 -32
- data/lib/rsmp/tlc.rb +885 -0
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp/wait.rb +7 -8
- data/rsmp.gemspec +10 -11
- metadata +40 -43
- data/lib/rsmp/probe.rb +0 -114
- data/lib/rsmp/probe_collection.rb +0 -28
- data/lib/rsmp/supervisor_base.rb +0 -10
data/lib/rsmp/version.rb
CHANGED
data/lib/rsmp/wait.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
# Helper for waiting for an Async condition using a block
|
2
|
-
|
3
1
|
module RSMP
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
module Wait
|
3
|
+
# wait for an async condition to signal, then yield to block
|
4
|
+
# if block returns true we're done. otherwise, wait again
|
5
|
+
def wait_for condition, timeout, &block
|
6
|
+
raise RuntimeError.new("Can't wait for condition because task is not running") unless @task.running?
|
7
|
+
@task.with_timeout(timeout) do
|
8
|
+
while @task.running? do
|
9
9
|
value = condition.wait
|
10
10
|
result = yield value
|
11
11
|
return result if result # return result of check, if not nil
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
16
15
|
end
|
17
16
|
end
|
data/rsmp.gemspec
CHANGED
@@ -41,18 +41,17 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
42
42
|
spec.require_paths = ["lib"]
|
43
43
|
|
44
|
-
spec.add_dependency "async", "~> 1.
|
45
|
-
spec.add_dependency "async-io", "~> 1.
|
44
|
+
spec.add_dependency "async", "~> 1.28.3"
|
45
|
+
spec.add_dependency "async-io", "~> 1.30.1"
|
46
46
|
spec.add_dependency "colorize", "~> 0.8.1"
|
47
|
-
spec.add_dependency "thor", "~> 0.
|
48
|
-
spec.add_dependency "json_schemer", "~> 0.2.
|
49
|
-
|
50
|
-
spec.add_development_dependency "bundler", "~> 2.
|
51
|
-
spec.add_development_dependency "rake", "~>
|
52
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
53
|
-
spec.add_development_dependency "rspec-expectations", "~> 3.
|
54
|
-
spec.add_development_dependency "rspec-with_params", "~> 0.2.0"
|
47
|
+
spec.add_dependency "thor", "~> 1.0.1"
|
48
|
+
spec.add_dependency "json_schemer", "~> 0.2.17"
|
49
|
+
|
50
|
+
spec.add_development_dependency "bundler", "~> 2.2.3"
|
51
|
+
spec.add_development_dependency "rake", "~> 13.0.1"
|
52
|
+
spec.add_development_dependency "rspec", "~> 3.9.0"
|
53
|
+
spec.add_development_dependency "rspec-expectations", "~> 3.9.1"
|
55
54
|
spec.add_development_dependency "timecop", "~> 0.9.1"
|
56
55
|
spec.add_development_dependency "cucumber", "~> 3.1.2"
|
57
|
-
spec.add_development_dependency "aruba", "~> 0.
|
56
|
+
spec.add_development_dependency "aruba", "~> 1.0.0"
|
58
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.28.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.28.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: async-io
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.30.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.30.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: colorize
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,98 +58,84 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 1.0.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 1.0.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json_schemer
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.2.
|
75
|
+
version: 0.2.17
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.2.
|
82
|
+
version: 0.2.17
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 2.2.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 2.2.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 13.0.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 13.0.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 3.9.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 3.9.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec-expectations
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 3.
|
131
|
+
version: 3.9.1
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 3.
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rspec-with_params
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 0.2.0
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 0.2.0
|
138
|
+
version: 3.9.1
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: timecop
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +170,14 @@ dependencies:
|
|
184
170
|
requirements:
|
185
171
|
- - "~>"
|
186
172
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.
|
173
|
+
version: 1.0.0
|
188
174
|
type: :development
|
189
175
|
prerelease: false
|
190
176
|
version_requirements: !ruby/object:Gem::Requirement
|
191
177
|
requirements:
|
192
178
|
- - "~>"
|
193
179
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.
|
180
|
+
version: 1.0.0
|
195
181
|
description: Easy RSMP site and supervisor communication.
|
196
182
|
email:
|
197
183
|
- zf0f@kk.dk
|
@@ -213,27 +199,32 @@ files:
|
|
213
199
|
- bin/setup
|
214
200
|
- config/site.yaml
|
215
201
|
- config/supervisor.yaml
|
202
|
+
- config/tlc.yaml
|
203
|
+
- documentation/classes_and_modules.md
|
204
|
+
- documentation/message_distribution.md
|
216
205
|
- exe/rsmp
|
217
206
|
- lib/rsmp.rb
|
218
207
|
- lib/rsmp/alarm.rb
|
219
208
|
- lib/rsmp/archive.rb
|
220
|
-
- lib/rsmp/base.rb
|
221
209
|
- lib/rsmp/cli.rb
|
210
|
+
- lib/rsmp/collector.rb
|
222
211
|
- lib/rsmp/component.rb
|
212
|
+
- lib/rsmp/components.rb
|
223
213
|
- lib/rsmp/error.rb
|
214
|
+
- lib/rsmp/listener.rb
|
224
215
|
- lib/rsmp/logger.rb
|
216
|
+
- lib/rsmp/logging.rb
|
225
217
|
- lib/rsmp/message.rb
|
226
218
|
- lib/rsmp/node.rb
|
227
|
-
- lib/rsmp/
|
228
|
-
- lib/rsmp/probe_collection.rb
|
219
|
+
- lib/rsmp/notifier.rb
|
229
220
|
- lib/rsmp/proxy.rb
|
230
221
|
- lib/rsmp/rsmp.rb
|
231
222
|
- lib/rsmp/site.rb
|
232
|
-
- lib/rsmp/site_base.rb
|
233
223
|
- lib/rsmp/site_proxy.rb
|
224
|
+
- lib/rsmp/site_proxy_wait.rb
|
234
225
|
- lib/rsmp/supervisor.rb
|
235
|
-
- lib/rsmp/supervisor_base.rb
|
236
226
|
- lib/rsmp/supervisor_proxy.rb
|
227
|
+
- lib/rsmp/tlc.rb
|
237
228
|
- lib/rsmp/version.rb
|
238
229
|
- lib/rsmp/wait.rb
|
239
230
|
- lib/rsmp_schema/schema/core/aggregated_status.json
|
@@ -286,7 +277,10 @@ files:
|
|
286
277
|
- lib/rsmp_schema/schema/tlc/commands/M0017.json
|
287
278
|
- lib/rsmp_schema/schema/tlc/commands/M0018.json
|
288
279
|
- lib/rsmp_schema/schema/tlc/commands/M0019.json
|
280
|
+
- lib/rsmp_schema/schema/tlc/commands/M0020.json
|
281
|
+
- lib/rsmp_schema/schema/tlc/commands/M0021.json
|
289
282
|
- lib/rsmp_schema/schema/tlc/commands/M0103.json
|
283
|
+
- lib/rsmp_schema/schema/tlc/commands/M0104.json
|
290
284
|
- lib/rsmp_schema/schema/tlc/commands/command_requests.json
|
291
285
|
- lib/rsmp_schema/schema/tlc/commands/command_responses.json
|
292
286
|
- lib/rsmp_schema/schema/tlc/commands/commands.json
|
@@ -319,10 +313,13 @@ files:
|
|
319
313
|
- lib/rsmp_schema/schema/tlc/statuses/S0027.json
|
320
314
|
- lib/rsmp_schema/schema/tlc/statuses/S0028.json
|
321
315
|
- lib/rsmp_schema/schema/tlc/statuses/S0029.json
|
316
|
+
- lib/rsmp_schema/schema/tlc/statuses/S0030.json
|
317
|
+
- lib/rsmp_schema/schema/tlc/statuses/S0031.json
|
322
318
|
- lib/rsmp_schema/schema/tlc/statuses/S0091.json
|
323
319
|
- lib/rsmp_schema/schema/tlc/statuses/S0092.json
|
324
320
|
- lib/rsmp_schema/schema/tlc/statuses/S0095.json
|
325
321
|
- lib/rsmp_schema/schema/tlc/statuses/S0096.json
|
322
|
+
- lib/rsmp_schema/schema/tlc/statuses/S0097.json
|
326
323
|
- lib/rsmp_schema/schema/tlc/statuses/S0201.json
|
327
324
|
- lib/rsmp_schema/schema/tlc/statuses/S0202.json
|
328
325
|
- lib/rsmp_schema/schema/tlc/statuses/S0203.json
|
@@ -342,7 +339,7 @@ metadata:
|
|
342
339
|
source_code_uri: https://github.com/rsmp-nordic/rsmp
|
343
340
|
changelog_uri: https://github.com/rsmp-nordic/rsmp/blob/master/CHANGELOG.md
|
344
341
|
bug_tracker_uri: https://github.com/rsmp-nordic/rsmp/issues
|
345
|
-
post_install_message:
|
342
|
+
post_install_message:
|
346
343
|
rdoc_options: []
|
347
344
|
require_paths:
|
348
345
|
- lib
|
@@ -357,8 +354,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
357
354
|
- !ruby/object:Gem::Version
|
358
355
|
version: '0'
|
359
356
|
requirements: []
|
360
|
-
rubygems_version: 3.
|
361
|
-
signing_key:
|
357
|
+
rubygems_version: 3.2.3
|
358
|
+
signing_key:
|
362
359
|
specification_version: 4
|
363
360
|
summary: RoadSide Message Protocol (RSMP) library.
|
364
361
|
test_files: []
|
data/lib/rsmp/probe.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
# A probe checks incoming messages and store matches
|
2
|
-
# Once it has collected what it needs, it triggers a condition variable
|
3
|
-
# and the client wakes up.
|
4
|
-
|
5
|
-
module RSMP
|
6
|
-
class Probe
|
7
|
-
attr_reader :condition, :items, :done
|
8
|
-
|
9
|
-
# block should send a message and return message just sent
|
10
|
-
def self.collect_response proxy, options={}, &block
|
11
|
-
from = proxy.archive.current_index
|
12
|
-
sent = yield
|
13
|
-
raise RuntimeError unless sent && sent[:message].is_a?(RSMP::Message)
|
14
|
-
item = proxy.archive.capture(options.merge(from: from+1, num: 1, with_message: true)) do |item|
|
15
|
-
["CommandResponse","StatusResponse","MessageNotAck"].include?(item[:message].type)
|
16
|
-
end
|
17
|
-
if item
|
18
|
-
item[:message]
|
19
|
-
else
|
20
|
-
nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
def initialize archive
|
26
|
-
raise ArgumentError.new("Archive expected") unless archive.is_a? Archive
|
27
|
-
@archive = archive
|
28
|
-
@items = []
|
29
|
-
@condition = Async::Notification.new
|
30
|
-
end
|
31
|
-
|
32
|
-
def capture task, options={}, &block
|
33
|
-
@options = options
|
34
|
-
@block = block
|
35
|
-
@num = options[:num]
|
36
|
-
|
37
|
-
if options[:earliest]
|
38
|
-
from = find_timestamp_index options[:earliest]
|
39
|
-
backscan from
|
40
|
-
elsif options[:from]
|
41
|
-
backscan options[:from]
|
42
|
-
end
|
43
|
-
|
44
|
-
# if backscan didn't find enough items, then
|
45
|
-
# insert ourself as probe and sleep until enough items are captured
|
46
|
-
if @items.size < @num
|
47
|
-
begin
|
48
|
-
@archive.probes.add self
|
49
|
-
task.with_timeout(options[:timeout]) do
|
50
|
-
@condition.wait
|
51
|
-
end
|
52
|
-
ensure
|
53
|
-
@archive.probes.remove self
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
if @num == 1
|
58
|
-
@items.first # if one item was requested, return item instead of array
|
59
|
-
else
|
60
|
-
@items[0..@num-1] # return array, but ensure we never return more than requested
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def find_timestamp_index earliest
|
65
|
-
(0..@archive.items.size).bsearch do |i| # use binary search to find item index
|
66
|
-
@archive.items[i][:timestamp] >= earliest
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def backscan from
|
71
|
-
from.upto(@archive.items.size-1) do |i|
|
72
|
-
return if process @archive.items[i]
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def reset
|
77
|
-
@items.clear
|
78
|
-
@done = false
|
79
|
-
end
|
80
|
-
|
81
|
-
def process item
|
82
|
-
raise ArgumentError unless item
|
83
|
-
return true if @done
|
84
|
-
if matches? item
|
85
|
-
@items << item
|
86
|
-
if @num && @items.size >= @num
|
87
|
-
@done = true
|
88
|
-
@condition.signal
|
89
|
-
return true
|
90
|
-
end
|
91
|
-
end
|
92
|
-
false
|
93
|
-
end
|
94
|
-
|
95
|
-
def matches? item
|
96
|
-
raise ArgumentError unless item
|
97
|
-
|
98
|
-
if @options[:type]
|
99
|
-
return false if item[:message] == nil
|
100
|
-
if @options[:type].is_a? Array
|
101
|
-
return false unless @options[:type].include? item[:message].type
|
102
|
-
else
|
103
|
-
return false unless item[:message].type == @options[:type]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
return if @options[:level] && item[:level] != @options[:level]
|
107
|
-
return false if @options[:with_message] && !(item[:direction] && item[:message])
|
108
|
-
if @block
|
109
|
-
return false if @block.call(item) == false
|
110
|
-
end
|
111
|
-
true
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Collection of probes
|
2
|
-
|
3
|
-
module RSMP
|
4
|
-
class ProbeCollection
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@probes = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def add probe
|
11
|
-
raise ArgumentError unless probe
|
12
|
-
@probes << probe
|
13
|
-
end
|
14
|
-
|
15
|
-
def remove probe
|
16
|
-
raise ArgumentError unless probe
|
17
|
-
@probes.delete probe
|
18
|
-
end
|
19
|
-
|
20
|
-
def process item
|
21
|
-
@probes.each { |probe| probe.process item }
|
22
|
-
end
|
23
|
-
|
24
|
-
def clear
|
25
|
-
@probes.each { |probe| probe.clear }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|