rsmp 0.13.0 → 0.13.3

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: 39bc5e9f248ab2db6d21e7a3c1e7c9e5ccb7c72e6e2be09dd28cbbaf5f6225d4
4
- data.tar.gz: 3215d99759e3fb98f97c591ff9c9a3b2f1b1080306284b50429c46b0f677b137
3
+ metadata.gz: a7fbae6ef01f7b0d6149360423fb4de524584cf74c7fbf1f5300ebd4115a43e3
4
+ data.tar.gz: 879d0da2780de89a5ef563b62ca36c4728313389671da5e33d0011c94bba9dac
5
5
  SHA512:
6
- metadata.gz: 3f1be038f5bee13b83ecc2a5fe9ca79ae4e06ee906aa00d9766874193a24b12bda38752041c8e8fe1436aa98f93f026d9fcd0afbdfcf1b9366e0531a8d5c48f8
7
- data.tar.gz: c52b47df3b59b30271c81b71b902fb55e2674de58c36e7458df091e39f1158641b98dcf94c840f8ab4673c35b7484b08770c0c8db1de30647f90df38ad590c34
6
+ metadata.gz: 2e905d13e37c7af948dc978cbb84257aeb7d292e605f9f98238a81311eb2344e37a1b3699998c75bef81ce844bb28564cecc581c6a3410a2cce76c558e7d6c6c
7
+ data.tar.gz: c2d737778d4e08f0c80a94af80953d47af23e93ca576ee9f468113c985b89221c8cf6a42bade00e99b5ded549bbe48fdb10541c8e721a061f4b5f8dac672036d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.13.0)
4
+ rsmp (0.13.3)
5
5
  async (~> 1.29.1)
6
6
  async-io (~> 1.32.2)
7
7
  colorize (~> 0.8.1)
@@ -68,7 +68,7 @@ GEM
68
68
  ffi (1.15.5-x64-mingw32)
69
69
  fiber-local (1.0.0)
70
70
  hana (1.3.7)
71
- json_schemer (0.2.20)
71
+ json_schemer (0.2.21)
72
72
  ecma-re-validator (~> 0.3)
73
73
  hana (~> 1.3)
74
74
  regexp_parser (~> 2.0)
@@ -79,7 +79,7 @@ GEM
79
79
  multi_test (0.1.2)
80
80
  nio4r (2.5.8)
81
81
  rake (13.0.6)
82
- regexp_parser (2.2.1)
82
+ regexp_parser (2.4.0)
83
83
  rsmp_schemer (0.4.0)
84
84
  json_schemer (~> 0.2.18)
85
85
  rspec (3.10.0)
@@ -1,7 +1,7 @@
1
1
  module RSMP
2
2
  # RSMP component
3
3
  class Component < ComponentBase
4
- def initialize node:, id:, grouped: false
4
+ def initialize node:, id:, ntsOId: nil, xNId: nil, grouped: false
5
5
  super
6
6
  end
7
7
 
@@ -5,7 +5,8 @@ module RSMP
5
5
  class ComponentBase
6
6
  include Inspect
7
7
 
8
- attr_reader :c_id, :node, :alarms, :statuses, :aggregated_status, :aggregated_status_bools, :grouped
8
+ attr_reader :c_id, :ntsOId, :xNId, :node, :alarms, :statuses,
9
+ :aggregated_status, :aggregated_status_bools, :grouped
9
10
 
10
11
  AGGREGATED_STATUS_KEYS = [ :local_control,
11
12
  :communication_distruption,
@@ -16,8 +17,13 @@ module RSMP
16
17
  :rest,
17
18
  :not_connected ]
18
19
 
19
- def initialize node:, id:, grouped: false
20
+ def initialize node:, id:, ntsOId: nil, xNId: nil, grouped: false
21
+ if grouped==false && (ntsOId || xNId)
22
+ raise RSMP::ConfigurationError.new("ntsOId and xNId are only allowed for grouped objects")
23
+ end
20
24
  @c_id = id
25
+ @ntsOId = ntsOId
26
+ @xNId = xNId
21
27
  @node = node
22
28
  @grouped = grouped
23
29
  clear_aggregated_status
@@ -1,7 +1,7 @@
1
1
  module RSMP
2
2
  # A proxy to a remote RSMP component.
3
3
  class ComponentProxy < ComponentBase
4
- def initialize node:, id:, grouped: false
4
+ def initialize node:, id:, ntsOId: nil, xNId: nil, grouped: false
5
5
  super
6
6
  @alarms = {}
7
7
  @statuses = {}
@@ -2,10 +2,11 @@
2
2
 
3
3
  module RSMP
4
4
  module Components
5
- attr_reader :components
5
+ attr_reader :components, :main
6
6
 
7
7
  def initialize_components
8
8
  @components = {}
9
+ @main = nil
9
10
  end
10
11
 
