rsmp 0.17.1 → 0.17.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: dace397e058229e79387d0b4b4f2a1f7289f2b6c0cbd2816836de542d39c764d
4
- data.tar.gz: 2b04dd58a9567875dcc231555fe2a1a03b63b0c02473b0afefdf534225e1cfc6
3
+ metadata.gz: 4b0fd1e980fcbbcccc0b302debbd6e128291dce874fc64f71f0ad5227bf387d9
4
+ data.tar.gz: 72172bb7a553ab5d411222de6fce9bb43f4e3754765bb122642c59b5b59a994b
5
5
  SHA512:
6
- metadata.gz: f290c20af069c92cfc1e4b6aabe2b73cc1f9c1e89556dc6be5dab000beafa670aebaf9b28dc103b65e456b25ef20313701fdce8f6ba22637f8f415e15e0a5c9f
7
- data.tar.gz: 34362a7e9ab6f52d0f26fc1fb267d22115d281ae7dfcd2d651186febe8677ef1a87161e661b769120dc91057bb406e75cecb4bf882e35e057e2fbbb6264818ff
6
+ metadata.gz: 3835c19f22d51abb95076f53374b4d78fd7a583a7984695a72e4ef7ea35cdf0168b4312cf1361c03cdbb5b8c9e9141a0041a792ab754adc9010b6893dd4d7afe
7
+ data.tar.gz: db8ac3294d90673d21b2a4e59e937452dddbb9eed3a7102981e115086ffc6c74b3ac8ff50c1267f0e4a68b31f45786bfe840b0ef155e80ccc20e8a0fade029d9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.17.1)
4
+ rsmp (0.17.3)
5
5
  async (~> 1.30.3)
6
6
  async-io (~> 1.33.0)
7
7
  colorize (~> 0.8.1)
@@ -33,6 +33,7 @@ module RSMP
33
33
 
34
34
  def reset_modes
35
35
  @function_position = 'NormalControl'
36
+ @function_position_source = 'startup'
36
37
  @previous_functional_position = nil
37
38
  @functional_position_timeout = nil
38
39
 
@@ -40,9 +41,13 @@ module RSMP
40
41
  @is_starting = false
41
42
  @control_mode = 'control'
42
43
  @manual_control = false
44
+ @manual_control_source = 'startup'
43
45
  @fixed_time_control = false
46
+ @fixed_time_control_source = 'startup'
44
47
  @isolated_control = false
48
+ @isolated_control_source = 'startup'
45
49
  @all_red = false
50
+ @all_red_source = 'startup'
46
51
  @police_key = 0
47
52
  end
48
53
 
@@ -50,10 +55,13 @@ module RSMP
50
55
  reset_modes
51
56
  @cycle_counter = 0
52
57
  @plan = 1
58
+ @plan_source = 'startup'
53
59
  @intersection = 0
60
+ @intersection_source = 'startup'
54
61
  @emergency_route = false
55
62
  @emergency_route_number = 0
56
63
  @traffic_situation = 0
64
+ @traffic_situation_source = 'startup'
57
65
  @day_time_table = {}
58
66
  @startup_sequence_active = false
59
67
  @startup_sequence_initiated_at = nil
@@ -61,6 +69,7 @@ module RSMP
61
69
  @time_int = nil
62
70
  @inputs.reset
63
71
  @signal_priorities = []
72
+ @dynamic_bands_timeout = 0
64
73
  end
65
74
 
66
75
  def dark?
@@ -140,7 +149,7 @@ module RSMP
140
149
  def check_functional_position_timeout
141
150
  return unless @functional_position_timeout
142
151
  if clock.now >= @functional_position_timeout
143
- switch_functional_position @previous_functional_position, reverting: true
152
+ switch_functional_position @previous_functional_position, reverting: true, source: 'calendar_clock'
144
153
  @functional_position_timeout = nil
145
154
  @previous_functional_position = nil
146
155
  end
@@ -231,7 +240,7 @@ module RSMP
231
240
  case command_code
