rsmp 0.1.10 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +47 -49
- data/README.md +7 -1
- data/config/site.yaml +3 -4
- data/config/supervisor.yaml +2 -5
- data/config/tlc.yaml +44 -0
- data/documentation/classes.md +62 -0
- data/lib/rsmp.rb +1 -0
- data/lib/rsmp/archive.rb +11 -5
- data/lib/rsmp/cli.rb +15 -5
- data/lib/rsmp/component.rb +12 -2
- data/lib/rsmp/error.rb +10 -1
- data/lib/rsmp/message.rb +25 -2
- data/lib/rsmp/node.rb +33 -6
- data/lib/rsmp/probe.rb +5 -18
- data/lib/rsmp/proxy.rb +43 -43
- data/lib/rsmp/site.rb +7 -3
- data/lib/rsmp/site_base.rb +6 -4
- data/lib/rsmp/site_proxy.rb +103 -59
- data/lib/rsmp/supervisor.rb +6 -5
- data/lib/rsmp/supervisor_proxy.rb +84 -31
- data/lib/rsmp/tlc.rb +869 -0
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp/wait.rb +149 -3
- data/rsmp.gemspec +9 -10
- metadata +28 -34
- data/lib/rsmp/supervisor_base.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfbb10fc77baf015a50f7ce94b2ee3b0830a09f8c083b9f0dfbb86fcd4285893
|
4
|
+
data.tar.gz: 8756ab6010d199fdc2e22973ab960156b66f000c7a8feacad201f5be5bb0ff08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af59d9680e6717f8d0e89cae43e1a95aa17ad322c54024c4dae91bb8e58216d7fc57c727c3e1d56ac9c6770131f2197f6708cceba890b0b83867a493b410111e
|
7
|
+
data.tar.gz: 20597a90bc6c9abaf196ffba19d233fa76716c2febee7af2c0c057337953d40d77ac965a671716ed5e645fb93734265231def5104efc7a39a6e92fade86a5ce7
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rsmp (0.1.
|
4
|
+
rsmp (0.1.19)
|
5
5
|
async (~> 1.23.0)
|
6
|
-
async-io (~> 1.27.
|
6
|
+
async-io (~> 1.27.4)
|
7
7
|
colorize (~> 0.8.1)
|
8
|
-
json_schemer (~> 0.2.
|
9
|
-
thor (~> 0.
|
8
|
+
json_schemer (~> 0.2.11)
|
9
|
+
thor (~> 1.0.1)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
aruba (0.
|
15
|
-
childprocess (
|
16
|
-
contracts (~> 0.
|
17
|
-
cucumber (>=
|
14
|
+
aruba (1.0.0)
|
15
|
+
childprocess (~> 3.0)
|
16
|
+
contracts (~> 0.16.0)
|
17
|
+
cucumber (>= 2.4, < 4.0)
|
18
18
|
ffi (~> 1.9)
|
19
|
-
rspec-expectations (
|
20
|
-
thor (~> 0
|
19
|
+
rspec-expectations (~> 3.4)
|
20
|
+
thor (~> 1.0)
|
21
21
|
async (1.23.0)
|
22
22
|
console (~> 1.0)
|
23
23
|
nio4r (~> 2.3)
|
24
24
|
timers (~> 4.1)
|
25
|
-
async-io (1.27.
|
25
|
+
async-io (1.27.7)
|
26
26
|
async (~> 1.14)
|
27
|
-
backports (3.
|
28
|
-
builder (3.2.
|
29
|
-
childprocess (
|
30
|
-
rake (< 13.0)
|
27
|
+
backports (3.17.0)
|
28
|
+
builder (3.2.4)
|
29
|
+
childprocess (3.0.0)
|
31
30
|
colorize (0.8.1)
|
32
|
-
console (1.
|
31
|
+
console (1.10.1)
|
32
|
+
fiber-local
|
33
33
|
contracts (0.16.0)
|
34
34
|
cucumber (3.1.2)
|
35
35
|
builder (>= 2.1.2)
|
@@ -48,54 +48,52 @@ GEM
|
|
48
48
|
cucumber-tag_expressions (1.1.1)
|
49
49
|
cucumber-wire (0.0.1)
|
50
50
|
diff-lcs (1.3)
|
51
|
-
ecma-re-validator (0.
|
52
|
-
regexp_parser (~>
|
53
|
-
ffi (1.
|
51
|
+
ecma-re-validator (0.3.0)
|
52
|
+
regexp_parser (~> 2.0)
|
53
|
+
ffi (1.12.2)
|
54
|
+
fiber-local (1.0.0)
|
54
55
|
gherkin (5.1.0)
|
55
|
-
hana (1.3.
|
56
|
-
json_schemer (0.2.
|
57
|
-
ecma-re-validator (~> 0.
|
56
|
+
hana (1.3.7)
|
57
|
+
json_schemer (0.2.17)
|
58
|
+
ecma-re-validator (~> 0.3)
|
58
59
|
hana (~> 1.3)
|
59
|
-
regexp_parser (~>
|
60
|
+
regexp_parser (~> 2.0)
|
60
61
|
uri_template (~> 0.7)
|
61
|
-
multi_json (1.
|
62
|
+
multi_json (1.14.1)
|
62
63
|
multi_test (0.1.2)
|
63
|
-
nio4r (2.5.
|
64
|
-
rake (
|
65
|
-
regexp_parser (
|
66
|
-
rspec (3.
|
67
|
-
rspec-core (~> 3.
|
68
|
-
rspec-expectations (~> 3.
|
69
|
-
rspec-mocks (~> 3.
|
70
|
-
rspec-core (3.
|
71
|
-
rspec-support (~> 3.
|
72
|
-
rspec-expectations (3.
|
64
|
+
nio4r (2.5.4)
|
65
|
+
rake (13.0.1)
|
66
|
+
regexp_parser (2.0.0)
|
67
|
+
rspec (3.9.0)
|
68
|
+
rspec-core (~> 3.9.0)
|
69
|
+
rspec-expectations (~> 3.9.0)
|
70
|
+
rspec-mocks (~> 3.9.0)
|
71
|
+
rspec-core (3.9.1)
|
72
|
+
rspec-support (~> 3.9.1)
|
73
|
+
rspec-expectations (3.9.1)
|
73
74
|
diff-lcs (>= 1.2.0, < 2.0)
|
74
|
-
rspec-support (~> 3.
|
75
|
-
rspec-mocks (3.
|
75
|
+
rspec-support (~> 3.9.0)
|
76
|
+
rspec-mocks (3.9.1)
|
76
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
-
rspec-support (~> 3.
|
78
|
-
rspec-support (3.
|
79
|
-
|
80
|
-
rspec (~> 3.0)
|
81
|
-
thor (0.20.3)
|
78
|
+
rspec-support (~> 3.9.0)
|
79
|
+
rspec-support (3.9.2)
|
80
|
+
thor (1.0.1)
|
82
81
|
timecop (0.9.1)
|
83
|
-
timers (4.3.
|
82
|
+
timers (4.3.2)
|
84
83
|
uri_template (0.7.0)
|
85
84
|
|
86
85
|
PLATFORMS
|
87
86
|
ruby
|
88
87
|
|
89
88
|
DEPENDENCIES
|
90
|
-
aruba (~> 0.
|
91
|
-
bundler (~> 2.
|
89
|
+
aruba (~> 1.0.0)
|
90
|
+
bundler (~> 2.1.4)
|
92
91
|
cucumber (~> 3.1.2)
|
93
|
-
rake (~>
|
92
|
+
rake (~> 13.0.1)
|
94
93
|
rsmp!
|
95
|
-
rspec (~> 3.0)
|
96
|
-
rspec-expectations (~> 3.
|
97
|
-
rspec-with_params (~> 0.2.0)
|
94
|
+
rspec (~> 3.9.0)
|
95
|
+
rspec-expectations (~> 3.9.1)
|
98
96
|
timecop (~> 0.9.1)
|
99
97
|
|
100
98
|
BUNDLED WITH
|
101
|
-
2.1.
|
99
|
+
2.1.4
|
data/README.md
CHANGED
@@ -163,6 +163,12 @@ The ```site``` command will start an RSMP site, which will try to connect to one
|
|
163
163
|
2019-11-11 12:22:00 UTC RN+SU0001 C1 <-- 8280 Sent AggregatedStatus
|
164
164
|
```
|
165
165
|
|
166
|
+
|
167
|
+
Use the the --type switch to select a specific type of site. Messages will be validated against the corresponding SXL JSON schema. Without any type specified, messages will be validated against the core RSMP schema only.
|
168
|
+
|
169
|
+
Use the ```tlc``` site type to run an emulation of a traffic light controller. This type of site implements enough of functionality to pass all the rsmp_validator tests. You can setup signal group components, in the config file.
|
170
|
+
|
171
|
+
|
166
172
|
### CLI help and options.
|
167
173
|
Use ```--help <command>``` to get a list of available options.
|
168
174
|
|
@@ -172,7 +178,7 @@ Use ```--config <path>``` to point to a .yaml config file, controlling things li
|
|
172
178
|
### RSpec
|
173
179
|
RSpec tests are located in spec/. The tests will start supervisor and sites to test communication, but will do so on port 13111, rather than the usual port 12111, to avoid inferference with other RMSP processes running locally.
|
174
180
|
|
175
|
-
Note that these tests are NOT intented for testing external equipment or systems. The tests are for validating the code in this repository. To test external equipment or systems.
|
181
|
+
Note that these tests are NOT intented for testing external equipment or systems. The tests are for validating the code in this repository. To test external equipment or systems use the rsmp_validator tool.
|
176
182
|
|
177
183
|
```console
|
178
184
|
$ rspec
|
data/config/site.yaml
CHANGED
@@ -12,13 +12,12 @@ rsmp_versions:
|
|
12
12
|
- 3.1.4
|
13
13
|
|
14
14
|
components:
|
15
|
-
|
16
|
-
|
15
|
+
main:
|
16
|
+
C1:
|
17
17
|
|
18
18
|
watchdog_interval: 1
|
19
19
|
watchdog_timeout: 2
|
20
|
-
acknowledgement_timeout:
|
21
|
-
store_messages: false
|
20
|
+
acknowledgement_timeout: 1
|
22
21
|
command_response_timeout: 1
|
23
22
|
status_response_timeout: 1
|
24
23
|
status_update_timeout: 1
|
data/config/supervisor.yaml
CHANGED
@@ -13,9 +13,6 @@ command_response_timeout: 1
|
|
13
13
|
status_response_timeout: 1
|
14
14
|
status_update_timeout: 1
|
15
15
|
|
16
|
-
sites:
|
17
|
-
any:
|
18
|
-
|
19
16
|
log:
|
20
17
|
active: true
|
21
18
|
color: true
|
@@ -28,6 +25,6 @@ log:
|
|
28
25
|
direction: true
|
29
26
|
level: false
|
30
27
|
json: true
|
31
|
-
acknowledgements:
|
32
|
-
watchdogs:
|
28
|
+
acknowledgements: false
|
29
|
+
watchdogs: false
|
33
30
|
|
data/config/tlc.yaml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
site_id: RN+SI0001
|
2
|
+
supervisors:
|
3
|
+
- ip: 127.0.0.1
|
4
|
+
port: 12111
|
5
|
+
|
6
|
+
components:
|
7
|
+
main:
|
8
|
+
TC:
|
9
|
+
cycle_time: 6
|
10
|
+
signal_group:
|
11
|
+
A1:
|
12
|
+
plan: '11NBBB'
|
13
|
+
A2:
|
14
|
+
plan: '1NBBBB'
|
15
|
+
B1:
|
16
|
+
plan: 'BBB11N'
|
17
|
+
B2:
|
18
|
+
plan: 'BBB1NB'
|
19
|
+
detector_logic:
|
20
|
+
DL1:
|
21
|
+
watchdog_interval: 0.1
|
22
|
+
watchdog_timeout: 0.2
|
23
|
+
acknowledgement_timeout: 0.2
|
24
|
+
reconnect_interval: 0.1
|
25
|
+
|
26
|
+
security_codes:
|
27
|
+
1: '1111'
|
28
|
+
2: '2222'
|
29
|
+
|
30
|
+
log:
|
31
|
+
active: true
|
32
|
+
color: true
|
33
|
+
timestamp: true
|
34
|
+
id: true
|
35
|
+
component: true
|
36
|
+
ip: false
|
37
|
+
site_id: true
|
38
|
+
level: false
|
39
|
+
text: true
|
40
|
+
direction: true
|
41
|
+
json: true
|
42
|
+
acknowledgements: false
|
43
|
+
watchdogs: false
|
44
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Classes
|
2
|
+
|
3
|
+
## Class tree:
|
4
|
+
```
|
5
|
+
|
6
|
+
.------ Base -------.
|
7
|
+
/ \
|
8
|
+
/ \
|
9
|
+
/ SiteBase module \
|
10
|
+
Node / \ Proxy
|
11
|
+
/ \ / \ / \
|
12
|
+
Super Site SiteProxy SupervisorProxy
|
13
|
+
|
14
|
+
```
|
15
|
+
|
16
|
+
|
17
|
+
## Base
|
18
|
+
The Base class handle logging.
|
19
|
+
|
20
|
+
Node and Site inherit from Base.
|
21
|
+
|
22
|
+
## Node
|
23
|
+
A Node has an async task. A node can be started and stopped.
|
24
|
+
|
25
|
+
Node has two child classes: Site and Supervisor.
|
26
|
+
|
27
|
+
## Site
|
28
|
+
A Site represents an RSMP site, typically a traffic light, variable message sign, or other type of field equipment. An RSMP site can connect to one or more supervisors.
|
29
|
+
|
30
|
+
A Site has one or more SupervisorProxies (connections to supervisor).
|
31
|
+
|
32
|
+
A site has one of more components.
|
33
|
+
|
34
|
+
## Supervisor
|
35
|
+
A Supervisor represents an RSMP supervisor, typically a central supervisor system. An RSMP supervisor can handle connections one or more sites.
|
36
|
+
|
37
|
+
A Supervisor has one or more SiteProxies (connections to sites).
|
38
|
+
|
39
|
+
## Proxy
|
40
|
+
A Proxy represents a connection to a remove Site or Supervisor and handles the RSMP interface.
|
41
|
+
|
42
|
+
A proxy has an async task listening for messages on an TCP/IP socket. Incoming RSMP messages are parsing and appropriate handles are called.
|
43
|
+
|
44
|
+
A proxy also has a repaating async timer task for handling watchdog and acknowledgement timeouts.
|
45
|
+
|
46
|
+
Proxy has to child classes: SiteProxy and SupervisorProxy.
|
47
|
+
|
48
|
+
## SiteProxy
|
49
|
+
A connection to a remote Site.
|
50
|
+
|
51
|
+
Handles RSMP messaging specific to a supervisor, including methods for requesting status, sending commands, etc.
|
52
|
+
|
53
|
+
A SiteProxy has one or more components, representing the components in the remote site.
|
54
|
+
|
55
|
+
## Supervisor Proxy
|
56
|
+
A connection to a remote Site. Handles RSMP messaging specific to a site, including sending aggregated status, handling status requests, status subscription and command requests.
|
57
|
+
|
58
|
+
Status and command requests are delegated to the appropriate components.
|
59
|
+
|
60
|
+
## SiteBase
|
61
|
+
Things shared between Site and SiteProxy, mainly handling components.
|
62
|
+
|
data/lib/rsmp.rb
CHANGED
data/lib/rsmp/archive.rb
CHANGED
@@ -6,6 +6,8 @@ module RSMP
|
|
6
6
|
attr_reader :items
|
7
7
|
attr_accessor :probes
|
8
8
|
|
9
|
+
@@index = 0
|
10
|
+
|
9
11
|
def initialize
|
10
12
|
@items = []
|
11
13
|
@probes = ProbeCollection.new
|
@@ -27,6 +29,14 @@ module RSMP
|
|
27
29
|
cleaned
|
28
30
|
end
|
29
31
|
|
32
|
+
def self.increase_index
|
33
|
+
@@index += 1
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.current_index
|
37
|
+
@@index
|
38
|
+
end
|
39
|
+
|
30
40
|
def by_level levels
|
31
41
|
items.select { |item| levels.include? item[:level] }
|
32
42
|
end
|
@@ -35,12 +45,8 @@ module RSMP
|
|
35
45
|
items.map { |item| item[:str] }
|
36
46
|
end
|
37
47
|
|
38
|
-
def current_index
|
39
|
-
@items.size
|
40
|
-
end
|
41
|
-
|
42
48
|
def add item
|
43
|
-
item[:index] =
|
49
|
+
item[:index] = RSMP::Archive.increase_index
|
44
50
|
@items << item
|
45
51
|
probe item
|
46
52
|
end
|
data/lib/rsmp/cli.rb
CHANGED
@@ -10,6 +10,7 @@ module RSMP
|
|
10
10
|
method_option :supervisors, :type => :string, :aliases => "-s", banner: 'ip:port,... list of supervisor to connect to'
|
11
11
|
method_option :log, :type => :string, :aliases => "-l", banner: 'Path to log file'
|
12
12
|
method_option :json, :type => :boolean, :aliases => "-j", banner: 'Show JSON messages in log'
|
13
|
+
method_option :type, :type => :string, :aliases => "-t", banner: 'Type of site: [tlc]'
|
13
14
|
def site
|
14
15
|
settings = {}
|
15
16
|
log_settings = { 'active' => true }
|
@@ -17,7 +18,7 @@ module RSMP
|
|
17
18
|
if options[:config]
|
18
19
|
if File.exist? options[:config]
|
19
20
|
settings = YAML.load_file options[:config]
|
20
|
-
log_settings = settings.delete
|
21
|
+
log_settings = settings.delete('log') || {}
|
21
22
|
else
|
22
23
|
puts "Error: Config #{options[:config]} not found"
|
23
24
|
exit
|
@@ -28,9 +29,9 @@ module RSMP
|
|
28
29
|
settings['site_id'] = options[:id]
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
if options[:supervisors]
|
33
|
+
options[:supervisors].split(',').each do |supervisor|
|
34
|
+
settings[:supervisors] ||= []
|
34
35
|
ip, port = supervisor.split ':'
|
35
36
|
ip = '127.0.0.1' if ip.empty?
|
36
37
|
port = '12111' if port.empty?
|
@@ -46,7 +47,16 @@ module RSMP
|
|
46
47
|
log_settings['json'] = options[:json]
|
47
48
|
end
|
48
49
|
|
49
|
-
RSMP::Site
|
50
|
+
site_class = RSMP::Site
|
51
|
+
if options[:type]
|
52
|
+
case options[:type]
|
53
|
+
when 'tlc'
|
54
|
+
site_class = RSMP::Tlc
|
55
|
+
else
|
56
|
+
site_class = RSMP::Site
|
57
|
+
end
|
58
|
+
end
|
59
|
+
site_class.new(site_settings:settings, log_settings: log_settings).start
|
50
60
|
end
|
51
61
|
|
52
62
|
desc "supervisor", "Run RSMP supervisor"
|
data/lib/rsmp/component.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module RSMP
|
2
2
|
class Component
|
3
|
-
attr_reader :c_id, :alarms, :statuses, :aggregated_status, :aggregated_status_bools, :grouped
|
3
|
+
attr_reader :c_id, :node, :alarms, :statuses, :aggregated_status, :aggregated_status_bools, :grouped
|
4
4
|
|
5
5
|
AGGREGATED_STATUS_KEYS = [ :local_control,
|
6
6
|
:communication_distruption,
|
@@ -23,6 +23,7 @@ module RSMP
|
|
23
23
|
def clear_aggregated_status
|
24
24
|
@aggregated_status = []
|
25
25
|
@aggregated_status_bools = Array.new(8,false)
|
26
|
+
@aggregated_status_bools[5] = true
|
26
27
|
end
|
27
28
|
|
28
29
|
def set_aggregated_status status
|
@@ -58,7 +59,16 @@ module RSMP
|
|
58
59
|
def alarm code:, status:
|
59
60
|
end
|
60
61
|
|
61
|
-
def
|
62
|
+
def log str, options
|
63
|
+
@node.log str, options
|
64
|
+
end
|
65
|
+
|
66
|
+
def handle_command command_code, arg
|
67
|
+
raise UnknownCommand.new "Command #{command_code} not implemented by #{self.class}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_status status_code, status_name=nil
|
71
|
+
raise UnknownStatus.new "Status #{status_code}/#{status_name} not implemented by #{self.class}"
|
62
72
|
end
|
63
73
|
|
64
74
|
end
|