rsmp 0.1.12 → 0.1.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e45799eb31adc34f3c6d80fbf0b5e24c41a07cf5561231d085d2a931119417dc
4
- data.tar.gz: a9ceb38c14787707b493ade46c861d4ee336b0b394890f3a62c56c079c978a60
3
+ metadata.gz: bae0b092e316d3d2fd5297d6c7a36bbe84f80150dd093d101c0c49916f4b93ba
4
+ data.tar.gz: 3fb3f09d863c7309e0eae3c61f0a31e3068d5d80ad520f706c4ed437f2414e90
5
5
  SHA512:
6
- metadata.gz: ba448443412590959523070ac30bad578ff4402ba55b9dacb9ddc4fefd48f596cdd0f34cb839e104b5ebbdb0ade447e51ab1c5e48caa9eabb96b9fc418932811
7
- data.tar.gz: ab21f83999dfbce048bfb86f56d9b07a542828422f6e706ce92ab3ded1e5e75c1e4d202ab8d24de14681b8f295701f9d51569e8047e15e5e12d72d8948a474f9
6
+ metadata.gz: 0ca10d29c54b8bcf3c7b359c78838b03f64c50b90c988d1cf2390bf392bad26570b7618045409a8b182df1cbcecd4c820be3ab535a47211c3149bdbcc9ccaab7
7
+ data.tar.gz: de933522e4f50fbd861bac067e803e56cad258903ab4a654ee7f994fc0d7c34150c6d70c55f8350e0e73a38e70673db9111bff4a2086b42628a85a71edf50b9b
data/.gitignore CHANGED
@@ -12,5 +12,6 @@ log
12
12
  /spec/reports/
13
13
  /tmp/
14
14
  /lib/rsmp_schema/
15
+ /config/private/
15
16
 
16
17
 
data/.gitmodules CHANGED
@@ -1,4 +0,0 @@
1
- [submodule "rsmp_schema"]
2
- path = lib/rsmp_schema
3
- url = git@github.com:rsmp-nordic/rsmp_schema.git
4
-
data/Gemfile.lock CHANGED
@@ -1,35 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.1.12)
5
- async (~> 1.23.0)
6
- async-io (~> 1.27.1)
4
+ rsmp (0.1.27)
5
+ async (~> 1.28.7)
6
+ async-io (~> 1.30.2)
7
7
  colorize (~> 0.8.1)
8
- json_schemer (~> 0.2.8)
9
- thor (~> 0.20.3)
8
+ rsmp_schemer (~> 0.2.0)
9
+ thor (~> 1.0.1)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- aruba (0.14.11)
15
- childprocess (>= 0.6.3, < 3.0.0)
16
- contracts (~> 0.9)
17
- cucumber (>= 1.3.19)
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 (>= 2.99)
20
- thor (~> 0.19)
21
- async (1.23.0)
22
- console (~> 1.0)
19
+ rspec-expectations (~> 3.4)
20
+ thor (~> 1.0)
21
+ async (1.28.9)
22
+ console (~> 1.10)
23
23
  nio4r (~> 2.3)
24
24
  timers (~> 4.1)
25
- async-io (1.27.1)
25
+ async-io (1.30.2)
26
26
  async (~> 1.14)
27
- backports (3.15.0)
28
- builder (3.2.3)
29
- childprocess (2.0.0)
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.6.0)
31
+ console (1.12.0)
32
+ fiber-local
33
33
  contracts (0.16.0)
34
34
  cucumber (3.1.2)
35
35
  builder (>= 2.1.2)
@@ -48,54 +48,54 @@ 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.2.0)
52
- regexp_parser (~> 1.2)
53
- ffi (1.11.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.5)
56
- json_schemer (0.2.8)
57
- ecma-re-validator (~> 0.2)
56
+ hana (1.3.7)
57
+ json_schemer (0.2.18)
58
+ ecma-re-validator (~> 0.3)
58
59
  hana (~> 1.3)
59
- regexp_parser (~> 1.5)
60
+ regexp_parser (~> 2.0)
60
61
  uri_template (~> 0.7)
61
- multi_json (1.13.1)
62
+ multi_json (1.14.1)
62
63
  multi_test (0.1.2)
