rsmp 0.41.0 → 0.42.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 +4 -4
- data/.github/workflows/{rspec.yaml → sus.yaml} +4 -4
- data/.rubocop.yml +10 -14
- data/Gemfile +3 -4
- data/Gemfile.lock +32 -37
- data/Rakefile +4 -3
- data/config/sus.rb +14 -0
- data/documentation/collecting_message.md +56 -41
- data/lib/rsmp/cli.rb +2 -1
- data/lib/rsmp/collect/collector.rb +3 -2
- data/lib/rsmp/command_list.rb +42 -0
- data/lib/rsmp/node/site/site.rb +2 -2
- data/lib/rsmp/proxy/modules/send.rb +8 -16
- data/lib/rsmp/proxy/site/modules/aggregated_status.rb +19 -8
- data/lib/rsmp/proxy/site/modules/commands.rb +22 -9
- data/lib/rsmp/proxy/site/modules/status.rb +74 -29
- data/lib/rsmp/proxy/supervisor/modules/aggregated_status.rb +3 -5
- data/lib/rsmp/proxy/supervisor/modules/alarms.rb +0 -6
- data/lib/rsmp/status_list.rb +44 -0
- data/lib/rsmp/tlc/modules/modes.rb +2 -2
- data/lib/rsmp/tlc/modules/system.rb +26 -12
- data/lib/rsmp/tlc/proxy/control.rb +16 -12
- data/lib/rsmp/tlc/proxy/detectors.rb +4 -6
- data/lib/rsmp/tlc/proxy/io.rb +18 -16
- data/lib/rsmp/tlc/proxy/plans.rb +21 -29
- data/lib/rsmp/tlc/proxy/status.rb +19 -26
- data/lib/rsmp/tlc/proxy/system.rb +4 -5
- data/lib/rsmp/tlc/traffic_controller_proxy.rb +2 -31
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp.rb +2 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 42d22cc3891135d1349e9c0c41aeaa16338f7ec77aaa6055de5da51899454332
|
|
4
|
+
data.tar.gz: '09df465e7c6bd906003b451a61f403f8ea472cf3b92c01b9b136d620b019d391'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4440c010e54e8a655f8424e2cc4c3a169fd1dcc992f838c8fc06894eebcccb12b5d0417b263b0de32fbffb66ebdccfb5b60940a3bd5122a9aa369921cd97e29
|
|
7
|
+
data.tar.gz: ae5f358894fe2ac1eded4d05be8e225959da65ba79251af378fb658f995569fd51b5f4dfe62bcbd9f0dabd560d07f42df56afe6ec6214fb44ea0f8cdaa9a3cfd
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# This workflow runs RSpec tests
|
|
2
2
|
|
|
3
|
-
name:
|
|
3
|
+
name: sus
|
|
4
4
|
on: [push]
|
|
5
5
|
jobs:
|
|
6
6
|
test:
|
|
7
|
-
timeout-minutes:
|
|
7
|
+
timeout-minutes: 3
|
|
8
8
|
strategy:
|
|
9
9
|
fail-fast: false
|
|
10
10
|
matrix:
|
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
- uses: actions/checkout@v4
|
|
15
15
|
- uses: ruby/setup-ruby@v1
|
|
16
16
|
with:
|
|
17
|
-
ruby-version:
|
|
17
|
+
ruby-version: 4.0
|
|
18
18
|
bundler-cache: true
|
|
19
|
-
- run: bundle exec
|
|
19
|
+
- run: bundle exec sus
|
|
20
20
|
|
data/.rubocop.yml
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
plugins:
|
|
2
|
-
- rubocop-rspec
|
|
3
|
-
- rubocop-rake
|
|
4
|
-
|
|
5
1
|
AllCops:
|
|
2
|
+
SuggestExtensions: false
|
|
6
3
|
NewCops: enable
|
|
7
4
|
TargetRubyVersion: 3.4
|
|
8
5
|
Exclude:
|
|
@@ -16,7 +13,7 @@ AllCops:
|
|
|
16
13
|
Layout/LineLength:
|
|
17
14
|
Max: 120
|
|
18
15
|
Exclude:
|
|
19
|
-
- '
|
|
16
|
+
- 'test/**/*'
|
|
20
17
|
|
|
21
18
|
# Allow some reasonable flexibility for domain-specific code
|
|
22
19
|
Metrics/MethodLength:
|
|
@@ -43,10 +40,15 @@ Metrics/ParameterLists:
|
|
|
43
40
|
# Allow some blocks to be longer for complex configurations and tests
|
|
44
41
|
Metrics/BlockLength:
|
|
45
42
|
Exclude:
|
|
46
|
-
- '
|
|
43
|
+
- 'test/**/*'
|
|
44
|
+
- 'test/**/*'
|
|
47
45
|
- 'features/**/*'
|
|
48
46
|
- '*.gemspec'
|
|
49
47
|
|
|
48
|
+
Style/NumericPredicate:
|
|
49
|
+
Exclude:
|
|
50
|
+
- 'test/**/*.rb'
|
|
51
|
+
|
|
50
52
|
# From Ruby 3.4, frozen string literals are the default anyways
|
|
51
53
|
Style/FrozenStringLiteralComment:
|
|
52
54
|
Enabled: false
|
|
@@ -54,16 +56,10 @@ Style/FrozenStringLiteralComment:
|
|
|
54
56
|
# Allow mix-in usage at top level in test files
|
|
55
57
|
Style/MixinUsage:
|
|
56
58
|
Exclude:
|
|
57
|
-
- '
|
|
59
|
+
- 'test/**/*'
|
|
58
60
|
- 'features/**/*'
|
|
59
61
|
|
|
60
62
|
# Allow constant definition in blocks for test helpers
|
|
61
63
|
Lint/ConstantDefinitionInBlock:
|
|
62
64
|
Exclude:
|
|
63
|
-
- '
|
|
64
|
-
|
|
65
|
-
RSpec/MultipleExpectations:
|
|
66
|
-
Max: 20
|
|
67
|
-
|
|
68
|
-
RSpec/ExampleLength:
|
|
69
|
-
Max: 50
|
|
65
|
+
- 'test/**/*'
|
data/Gemfile
CHANGED
|
@@ -9,10 +9,9 @@ group :development do
|
|
|
9
9
|
gem 'bundler', '~> 4.0'
|
|
10
10
|
gem 'cucumber', '~> 9.2'
|
|
11
11
|
gem 'rake', '~> 13.2'
|
|
12
|
-
gem '
|
|
13
|
-
gem 'rspec-expectations', '~> 3.13'
|
|
14
|
-
gem 'rubocop', '~> 1.65'
|
|
12
|
+
gem 'rubocop'
|
|
15
13
|
gem 'rubocop-rake', require: false
|
|
16
|
-
gem '
|
|
14
|
+
gem 'sus'
|
|
15
|
+
gem 'sus-fixtures-async'
|
|
17
16
|
gem 'timecop', '~> 0.9'
|
|
18
17
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rsmp (0.
|
|
4
|
+
rsmp (0.42.1)
|
|
5
5
|
async (~> 2.32)
|
|
6
6
|
colorize (~> 1.1)
|
|
7
7
|
io-endpoint (~> 0.15)
|
|
@@ -20,13 +20,13 @@ GEM
|
|
|
20
20
|
rspec-expectations (>= 3.4, < 5.0)
|
|
21
21
|
thor (~> 1.0)
|
|
22
22
|
ast (2.4.3)
|
|
23
|
-
async (2.
|
|
23
|
+
async (2.39.0)
|
|
24
24
|
console (~> 1.29)
|
|
25
25
|
fiber-annotation
|
|
26
26
|
io-event (~> 1.11)
|
|
27
27
|
metrics (~> 0.12)
|
|
28
28
|
traces (~> 0.18)
|
|
29
|
-
bigdecimal (4.
|
|
29
|
+
bigdecimal (4.1.1)
|
|
30
30
|
builder (3.3.0)
|
|
31
31
|
colorize (1.1.0)
|
|
32
32
|
console (1.34.3)
|
|
@@ -60,18 +60,17 @@ GEM
|
|
|
60
60
|
cucumber-messages (22.0.0)
|
|
61
61
|
cucumber-tag-expressions (6.1.2)
|
|
62
62
|
diff-lcs (1.6.2)
|
|
63
|
-
ffi (1.17.
|
|
64
|
-
ffi (1.17.
|
|
65
|
-
ffi (1.17.
|
|
66
|
-
ffi (1.17.
|
|
67
|
-
ffi (1.17.3-x86_64-linux-gnu)
|
|
63
|
+
ffi (1.17.4-arm64-darwin)
|
|
64
|
+
ffi (1.17.4-x64-mingw-ucrt)
|
|
65
|
+
ffi (1.17.4-x86_64-darwin)
|
|
66
|
+
ffi (1.17.4-x86_64-linux-gnu)
|
|
68
67
|
fiber-annotation (0.2.0)
|
|
69
68
|
fiber-local (1.1.0)
|
|
70
69
|
fiber-storage
|
|
71
70
|
fiber-storage (1.0.1)
|
|
72
71
|
hana (1.3.7)
|
|
73
72
|
io-endpoint (0.17.2)
|
|
74
|
-
io-event (1.
|
|
73
|
+
io-event (1.15.1)
|
|
75
74
|
io-stream (0.11.1)
|
|
76
75
|
json (2.19.3)
|
|
77
76
|
json_schemer (2.5.0)
|
|
@@ -87,62 +86,59 @@ GEM
|
|
|
87
86
|
mini_mime (1.1.5)
|
|
88
87
|
multi_test (1.1.0)
|
|
89
88
|
ostruct (0.6.3)
|
|
90
|
-
parallel (
|
|
91
|
-
parser (3.3.
|
|
89
|
+
parallel (2.0.1)
|
|
90
|
+
parser (3.3.11.1)
|
|
92
91
|
ast (~> 2.4.1)
|
|
93
92
|
racc
|
|
94
|
-
prism (1.
|
|
93
|
+
prism (1.9.0)
|
|
95
94
|
racc (1.8.1)
|
|
96
95
|
rainbow (3.1.1)
|
|
97
|
-
rake (13.
|
|
98
|
-
regexp_parser (2.
|
|
96
|
+
rake (13.4.2)
|
|
97
|
+
regexp_parser (2.12.0)
|
|
99
98
|
rsmp_schema (0.10.1)
|
|
100
99
|
json_schemer (~> 2.5)
|
|
101
100
|
thor (~> 1.5)
|
|
102
|
-
rspec (3.13.2)
|
|
103
|
-
rspec-core (~> 3.13.0)
|
|
104
|
-
rspec-expectations (~> 3.13.0)
|
|
105
|
-
rspec-mocks (~> 3.13.0)
|
|
106
|
-
rspec-core (3.13.6)
|
|
107
|
-
rspec-support (~> 3.13.0)
|
|
108
101
|
rspec-expectations (3.13.5)
|
|
109
102
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
110
103
|
rspec-support (~> 3.13.0)
|
|
111
|
-
rspec-
|
|
112
|
-
|
|
113
|
-
rspec-support (~> 3.13.0)
|
|
114
|
-
rspec-support (3.13.6)
|
|
115
|
-
rubocop (1.82.1)
|
|
104
|
+
rspec-support (3.13.7)
|
|
105
|
+
rubocop (1.86.1)
|
|
116
106
|
json (~> 2.3)
|
|
117
107
|
language_server-protocol (~> 3.17.0.2)
|
|
118
108
|
lint_roller (~> 1.1.0)
|
|
119
|
-
parallel (
|
|
109
|
+
parallel (>= 1.10)
|
|
120
110
|
parser (>= 3.3.0.2)
|
|
121
111
|
rainbow (>= 2.2.2, < 4.0)
|
|
122
112
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
123
|
-
rubocop-ast (>= 1.
|
|
113
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
124
114
|
ruby-progressbar (~> 1.7)
|
|
125
115
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
126
|
-
rubocop-ast (1.49.
|
|
116
|
+
rubocop-ast (1.49.1)
|
|
127
117
|
parser (>= 3.3.7.2)
|
|
128
118
|
prism (~> 1.7)
|
|
129
119
|
rubocop-rake (0.7.1)
|
|
130
120
|
lint_roller (~> 1.1)
|
|
131
121
|
rubocop (>= 1.72.1)
|
|
132
|
-
rubocop-rspec (3.9.0)
|
|
133
|
-
lint_roller (~> 1.1)
|
|
134
|
-
rubocop (~> 1.81)
|
|
135
122
|
ruby-progressbar (1.13.0)
|
|
136
123
|
simpleidn (0.2.3)
|
|
137
|
-
|
|
124
|
+
sus (0.36.0)
|
|
125
|
+
sus-fixtures-async (0.2.0)
|
|
126
|
+
async
|
|
127
|
+
sus (~> 0.10)
|
|
128
|
+
sys-uname (1.5.1)
|
|
129
|
+
ffi (~> 1.1)
|
|
130
|
+
memoist3 (~> 1.0.0)
|
|
131
|
+
sys-uname (1.5.1-universal-mingw32)
|
|
138
132
|
ffi (~> 1.1)
|
|
139
133
|
memoist3 (~> 1.0.0)
|
|
134
|
+
win32ole
|
|
140
135
|
thor (1.5.0)
|
|
141
|
-
timecop (0.9.
|
|
136
|
+
timecop (0.9.11)
|
|
142
137
|
traces (0.18.2)
|
|
143
138
|
unicode-display_width (3.2.0)
|
|
144
139
|
unicode-emoji (~> 4.1)
|
|
145
140
|
unicode-emoji (4.2.0)
|
|
141
|
+
win32ole (1.9.3)
|
|
146
142
|
|
|
147
143
|
PLATFORMS
|
|
148
144
|
arm64-darwin-23
|
|
@@ -157,11 +153,10 @@ DEPENDENCIES
|
|
|
157
153
|
cucumber (~> 9.2)
|
|
158
154
|
rake (~> 13.2)
|
|
159
155
|
rsmp!
|
|
160
|
-
|
|
161
|
-
rspec-expectations (~> 3.13)
|
|
162
|
-
rubocop (~> 1.65)
|
|
156
|
+
rubocop
|
|
163
157
|
rubocop-rake
|
|
164
|
-
|
|
158
|
+
sus
|
|
159
|
+
sus-fixtures-async
|
|
165
160
|
timecop (~> 0.9)
|
|
166
161
|
|
|
167
162
|
BUNDLED WITH
|
data/Rakefile
CHANGED
data/config/sus.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'rsmp'
|
|
2
|
+
require 'sus/fixtures/async'
|
|
3
|
+
require_relative '../test/support/async_helper'
|
|
4
|
+
|
|
5
|
+
def test_paths
|
|
6
|
+
Dir.glob('test/**/*.rb', base: @root).reject { |p| p.start_with?('test/support/') }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def make_registry
|
|
10
|
+
registry = Sus::Registry.new(root: @root)
|
|
11
|
+
registry.base.include(Sus::Fixtures::Async::ReactorContext)
|
|
12
|
+
registry.base.include(AsyncHelper)
|
|
13
|
+
registry
|
|
14
|
+
end
|
|
@@ -145,67 +145,82 @@ result = matcher.collect(options) do |message,item|
|
|
|
145
145
|
end
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
##
|
|
149
|
-
The method `
|
|
148
|
+
## Sending commands
|
|
149
|
+
The method `send_command` sends a CommandRequest to the site and returns the sent message. `component:` defaults to `main.c_id`.
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
```ruby
|
|
152
|
+
message = send_command(
|
|
153
|
+
[{'cCI' => 'M0001', 'n' => 'status', 'v' => 'NormalControl'}],
|
|
154
|
+
component: 'AA+BBCCC=DDDEE001'
|
|
155
|
+
)
|
|
156
|
+
```
|
|
153
157
|
|
|
154
|
-
|
|
158
|
+
To send and wait for the CommandResponse, use `send_command_and_collect`. It returns a collector; call `.ok!` to raise on NotAck or timeout.
|
|
155
159
|
|
|
156
160
|
```ruby
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
collector = send_command_and_collect(
|
|
162
|
+
[{'cCI' => 'M0001', 'n' => 'status', 'v' => 'NormalControl'}],
|
|
163
|
+
within: 5,
|
|
164
|
+
component: 'AA+BBCCC=DDDEE001'
|
|
165
|
+
)
|
|
166
|
+
collector.ok!
|
|
162
167
|
```
|
|
163
168
|
|
|
164
|
-
|
|
169
|
+
## Requesting status
|
|
170
|
+
The method `request_status` sends a StatusRequest to the site and returns `{ sent: message }`. `component:` defaults to `main.c_id`.
|
|
165
171
|
|
|
166
172
|
```ruby
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
result = request_status(
|
|
174
|
+
[{'sCI' => 'S0001', 'n' => 'signalgroupstatus'}],
|
|
175
|
+
component: 'AA+BBCCC=DDDEE001'
|
|
176
|
+
)
|
|
177
|
+
result[:sent] # => the StatusRequest message
|
|
172
178
|
```
|
|
173
179
|
|
|
174
|
-
|
|
175
|
-
If you provide `:collect` options, it will be used to construct a StatusCollector for collecting the relevant status messages. When collection completes the collector is returned in the `:collector` key:
|
|
180
|
+
To send and wait for the StatusResponse, use `request_status_and_collect`. It returns a collector; call `.ok!` to raise on NotAck or timeout.
|
|
176
181
|
|
|
177
182
|
```ruby
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
result[:collector].messages # => list of collected messages
|
|
183
|
+
collector = request_status_and_collect(
|
|
184
|
+
[{'sCI' => 'S0001', 'n' => 'signalgroupstatus'}],
|
|
185
|
+
within: 5,
|
|
186
|
+
component: 'AA+BBCCC=DDDEE001'
|
|
187
|
+
)
|
|
188
|
+
collector.ok!
|
|
185
189
|
```
|
|
186
190
|
|
|
187
|
-
|
|
191
|
+
## Subscribing to status updates
|
|
192
|
+
The method `subscribe_to_status` sends a StatusSubscribe message to the site and returns `{ sent: message }`. `component:` defaults to `main.c_id`.
|
|
193
|
+
|
|
194
|
+
### Without collection
|
|
188
195
|
|
|
189
196
|
```ruby
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
result[:
|
|
197
|
+
result = subscribe_to_status(
|
|
198
|
+
[{'sCI' => 'S0001', 'n' => 'signalgroupstatus', 'uRt' => '1'}],
|
|
199
|
+
component: 'AA+BBCCC=DDDEE001'
|
|
200
|
+
)
|
|
201
|
+
result[:sent] # => the StatusSubscribe message
|
|
195
202
|
```
|
|
196
203
|
|
|
197
|
-
|
|
198
|
-
If you pass a block, the block will be used to construct a collector. The block will be called for each matching status item received.
|
|
199
|
-
Collection will continue until the block returns :cancel, or it times out.
|
|
204
|
+
If you want to manually collect incoming status updates after subscribing, start a collector before subscribing so you don't miss early responses:
|
|
200
205
|
|
|
201
206
|
```ruby
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
result = subscribe_to_status(options) do |message|
|
|
206
|
-
# do something with message
|
|
207
|
-
:keep # or not
|
|
207
|
+
task = async do
|
|
208
|
+
MessageCollector.new(options).collect(num: 5, timeout: 10)
|
|
208
209
|
end
|
|
209
|
-
|
|
210
|
+
subscribe_to_status(status_list)
|
|
211
|
+
task.wait
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### With collection
|
|
215
|
+
|
|
216
|
+
Use `subscribe_to_status_and_collect` to subscribe and collect status updates matching the criteria. It returns a collector; call `.ok!` to raise on NotAck or timeout.
|
|
217
|
+
|
|
218
|
+
```ruby
|
|
219
|
+
collector = subscribe_to_status_and_collect(
|
|
220
|
+
[{'sCI' => 'S0001', 'n' => 'signalgroupstatus', 'uRt' => '1'}],
|
|
221
|
+
within: 5,
|
|
222
|
+
component: 'AA+BBCCC=DDDEE001'
|
|
223
|
+
)
|
|
224
|
+
collector.ok!
|
|
210
225
|
```
|
|
211
226
|
|
data/lib/rsmp/cli.rb
CHANGED
|
@@ -86,7 +86,8 @@ module RSMP
|
|
|
86
86
|
|
|
87
87
|
def apply_basic_site_options(settings)
|
|
88
88
|
settings['site_id'] = options[:id] if options[:id]
|
|
89
|
-
settings['core_version'] = options[:core] if options[:core]
|
|
89
|
+
settings['core_version'] = options[:core] || ENV['CORE_VERSION'] if options[:core] || ENV['CORE_VERSION']
|
|
90
|
+
settings['sxl_version'] = ENV['SXL_VERSION'] if ENV['SXL_VERSION']
|
|
90
91
|
end
|
|
91
92
|
|
|
92
93
|
def parse_supervisors(settings)
|
|
@@ -8,7 +8,7 @@ module RSMP
|
|
|
8
8
|
include Reporting
|
|
9
9
|
include Logging
|
|
10
10
|
|
|
11
|
-
attr_reader :condition, :messages, :status, :error, :task, :m_id
|
|
11
|
+
attr_reader :condition, :messages, :status, :error, :task, :m_id, :initiator
|
|
12
12
|
|
|
13
13
|
def initialize(distributor, options = {})
|
|
14
14
|
initialize_receiver distributor, filter: options[:filter]
|
|
@@ -20,7 +20,8 @@ module RSMP
|
|
|
20
20
|
}.deep_merge options
|
|
21
21
|
@timeout = options[:timeout]
|
|
22
22
|
@num = options[:num]
|
|
23
|
-
@
|
|
23
|
+
@initiator = options[:initiator]
|
|
24
|
+
@m_id = options[:m_id] || @initiator&.attributes&.dig('mId')
|
|
24
25
|
@condition = Async::Notification.new
|
|
25
26
|
make_title options[:title]
|
|
26
27
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module RSMP
|
|
2
|
+
# Represents an RSMP command list and converts between the two common formats:
|
|
3
|
+
#
|
|
4
|
+
# Compact form (used in validators and helpers):
|
|
5
|
+
# RSMP::CommandList.new(:M0001, :setValue, securityCode: '1111', status: 'NormalControl')
|
|
6
|
+
#
|
|
7
|
+
# Raw wire Array (used in RSMP messages):
|
|
8
|
+
# [
|
|
9
|
+
# { 'cCI' => 'M0001', 'cO' => 'setValue', 'n' => 'securityCode', 'v' => '1111' },
|
|
10
|
+
# { 'cCI' => 'M0001', 'cO' => 'setValue', 'n' => 'status', 'v' => 'NormalControl' }
|
|
11
|
+
# ]
|
|
12
|
+
class CommandList
|
|
13
|
+
include Enumerable
|
|
14
|
+
|
|
15
|
+
def initialize(command_code_id, command_name, values)
|
|
16
|
+
@list = values.compact.map do |n, v|
|
|
17
|
+
{
|
|
18
|
+
'cCI' => command_code_id.to_s,
|
|
19
|
+
'cO' => command_name.to_s,
|
|
20
|
+
'n' => n.to_s,
|
|
21
|
+
'v' => v.to_s
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def each(&)
|
|
27
|
+
@list.each(&)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def to_a
|
|
31
|
+
@list
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def to_h
|
|
35
|
+
@list.each_with_object({}) do |item, hash|
|
|
36
|
+
code = item['cCI']
|
|
37
|
+
command = item['cO']
|
|
38
|
+
((hash[code] ||= {})[command] ||= {})[item['n']] = item['v']
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/rsmp/node/site/site.rb
CHANGED
|
@@ -93,9 +93,9 @@ module RSMP
|
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
def aggregated_status_changed(component,
|
|
96
|
+
def aggregated_status_changed(component, _options = {})
|
|
97
97
|
@proxies.each do |proxy|
|
|
98
|
-
proxy.send_aggregated_status component
|
|
98
|
+
proxy.send_aggregated_status component if proxy.ready?
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
@@ -47,23 +47,15 @@ module RSMP
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
def
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
collector = yield collect_options # call block to create collector
|
|
56
|
-
collector.collect
|
|
57
|
-
collector.ok! if options[:collect!] # raise any errors if the bang version was specified
|
|
58
|
-
collector
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
send_message message, validate: options[:validate]
|
|
62
|
-
{ sent: message, collector: task.wait }
|
|
63
|
-
else
|
|
64
|
-
send_message message, validate: options[:validate]
|
|
65
|
-
{ sent: message }
|
|
50
|
+
def send_message_and_collect(message, collector, validate: true)
|
|
51
|
+
task = @task.async do |t|
|
|
52
|
+
t.annotate 'send_message_and_collect'
|
|
53
|
+
collector.collect
|
|
54
|
+
collector
|
|
66
55
|
end
|
|
56
|
+
send_message message, validate: validate
|
|
57
|
+
collector = task.wait
|
|
58
|
+
{ sent: message, collector: collector }
|
|
67
59
|
end
|
|
68
60
|
|
|
69
61
|
def apply_nts_message_attributes(message)
|
|
@@ -3,20 +3,31 @@ module RSMP
|
|
|
3
3
|
module Modules
|
|
4
4
|
# Handles aggregated status requests and responses
|
|
5
5
|
module AggregatedStatus
|
|
6
|
-
|
|
6
|
+
# Build and send an AggregatedStatusRequest. Returns { sent: message }.
|
|
7
|
+
def request_aggregated_status(component, m_id: nil, validate: true)
|
|
7
8
|
validate_ready 'request aggregated status'
|
|
8
|
-
m_id
|
|
9
|
+
m_id ||= RSMP::Message.make_m_id
|
|
9
10
|
message = RSMP::AggregatedStatusRequest.new({
|
|
10
11
|
'cId' => component,
|
|
11
12
|
'mId' => m_id
|
|
12
13
|
})
|
|
13
14
|
apply_nts_message_attributes message
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
send_message message, validate: validate
|
|
16
|
+
{ sent: message }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Build, send an AggregatedStatusRequest and collect the response. Returns the collector.
|
|
20
|
+
# Call .ok! on the result to raise on NotAck or timeout.
|
|
21
|
+
def request_aggregated_status_and_collect(component, within:, m_id: nil, validate: true)
|
|
22
|
+
validate_ready 'request aggregated status'
|
|
23
|
+
m_id ||= RSMP::Message.make_m_id
|
|
24
|
+
message = RSMP::AggregatedStatusRequest.new({
|
|
25
|
+
'cId' => component,
|
|
26
|
+
'mId' => m_id
|
|
27
|
+
})
|
|
28
|
+
apply_nts_message_attributes message
|
|
29
|
+
collector = AggregatedStatusCollector.new(self, timeout: within, m_id: m_id, num: 1)
|
|
30
|
+
send_message_and_collect(message, collector, validate: validate)[:collector]
|
|
20
31
|
end
|
|
21
32
|
|
|
22
33
|
def validate_aggregated_status(message, status_elements)
|
|
@@ -3,22 +3,35 @@ module RSMP
|
|
|
3
3
|
module Modules
|
|
4
4
|
# Handles command requests and responses
|
|
5
5
|
module Commands
|
|
6
|
-
|
|
6
|
+
# Build and send a CommandRequest. Returns the CommandRequest message.
|
|
7
|
+
def send_command(command_list, component: nil, validate: true)
|
|
7
8
|
validate_ready 'send command'
|
|
8
|
-
|
|
9
|
+
component ||= main.c_id
|
|
10
|
+
m_id = RSMP::Message.make_m_id
|
|
9
11
|
message = RSMP::CommandRequest.new({
|
|
10
12
|
'cId' => component,
|
|
11
13
|
'arg' => command_list,
|
|
12
14
|
'mId' => m_id
|
|
13
15
|
})
|
|
14
16
|
apply_nts_message_attributes message
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
send_message message, validate: validate
|
|
18
|
+
message
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Build, send a CommandRequest and collect the CommandResponse. Returns the collector.
|
|
22
|
+
# Raises on NotAck or timeout if ok! is called on the result.
|
|
23
|
+
def send_command_and_collect(command_list, within:, component: nil, validate: true)
|
|
24
|
+
validate_ready 'send command'
|
|
25
|
+
component ||= main.c_id
|
|
26
|
+
m_id = RSMP::Message.make_m_id
|
|
27
|
+
message = RSMP::CommandRequest.new({
|
|
28
|
+
'cId' => component,
|
|
29
|
+
'arg' => command_list,
|
|
30
|
+
'mId' => m_id
|
|
31
|
+
})
|
|
32
|
+
apply_nts_message_attributes message
|
|
33
|
+
collector = CommandResponseCollector.new(self, command_list, timeout: within, initiator: message)
|
|
34
|
+
send_message_and_collect(message, collector, validate: validate)[:collector]
|
|
22
35
|
end
|
|
23
36
|
|
|
24
37
|
def process_command_response(message)
|