rsmp 0.13.6 → 0.14.0

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: 4cda7f9e8c968b04c5b584c0e9cb9af6ec139f955c3c305ddcb6d00b064d377f
4
- data.tar.gz: 57adfef975bb4cdb7adad247f8a3aebbd04d081e6cf92655b86925008c35f831
3
+ metadata.gz: ff38488f573505ba26ab81c6f586c341a40bc6d00999b33fb97226c48d989dc1
4
+ data.tar.gz: 5c9d199fcbd87090a65d2148efe02a2521d726a272c0b20a0756570961439c6f
5
5
  SHA512:
6
- metadata.gz: 0e525d88e1b2f6a71a62ed3c711eee82c918a8b14d3f893b2d8ecf4351f7d4516e39ba4be6462bd398ab01be543c86a238e3de37c38bc785f18a1cc3fb2e8e6c
7
- data.tar.gz: ff0d0e1402d27b8952355cc3c65a2cb78166e334b35e281cf8707b063eb35ee606126d82650d7d94d37709cb70fbcf4e93710760bb659de13075bd8e8ce1792c
6
+ metadata.gz: 9f5dd8a06e3d7684eed3653b0b6b810e2d75f9447078dc93504a2aebd30bdb5b2ede91a7d8b5c3e30e4e2687e0e3c3faf1b5fc625c1b5c197f9a58b77a49f009
7
+ data.tar.gz: 503e4e15aec9293d4c1b0d057e57f79ed67680db3321ea7c6d513b4290c231da38c3d531f8ac32cf1bc4da649631c54c5374c6a388e90f1646ce3251e40dfd4d
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.0
1
+ 3.1.2
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.13.6)
5
- async (~> 1.29.1)
6
- async-io (~> 1.32.2)
4
+ rsmp (0.14.0)
5
+ async (~> 1.30.3)
6
+ async-io (~> 1.33.0)
7
7
  colorize (~> 0.8.1)
8
8
  rsmp_schemer
9
9
  thor (~> 1.2.1)
@@ -11,18 +11,18 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- aruba (2.0.0)
14
+ aruba (2.0.1)
15
15
  bundler (>= 1.17, < 3.0)
16
16
  childprocess (>= 2.0, < 5.0)
17
17
  contracts (>= 0.16.0, < 0.18.0)
18
18
  cucumber (>= 4.0, < 8.0)
19
19
  rspec-expectations (~> 3.4)
20
20
  thor (~> 1.0)
21
- async (1.29.2)
21
+ async (1.30.3)
22
22
  console (~> 1.10)
23
23
  nio4r (~> 2.3)
24
24
  timers (~> 4.1)
25
- async-io (1.32.2)
25
+ async-io (1.33.0)
26
26
  async
27
27
  builder (3.2.4)
28
28
  childprocess (4.1.0)
@@ -80,25 +80,25 @@ GEM
80
80
  nio4r (2.5.8)
81
81
  rake (13.0.6)
82
82
  regexp_parser (2.5.0)
83
- rsmp_schemer (0.4.1)
83
+ rsmp_schemer (0.5.0)
84
84
  json_schemer (~> 0.2.21)
85
85
  rspec (3.10.0)
86
86
  rspec-core (~> 3.10.0)
87
87
  rspec-expectations (~> 3.10.0)
88
88
  rspec-mocks (~> 3.10.0)
89
- rspec-core (3.10.1)
89
+ rspec-core (3.10.2)
90
90
  rspec-support (~> 3.10.0)
91
91
  rspec-expectations (3.10.2)
92
92
  diff-lcs (>= 1.2.0, < 2.0)
93
93
  rspec-support (~> 3.10.0)
94
- rspec-mocks (3.10.2)
94
+ rspec-mocks (3.10.3)
95
95
  diff-lcs (>= 1.2.0, < 2.0)
96
96
  rspec-support (~> 3.10.0)
97
97
  rspec-support (3.10.3)
98
98
  sys-uname (1.2.2)
99
99
  ffi (~> 1.1)
100
100
  thor (1.2.1)
101
- timecop (0.9.4)
101
+ timecop (0.9.5)
102
102
  timers (4.3.3)
103
103
  uri_template (0.7.0)
104
104
 
@@ -112,7 +112,7 @@ PLATFORMS
112
112
 
113
113
  DEPENDENCIES
114
114
  aruba (~> 2.0.0)
115
- bundler (~> 2.3.6)
115
+ bundler (~> 2.3.7)
116
116
  cucumber (~> 7.1.0)
117
117
  rake (~> 13.0.6)
118
118
  rsmp!