63
- nio4r (2.5.2)
64
- rake (10.5.0)
65
- regexp_parser (1.6.0)
66
- rspec (3.8.0)
67
- rspec-core (~> 3.8.0)
68
- rspec-expectations (~> 3.8.0)
69
- rspec-mocks (~> 3.8.0)
70
- rspec-core (3.8.2)
71
- rspec-support (~> 3.8.0)
72
- rspec-expectations (3.8.4)
64
+ nio4r (2.5.7)
65
+ rake (13.0.1)
66
+ regexp_parser (2.1.1)
67
+ rsmp_schemer (0.2.0)
68
+ json_schemer (~> 0.2.18)
69
+ rspec (3.9.0)
70
+ rspec-core (~> 3.9.0)
71
+ rspec-expectations (~> 3.9.0)
72
+ rspec-mocks (~> 3.9.0)
73
+ rspec-core (3.9.1)
74
+ rspec-support (~> 3.9.1)
75
+ rspec-expectations (3.9.1)
73
76
  diff-lcs (>= 1.2.0, < 2.0)
74
- rspec-support (~> 3.8.0)
75
- rspec-mocks (3.8.1)
77
+ rspec-support (~> 3.9.0)
78
+ rspec-mocks (3.9.1)
76
79
  diff-lcs (>= 1.2.0, < 2.0)
77
- rspec-support (~> 3.8.0)
78
- rspec-support (3.8.2)
79
- rspec-with_params (0.2.0)
80
- rspec (~> 3.0)
81
- thor (0.20.3)
80
+ rspec-support (~> 3.9.0)
81
+ rspec-support (3.9.2)
82
+ thor (1.0.1)
82
83
  timecop (0.9.1)
83
- timers (4.3.0)
84
+ timers (4.3.3)
84
85
  uri_template (0.7.0)
85
86
 
86
87
  PLATFORMS
87
88
  ruby
88
89
 
89
90
  DEPENDENCIES
90
- aruba (~> 0.14.11)
91
- bundler (~> 2.0)
91
+ aruba (~> 1.0.0)
92
+ bundler (~> 2.2.3)
92
93
  cucumber (~> 3.1.2)
93
- rake (~> 10.0)
94
+ rake (~> 13.0.1)
94
95
  rsmp!
95
- rspec (~> 3.0)
96
- rspec-expectations (~> 3.8.3)
97
- rspec-with_params (~> 0.2.0)
96
+ rspec (~> 3.9.0)
97
+ rspec-expectations (~> 3.9.1)
98
98
  timecop (~> 0.9.1)
99
99
 
100
100
  BUNDLED WITH
101
- 2.1.0.pre.2
101
+ 2.2.3
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,8 +12,8 @@ rsmp_versions:
12
12
  - 3.1.4
13
13
 
14
14
  components:
15
- C1:
16
- type: main
15
+ main:
16
+ C1:
17
17
 
18
18
  watchdog_interval: 1
19
19
  watchdog_timeout: 2
@@ -4,14 +4,19 @@ rsmp_versions:
4
4
  - 3.1.2
5
5
  - 3.1.3
6
6
  - 3.1.4
7
+ - 3.1.5
7
8
 
8
- watchdog_interval: 1
9
- watchdog_timeout: 2
10
- acknowledgement_timeout: 2
9
+ sites:
10
+ :any:
11
+ sxl: tlc
12
+
13
+ watchdog_interval: 0.1
14
+ watchdog_timeout: 0.2
15
+ acknowledgement_timeout: 0.2
11
16
  store_messages: false
12
- command_response_timeout: 1
13
- status_response_timeout: 1
14
- status_update_timeout: 1
17
+ command_response_timeout: 0.1
18
+ status_response_timeout: 0.1
19
+ status_update_timeout: 0.1
15
20
 
16
21
  log:
17
22
  active: true
@@ -20,6 +25,7 @@ log:
20
25
  id: true
21
26
  component: true
22
27
  ip: false
28
+ port: true
23
29
  site_id: true
24
30
  text: true
25
31
  direction: true