232
241
  when 'M0001', 'M0002', 'M0003', 'M0004', 'M0005', 'M0006', 'M0007',
233
242
  'M0012', 'M0013', 'M0014', 'M0015', 'M0016', 'M0017', 'M0018',
234
- 'M0019', 'M0020', 'M0021', 'M0022',
243
+ 'M0019', 'M0020', 'M0021', 'M0022', 'M0023',
235
244
  'M0103', 'M0104'
236
245
 
237
246
  return send("handle_#{command_code.downcase}", arg, options)
@@ -242,21 +251,29 @@ module RSMP
242
251
 
243
252
  def handle_m0001 arg, options={}
244
253
  @node.verify_security_code 2, arg['securityCode']
245
- switch_functional_position arg['status'], timeout: arg['timeout'].to_i*60
254
+ switch_functional_position arg['status'],
255
+ timeout: arg['timeout'].to_i*60,
256
+ source: 'forced'
257
+
246
258
  end
247
259
 
248
260
  def handle_m0002 arg, options={}
249
261
  @node.verify_security_code 2, arg['securityCode']
250
262
  if TrafficControllerSite.from_rsmp_bool(arg['status'])
251
- switch_plan arg['timeplan']
263
+ switch_plan arg['timeplan'], source: 'force'
252
264
  else
253
- switch_plan 0 # TODO use clock/calender
265
+ switch_plan 0, source: 'startup' # TODO use clock/calender
254
266
  end
255
267
  end
256
268
 
257
269
  def handle_m0003 arg, options={}
258
270
  @node.verify_security_code 2, arg['securityCode']
259
- @traffic_situation = arg['traficsituation'].to_i
271
+ switch_traffic_situation arg['traficsituation'], source: 'forced'
272
+ end
273
+
274
+ def switch_traffic_situation situation, source:
275
+ @traffic_situation = situation.to_i
276
+ @traffic_situation_source = 'forced'
260
277
  end
261
278
 
262
279
  def handle_m0004 arg, options={}
@@ -313,7 +330,7 @@ module RSMP
313
330
 
314
331
  def handle_m0007 arg, options={}
315
332
  @node.verify_security_code 2, arg['securityCode']
316
- set_fixed_time_control arg['status']
333
+ set_fixed_time_control arg['status'], source: 'forced'
317
334
  end
318
335
 
319
336
  def handle_m0012 arg, options={}
@@ -458,6 +475,20 @@ module RSMP
458
475
  end
459
476
  end
460
477
 
478
+ def handle_m0023 arg, options={}
479
+ @node.verify_security_code 2, arg['securityCode']
480
+ timeout = arg['status'].to_i
481
+ unless timeout>=0 and timeout <= 65535
482
+ raise RSMP::MessageRejected.new "Timeout must be in the range 0-65535, got #{timeout}"
483
+ end
484
+ if timeout == 0
485
+ log "Dynamic bands timeout disabled", level: :info
486
+ else
487
+ log "Dynamic bands timeout set to #{timeout}min", level: :info
488
+ end
489
+ @dynamic_bands_timeout = timeout
490
+ end
491
+
461
492
  def handle_m0103 arg, options={}
462
493
  level = {'Level1'=>1,'Level2'=>2}[arg['status']]
463
494
  @node.change_security_code level, arg['oldSecurityCode'], arg['newSecurityCode']
@@ -483,11 +514,12 @@ module RSMP
483
514
  @inputs[i] = bool_to_digit arg['value']
484
515
  end
485
516
 
486
- def set_fixed_time_control status
517
+ def set_fixed_time_control status, source:
487
518
  @fixed_time_control = status
519
+ @fixed_time_control_source = source
488
520
  end
489
521
 
490
- def switch_plan plan
522
+ def switch_plan plan, source:
491
523
  plan_nr = plan.to_i
492
524
  if plan_nr == 0
493
525
  log "Switching to plan selection by time table", level: :info
@@ -496,9 +528,10 @@ module RSMP
496
528
  log "Switching to plan #{plan_nr}", level: :info
497
529
  end
