rsmp 0.9.5 → 0.9.8

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: 774c3a61fac3a93f87f5d8512da860cbf28cbfb47ff568d2035006d08ac98cf1
4
- data.tar.gz: 238b160b9786c76e78639f9c470abcb196aa24476466a1e2ca53cbca8f41eb03
3
+ metadata.gz: 34b503622433b88389b62af2deca5e8c296fb305701ed1a8ed92b9b32dfe8893
4
+ data.tar.gz: b76db428241ac087692925b5b259f55e40145a13f0436e56be4eb698688b6edb
5
5
  SHA512:
6
- metadata.gz: c8573e91e6d88cc6be7806d81098e4894d3b220f50997867fca64b8c1161f5f6019fed0383a70c7ee48d61182cdd0a38feb9be3509d2c624224235147839831c
7
- data.tar.gz: 487cc05ad5fdb48ad7efbc5415640f2d1aeac49bebb7c2989b97e251a6d1d34e2bce6c6b03596190083c4eeb9b48eaaf33023d8ce382961c25f09a2c17c9db8b
6
+ metadata.gz: bb0a905c3129dfa6960178fe427490950d10f4d04dd58ece46cea4ccfb318abffd18835b6a7b4cbefeb80103542be68c1a258687b97f632bbaa574cff409f73c
7
+ data.tar.gz: 87e9b41facacfd9170874c1a19f5a3738261d55b8cd4eeecc53c51c5a540c0c6503e3756f8bdaa59dbf5eb7393c66ae5d61e93f77a58ad0bbe634a1886076061
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.9.5)
4
+ rsmp (0.9.8)
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
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,22 @@ 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
+
21
+ if inputs
22
+ @num_inputs = inputs['total'] || 8
23
+ @input_programming = inputs['programming']
24
+ else
25
+ @num_inputs = 8
26
+ @input_programming = nil
27
+ end
28
+
21
29
  @startup_sequence = startup_sequence
22
30
  @live_output = live_output
23
31
  reset
@@ -268,14 +276,29 @@ module RSMP
268
276
  def handle_m0006 arg
269
277
  @node.verify_security_code 2, arg['securityCode']
270
278
  input = arg['input'].to_i
279
+ unless input>0 && input<=@num_inputs
280
+ raise MessageRejected.new("Input #{idx} is invalid, must be in the range 1-#{@num_inputs}")
281
+ end
271
282
  idx = input - 1
272
- return unless idx>=0 && input<@num_inputs # TODO should NotAck
273
283
  @input_activations[idx] = bool_string_to_digit arg['status']
274
284
  recompute_input idx
275
- if @input_activations[idx] == '1'
276
- log "Activating input #{idx+1}", level: :info
285
+ activate = @input_activations[idx] == '1'
286
+ if activate
287
+ log "Activating input #{input}", level: :info
277
288
  else
278
- log "Deactivating input #{idx+1}", level: :info
289
+ log "Deactivating input #{input}", level: :info
290
+ end
291
+
292
+ if @input_programming
293
+ actions = @input_programming[input]
294
+ if actions && actions['raise']
295
+ alarm_code = actions['raise']
296
+ if activate
297
+ log "Activating alarm #{alarm_code}, due to input #{input} programming", level: :info
298
+ else
299
+ log "Deactivating alarm #{alarm_code}, due to input #{input} programming", level: :info
300
+ end
301
+ end
279
302
  end
280
303
  end
281
304
 
@@ -428,7 +451,7 @@ module RSMP
428
451
  if reverting
429
452
  log "Reverting to functional position #{mode} after timeout", level: :info
430
453
  elsif timeout && timeout > 0
431
- log "Switching to functional position #{mode} with timeout #{timeout}min", level: :info
454
+ log "Switching to functional position #{mode} with timeout #{(timeout/60).round(1)}min", level: :info
432
455
  @previous_functional_position = @function_position
433
456
  now = clock.now
434
457
  @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.5"
2
+ VERSION = "0.9.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Tin