data/config/tlc.yaml ADDED
@@ -0,0 +1,52 @@
1
+ site_id: RN+SI0001
2
+ supervisors:
3
+ - ip: 127.0.0.1
4
+ port: 12111
5
+
6
+ # if you leave it out, all know version will be allowed
7
+ #rsmp_versions:
8
+ # - 3.1.4
9
+ # - 3.1.5
10
+
11
+ sxl: tlc
12
+ sxl_version: 1.0.15
13
+
14
+ components:
15
+ main:
16
+ TC:
17
+ cycle_time: 6
18
+ signal_group:
19
+ A1:
20
+ plan: '11NBBB'
21
+ A2:
22
+ plan: '1NBBBB'
23
+ B1:
24
+ plan: 'BBB11N'
25
+ B2:
26
+ plan: 'BBB1NB'
27
+ detector_logic:
28
+ DL1:
29
+ watchdog_interval: 0.1
30
+ watchdog_timeout: 0.2
31
+ acknowledgement_timeout: 0.2
32
+ reconnect_interval: 0.1
33
+
34
+ security_codes:
35
+ 1: '1111'
36
+ 2: '2222'
37
+
38
+ log:
39
+ active: true
40
+ color: true
41
+ timestamp: true
42
+ id: true
43
+ component: true
44
+ ip: false
45
+ site_id: true
46
+ level: false
47
+ text: true
48
+ direction: true
49
+ json: true
50
+ acknowledgements: false
51
+ watchdogs: false
52
+
@@ -0,0 +1,65 @@
1
+ # Classes and Modules
2
+
3
+ ## Overview
4
+ ```
5
+ Node - - include Logging, Wait
6
+ / \
7
+ Super Site - - include Components
8
+
9
+
10
+ Proxy - - include Logging, Wait
11
+ / \
12
+ SupervisorProxy SiteProxy - - include Components, SiteProxyWait
13
+ ```
14
+
15
+ ## Modules
16
+ ### Logging
17
+ Handle logging.
18
+
19
+ ### Wait
20
+ Handles waiting for an async condition and block.
21
+
22
+ ### SiteProxyWait
23
+ Handles waiting for different types of messages and responses from a remote site.
24
+
25
+ ### Components
26
+ Component handling.
27
+
28
+ ## Classes
29
+ ### Node
30
+ A Node has an async task. A node can be started and stopped.
31
+
32
+ Node has two child classes: Site and Supervisor.
33
+
34
+ ### Site
35
+ 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.
36
+
37
+ A Site has one or more SupervisorProxies (connections to supervisor).
38
+
39
+ A site has one of more components.
40
+
41
+ ### Supervisor
42
+ A Supervisor represents an RSMP supervisor, typically a central supervisor system. An RSMP supervisor can handle connections one or more sites.
43
+
44
+ A Supervisor has one or more SiteProxies (connections to sites).
45
+
46
+ ### Proxy
47
+ A Proxy represents a connection to a remove Site or Supervisor and handles the RSMP interface.
48
+
49
+ A proxy has an async task listening for messages on an TCP/IP socket. Incoming RSMP messages are parsing and appropriate handles are called.
50
+
51
+ A proxy also has a repaating async timer task for handling watchdog and acknowledgement timeouts.
52
+
53
+ Proxy has to child classes: SiteProxy and SupervisorProxy.
54
+
55
+ ### SiteProxy
56
+ A connection to a remote Site.
57
+
58
+ Handles RSMP messaging specific to a supervisor, including methods for requesting status, sending commands, etc.
59
+
60
+ A SiteProxy has one or more components, representing the components in the remote site.
61
+
62
+ ### SupervisorProxy
63
+ 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.
64
+
65
+ Status and command requests are delegated to the appropriate components.
@@ -0,0 +1,23 @@
1
+ # Message distribution
2
+
3
+ Proxy - - Notifier --> Listeners
4
+
5
+ A proxy distributes messages to listeners, when they are installed.
6
+
7
+ Collectors are special listenerws that waits for specific message, and are used to implement methods for waiting for RMSP responses, statuses, alarms, etc.
8
+
9
+ Note that Archive is not a listener, and does not receive messages via the Notifier. Instead the Archive gets and stores messages via the log() interface in the Logging module. The reason is that the items that the Archive and the Logger contain other data as well as the message, like error messages, warnings, text descriptions, colors codes, etc. The Distributor and Receiver handles only Message objects.
10
+
11
+ ## Notifier
12
+ A module that handles distributing messages to receivers.
13
+
14
+ ## Listener
15
+ Receives messages as long as it's installed into a distributor.
16
+
17
+ ## Collector
18
+ A subclass of Receiver that wait for specific messages. Once received
19
+ the client receives the collection.
20
+
21
+ ## Proxy
22
+ A proxy includes the Notifier module and distributes each message to listerens after processing it.
23
+
data/lib/rsmp.rb CHANGED
@@ -10,20 +10,29 @@ require 'json_schemer'
10
10
  require 'async/queue'
