rsmp 0.3.5 → 0.3.9
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rsmp/component.rb +1 -1
- data/lib/rsmp/components.rb +16 -3
- data/lib/rsmp/site_proxy.rb +8 -22
- data/lib/rsmp/tlc.rb +17 -7
- data/lib/rsmp/version.rb +1 -1
- data/test.rb +27 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f137a9e58a8af4524954c33515926c1b6eb2dc8aa7e4fa9bfd00b22f6e5e4bb
|
4
|
+
data.tar.gz: a9710492f633d584e6ac0acdac9b8f5bf9b820dbe3ad14ca31295bc56b41e232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb33932006870bcedfbf3a8d07311c1a752ffccdb23c5d72303b80e47fef0f1b61a4a9fc01521afb8c02bfa32a039b54356687e2d912c03ae9c6238159fdc291
|
7
|
+
data.tar.gz: c7161ce4a72fbf33394336ad1d8a8db1aedb5148c8988c66fd7ea361b1afa8efddbccb34e376c47ac030ed30b785b118670f4005412752d490b66696213081f7
|
data/Gemfile.lock
CHANGED
data/lib/rsmp/component.rb
CHANGED
data/lib/rsmp/components.rb
CHANGED
@@ -38,10 +38,23 @@ module RSMP
|
|
38
38
|
Component.new id:id, node: self, grouped: type=='main'
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def infer_component_type component_id
|
42
|
+
Component
|
43
|
+
end
|
44
|
+
|
45
|
+
def find_component component_id, build: true
|
42
46
|
component = @components[component_id]
|
43
|
-
|
44
|
-
|
47
|
+
return component if component
|
48
|
+
if build
|
49
|
+
inferred = infer_component_type component_id
|
50
|
+
component = inferred.new node: self, id: component_id
|
51
|
+
@components[ component_id] = component
|
52
|
+
class_name = component.class.name.split('::').last
|
53
|
+
log "Inferred #{class_name} component #{component_id}", level: :info
|
54
|
+
component
|
55
|
+
else
|
56
|
+
raise UnknownComponent.new("Component #{component_id} not found") unless component
|
57
|
+
end
|
45
58
|
end
|
46
59
|
|
47
60
|
end
|
data/lib/rsmp/site_proxy.rb
CHANGED
@@ -125,17 +125,11 @@ module RSMP
|
|
125
125
|
se = message.attribute("se")
|
126
126
|
validate_aggregated_status(message,se) == false
|
127
127
|
c_id = message.attributes["cId"]
|
128
|
-
component =
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
log "Adding component #{c_id} to site #{@site_id}", level: :info
|
134
|
-
else
|
135
|
-
reason = "component #{c_id} not found"
|
136
|
-
dont_acknowledge message, "Ignoring #{message.type}:", reason
|
137
|
-
return
|
138
|
-
end
|
128
|
+
component = find_component c_id
|
129
|
+
unless component
|
130
|
+
reason = "component #{c_id} not found"
|
131
|
+
dont_acknowledge message, "Ignoring #{message.type}:", reason
|
132
|
+
return
|
139
133
|
end
|
140
134
|
|
141
135
|
component.set_aggregated_status_bools se
|
@@ -341,20 +335,12 @@ module RSMP
|
|
341
335
|
@supervisor.notify_error e, options if @supervisor
|
342
336
|
end
|
343
337
|
|
344
|
-
def
|
345
|
-
|
346
|
-
message = collect(parent_task,options.merge(type: "Alarm", with_message: true, num: 1)) do |message|
|
347
|
-
# TODO check components
|
348
|
-
matching_alarm = nil
|
349
|
-
alarm = message
|
338
|
+
def collect_alarms parent_task, options={}
|
339
|
+
collect(parent_task,options.merge(type: "Alarm")) do |alarm|
|
350
340
|
next if options[:aCId] && options[:aCId] != alarm.attribute("aCId")
|
351
341
|
next if options[:aSp] && options[:aSp] != alarm.attribute("aSp")
|
352
342
|
next if options[:aS] && options[:aS] != alarm.attribute("aS")
|
353
|
-
|
354
|
-
break
|
355
|
-
end
|
356
|
-
if item
|
357
|
-
{ message: message, status: matching_alarm }
|
343
|
+
true
|
358
344
|
end
|
359
345
|
end
|
360
346
|
|
data/lib/rsmp/tlc.rb
CHANGED
@@ -5,7 +5,7 @@ module RSMP
|
|
5
5
|
class TrafficController < Component
|
6
6
|
attr_reader :pos, :cycle_time
|
7
7
|
|
8
|
-
def initialize node:, id:, cycle_time:
|
8
|
+
def initialize node:, id:, cycle_time: 10
|
9
9
|
super node: node, id: id, grouped: true
|
10
10
|
@signal_groups = []
|
11
11
|
@detector_logics = []
|
@@ -293,7 +293,8 @@ module RSMP
|
|
293
293
|
def handle_s0002 status_code, status_name=nil
|
294
294
|
case status_name
|
295
295
|
when 'detectorlogicstatus'
|
296
|
-
RSMP::Tlc.make_status @detector_logics.
|
296
|
+
RSMP::Tlc.make_status @detector_logics.each { |dl| p dl.value }
|
297
|
+
RSMP::Tlc.make_status @detector_logics.map { |dl| dl.value ? '1' : '0' }.join
|
297
298
|
end
|
298
299
|
end
|
299
300
|
|
@@ -625,13 +626,15 @@ module RSMP
|
|
625
626
|
class SignalGroup < Component
|
626
627
|
attr_reader :plan, :state
|
627
628
|
|
628
|
-
|
629
|
+
# plan is a string, with each character representing a signal phase at a particular second in the cycle
|
630
|
+
def initialize node:, id:, plan: nil
|
629
631
|
super node: node, id: id, grouped: false
|
630
632
|
@plan = plan
|
631
633
|
move 0
|
632
634
|
end
|
633
635
|
|
634
636
|
def get_state pos
|
637
|
+
return 'a' unless @plan # if no plan, use phase a, which means disabled/dark
|
635
638
|
if pos > @plan.length
|
636
639
|
'.'
|
637
640
|
else
|
@@ -701,7 +704,7 @@ module RSMP
|
|
701
704
|
end
|
702
705
|
|
703
706
|
class DetectorLogic < Component
|
704
|
-
attr_reader :
|
707
|
+
attr_reader :forced, :value
|
705
708
|
|
706
709
|
def initialize node:, id:
|
707
710
|
super node: node, id: id, grouped: false
|
@@ -781,13 +784,20 @@ module RSMP
|
|
781
784
|
|
782
785
|
def handle_m0008 arg
|
783
786
|
@node.verify_security_code 2, arg['securityCode']
|
784
|
-
|
787
|
+
status = arg['status']=='True'
|
788
|
+
mode = arg['mode']=='True'
|
789
|
+
force_detector_logic status, mode
|
785
790
|
arg
|
786
791
|
end
|
787
792
|
|
788
|
-
def force_detector_logic
|
789
|
-
@forced =
|
793
|
+
def force_detector_logic forced, value
|
794
|
+
@forced = forced
|
790
795
|
@value = value
|
796
|
+
if @forced
|
797
|
+
log "Forcing to #{value}", level: :info
|
798
|
+
else
|
799
|
+
log "Releasing", level: :info
|
800
|
+
end
|
791
801
|
end
|
792
802
|
|
793
803
|
end
|
data/lib/rsmp/version.rb
CHANGED
data/test.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class A
|
2
|
+
def go &block
|
3
|
+
@block = block # block will be converted automatically to a Proc
|
4
|
+
indirect
|
5
|
+
end
|
6
|
+
|
7
|
+
def call
|
8
|
+
@block.call
|
9
|
+
end
|
10
|
+
|
11
|
+
def indirect
|
12
|
+
call
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
a = A.new
|
18
|
+
|
19
|
+
a.go do
|
20
|
+
break # this is ok. break causes the block to exit, and the encasing method to return - go() will exit
|
21
|
+
end
|
22
|
+
|
23
|
+
# this raises an error. the block we passed to go() will be called again, and it tries to break
|
24
|
+
# but we're not inside a method we can exit from
|
25
|
+
|
26
|
+
|
27
|
+
a.indirect
|
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.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- lib/rsmp/version.rb
|
232
232
|
- lib/rsmp/wait.rb
|
233
233
|
- rsmp.gemspec
|
234
|
+
- test.rb
|
234
235
|
homepage: https://github.com/rsmp-nordic/rsmp
|
235
236
|
licenses:
|
236
237
|
- MIT
|
@@ -254,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
255
|
- !ruby/object:Gem::Version
|
255
256
|
version: '0'
|
256
257
|
requirements: []
|
257
|
-
rubygems_version: 3.2.
|
258
|
+
rubygems_version: 3.2.26
|
258
259
|
signing_key:
|
259
260
|
specification_version: 4
|
260
261
|
summary: RoadSide Message Protocol (RSMP) library.
|