rsmp 0.9.4 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a49bbf353b5a4adb3d680a56cdba0a116f1b401e8f536b4a2dcc8063c355e547
4
- data.tar.gz: b06a26d960020160286b64a45f670783967f2ebb214261ce821ee92126b2fab4
3
+ metadata.gz: 9634c9a0b4e843d2f9d53f85023a51584a4686bea45aeb4cc74dbca7d63a117b
4
+ data.tar.gz: 598c15d07dc9dd22bda5e4901e2537b902b675af9a88281c2dae9b494d41a52f
5
5
  SHA512:
6
- metadata.gz: c91fa2fd2ed113c3ebb095e7189c1c32c54d547532c76addb1ae2ec38a13804e06e7e2c45371ea366d45a26ab10a4fe5a02d60e7529620023e8f5aae3f35361d
7
- data.tar.gz: c32531fe57674815cbef9ff124c6cb0e575891e6de836fe9013e26f391efffe8b671c86b62c2da14d8472752af2b8d023e6175e4cd6eaa2cee92cdd023d52b11
6
+ metadata.gz: 990b18990bc24622bdceb84c9f19a247fb3c6e6cca82fb0a4019e1aa1da7f33503f182ebd4d7789ab890c4d9d51c83062f7f6ff8ab96681bc8cd98cc626418e8
7
+ data.tar.gz: 20d4a23d38c6cce0ce46fe7def72d90a822627f51800a82d90c06f433e7104d3336a1c300ba6462038c641d08378980ceb794dc0ec54a91d36a17b21d1bf589a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.9.4)
4
+ rsmp (0.9.7)
5
5
  async (~> 1.29.1)
6
6
  async-io (~> 1.32.2)
7
7
  colorize (~> 0.8.1)
data/config/tlc.yaml CHANGED
@@ -31,6 +31,11 @@ signal_plans:
31
31
  A2: 'NNNNBN'
32
32
  B1: 'BBNNNN'
33
33
  B2: 'BNNNNN'
34
+ inputs:
35
+ total: 8
36
+ programming:
37
+ 8:
38
+ raise: A0301
34
39
  startup_sequence: 'efg'
35
40
  intervals:
36
41
  timer: 0.1
@@ -1,8 +1,8 @@
1
1
  module RSMP
2
2
  # Class for waiting for specific command responses
3
3
  class AlarmCollector < Collector
4
- def initialize proxy, want, options={}
5
- @want = want
4
+ def initialize proxy,options={}
5
+ @query = options[:query] || {}
6
6
  super proxy, options.merge(
7
7
  type: 'Alarm',
8
8
  title:'alarm'
@@ -11,8 +11,23 @@ module RSMP
11
11
 
12
12
  def type_match? message
13
13
  return false if super(message) == false
14
- [:aCId, :aSp, :ack, :aS, :sS, :cat, :pri].each do |key|
15
- return false if @want[key] && @want[key] != message.attribute(key.to_s)
14
+
15
+ # match fixed attributes
16
+ %w{aCId aSp ack aS sS cat pri}.each do |key|
17
+ return false if @query[key] && @query[key] != message.attribute(key)
18
+ end
19
+
20
+ # match rvs items
21
+ if @query['rvs']
22
+ query_rvs = @query['rvs']
23
+ message_rvs = message.attributes['rvs']
24
+ return false unless message_rvs
25
+ return false unless query_rvs.all? do |query_item|
26
+ return false unless message_rvs.any? do |message_item|
27
+ next message_item['n'] == query_item['n'] && message_item['v'] == query_item['v']
28
+ end
29
+ next true
30
+ end
16
31
  end
17
32
  true
18
33
  end
data/lib/rsmp/error.rb CHANGED
@@ -64,4 +64,7 @@ module RSMP
64
64
 
65
65
  class RepeatedStatusError < Error
66
66
  end
67
+
68
+ class TimestampError < Error
69
+ end
67
70
  end
@@ -10,14 +10,15 @@ module RSMP
10
10
  :startup_sequence_active, :startup_sequence, :startup_sequence_pos
11
11
 
12
12
  def initialize node:, id:, cycle_time: 10, signal_plans:,
13
- startup_sequence:, live_output:nil
13
+ startup_sequence:, live_output:nil, inputs:
14
14
  super node: node, id: id, grouped: true
15
15
  @signal_groups = []
16
16
  @detector_logics = []
17
17
  @plans = signal_plans
18
18
  @cycle_time = cycle_time
19
19
  @num_traffic_situations = 1
20
- @num_inputs = 8
20
+ @num_inputs = inputs['total']
21
+ @input_programming = inputs['programming']
21
22
  @startup_sequence = startup_sequence
22
23
  @live_output = live_output
23
24
  reset
@@ -268,14 +269,29 @@ module RSMP
268
269
  def handle_m0006 arg
269
270
  @node.verify_security_code 2, arg['securityCode']
270
271
  input = arg['input'].to_i
272
+ unless input>0 && input<=@num_inputs
273
+ raise MessageRejected.new("Input #{idx} is invalid, must be in the range 1-#{@num_inputs}")
274
+ end
271
275
  idx = input - 1
272
- return unless idx>=0 && input<@num_inputs # TODO should NotAck
273
276
  @input_activations[idx] = bool_string_to_digit arg['status']
274
277
  recompute_input idx
275
- if @input_activations[idx] == '1'
276
- log "Activating input #{idx+1}", level: :info
278
+ activate = @input_activations[idx] == '1'
279
+ if activate
280
+ log "Activating input #{input}", level: :info
277
281
  else
278
- log "Deactivating input #{idx+1}", level: :info
282
+ log "Deactivating input #{input}", level: :info
283
+ end
284
+
285
+ if @input_programming
286
+ actions = @input_programming[input]
287
+ if actions && actions['raise']
288
+ alarm_code = actions['raise']
289
+ if activate
290
+ log "Activating alarm #{alarm_code}, due to input #{input} programming", level: :info
291
+ else
292
+ log "Deactivating alarm #{alarm_code}, due to input #{input} programming", level: :info
293
+ end
294
+ end
279
295
  end
280
296
  end
281
297
 
@@ -428,7 +444,7 @@ module RSMP
428
444
  if reverting
429
445
  log "Reverting to functional position #{mode} after timeout", level: :info
430
446
  elsif timeout && timeout > 0
431
- log "Switching to functional position #{mode} with timeout #{timeout}min", level: :info
447
+ log "Switching to functional position #{mode} with timeout #{(timeout/60).round(1)}min", level: :info
432
448
  @previous_functional_position = @function_position
433
449
  now = clock.now
434
450
  @functional_position_timeout = now + timeout
@@ -56,7 +56,8 @@ module RSMP
56
56
  cycle_time: settings['cycle_time'],
57
57
  startup_sequence: @startup_sequence,
58
58
  signal_plans: @signal_plans,
59
- live_output: @site_settings['live_output']
59
+ live_output: @site_settings['live_output'],
60
+ inputs: @site_settings['inputs']
60
61
  when 'signal_group'
61
62
  group = SignalGroup.new node: self, id: id
62
63
  @main.add_signal_group group
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.7"
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.9.4
4
+ version: 0.9.7
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-03-09 00:00:00.000000000 Z
11
+ date: 2022-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async