11
12
  def aggregated_status_changed component, options={}
@@ -18,6 +19,7 @@ module RSMP
18
19
  if components_by_type
19
20
  components_by_type.each_pair do |id,settings|
20
21
  @components[id] = build_component(id:id, type:type, settings:settings)
22
+ @main = @components[id] if type=='main'
21
23
  end
22
24
  end
23
25
  end
@@ -36,10 +38,6 @@ module RSMP
36
38
  @components[component.c_id] = component
37
39
  end
38
40
 
39
- #def build_component id:, type:, settings:{}
40
- # Component.new id:id, node: self, grouped: type=='main'
41
- #end
42
-
43
41
  def infer_component_type component_id
44
42
  Component
45
43
  end
data/lib/rsmp/proxy.rb CHANGED
@@ -438,7 +438,6 @@ module RSMP
438
438
  end
439
439
 
440
440
  def will_not_handle message
441
- "WILL NOT HANDLE"
442
441
  reason = "since we're a #{self.class.name.downcase}" unless reason
443
442
  log "Ignoring #{message.type}, #{reason}", message: message, level: :warning
444
443
  dont_acknowledge message, nil, reason
@@ -643,5 +642,13 @@ module RSMP
643
642
  return { sent: message }
644
643
  end
645
644
  end
645
+
646
+ def set_nts_message_attributes message
647
+ return unless main
648
+ ntsOId = main.ntsOId
649
+ xNId = main.xNId
650
+ message.attributes['ntsOId'] = ntsOId if ntsOId
651
+ message.attributes['xNId'] = xNId if xNId
652
+ end
646
653
  end
647
654
  end
data/lib/rsmp/site.rb CHANGED
@@ -161,7 +161,12 @@ module RSMP
161
161
  end
162
162
 
163
163
  def build_component id:, type:, settings:{}
164
- Component.new id:id, node: self, grouped: type=='main'
164
+ if type == 'main'
165
+ Component.new id:id, node: self, grouped: true,
166
+ ntsOId: settings['ntsOId'], xNId: settings['xNId']
167
+ else
168
+ Component.new id:id, node: self, grouped: false
169
+ end
165
170
  end
166
171
  end
167
172
  end
@@ -114,13 +114,11 @@ module RSMP
114
114
  def request_aggregated_status component, options={}
115
115
  validate_ready 'request aggregated status'
116
116
  m_id = options[:m_id] || RSMP::Message.make_m_id
117
-
118
117
  message = RSMP::AggregatedStatusRequest.new({
119
- "ntsOId" => '',
120
- "xNId" => '',
121
- "cId" => component,
122
- "mId" => m_id
118
+ "cId" => component,
119
+ "mId" => m_id
123
120
  })
121
+ set_nts_message_attributes message
124
122
  send_and_optionally_collect message, options do |collect_options|
125
123
  AggregatedStatusCollector.new(
126
124
  self,
@@ -187,12 +185,11 @@ module RSMP
187
185
  request_list = status_list.map { |item| item.slice('sCI','n') }
188
186
 
189
187
  message = RSMP::StatusRequest.new({
190
- "ntsOId" => '',
191
- "xNId" => '',
192
188
  "cId" => component,
193
189
  "sS" => request_list,
194
190
  "mId" => m_id
195
191
  })
192
+ set_nts_message_attributes message
196
193
  send_and_optionally_collect message, options do |collect_options|
197
194
  StatusCollector.new(
198
195
  self,
@@ -232,12 +229,11 @@ module RSMP
232
229
  component.allow_repeat_updates subscribe_list
233
230
 
234
231
  message = RSMP::StatusSubscribe.new({
235
- "ntsOId" => '',
236
- "xNId" => '',
237
232
  "cId" => component_id,
238
233
  "sS" => subscribe_list,
239
234
  'mId' => m_id
240
235
  })
236
+ set_nts_message_attributes message
241
237
  send_and_optionally_collect message, options do |collect_options|
242
238
  StatusCollector.new(
243
239
  self,
@@ -262,11 +258,10 @@ module RSMP
262
258
  end
263
259
 
264
260
  message = RSMP::StatusUnsubscribe.new({
265
- "ntsOId" => '',
266
- "xNId" => '',
267
261
  "cId" => component_id,
268
262
  "sS" => status_list
269
263
  })
264
+ set_nts_message_attributes message
270
265
  send_message message, validate: options[:validate]
271
266
  message
272
267
  end
@@ -292,12 +287,11 @@ module RSMP
292
287
  validate_ready 'send command'
293
288
  m_id = options[:m_id] || RSMP::Message.make_m_id
294
289
  message = RSMP::CommandRequest.new({
295
- "ntsOId" => '',
296
- "xNId" => '',
297
290
  "cId" => component,
298
291
  "arg" => command_list,
299
292
  "mId" => m_id
300
293
  })
294
+ set_nts_message_attributes message
301
295
  send_and_optionally_collect message, options do |collect_options|
302
296
  CommandResponseCollector.new(
303
297
  self,
@@ -381,7 +375,12 @@ module RSMP
381
375
  end
382
376
 
383
377
  def build_component id:, type:, settings:{}
384
- ComponentProxy.new id:id, node: self, grouped: type=='main'
378
+ if type == 'main'
379
+ ComponentProxy.new id:id, node: self, grouped: true,
380
+ ntsOId: settings['ntsOId'], xNId: settings['xNId']
381
+ else
382
+ ComponentProxy.new id:id, node: self, grouped: false
383
+ end
385
384
  end
386
385
 
387
386
  end
@@ -160,7 +160,7 @@ module RSMP
160
160
  "se" => component.aggregated_status_bools,
161
161
  "mId" => m_id,
162
162
  })
163
-
163
+ set_nts_message_attributes message
164
164
  send_and_optionally_collect message, options do |collect_options|
165
165
  Collector.new self, collect_options.merge(task:@task, type: 'MessageAck')
166
166
  end
@@ -254,6 +254,7 @@ module RSMP
254
254
  "cTS"=>clock.to_s,
255
255
  "rvs"=>rvs
256
256
  })
