rsmp 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rsmp/tlc/signal_group.rb +2 -2
- data/lib/rsmp/tlc/traffic_controller.rb +60 -35
- data/lib/rsmp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fa8cde971466041262bd390c93f4f976cb0942ca6d78aadd2707e87e90fddb2
|
4
|
+
data.tar.gz: f7970833a69ea2ed5741a5b7f6d3619bfca25df8343f0b6a02a304dc7a74fce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3a857d4b29b9b1e2f9bbf0181ed86586ade1b15eedbbbd79fbc4ca0a3f65b5e67c8f96224b55a87a3c05622a75353fc7fb29d61e1ecfb8af464c99873cc0bae
|
7
|
+
data.tar.gz: 499d7c02e691e0a3aa0fdf2f1f000f30bbda8bc9240836f00c6e8ca0114298666a92ffd20953d57887f359bec45ca983cf12624fc0b49eee952eb24eea8b80ca
|
data/Gemfile.lock
CHANGED
@@ -6,7 +6,7 @@ module RSMP
|
|
6
6
|
# not have dedicated components.
|
7
7
|
class TrafficController < Component
|
8
8
|
attr_reader :pos, :cycle_time, :plan, :cycle_counter,
|
9
|
-
:
|
9
|
+
:functional_position,
|
10
10
|
:startup_sequence_active, :startup_sequence, :startup_sequence_pos
|
11
11
|
|
12
12
|
def initialize node:, id:, cycle_time: 10, signal_plans:,
|
@@ -24,15 +24,16 @@ module RSMP
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def reset_modes
|
27
|
-
@
|
28
|
-
@
|
27
|
+
@function_position = 'NormalControl'
|
28
|
+
@previous_functional_position = nil
|
29
|
+
@functional_position_timeout = nil
|
30
|
+
|
29
31
|
@booting = false
|
30
32
|
@is_starting = false
|
31
33
|
@control_mode = 'control'
|
32
34
|
@manual_control = false
|
33
35
|
@fixed_time_control = false
|
34
36
|
@isolated_control = false
|
35
|
-
@yellow_flash = false
|
36
37
|
@all_red = false
|
37
38
|
@police_key = 0
|
38
39
|
end
|
@@ -60,6 +61,18 @@ module RSMP
|
|
60
61
|
@time_int = nil
|
61
62
|
end
|
62
63
|
|
64
|
+
def dark?
|
65
|
+
@function_position == 'Dark'
|
66
|
+
end
|
67
|
+
|
68
|
+
def yellow_flash?
|
69
|
+
@function_position == 'YellowFlash'
|
70
|
+
end
|
71
|
+
|
72
|
+
def normal_control?
|
73
|
+
@function_position == 'NormalControl'
|
74
|
+
end
|
75
|
+
|
63
76
|
def clock
|
64
77
|
node.clock
|
65
78
|
end
|
@@ -87,6 +100,7 @@ module RSMP
|
|
87
100
|
return if time == @time_int
|
88
101
|
@time_int = time
|
89
102
|
move_cycle_counter
|
103
|
+
check_functional_position_timeout
|
90
104
|
move_startup_sequence if @startup_sequence_active
|
91
105
|
|
92
106
|
@signal_groups.each { |group| group.timer }
|
@@ -99,6 +113,15 @@ module RSMP
|
|
99
113
|
@cycle_counter = counter
|
100
114
|
end
|
101
115
|
|
116
|
+
def check_functional_position_timeout
|
117
|
+
return unless @functional_position_timeout
|
118
|
+
if clock.now >= @functional_position_timeout
|
119
|
+
switch_functional_position @previous_functional_position, reverting: true
|
120
|
+
@functional_position_timeout = nil
|
121
|
+
@previous_functional_position = nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
102
125
|
def startup_state
|
103
126
|
return unless @startup_sequence_active
|
104
127
|
return unless @startup_sequence_pos
|
@@ -108,7 +131,6 @@ module RSMP
|
|
108
131
|
def initiate_startup_sequence
|
109
132
|
log "Initiating startup sequence", level: :info
|
110
133
|
reset_modes
|
111
|
-
@dark_mode = false
|
112
134
|
@startup_sequence_active = true
|
113
135
|
@startup_sequence_initiated_at = nil
|
114
136
|
@startup_sequence_pos = nil
|
@@ -118,8 +140,6 @@ module RSMP
|
|
118
140
|
@startup_sequence_active = false
|
119
141
|
@startup_sequence_initiated_at = nil
|
120
142
|
@startup_sequence_pos = nil
|
121
|
-
@yellow_flash = false
|
122
|
-
@dark_mode = false
|
123
143
|
end
|
124
144
|
|
125
145
|
def move_startup_sequence
|
@@ -157,15 +177,16 @@ module RSMP
|
|
157
177
|
end.join ' '
|
158
178
|
|
159
179
|
modes = '.'*9
|
160
|
-
modes[0] = '
|
161
|
-
modes[1] = '
|
162
|
-
modes[2] = 'D' if @
|
163
|
-
modes[3] = '
|
164
|
-
modes[4] = '
|
165
|
-
modes[5] = '
|
166
|
-
modes[6] = '
|
167
|
-
modes[7] = '
|
168
|
-
modes[8] = '
|
180
|
+
modes[0] = 'N' if @function_position == 'NormalControl'
|
181
|
+
modes[1] = 'Y' if @function_position == 'YellowFlash'
|
182
|
+
modes[2] = 'D' if @function_position == 'Dark'
|
183
|
+
modes[3] = 'B' if @booting
|
184
|
+
modes[4] = 'S' if @startup_sequence_active
|
185
|
+
modes[5] = 'M' if @manual_control
|
186
|
+
modes[6] = 'F' if @fixed_time_control
|
187
|
+
modes[7] = 'R' if @all_red
|
188
|
+
modes[8] = 'I' if @isolated_control
|
189
|
+
modes[9] = 'P' if @police_key != 0
|
169
190
|
|
170
191
|
plan = "P#{@plan}"
|
171
192
|
|
@@ -197,7 +218,7 @@ module RSMP
|
|
197
218
|
|
198
219
|
def handle_m0001 arg
|
199
220
|
@node.verify_security_code 2, arg['securityCode']
|
200
|
-
|
221
|
+
switch_functional_position arg['status'], timeout: arg['timeout'].to_i*60
|
201
222
|
end
|
202
223
|
|
203
224
|
def handle_m0002 arg
|
@@ -376,8 +397,8 @@ module RSMP
|
|
376
397
|
arg['second'],
|
377
398
|
'UTC'
|
378
399
|
)
|
379
|
-
|
380
|
-
log "Clock set to #{time}, (adjustment is #{
|
400
|
+
clock.set time
|
401
|
+
log "Clock set to #{time}, (adjustment is #{clock.adjustment}s)", level: :info
|
381
402
|
end
|
382
403
|
|
383
404
|
def set_input i, value
|
@@ -400,20 +421,24 @@ module RSMP
|
|
400
421
|
@plan = plan_nr
|
401
422
|
end
|
402
423
|
|
403
|
-
def
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
@
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
424
|
+
def switch_functional_position mode, timeout: nil, reverting: false
|
425
|
+
unless ['NormalControl','YellowFlash','Dark'].include? mode
|
426
|
+
raise RSMP::MessageRejected.new "Invalid functional position '#{mode}', must be NormalControl, YellowFlash or Dark'"
|
427
|
+
end
|
428
|
+
if reverting
|
429
|
+
log "Reverting to functional position #{mode} after timeout", level: :info
|
430
|
+
elsif timeout && timeout > 0
|
431
|
+
log "Switching to functional position #{mode} with timeout #{timeout}min", level: :info
|
432
|
+
@previous_functional_position = @function_position
|
433
|
+
now = clock.now
|
434
|
+
@functional_position_timeout = now + timeout
|
435
|
+
else
|
436
|
+
log "Switching to functional position #{mode}", level: :info
|
437
|
+
end
|
438
|
+
if mode == 'NormalControl'
|
439
|
+
initiate_startup_sequence if @function_position != 'NormalControl'
|
416
440
|
end
|
441
|
+
@function_position = mode
|
417
442
|
mode
|
418
443
|
end
|
419
444
|
|
@@ -491,7 +516,7 @@ module RSMP
|
|
491
516
|
when 'intersection'
|
492
517
|
TrafficControllerSite.make_status @intersection
|
493
518
|
when 'status'
|
494
|
-
TrafficControllerSite.make_status
|
519
|
+
TrafficControllerSite.make_status @function_position != 'Dark'
|
495
520
|
end
|
496
521
|
end
|
497
522
|
|
@@ -527,7 +552,7 @@ module RSMP
|
|
527
552
|
when 'intersection'
|
528
553
|
TrafficControllerSite.make_status @intersection
|
529
554
|
when 'status'
|
530
|
-
TrafficControllerSite.make_status @
|
555
|
+
TrafficControllerSite.make_status TrafficControllerSite.to_rmsp_bool( @function_position == 'YellowFlash' )
|
531
556
|
end
|
532
557
|
end
|
533
558
|
|
@@ -723,7 +748,7 @@ module RSMP
|
|
723
748
|
when 'checksum'
|
724
749
|
TrafficControllerSite.make_status '1'
|
725
750
|
when 'timestamp'
|
726
|
-
now =
|
751
|
+
now = clock.to_s
|
727
752
|
TrafficControllerSite.make_status now
|
728
753
|
end
|
729
754
|
end
|
data/lib/rsmp/version.rb
CHANGED
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
|
+
version: 0.9.2
|
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-02-
|
11
|
+
date: 2022-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|