rsmp 0.1.32 → 0.1.37
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/Gemfile.lock +4 -4
- data/lib/rsmp/component.rb +5 -5
- data/lib/rsmp/components.rb +1 -1
- data/lib/rsmp/proxy.rb +29 -15
- data/lib/rsmp/site.rb +20 -3
- data/lib/rsmp/site_proxy.rb +7 -6
- data/lib/rsmp/site_proxy_wait.rb +1 -36
- data/lib/rsmp/supervisor.rb +0 -1
- data/lib/rsmp/supervisor_proxy.rb +18 -4
- data/lib/rsmp/tlc.rb +1 -1
- data/lib/rsmp/version.rb +1 -1
- data/rsmp.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a20b2e46548b2ebcdc9e3148168fafb7062113d171d88bef186900b0c8fe98a9
|
4
|
+
data.tar.gz: 436e96144e55742c3c9df9f549ca345c21137deb579c10d10fcefdaad1d94a39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2e07fc806b798e15af70789085d6c5ecf582b46dfe9ff7e5ed2cd48f8e8b2d7d74eddb66ed488150dee047d1fc3886b8d84edf7dc85976db570e89544f29160
|
7
|
+
data.tar.gz: 8baba395982e5c105a7e04d3a0c01c91a89ae82fb21cfd180c3fe6adf436cc4b70a437206c1f499f5c5cbfe476746d7cebd1c0b38f1354a467ff4e0f80b6904d
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rsmp (0.1.
|
4
|
+
rsmp (0.1.37)
|
5
5
|
async (~> 1.28.7)
|
6
6
|
async-io (~> 1.30.2)
|
7
7
|
colorize (~> 0.8.1)
|
8
|
-
rsmp_schemer
|
8
|
+
rsmp_schemer
|
9
9
|
thor (~> 1.0.1)
|
10
10
|
|
11
11
|
GEM
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
builder (3.2.4)
|
29
29
|
childprocess (3.0.0)
|
30
30
|
colorize (0.8.1)
|
31
|
-
console (1.
|
31
|
+
console (1.13.1)
|
32
32
|
fiber-local
|
33
33
|
contracts (0.16.0)
|
34
34
|
cucumber (3.1.2)
|
@@ -64,7 +64,7 @@ GEM
|
|
64
64
|
nio4r (2.5.7)
|
65
65
|
rake (13.0.1)
|
66
66
|
regexp_parser (2.1.1)
|
67
|
-
rsmp_schemer (0.
|
67
|
+
rsmp_schemer (0.3)
|
68
68
|
json_schemer (~> 0.2.18)
|
69
69
|
rspec (3.9.0)
|
70
70
|
rspec-core (~> 3.9.0)
|
data/lib/rsmp/component.rb
CHANGED
@@ -28,7 +28,7 @@ module RSMP
|
|
28
28
|
@aggregated_status_bools[5] = true
|
29
29
|
end
|
30
30
|
|
31
|
-
def set_aggregated_status status
|
31
|
+
def set_aggregated_status status, options={}
|
32
32
|
status = [status] if status.is_a? Symbol
|
33
33
|
raise InvalidArgument unless status.is_a? Array
|
34
34
|
input = status & AGGREGATED_STATUS_KEYS
|
@@ -36,7 +36,7 @@ module RSMP
|
|
36
36
|
AGGREGATED_STATUS_KEYS.each_with_index do |key,index|
|
37
37
|
@aggregated_status_bools[index] = status.include?(key)
|
38
38
|
end
|
39
|
-
|
39
|
+
aggregated_status_changed options
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -50,12 +50,12 @@ module RSMP
|
|
50
50
|
@aggregated_status_bools[index] = on
|
51
51
|
@aggregated_status << key if on
|
52
52
|
end
|
53
|
-
|
53
|
+
aggregated_status_changed
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
58
|
-
@node.
|
57
|
+
def aggregated_status_changed options={}
|
58
|
+
@node.aggregated_status_changed self, options
|
59
59
|
end
|
60
60
|
|
61
61
|
def alarm code:, status:
|
data/lib/rsmp/components.rb
CHANGED
data/lib/rsmp/proxy.rb
CHANGED
@@ -162,6 +162,8 @@ module RSMP
|
|
162
162
|
begin
|
163
163
|
now = Clock.now
|
164
164
|
timer(now)
|
165
|
+
rescue RSMP::Schemer::Error => e
|
166
|
+
puts "Timer: Schema error: #{e}"
|
165
167
|
rescue EOFError => e
|
166
168
|
log "Timer: Connection closed: #{e}", level: :warning
|
167
169
|
rescue IOError => e
|
@@ -246,7 +248,7 @@ module RSMP
|
|
246
248
|
# TODO
|
247
249
|
# what schema should we use to validate the intial Version and MessageAck messages?
|
248
250
|
schemas = { core: '3.1.5' }
|
249
|
-
schemas[sxl] = sxl_version if sxl
|
251
|
+
schemas[sxl] = RSMP::Schemer.sanitize_version(sxl_version) if sxl
|
250
252
|
schemas
|
251
253
|
end
|
252
254
|
|
@@ -261,7 +263,7 @@ module RSMP
|
|
261
263
|
log_send message, reason
|
262
264
|
rescue EOFError, IOError
|
263
265
|
buffer_message message
|
264
|
-
rescue SchemaError => e
|
266
|
+
rescue SchemaError, RSMP::Schemer::Error => e
|
265
267
|
str = "Could not send #{message.type} because schema validation failed: #{e.message}"
|
266
268
|
log str, message: message, level: :error
|
267
269
|
notify_error e.exception("#{str} #{message.json}")
|
@@ -306,7 +308,7 @@ module RSMP
|
|
306
308
|
log str, message: Malformed.new(attributes), level: :warning
|
307
309
|
# cannot send NotAcknowledged for a malformed message since we can't read it, just ignore it
|
308
310
|
nil
|
309
|
-
rescue SchemaError => e
|
311
|
+
rescue SchemaError, RSMP::Schemer::Error => e
|
310
312
|
str = "Received invalid #{message.type}, schema errors: #{e.message}"
|
311
313
|
log str, message: message, level: :warning
|
312
314
|
notify_error e.exception("#{str} #{message.json}")
|
@@ -528,18 +530,6 @@ module RSMP
|
|
528
530
|
def version_acknowledged
|
529
531
|
end
|
530
532
|
|
531
|
-
def wait_for_acknowledgement original, timeout
|
532
|
-
raise ArgumentError unless original
|
533
|
-
wait_for(@acknowledgement_condition,timeout) do |message|
|
534
|
-
if message.is_a?(MessageNotAck) && message.attributes["oMId"] == original.m_id
|
535
|
-
raise RSMP::MessageRejected.new(message.attributes['rea'])
|
536
|
-
end
|
537
|
-
message.is_a?(MessageAck) && message.attributes["oMId"] == original.m_id
|
538
|
-
end
|
539
|
-
rescue Async::TimeoutError
|
540
|
-
raise RSMP::TimeoutError.new("Acknowledgement for #{original.type} #{original.m_id} not received within #{timeout}s")
|
541
|
-
end
|
542
|
-
|
543
533
|
def node
|
544
534
|
raise 'Must be overridden'
|
545
535
|
end
|
@@ -547,5 +537,29 @@ module RSMP
|
|
547
537
|
def author
|
548
538
|
node.site_id
|
549
539
|
end
|
540
|
+
|
541
|
+
def wait_for_acknowledgement parent_task, options={}, m_id
|
542
|
+
collect(parent_task,options.merge({
|
543
|
+
type: ['MessageAck','MessageNotAck'],
|
544
|
+
num: 1
|
545
|
+
})) do |message|
|
546
|
+
if message.is_a?(MessageNotAck)
|
547
|
+
if message.attribute('oMId') == m_id
|
548
|
+
# set result to an exception, but don't raise it.
|
549
|
+
# this will be returned by the task and stored as the task result
|
550
|
+
# when the parent task call wait() on the task, the exception
|
551
|
+
# will be raised in the parent task, and caught by rspec.
|
552
|
+
# rspec will then show the error and record the test as failed
|
553
|
+
m_id_short = RSMP::Message.shorten_m_id m_id, 8
|
554
|
+
result = RSMP::MessageRejected.new "Aggregated status request #{m_id_short} was rejected: #{message.attribute('rea')}"
|
555
|
+
next true # done, no more messages wanted
|
556
|
+
end
|
557
|
+
elsif message.is_a?(MessageAck)
|
558
|
+
next true if message.attribute('oMId') == m_id
|
559
|
+
end
|
560
|
+
false
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
550
564
|
end
|
551
565
|
end
|
data/lib/rsmp/site.rb
CHANGED
@@ -14,6 +14,7 @@ module RSMP
|
|
14
14
|
super options
|
15
15
|
@proxies = []
|
16
16
|
@sleep_condition = Async::Notification.new
|
17
|
+
@proxies_condition = Async::Notification.new
|
17
18
|
end
|
18
19
|
|
19
20
|
def site_id
|
@@ -52,7 +53,7 @@ module RSMP
|
|
52
53
|
def check_sxl_version
|
53
54
|
sxl = @site_settings['sxl']
|
54
55
|
version = @site_settings['sxl_version']
|
55
|
-
RSMP::Schemer::find_schema! sxl, version
|
56
|
+
RSMP::Schemer::find_schema! sxl, version, lenient: true
|
56
57
|
end
|
57
58
|
|
58
59
|
def reconnect
|
@@ -74,9 +75,9 @@ module RSMP
|
|
74
75
|
SupervisorProxy.new settings
|
75
76
|
end
|
76
77
|
|
77
|
-
def
|
78
|
+
def aggregated_status_changed component, options={}
|
78
79
|
@proxies.each do |proxy|
|
79
|
-
proxy.send_aggregated_status component
|
80
|
+
proxy.send_aggregated_status component, options
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -91,9 +92,11 @@ module RSMP
|
|
91
92
|
archive: @archive
|
92
93
|
})
|
93
94
|
@proxies << proxy
|
95
|
+
@proxies_condition.signal
|
94
96
|
run_site_proxy task, proxy
|
95
97
|
ensure
|
96
98
|
@proxies.delete proxy
|
99
|
+
@proxies_condition.signal
|
97
100
|
end
|
98
101
|
|
99
102
|
def run_site_proxy task, proxy
|
@@ -142,5 +145,19 @@ module RSMP
|
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
148
|
+
def wait_for_supervisor ip, timeout
|
149
|
+
supervisor = find_supervisor ip
|
150
|
+
return supervisor if supervisor
|
151
|
+
wait_for(@proxy_condition,timeout) { find_supervisor ip }
|
152
|
+
rescue Async::TimeoutError
|
153
|
+
raise RSMP::TimeoutError.new "Supervisor '#{ip}' did not connect within #{timeout}s"
|
154
|
+
end
|
155
|
+
|
156
|
+
def find_supervisor ip
|
157
|
+
@proxies.each do |supervisor|
|
158
|
+
return supervisor if ip == :any || supervisor.ip == ip
|
159
|
+
end
|
160
|
+
nil
|
161
|
+
end
|
145
162
|
end
|
146
163
|
end
|
data/lib/rsmp/site_proxy.rb
CHANGED
@@ -36,7 +36,8 @@ module RSMP
|
|
36
36
|
|
37
37
|
def connection_complete
|
38
38
|
super
|
39
|
-
|
39
|
+
sanitized_sxl_version = RSMP::Schemer.sanitize_version(@site_sxl_version)
|
40
|
+
log "Connection to site #{@site_id} established, using core #{@rsmp_version}, #{@sxl} #{sanitized_sxl_version}", level: :info
|
40
41
|
end
|
41
42
|
|
42
43
|
def process_message message
|
@@ -94,7 +95,7 @@ module RSMP
|
|
94
95
|
if options[:collect]
|
95
96
|
result = nil
|
96
97
|
task = @task.async do |task|
|
97
|
-
wait_for_aggregated_status task, options[:collect]
|
98
|
+
wait_for_aggregated_status task, options[:collect], m_id
|
98
99
|
end
|
99
100
|
send_message message, validate: options[:validate]
|
100
101
|
return message, task.wait
|
@@ -134,7 +135,7 @@ module RSMP
|
|
134
135
|
acknowledge message
|
135
136
|
end
|
136
137
|
|
137
|
-
def
|
138
|
+
def aggregated_status_changed component, options={}
|
138
139
|
@supervisor.aggregated_status_changed self, component
|
139
140
|
end
|
140
141
|
|
@@ -308,11 +309,13 @@ module RSMP
|
|
308
309
|
# comes from the Version message send by the site
|
309
310
|
type = 'tlc'
|
310
311
|
version = message.attribute 'SXL'
|
311
|
-
RSMP::Schemer::find_schema! type, version
|
312
|
+
RSMP::Schemer::find_schema! type, version, lenient: true
|
312
313
|
|
313
314
|
# store sxl version requested by site
|
314
315
|
# TODO should check agaist site settings
|
315
316
|
@site_sxl_version = message.attribute 'SXL'
|
317
|
+
rescue RSMP::Schemer::UnknownSchemaError => e
|
318
|
+
dont_acknowledge message, "Rejected #{message.type} message,", "#{e}"
|
316
319
|
end
|
317
320
|
|
318
321
|
def sxl_version
|
@@ -327,8 +330,6 @@ module RSMP
|
|
327
330
|
check_rsmp_version message
|
328
331
|
check_sxl_version message
|
329
332
|
version_accepted message
|
330
|
-
rescue RSMP::Schemer::UnknownSchemaError => e
|
331
|
-
dont_acknowledge message, "Rejected #{message.type} message,", "#{e}"
|
332
333
|
end
|
333
334
|
|
334
335
|
def check_site_ids message
|
data/lib/rsmp/site_proxy_wait.rb
CHANGED
@@ -2,24 +2,6 @@
|
|
2
2
|
module RSMP
|
3
3
|
module SiteProxyWait
|
4
4
|
|
5
|
-
def wait_for_status_updates parent_task, options={}, &send_block
|
6
|
-
send_while_collecting parent_task, send_block do |task, m_id|
|
7
|
-
collect_status_updates_or_responses task, 'StatusUpdate', options, m_id
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def wait_for_status_responses parent_task, options={}, &send_block
|
12
|
-
send_while_collecting parent_task, send_block do |task, m_id|
|
13
|
-
collect_status_updates_or_responses task, 'StatusResponse', options, m_id
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def wait_for_command_responses parent_task, options={}, &send_block
|
18
|
-
send_while_collecting parent_task, send_block do |task, m_id|
|
19
|
-
collect_command_responses task, options, m_id
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
5
|
def wait_for_alarm parent_task, options={}
|
24
6
|
matching_alarm = nil
|
25
7
|
message = collect(parent_task,options.merge(type: "Alarm", with_message: true, num: 1)) do |message|
|
@@ -161,24 +143,7 @@ module RSMP
|
|
161
143
|
true
|
162
144
|
end
|
163
145
|
|
164
|
-
def
|
165
|
-
m_id = RSMP::Message.make_m_id # make message id so we can start waiting for it
|
166
|
-
|
167
|
-
# wait for command responses in an async task
|
168
|
-
task = parent_task.async do |task|
|
169
|
-
collect_block.call task, m_id
|
170
|
-
rescue StandardError => e
|
171
|
-
notify_error e, level: :internal
|
172
|
-
end
|
173
|
-
|
174
|
-
# call block, it should send command request using the given m_id
|
175
|
-
send_block.call m_id
|
176
|
-
|
177
|
-
# wait for the response and return it, raise exception if NotAck received, it it timed out
|
178
|
-
task.wait
|
179
|
-
end
|
180
|
-
|
181
|
-
def wait_for_aggregated_status parent_task, options={}
|
146
|
+
def wait_for_aggregated_status parent_task, options, m_id
|
182
147
|
collect(parent_task,options.merge({
|
183
148
|
type: ['AggregatedStatus','MessageNotAck'],
|
184
149
|
num: 1
|
data/lib/rsmp/supervisor.rb
CHANGED
@@ -49,7 +49,6 @@ module RSMP
|
|
49
49
|
raise RSMP::ConfigurationError.new("Configuration for site '#{site_id}' is empty")
|
50
50
|
end
|
51
51
|
sxl = settings['sxl']
|
52
|
-
sxl = 'tlc' unless sxl # temporary fix until configs are updated
|
53
52
|
unless sxl
|
54
53
|
raise RSMP::ConfigurationError.new("Configuration error for site '#{site_id}': No SXL specified")
|
55
54
|
end
|
@@ -54,7 +54,8 @@ module RSMP
|
|
54
54
|
|
55
55
|
def connection_complete
|
56
56
|
super
|
57
|
-
|
57
|
+
sanitized_sxl_version = RSMP::Schemer.sanitize_version(sxl_version)
|
58
|
+
log "Connection to supervisor established, using core #{@rsmp_version}, #{sxl} #{sanitized_sxl_version}", level: :info
|
58
59
|
start_watchdog
|
59
60
|
end
|
60
61
|
|
@@ -123,15 +124,28 @@ module RSMP
|
|
123
124
|
@version_determined = true
|
124
125
|
end
|
125
126
|
|
126
|
-
def send_aggregated_status component
|
127
|
+
def send_aggregated_status component, options={}
|
128
|
+
m_id = options[:m_id] || RSMP::Message.make_m_id
|
127
129
|
message = AggregatedStatus.new({
|
128
130
|
"aSTS" => clock.to_s,
|
129
131
|
"cId" => component.c_id,
|
130
132
|
"fP" => 'NormalControl',
|
131
133
|
"fS" => nil,
|
132
|
-
"se" => component.aggregated_status_bools
|
134
|
+
"se" => component.aggregated_status_bools,
|
135
|
+
"mId" => m_id
|
133
136
|
})
|
134
|
-
|
137
|
+
|
138
|
+
if options[:collect]
|
139
|
+
result = nil
|
140
|
+
task = @task.async do |task|
|
141
|
+
wait_for_acknowledgement task, options[:collect], m_id
|
142
|
+
end
|
143
|
+
send_message message, validate: options[:validate]
|
144
|
+
return message, task.wait
|
145
|
+
else
|
146
|
+
send_message message, validate: options[:validate]
|
147
|
+
message
|
148
|
+
end
|
135
149
|
end
|
136
150
|
|
137
151
|
def process_aggregated_status message
|
data/lib/rsmp/tlc.rb
CHANGED
data/lib/rsmp/version.rb
CHANGED
data/rsmp.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "async-io", "~> 1.30.2"
|
35
35
|
spec.add_dependency "colorize", "~> 0.8.1"
|
36
36
|
spec.add_dependency "thor", "~> 1.0.1"
|
37
|
-
spec.add_dependency "rsmp_schemer"
|
37
|
+
spec.add_dependency "rsmp_schemer"
|
38
38
|
|
39
39
|
spec.add_development_dependency "bundler", "~> 2.2.3"
|
40
40
|
spec.add_development_dependency "rake", "~> 13.0.1"
|
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.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: rsmp_schemer
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '0'
|
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
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|