257
+ set_nts_message_attributes response
257
258
  acknowledge message
258
259
  send_message response
259
260
  end
@@ -272,6 +273,7 @@ module RSMP
272
273
  "sS"=>sS,
273
274
  "mId" => options[:m_id]
274
275
  })
276
+ set_nts_message_attributes response
275
277
  acknowledge message
276
278
  send_message response
277
279
  end
@@ -409,6 +411,7 @@ module RSMP
409
411
  "sTs"=>now,
410
412
  "sS"=>sS
411
413
  })
414
+ set_nts_message_attributes update
412
415
  send_message update
413
416
  store_last_sent_status update
414
417
  end
@@ -429,5 +432,8 @@ module RSMP
429
432
  def check_sxl_version message
430
433
  end
431
434
 
435
+ def main
436
+ @site.main
437
+ end
432
438
  end
433
439
  end
@@ -9,9 +9,9 @@ module RSMP
9
9
  :functional_position,
10
10
  :startup_sequence_active, :startup_sequence, :startup_sequence_pos
11
11
 
12
- def initialize node:, id:, cycle_time: 10, signal_plans:,
12
+ def initialize node:, id:, ntsOId: nil, xNId: nil, cycle_time: 10, signal_plans:,
13
13
  startup_sequence:, live_output:nil, inputs:{}
14
- super node: node, id: id, grouped: true
14
+ super node: node, id: id, ntsOId: ntsOId, xNId: xNId, grouped: true
15
15
  @signal_groups = []
16
16
  @detector_logics = []
17
17
  @plans = signal_plans
@@ -15,7 +15,7 @@ module RSMP
15
15
 
16
16
  super options
17
17
 
18
- unless @main
18
+ unless main
19
19
  raise ConfigurationError.new "TLC must have a main component"
20
20
  end
21
21
 
@@ -24,7 +24,7 @@ module RSMP
24
24
  def start
25
25
  super
26
26
  start_tlc_timer
27
- @main.initiate_startup_sequence
27
+ main.initiate_startup_sequence
28
28
  end
29
29
 
30
30
  def stop_subtasks
@@ -52,7 +52,10 @@ module RSMP
52
52
  def build_component id:, type:, settings:{}
53
53
  component = case type
54
54
  when 'main'
55
- @main = TrafficController.new node: self, id: id,
55
+ TrafficController.new node: self,
56
+ id: id,
57
+ ntsOId: settings['ntsOId'],
58
+ xNId: settings['xNId'],
56
59
  cycle_time: settings['cycle_time'],
57
60
  startup_sequence: @startup_sequence,
58
61
  signal_plans: @signal_plans,
@@ -60,11 +63,11 @@ module RSMP
60
63
  inputs: @site_settings['inputs']
61
64
  when 'signal_group'
62
65
  group = SignalGroup.new node: self, id: id
63
- @main.add_signal_group group
66
+ main.add_signal_group group
64
67
  group
65
68
  when 'detector_logic'
66
69
  logic = DetectorLogic.new node: self, id: id
67
- @main.add_detector_logic logic
70
+ main.add_detector_logic logic
68
71
  logic
69
72
  end
70
73
  end
@@ -109,8 +112,8 @@ module RSMP
109
112
  end
110
113
 
111
114
  def timer now
112
- return unless @main
113
- @main.timer now
115
+ return unless main
116
+ main.timer now
114
117
  end
115
118
 
116
119
  def verify_security_code level, code
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.13.0"
2
+ VERSION = "0.13.3"
3
3
  end
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.0
4
+ version: 0.13.3
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-04-05 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async