rsmp 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +2 -1
- data/Gemfile.lock +1 -1
- data/config/supervisor.yaml +6 -2
- data/lib/rsmp/base.rb +2 -2
- data/lib/rsmp/error.rb +2 -0
- data/lib/rsmp/logger.rb +3 -0
- data/lib/rsmp/proxy.rb +6 -3
- data/lib/rsmp/site_base.rb +6 -0
- data/lib/rsmp/site_proxy.rb +18 -5
- data/lib/rsmp/supervisor.rb +1 -1
- data/lib/rsmp/supervisor_proxy.rb +6 -1
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp_schema/schema/core/alarm.json +6 -6
- data/lib/rsmp_schema/schema/core/definitions.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df1c6fd543202b5e5364133461d565269e5301976301c029e2d4311e6e74611
|
4
|
+
data.tar.gz: 2944466c2816349afe4f350052bb7756909a271d8466aa954294d905c1e69ae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5341c781360c44b1a68fd6c483618fc61d580986ba846fc85192ab02dae3318a526d66dcf911ca84518ad02e2b5263c7149c76df135afc589c6a2c75047bdbd7
|
7
|
+
data.tar.gz: 4023179107aac97ef4fa93daee1932e0b6cfbf4a1f11ae42c1831ea3970813737ae9127667578c1515dbad51d93277274999ab2aece8f3acc08d2450e0c15cac
|
data/.gitmodules
CHANGED
data/Gemfile.lock
CHANGED
data/config/supervisor.yaml
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
site_id: RN+SU0001
|
2
2
|
port: 12111
|
3
3
|
rsmp_versions:
|
4
|
+
- 3.1.1
|
5
|
+
- 3.1.2
|
6
|
+
- 3.1.3
|
4
7
|
- 3.1.4
|
5
8
|
|
6
|
-
watchdog_interval:
|
7
|
-
watchdog_timeout:
|
9
|
+
watchdog_interval: 5
|
10
|
+
watchdog_timeout: 10
|
8
11
|
acknowledgement_timeout: 2
|
9
12
|
store_messages: false
|
10
13
|
command_response_timeout: 1
|
@@ -12,6 +15,7 @@ status_response_timeout: 1
|
|
12
15
|
status_update_timeout: 1
|
13
16
|
|
14
17
|
sites:
|
18
|
+
KK+AG9998: # dynniq test tlc
|
15
19
|
AA+BBCCC=DDD: # rsmp simulator
|
16
20
|
RN+SI0001: # ruby rsmp site
|
17
21
|
|
data/lib/rsmp/base.rb
CHANGED
@@ -15,8 +15,8 @@ module RSMP
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def log str, options={}
|
18
|
-
default = { level: :log, author: author }
|
19
|
-
prepared = RSMP::Archive.prepare_item default.merge(options
|
18
|
+
default = { str:str, level: :log, author: author }
|
19
|
+
prepared = RSMP::Archive.prepare_item default.merge(options)
|
20
20
|
@archive.add prepared
|
21
21
|
@logger.log prepared
|
22
22
|
prepared
|
data/lib/rsmp/error.rb
CHANGED
data/lib/rsmp/logger.rb
CHANGED
@@ -57,6 +57,7 @@ module RSMP
|
|
57
57
|
return false if @settings["info"] == false && item[:level] == :info
|
58
58
|
return false if @settings["debug"] != true && item[:level] == :debug
|
59
59
|
return false if @settings["statistics"] != true && item[:level] == :statistics
|
60
|
+
return false if @settings["test"] != true && item[:level] == :test
|
60
61
|
|
61
62
|
if item[:message]
|
62
63
|
type = item[:message].type
|
@@ -96,6 +97,8 @@ module RSMP
|
|
96
97
|
str.colorize(:light_blue)
|
97
98
|
when :statistics
|
98
99
|
str.colorize(:light_black)
|
100
|
+
when :test
|
101
|
+
str.colorize(:light_magenta)
|
99
102
|
else
|
100
103
|
str
|
101
104
|
end
|
data/lib/rsmp/proxy.rb
CHANGED
@@ -179,9 +179,12 @@ module RSMP
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def check_watchdog_timeout now
|
182
|
+
|
182
183
|
timeout = @settings["watchdog_timeout"]
|
183
184
|
latest = @latest_watchdog_received + timeout
|
184
|
-
|
185
|
+
left = latest - now
|
186
|
+
log "check watchdog, time:#{timeout}, last:#{@latest_watchdog_received}, now: #{now}, latest:#{latest}, left #{left}, fail:#{left<0}", level: :debug
|
187
|
+
if left < 0
|
185
188
|
log "No Watchdog within #{timeout} seconds, received at #{@latest_watchdog_received}, now is #{now}, diff #{now-latest}", level: :error
|
186
189
|
stop
|
187
190
|
return true
|
@@ -354,11 +357,11 @@ module RSMP
|
|
354
357
|
@state
|
355
358
|
end
|
356
359
|
|
357
|
-
def send_version rsmp_versions
|
360
|
+
def send_version site_id_array, rsmp_versions
|
358
361
|
versions_hash = [rsmp_versions].flatten.map {|v| {"vers" => v} }
|
359
362
|
version_response = Version.new({
|
360
363
|
"RSMP"=>versions_hash,
|
361
|
-
"siteId"=>
|
364
|
+
"siteId"=>site_id_array,
|
362
365
|
"SXL"=>sxl_version
|
363
366
|
})
|
364
367
|
send_message version_response
|
data/lib/rsmp/site_base.rb
CHANGED
@@ -26,5 +26,11 @@ module RSMP
|
|
26
26
|
Component.new id: id, node: self, grouped: true
|
27
27
|
end
|
28
28
|
|
29
|
+
def find_component component_id
|
30
|
+
component = @components[component_id]
|
31
|
+
raise UnknownComponent.new("Component #{component_id} not found") unless component
|
32
|
+
component
|
33
|
+
end
|
34
|
+
|
29
35
|
end
|
30
36
|
end
|
data/lib/rsmp/site_proxy.rb
CHANGED
@@ -53,7 +53,8 @@ module RSMP
|
|
53
53
|
log "Received Version message for sites [#{@site_ids.join(',')}] using RSMP #{rsmp_version}", message: message, level: :log
|
54
54
|
start_timer
|
55
55
|
acknowledge message
|
56
|
-
send_version rsmp_version
|
56
|
+
send_version message.attributes['siteId'], rsmp_version
|
57
|
+
|
57
58
|
@version_determined = true
|
58
59
|
|
59
60
|
site_id = @site_ids.first
|
@@ -81,6 +82,7 @@ module RSMP
|
|
81
82
|
if component == nil
|
82
83
|
if @site_settings == nil || @site_settings['components'] == nil
|
83
84
|
component = build_component c_id
|
85
|
+
@components[c_id] = component
|
84
86
|
log "Adding component #{c_id} to site #{site_id}", level: :info
|
85
87
|
else
|
86
88
|
reason = "component #{c_id} not found"
|
@@ -158,7 +160,7 @@ module RSMP
|
|
158
160
|
item[:message] if item
|
159
161
|
end
|
160
162
|
|
161
|
-
def subscribe_to_status component, status_list
|
163
|
+
def subscribe_to_status component, status_list, timeout
|
162
164
|
raise NotReady unless @state == :ready
|
163
165
|
message = RSMP::StatusSubscribe.new({
|
164
166
|
"ntsOId" => '',
|
@@ -167,7 +169,7 @@ module RSMP
|
|
167
169
|
"sS" => status_list
|
168
170
|
})
|
169
171
|
send_message message
|
170
|
-
message
|
172
|
+
return message, wait_for_status_update(component: component, timeout: timeout)
|
171
173
|
end
|
172
174
|
|
173
175
|
def unsubscribe_to_status component, status_list
|
@@ -189,8 +191,19 @@ module RSMP
|
|
189
191
|
|
190
192
|
def wait_for_status_update options={}
|
191
193
|
raise ArgumentError unless options[:component]
|
192
|
-
item = @archive.capture(options.merge(type: "StatusUpdate", with_message: true, num: 1)) do |item|
|
193
|
-
# check
|
194
|
+
item = @archive.capture(@task,options.merge(type: "StatusUpdate", with_message: true, num: 1)) do |item|
|
195
|
+
# TODO check components
|
196
|
+
found = false
|
197
|
+
sS = item[:message].attributes['sS']
|
198
|
+
sS.each do |status|
|
199
|
+
break if options[:sCI] && options[:sCI] != status['sCI']
|
200
|
+
break if options[:n] && options[:n] != status['n']
|
201
|
+
break if options[:q] && options[:q] != status['q']
|
202
|
+
break if options[:s] && options[:s] != status['s']
|
203
|
+
found = true
|
204
|
+
break
|
205
|
+
end
|
206
|
+
found
|
194
207
|
end
|
195
208
|
item[:message] if item
|
196
209
|
end
|
data/lib/rsmp/supervisor.rb
CHANGED
@@ -186,7 +186,7 @@ module RSMP
|
|
186
186
|
def find_allowed_site_setting site_id
|
187
187
|
return {} unless @supervisor_settings['sites']
|
188
188
|
@supervisor_settings['sites'].each_pair do |id,settings|
|
189
|
-
if id == site_id
|
189
|
+
if id == :any || id == site_id
|
190
190
|
return settings
|
191
191
|
end
|
192
192
|
end
|
@@ -156,6 +156,9 @@ module RSMP
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def process_status_request message
|
159
|
+
component_id = message.attributes["cId"]
|
160
|
+
component = @site.find_component component_id
|
161
|
+
|
159
162
|
log "Received #{message.type}", message: message, level: :log
|
160
163
|
sS = message.attributes["sS"].clone.map do |request|
|
161
164
|
request["s"] = rand(100).to_s
|
@@ -163,12 +166,14 @@ module RSMP
|
|
163
166
|
request
|
164
167
|
end
|
165
168
|
response = StatusResponse.new({
|
166
|
-
"cId"=>
|
169
|
+
"cId"=>component_id,
|
167
170
|
"sTs"=>RSMP.now_string,
|
168
171
|
"sS"=>sS
|
169
172
|
})
|
170
173
|
acknowledge message
|
171
174
|
send_message response
|
175
|
+
rescue UnknownComponent => e
|
176
|
+
dont_acknowledge message, '', e.to_s
|
172
177
|
end
|
173
178
|
|
174
179
|
def process_status_subcribe message
|
data/lib/rsmp/version.rb
CHANGED
@@ -9,33 +9,33 @@
|
|
9
9
|
"aSp" : {
|
10
10
|
"description" : "Alarm message variant",
|
11
11
|
"type" : "string",
|
12
|
-
"enum" : [ "
|
12
|
+
"enum" : [ "issue", "acknowledge", "suspend", "resume" ]
|
13
13
|
},
|
14
14
|
"ack" : {
|
15
15
|
"description" : "Acknowledgement",
|
16
16
|
"type" : "string",
|
17
|
-
"enum" : [ "
|
17
|
+
"enum" : [ "acknowledged", "notAcknowledged" ]
|
18
18
|
},
|
19
19
|
"aS" : {
|
20
20
|
"description" : "Status",
|
21
21
|
"type" : "string",
|
22
|
-
"enum" : [ "
|
22
|
+
"enum" : [ "inactive", "active" ]
|
23
23
|
},
|
24
24
|
"sS" : {
|
25
25
|
"description" : "Suspended",
|
26
26
|
"type" : "string",
|
27
|
-
"enum" : [ "suspended", "notSuspended" ]
|
27
|
+
"enum" : [ "suspended", "notSuspended" ]
|
28
28
|
},
|
29
29
|
"aTs" : { "$ref": "definitions.json#/timestamp" },
|
30
30
|
"cat" : {
|
31
31
|
"description" : "Category",
|
32
32
|
"type" : "string",
|
33
|
-
"enum" : [ "T", "D" ]
|
33
|
+
"enum" : [ "T", "D" ]
|
34
34
|
},
|
35
35
|
"pri" : {
|
36
36
|
"description" : "Priority",
|
37
37
|
"type" : "string",
|
38
|
-
"enum" : [ "1", "2", "3" ]
|
38
|
+
"enum" : [ "1", "2", "3" ]
|
39
39
|
},
|
40
40
|
"rvs" : {
|
41
41
|
"description" : "Return values",
|
@@ -21,7 +21,7 @@
|
|
21
21
|
"description" : "Version",
|
22
22
|
"type": "string",
|
23
23
|
"$comment" : "Example: 1.2.3 or 1.2",
|
24
|
-
"pattern" : "^[0-9]{1,2}\\.[0-9]{1,2}(\\.[0-9]{1,2})
|
24
|
+
"pattern" : "^[0-9]{1,2}\\.[0-9]{1,2}(\\.[0-9]{1,2})?"
|
25
25
|
},
|
26
26
|
"command_code": {
|
27
27
|
"description" : "Command code id",
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|