11
11
 
12
12
  require 'rsmp/rsmp'
13
- require 'rsmp/base'
13
+ require 'rsmp/inspect'
14
+ require 'rsmp/logging'
14
15
  require 'rsmp/wait'
15
- require 'rsmp/version'
16
16
  require 'rsmp/node'
17
17
  require 'rsmp/supervisor'
18
+ require 'rsmp/components'
19
+ require 'rsmp/notifier'
20
+
21
+ require 'rsmp/listener'
22
+ require 'rsmp/collector'
18
23
  require 'rsmp/component'
19
- require 'rsmp/site_base'
20
24
  require 'rsmp/site'
21
25
  require 'rsmp/proxy'
22
26
  require 'rsmp/supervisor_proxy'
27
+ require 'rsmp/site_proxy_wait'
23
28
  require 'rsmp/site_proxy'
24
29
  require 'rsmp/error'
25
- require 'rsmp/probe'
26
- require 'rsmp/probe_collection'
27
30
  require 'rsmp/message'
28
31
  require 'rsmp/logger'
29
32
  require 'rsmp/archive'
33
+ require 'rsmp/tlc'
34
+
35
+ require 'rsmp/convert/import/yaml'
36
+ require 'rsmp/convert/export/json_schema'
37
+
38
+ require 'rsmp/version'
data/lib/rsmp/archive.rb CHANGED
@@ -3,22 +3,26 @@
3
3
 
4
4
  module RSMP
5
5
  class Archive
6
+ include Inspect
7
+
6
8
  attr_reader :items
7
- attr_accessor :probes
8
9
 
9
- def initialize
10
+ @@index = 0
11
+
12
+ def initialize max=100
10
13
  @items = []
11
- @probes = ProbeCollection.new
14
+ @max = max
15
+ end
16
+
17
+ def inspect
18
+ "#<#{self.class.name}:#{self.object_id}, #{inspector(:@items)}>"
12
19
  end
13
20
 
14
21
  def self.prepare_item item
15
22
  raise ArgumentError unless item.is_a? Hash
16
23
 
17
- now_obj = RSMP.now_object
18
- now_str = RSMP.now_string(now_obj)
19
-
20
24
  cleaned = item.select { |k,v| [:author,:level,:ip,:port,:site_id,:component_id,:str,:message,:exception].include? k }
21
- cleaned[:timestamp] = now_obj
25
+ cleaned[:timestamp] = Clock.now
22
26
  if item[:message]
23
27
  cleaned[:direction] = item[:message].direction
24
28
  cleaned[:component_id] = item[:message].attributes['cId']
@@ -27,6 +31,14 @@ module RSMP
27
31
  cleaned
28
32
  end
29
33
 
34
+ def self.increase_index
35
+ @@index += 1
36
+ end
37
+
38
+ def self.current_index
39
+ @@index
40
+ end
41
+
30
42
  def by_level levels
31
43
  items.select { |item| levels.include? item[:level] }
32
44
  end
@@ -35,27 +47,16 @@ module RSMP
35
47
  items.map { |item| item[:str] }
36
48
  end
37
49
 
38
- def current_index
39
- @items.size
40
- end
41
-
42
50
  def add item
43
- item[:index] = @items.size
51
+ item[:index] = RSMP::Archive.increase_index
44
52
  @items << item
45
- probe item
46
- end
47
-
48
- def capture task, options, &block
49
- probe = RSMP::Probe.new self
50
- probe.capture task, options, &block
53
+ if @items.size > @max
54
+ @items.shift
55
+ end
51
56
  end
52
57
 
53
58
  private
54
59
 
55
- def probe item
56
- @probes.process item
57
- end
58
-
59
60
  def find options, &block
60
61
  # search backwards from newest to older, stopping once messages
61
62
  # are older that options[:earliest]