rsmp 0.13.9 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -3
- data/lib/rsmp/cli.rb +2 -2
- data/lib/rsmp/component_proxy.rb +2 -0
- data/lib/rsmp/convert/export/json_schema.rb +10 -8
- data/lib/rsmp/convert/import/yaml.rb +6 -3
- data/lib/rsmp/message.rb +2 -2
- data/lib/rsmp/proxy.rb +4 -4
- data/lib/rsmp/site.rb +1 -1
- data/lib/rsmp/site_proxy.rb +6 -4
- data/lib/rsmp/supervisor.rb +2 -2
- data/lib/rsmp/supervisor_proxy.rb +1 -1
- data/lib/rsmp/version.rb +1 -1
- data/rsmp.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38e231d49b1f3b8bf84cd427c830817f1f029aad140feb5a41a254b3085e03cc
|
4
|
+
data.tar.gz: 3d7c432f63819f3fd76c9476fb8aee6ee3160c791031270124ef60e5c34921dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 371f226083bca88553ca127e8228442cde2917c54995b57a472fa423339144806aaa3d6271d7f7d5c774f3b3c566ef842866806cce7e3633ed566a8b8a6f0f6f
|
7
|
+
data.tar.gz: f27787a527fc41626dd6903542bd03eb5fb12debee2bfa5e87d1635a965e27c4333d814b179ba937849c6f172b3dd7d0ae6d9e50fed62ef6e51131fc717cf4fc
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rsmp (0.
|
4
|
+
rsmp (0.14.2)
|
5
5
|
async (~> 1.30.3)
|
6
6
|
async-io (~> 1.33.0)
|
7
7
|
colorize (~> 0.8.1)
|
8
|
-
|
8
|
+
rsmp_schema (~> 0.1.0)
|
9
9
|
thor (~> 1.2.1)
|
10
10
|
|
11
11
|
GEM
|
@@ -80,8 +80,9 @@ GEM
|
|
80
80
|
nio4r (2.5.8)
|
81
81
|
rake (13.0.6)
|
82
82
|
regexp_parser (2.5.0)
|
83
|
-
|
83
|
+
rsmp_schema (0.1.1)
|
84
84
|
json_schemer (~> 0.2.21)
|
85
|
+
thor (~> 1.2.1)
|
85
86
|
rspec (3.10.0)
|
86
87
|
rspec-core (~> 3.10.0)
|
87
88
|
rspec-expectations (~> 3.10.0)
|
data/lib/rsmp/cli.rb
CHANGED
@@ -74,9 +74,9 @@ module RSMP
|
|
74
74
|
end
|
75
75
|
rescue Interrupt
|
76
76
|
# cntr-c
|
77
|
-
rescue RSMP::
|
77
|
+
rescue RSMP::Schema::UnknownSchemaTypeError => e
|
78
78
|
puts "Cannot start site: #{e}"
|
79
|
-
rescue RSMP::
|
79
|
+
rescue RSMP::Schema::UnknownSchemaVersionError => e
|
80
80
|
puts "Cannot start site: #{e}"
|
81
81
|
rescue Psych::SyntaxError => e
|
82
82
|
puts "Cannot read config file #{e}"
|
data/lib/rsmp/component_proxy.rb
CHANGED
@@ -25,6 +25,8 @@ module RSMP
|
|
25
25
|
sCI, n, s, q = item['sCI'], item['n'], item['s'], item['q']
|
26
26
|
uRt = subscription_list.dig(c_id,sCI,n,'uRt')
|
27
27
|
next if uRt.to_i > 0
|
28
|
+
sOc = subscription_list.dig(c_id,sCI,n,'sOc')
|
29
|
+
next if sOc == 'False'
|
28
30
|
next if @allow_repeat_updates[sCI] && @allow_repeat_updates[sCI].include?(n)
|
29
31
|
new_values = {'s'=>s,'q'=>q}
|
30
32
|
old_values = @statuses.dig(sCI,n)
|
@@ -31,9 +31,9 @@ module RSMP
|
|
31
31
|
if item['list']
|
32
32
|
case item['type']
|
33
33
|
when "boolean"
|
34
|
-
out["$ref"] = "
|
34
|
+
out["$ref"] = "../../../core/3.1.1/definitions.json#/boolean_list"
|
35
35
|
when "integer", "ordinal", "unit", "scale", "long"
|
36
|
-
out["$ref"] = "
|
36
|
+
out["$ref"] = "../../../core/3.1.1/definitions.json#/integer_list"
|
37
37
|
else
|
38
38
|
raise "Error: List of #{item['type']} is not supported: #{item.inspect}"
|
39
39
|
end
|
@@ -51,11 +51,11 @@ module RSMP
|
|
51
51
|
when "string", "base64"
|
52
52
|
out["type"] = "string"
|
53
53
|
when "boolean"
|
54
|
-
out["$ref"] = "
|
54
|
+
out["$ref"] = "../../../core/3.1.1/definitions.json#/boolean"
|
55
55
|
when "timestamp"
|
56
|
-
out["$ref"] = "
|
56
|
+
out["$ref"] = "../../../core/3.1.1/definitions.json#/timestamp"
|
57
57
|
when "integer", "ordinal", "unit", "scale", "long"
|
58
|
-
out["$ref"] = "
|
58
|
+
out["$ref"] = "../../../core/3.1.1/definitions.json#/integer"
|
59
59
|
else
|
60
60
|
out["type"] = "string"
|
61
61
|
end
|
@@ -153,9 +153,11 @@ module RSMP
|
|
153
153
|
out["commands/#{key}.json"] = output_json json
|
154
154
|
end
|
155
155
|
|
156
|
-
def self.output_root out
|
156
|
+
def self.output_root out, meta
|
157
157
|
json = {
|
158
|
-
"
|
158
|
+
"name"=> meta['name'],
|
159
|
+
"description"=> meta['description'],
|
160
|
+
"version"=> meta['version'],
|
159
161
|
"allOf" => [
|
160
162
|
{
|
161
163
|
"if" => { "required" => ["type"], "properties" => { "type" => { "const" => "CommandRequest" }}},
|
@@ -180,7 +182,7 @@ module RSMP
|
|
180
182
|
|
181
183
|
def self.generate sxl
|
182
184
|
out = {}
|
183
|
-
output_root out
|
185
|
+
output_root out, sxl[:meta]
|
184
186
|
output_alarms out, sxl[:alarms]
|
185
187
|
output_statuses out, sxl[:statuses]
|
186
188
|
output_commands out, sxl[:commands]
|
@@ -19,15 +19,18 @@ module RSMP
|
|
19
19
|
|
20
20
|
def self.convert yaml
|
21
21
|
sxl = {
|
22
|
+
meta: {},
|
22
23
|
alarms: {},
|
23
24
|
statuses: {},
|
24
25
|
commands: {}
|
25
26
|
}
|
26
27
|
|
28
|
+
sxl[:meta] = yaml['meta']
|
29
|
+
|
27
30
|
yaml['objects'].each_pair do |type,object|
|
28
|
-
object["alarms"].each { |id,item| sxl[:alarms][id] = item }
|
29
|
-
object["statuses"].each { |id,item| sxl[:statuses][id] = item }
|
30
|
-
object["commands"].each { |id,item| sxl[:commands][id] = item }
|
31
|
+
object["alarms"].each { |id,item| sxl[:alarms][id] = item } if object["alarms"]
|
32
|
+
object["statuses"].each { |id,item| sxl[:statuses][id] = item } if object["statuses"]
|
33
|
+
object["commands"].each { |id,item| sxl[:commands][id] = item } if object["commands"]
|
31
34
|
end
|
32
35
|
sxl
|
33
36
|
end
|
data/lib/rsmp/message.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'rsmp_schema'
|
2
2
|
|
3
3
|
# rsmp messages
|
4
4
|
module RSMP
|
@@ -146,7 +146,7 @@ module RSMP
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def validate schemas
|
149
|
-
errors = RSMP::
|
149
|
+
errors = RSMP::Schema.validate attributes, schemas
|
150
150
|
if errors
|
151
151
|
error_string = errors.map {|item| item.reject {|e| e=='' } }.compact.join(', ').strip
|
152
152
|
raise SchemaError.new error_string
|
data/lib/rsmp/proxy.rb
CHANGED
@@ -230,7 +230,7 @@ module RSMP
|
|
230
230
|
begin
|
231
231
|
now = Clock.now
|
232
232
|
timer(now)
|
233
|
-
rescue RSMP::
|
233
|
+
rescue RSMP::Schema::Error => e
|
234
234
|
log "Timer: Schema error: #{e}", level: :warning
|
235
235
|
rescue EOFError => e
|
236
236
|
log "Timer: Connection closed: #{e}", level: :warning
|
@@ -319,7 +319,7 @@ module RSMP
|
|
319
319
|
# TODO
|
320
320
|
# what schema should we use to validate the intial Version and MessageAck messages?
|
321
321
|
schemas = { core: '3.1.5' }
|
322
|
-
schemas[sxl] = RSMP::
|
322
|
+
schemas[sxl] = RSMP::Schema.sanitize_version(sxl_version) if sxl && sxl_version
|
323
323
|
schemas
|
324
324
|
end
|
325
325
|
|
@@ -335,7 +335,7 @@ module RSMP
|
|
335
335
|
log_send message, reason
|
336
336
|
rescue EOFError, IOError
|
337
337
|
buffer_message message
|
338
|
-
rescue SchemaError, RSMP::
|
338
|
+
rescue SchemaError, RSMP::Schema::Error => e
|
339
339
|
str = "Could not send #{message.type} because schema validation failed: #{e.message}"
|
340
340
|
log str, message: message, level: :error
|
341
341
|
notify_error e.exception("#{str} #{message.json}")
|
@@ -398,7 +398,7 @@ module RSMP
|
|
398
398
|
log str, message: Malformed.new(attributes), level: :warning
|
399
399
|
# cannot send NotAcknowledged for a malformed message since we can't read it, just ignore it
|
400
400
|
nil
|
401
|
-
rescue SchemaError, RSMP::
|
401
|
+
rescue SchemaError, RSMP::Schema::Error => e
|
402
402
|
reason = "schema errors: #{e.message}"
|
403
403
|
str = "Received invalid #{message.type}, #{reason}"
|
404
404
|
log str, message: message, level: :warning
|
data/lib/rsmp/site.rb
CHANGED
data/lib/rsmp/site_proxy.rb
CHANGED
@@ -47,7 +47,7 @@ module RSMP
|
|
47
47
|
|
48
48
|
def handshake_complete
|
49
49
|
super
|
50
|
-
sanitized_sxl_version = RSMP::
|
50
|
+
sanitized_sxl_version = RSMP::Schema.sanitize_version(@site_sxl_version)
|
51
51
|
log "Connection to site #{@site_id} established, using core #{@rsmp_version}, #{@sxl} #{sanitized_sxl_version}", level: :log
|
52
52
|
start_watchdog
|
53
53
|
end
|
@@ -212,7 +212,7 @@ module RSMP
|
|
212
212
|
|
213
213
|
# additional items can be used when verifying the response,
|
214
214
|
# but must be removed from the subscribe message
|
215
|
-
subscribe_list = status_list.map { |item| item.slice('sCI','n','uRt') }
|
215
|
+
subscribe_list = status_list.map { |item| item.slice('sCI','n','uRt','sOc') }
|
216
216
|
|
217
217
|
# update our subcription list
|
218
218
|
@status_subscriptions[component_id] ||= {}
|
@@ -220,9 +220,11 @@ module RSMP
|
|
220
220
|
sCI = item["sCI"]
|
221
221
|
n = item["n"]
|
222
222
|
uRt = item["uRt"]
|
223
|
+
sOc = item["sOc"]
|
223
224
|
@status_subscriptions[component_id][sCI] ||= {}
|
224
225
|
@status_subscriptions[component_id][sCI][n] ||= {}
|
225
226
|
@status_subscriptions[component_id][sCI][n]['uRt'] = uRt
|
227
|
+
@status_subscriptions[component_id][sCI][n]['sOc'] = sOc
|
226
228
|
end
|
227
229
|
|
228
230
|
component = find_component component_id
|
@@ -312,12 +314,12 @@ module RSMP
|
|
312
314
|
# comes from the Version message send by the site
|
313
315
|
type = 'tlc'
|
314
316
|
version = message.attribute 'SXL'
|
315
|
-
RSMP::
|
317
|
+
RSMP::Schema::find_schema! type, version, lenient: true
|
316
318
|
|
317
319
|
# store sxl version requested by site
|
318
320
|
# TODO should check agaist site settings
|
319
321
|
@site_sxl_version = message.attribute 'SXL'
|
320
|
-
rescue RSMP::
|
322
|
+
rescue RSMP::Schema::UnknownSchemaError => e
|
321
323
|
dont_acknowledge message, "Rejected #{message.type} message,", "#{e}"
|
322
324
|
end
|
323
325
|
|
data/lib/rsmp/supervisor.rb
CHANGED
@@ -52,8 +52,8 @@ module RSMP
|
|
52
52
|
unless sxl
|
53
53
|
raise RSMP::ConfigurationError.new("Configuration error for site '#{site_id}': No SXL specified")
|
54
54
|
end
|
55
|
-
RSMP::
|
56
|
-
rescue RSMP::
|
55
|
+
RSMP::Schema.find_schemas! sxl if sxl
|
56
|
+
rescue RSMP::Schema::UnknownSchemaError => e
|
57
57
|
raise RSMP::ConfigurationError.new("Configuration error for site '#{site_id}': #{e}")
|
58
58
|
end
|
59
59
|
end
|
@@ -82,7 +82,7 @@ module RSMP
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def handshake_complete
|
85
|
-
sanitized_sxl_version = RSMP::
|
85
|
+
sanitized_sxl_version = RSMP::Schema.sanitize_version(sxl_version)
|
86
86
|
log "Connection to supervisor established, using core #{@rsmp_version}, #{sxl} #{sanitized_sxl_version}", level: :info
|
87
87
|
start_watchdog
|
88
88
|
if @site_settings['send_after_connect']
|
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.33.0"
|
35
35
|
spec.add_dependency "colorize", "~> 0.8.1"
|
36
36
|
spec.add_dependency "thor", "~> 1.2.1"
|
37
|
-
spec.add_dependency "
|
37
|
+
spec.add_dependency "rsmp_schema", "~> 0.1.0"
|
38
38
|
|
39
39
|
spec.add_development_dependency "bundler", "~> 2.3.7"
|
40
40
|
spec.add_development_dependency "rake", "~> 13.0.6"
|
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.
|
4
|
+
version: 0.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.2.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rsmp_schema
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.1.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:
|
82
|
+
version: 0.1.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|