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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d22d8796a378484c9c7a9d50b3bc48386db2e12893c5af07a1ef83825d2f1b0e
4
- data.tar.gz: ee6a4ebb4fcf094cb45e1f541e6f228e6ea9c3364fca6e1526e4fe46026751f2
3
+ metadata.gz: '06464038166b8a2a0dbd21e7e53d28472117acfb704312755023792d2650943b'
4
+ data.tar.gz: 149b50fb2e39d2287fd3fbd7fbc6f5520a9922d778315272250a361a6cf4d4be
5
5
  SHA512:
6
- metadata.gz: a1a495ba2c110ebb42db60596516de255b9c9a9cb903fdd66bf77bd27a3f5d5b786b273436b522af3dbf57e983651676b9a9e67aee7387ba134ef89812261618
7
- data.tar.gz: 21f2e48b596dcca6296da89f687ec46d3845eaafb6cad497a16ac4fabca1cb5574da6df324256f4929b7207eeccd17697bd5021b328b4d265ff7d836d2a5e2c3
6
+ metadata.gz: 115228cc10a63d009bffd2a7f3f0408ad47e2dafd14883f8a25b38870ef99fe73292ddc61ac9e38a1d895d70f53c5a08928492c940d01641d87b19e466764dba
7
+ data.tar.gz: 6df15fe4e9c6044cb5fab93da68202d4e0bdb32e109bc538fc4d55c232669cbbf745e7aeacee87fa75567658687683d84ee5255d98b9841f05090a918d6b6c49
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.3.5)
4
+ rsmp (0.3.6)
5
5
  async (~> 1.29.1)
6
6
  async-io (~> 1.32.1)
7
7
  colorize (~> 0.8.1)
@@ -38,10 +38,23 @@ module RSMP
38
38
  Component.new id:id, node: self, grouped: type=='main'
39
39
  end
40
40
 
41
- def find_component component_id
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
- raise UnknownComponent.new("Component #{component_id} not found") unless component
44
- component
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
@@ -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 = @components[c_id]
129
- if component == nil
130
- if @site_settings == nil || @site_settings['components'] == nil
131
- component = build_component(id:c_id, type:nil)
132
- @components[c_id] = component
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
@@ -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 = []
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
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.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Tin