rsmp 0.3.5 → 0.3.6
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/components.rb +16 -3
- data/lib/rsmp/site_proxy.rb +17 -11
- data/lib/rsmp/tlc.rb +1 -1
- data/lib/rsmp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '06464038166b8a2a0dbd21e7e53d28472117acfb704312755023792d2650943b'
|
4
|
+
data.tar.gz: 149b50fb2e39d2287fd3fbd7fbc6f5520a9922d778315272250a361a6cf4d4be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 115228cc10a63d009bffd2a7f3f0408ad47e2dafd14883f8a25b38870ef99fe73292ddc61ac9e38a1d895d70f53c5a08928492c940d01641d87b19e466764dba
|
7
|
+
data.tar.gz: 6df15fe4e9c6044cb5fab93da68202d4e0bdb32e109bc538fc4d55c232669cbbf745e7aeacee87fa75567658687683d84ee5255d98b9841f05090a918d6b6c49
|
data/Gemfile.lock
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
|
+
{ klass: Component, grouped: false }
|
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[:klass].new node: self, id: component_id
|
51
|
+
@components[ component_id] = component
|
52
|
+
class_name = component.class.name.split('::').last
|
53
|
+
log "Inferred component #{component_id} of type #{class_name} for site #{@site_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
@@ -121,21 +121,27 @@ module RSMP
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
+
def infer_component_type component_id
|
125
|
+
if component_id =~ /TC/
|
126
|
+
{ klass: TrafficController, grouped: true }
|
127
|
+
elsif component_id =~ /DL/
|
128
|
+
{ klass: DetectorLogic, goruped: false }
|
129
|
+
elsif component_id =~ /SG/
|
130
|
+
{ klass: SignalGroup, grouped: false }
|
131
|
+
else
|
132
|
+
super
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
124
136
|
def process_aggregated_status message
|
125
137
|
se = message.attribute("se")
|
126
138
|
validate_aggregated_status(message,se) == false
|
127
139
|
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
|
140
|
+
component = find_component c_id
|
141
|
+
unless component
|
142
|
+
reason = "component #{c_id} not found"
|
143
|
+
dont_acknowledge message, "Ignoring #{message.type}:", reason
|
144
|
+
return
|
139
145
|
end
|
140
146
|
|
141
147
|
component.set_aggregated_status_bools se
|
data/lib/rsmp/tlc.rb
CHANGED
data/lib/rsmp/version.rb
CHANGED