498
530
  @plan = plan_nr
531
+ @plan_source = source
499
532
  end
500
533
 
501
- def switch_functional_position mode, timeout: nil, reverting: false
534
+ def switch_functional_position mode, timeout: nil, reverting: false, source:
502
535
  unless ['NormalControl','YellowFlash','Dark'].include? mode
503
536
  raise RSMP::MessageRejected.new "Invalid functional position '#{mode}', must be NormalControl, YellowFlash or Dark'"
504
537
  end
@@ -516,6 +549,7 @@ module RSMP
516
549
  initiate_startup_sequence if @function_position != 'NormalControl'
517
550
  end
518
551
  @function_position = mode
552
+ @function_position_source = source
519
553
  mode
520
554
  end
521
555
 
@@ -594,6 +628,8 @@ module RSMP
594
628
  TrafficControllerSite.make_status @intersection
595
629
  when 'status'
596
630
  TrafficControllerSite.make_status @function_position != 'Dark'
631
+ when 'source'
632
+ TrafficControllerSite.make_status @function_position_source
597
633
  end
598
634
  end
599
635
 
@@ -603,6 +639,8 @@ module RSMP
603
639
  TrafficControllerSite.make_status @intersection
604
640
  when 'status'
605
641
  TrafficControllerSite.make_status @manual_control
642
+ when 'source'
643
+ TrafficControllerSite.make_status @manual_control_source
606
644
  end
607
645
  end
608
646
 
@@ -612,6 +650,8 @@ module RSMP
612
650
  TrafficControllerSite.make_status @intersection
613
651
  when 'status'
614
652
  TrafficControllerSite.make_status @fixed_time_control
653
+ when 'source'
654
+ TrafficControllerSite.make_status @fixed_time_control_source
615
655
  end
616
656
  end
617
657
 
@@ -621,6 +661,8 @@ module RSMP
621
661
  TrafficControllerSite.make_status @intersection
622
662
  when 'status'
623
663
  TrafficControllerSite.make_status @isolated_control
664
+ when 'source'
665
+ TrafficControllerSite.make_status @isolated_control_source
624
666
  end
625
667
  end
626
668
 
@@ -630,6 +672,8 @@ module RSMP
630
672
  TrafficControllerSite.make_status @intersection
631
673
  when 'status'
632
674
  TrafficControllerSite.make_status TrafficControllerSite.to_rmsp_bool( @function_position == 'YellowFlash' )
675
+ when 'source'
676
+ TrafficControllerSite.make_status @function_position_source
633
677
  end
634
678
  end
635
679
 
@@ -639,6 +683,8 @@ module RSMP
639
683
  TrafficControllerSite.make_status @intersection
640
684
  when 'status'
641
685
  TrafficControllerSite.make_status @all_red
686
+ when 'source'
687
+ TrafficControllerSite.make_status @all_red_source
642
688
  end
643
689
  end
644
690
 
@@ -655,6 +701,8 @@ module RSMP
655
701
  case status_name
656
702
  when 'status'
657
703
  TrafficControllerSite.make_status @plan
704
+ when 'source'
705
+ TrafficControllerSite.make_status @plan_source
658
706
  end
659
707
  end
660
708
 
@@ -662,6 +710,8 @@ module RSMP
662
710
  case status_name
663
711
  when 'status'
664
712
  TrafficControllerSite.make_status @traffic_situation
713
+ when 'source'
714
+ TrafficControllerSite.make_status @traffic_situation_source
665
715
  end
666
716
  end
667
717
 
@@ -784,7 +834,7 @@ module RSMP
784
834
  when 'status'
785
835
  TrafficControllerSite.make_status 'local'
786
836
  when 'source'
787
- TrafficControllerSite.make_status 'startup'
837
+ TrafficControllerSite.make_status @intersection_source
788
838
  end
789
839
  end
790
840
 
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.17.1"
2
+ VERSION = "0.17.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.17.1
4
+ version: 0.17.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: 2023-04-13 00:00:00.000000000 Z
11
+ date: 2023-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async