@@ -121,4 +121,4 @@ DEPENDENCIES
121
121
  timecop (~> 0.9.4)
122
122
 
123
123
  BUNDLED WITH
124
- 2.3.6
124
+ 2.3.7
@@ -17,6 +17,19 @@ module RSMP
17
17
  @rvs = []
18
18
  end
19
19
 
20
+ def to_hash
21
+ {
22
+ 'cId' => component_id,
23
+ 'aCId' => code,
24
+ 'aTs' => Clock.to_s(timestamp),
25
+ 'ack' => (acknowledged ? 'Acknowledged' : 'notAcknowledged'),
26
+ 'sS' => (suspended ? 'suspended' : 'notSuspended'),
27
+ 'aS' => (active ? 'Active' : 'inActive'),
28
+ 'cat' => category,
29
+ 'pri' => priority.to_s,
30
+ 'rvs' => rvs
31
+ }
32
+ end
20
33
  def suspend
21
34
  change, @suspended = !@suspended, true
22
35
  update_timestamp if change
@@ -89,6 +102,5 @@ module RSMP
89
102
  @priority = message.attribute('pri').to_i
90
103
  @rvs = message.attribute('rvs')
91
104
  end
92
-
93
105
  end
94
106
  end
@@ -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)
@@ -50,8 +50,8 @@ module RSMP
50
50
  component = inferred.new node: self, id: component_id
51
51
  @components[ component_id] = component
52
52
  class_name = component.class.name.split('::').last
53
- class_name << " compoent" unless class_name == 'Component'
54
- log "Inferred #{class_name} #{component_id}", level: :debug
53
+ class_name << " component" unless (class_name == 'Component' || class_name == 'ComponentProxy')
54
+ log "Adding component #{component_id} with the inferred type #{class_name}", level: :debug
55
55
  component
56
56
  else
57
57
  raise UnknownComponent.new("Component #{component_id} not found") unless component
@@ -31,9 +31,9 @@ module RSMP
31
31
  if item['list']
32
32
  case item['type']
33
33
  when "boolean"
34
- out["$ref"] = "../../core/definitions.json#/boolean_list"
34
+ out["$ref"] = "../../../core/3.1.1/definitions.json#/boolean_list"
35
35
  when "integer", "ordinal", "unit", "scale", "long"
36
- out["$ref"] = "../../core/definitions.json#/integer_list"
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"] = "../../core/definitions.json#/boolean"
54
+ out["$ref"] = "../../../core/3.1.1/definitions.json#/boolean"
55
55
  when "timestamp"
56
- out["$ref"] = "../../core/definitions.json#/timestamp"
56
+ out["$ref"] = "../../../core/3.1.1/definitions.json#/timestamp"
57
57
  when "integer", "ordinal", "unit", "scale", "long"
58
- out["$ref"] = "../../core/definitions.json#/integer"
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
- "description"=> "A schema validatating message against the RSMP SXL for Traffic Light Controllers",
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/site.rb CHANGED
@@ -15,7 +15,6 @@ module RSMP
15
15
  @proxies = []
16
16
  @sleep_condition = Async::Notification.new
17
17
  @proxies_condition = Async::Notification.new
18
-
19
18
  build_proxies
20
19
  end
21
20
 
@@ -93,27 +92,13 @@ module RSMP
93
92
  end
94
93
  end
95
94
 
96
- def alarm_state_to_hash alarm_state
97
- {
98
- 'cId' => alarm_state.component_id,
99
- 'aCId' => alarm_state.code,
100
- 'aTs' => Clock.to_s(alarm_state.timestamp),
101
- 'ack' => (alarm_state.acknowledged ? 'Acknowledged' : 'notAcknowledged'),
102
- 'sS' => (alarm_state.suspended ? 'suspended' : 'notSuspended'),
103
- 'aS' => (alarm_state.active ? 'Active' : 'inActive'),
104
- 'cat' => alarm_state.category,
105
- 'pri' => alarm_state.priority.to_s,
106
- 'rvs' => alarm_state.rvs
107
- }
108
- end
109
-
110
95
  def alarm_suspended_or_resumed alarm_state
111
- alarm = AlarmIssue.new( alarm_state_to_hash(alarm_state).merge('aSp' => 'Suspend') )
96
+ alarm = AlarmIssue.new( alarm_state.to_hash.merge('aSp' => 'Suspend') )
112
97
  send_alarm alarm
113
98
  end
114
99
 
115
100
  def alarm_activated_or_deactivated alarm_state
116
- alarm = AlarmIssue.new( alarm_state_to_hash(alarm_state).merge('aSp' => 'Issue') )
101
+ alarm = AlarmIssue.new( alarm_state.to_hash.merge('aSp' => 'Issue') )
117
102
  send_alarm alarm
118
103
  end
119
104
 
@@ -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
@@ -384,5 +386,8 @@ module RSMP
384
386
  end
385
387
  end
386
388
 
389
+ def infer_component_type component_id
390
+ ComponentProxy
391
+ end
387
392
  end
388
393
  end
@@ -85,7 +85,10 @@ module RSMP
85
85
  sanitized_sxl_version = RSMP::Schemer.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
- send_all_aggregated_status if @site_settings['send_after_connect']
88
+ if @site_settings['send_after_connect']
89
+ send_all_aggregated_status
90
+ send_active_alarms
91
+ end
89
92
  super
90
93
  end
91
94
 
@@ -116,9 +119,6 @@ module RSMP
116
119
  end
117
120
 
118
121
  def acknowledged_first_ingoing message
119
- # TODO
120
- # aggregateds status should only be send for later version of rsmp
121
- # to handle verison differences, we probably need inherited classes
122
122
  case message.type
123
123
  when "Watchdog"
124
124
  handshake_complete
@@ -133,6 +133,17 @@ module RSMP
133
133
  end
134
134
  end
135
135
 
136
+ def send_active_alarms
137
+ @site.components.each_pair do |c_id,component|
138
+ component.alarms.each_pair do |alarm_code, alarm_state|
139
+ if alarm_state.active
140
+ alarm = AlarmIssue.new( alarm_state.to_hash.merge('aSp' => 'Issue') )
141
+ send_message alarm
142
+ end
143
+ end
144
+ end
145
+ end
146
+
136
147
  def reconnect_delay
137
148
  return false if @site_settings['intervals']['reconnect'] == :no
138
149
  interval = @site_settings['intervals']['reconnect']
@@ -263,10 +263,10 @@ module RSMP
263
263
  if actions['raise']
264
264
  alarm_code = actions['raise']
265
265
  if change
266
- log "Activating alarm #{alarm_code}, because input #{input} was activated", level: :info
266
+ log "Activating input #{input} is programmed to activate alarm #{alarm_code}", level: :info
267
267
  activate_alarm alarm_code
268
268
  else
269
- log "Deactivating alarm #{alarm_code}, because input #{input} was deactivated", level: :info
269
+ log "Deactivating input #{input} is programmed to deactivate alarm #{alarm_code}", level: :info
270
270
  deactivate_alarm alarm_code
271
271
  end
272
272
  end
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.13.6"
2
+ VERSION = "0.14.0"
3
3
  end
data/rsmp.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.description = %q{Easy RSMP site and supervisor communication.}
14
14
  spec.homepage = "https://github.com/rsmp-nordic/rsmp"
15
15
  spec.licenses = ['MIT']
16
- spec.required_ruby_version = '>= 2.0.0'
16
+ spec.required_ruby_version = '>= 3.0.0'
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/rsmp-nordic/rsmp"
@@ -30,13 +30,13 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency "async", "~> 1.29.1"
34
- spec.add_dependency "async-io", "~> 1.32.2"
33
+ spec.add_dependency "async", "~> 1.30.3"
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
37
  spec.add_dependency "rsmp_schemer"
38
38
 
39
- spec.add_development_dependency "bundler", "~> 2.3.6"
39
+ spec.add_development_dependency "bundler", "~> 2.3.7"
40
40
  spec.add_development_dependency "rake", "~> 13.0.6"
41
41
  spec.add_development_dependency "rspec", "~> 3.10.0"
42
42
  spec.add_development_dependency "rspec-expectations", "~> 3.10.2"
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.13.6
4
+ version: 0.14.0
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-04 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.29.1
19
+ version: 1.30.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.29.1
26
+ version: 1.30.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: async-io
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.32.2
33
+ version: 1.33.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.32.2
40
+ version: 1.33.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: colorize
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 2.3.6
89
+ version: 2.3.7
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 2.3.6
96
+ version: 2.3.7
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -269,14 +269,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
269
  requirements:
270
270
  - - ">="
271
271
  - !ruby/object:Gem::Version
272
- version: 2.0.0
272
+ version: 3.0.0
273
273
  required_rubygems_version: !ruby/object:Gem::Requirement
274
274
  requirements:
275
275
  - - ">="
276
276
  - !ruby/object:Gem::Version
277
277
  version: '0'
278
278
  requirements: []
279
- rubygems_version: 3.3.3
279
+ rubygems_version: 3.3.7
280
280
  signing_key:
281
281
  specification_version: 4
282
282
  summary: RoadSide Message Protocol (RSMP) library.