rsmp 0.8.4 → 0.9.1

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec.yaml +21 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile.lock +51 -67
  5. data/README.md +2 -12
  6. data/bin/console +1 -1
  7. data/cucumber.yml +1 -0
  8. data/documentation/classes_and_modules.md +4 -4
  9. data/documentation/collecting_message.md +2 -2
  10. data/documentation/tasks.md +149 -0
  11. data/lib/rsmp/archive.rb +3 -3
  12. data/lib/rsmp/cli.rb +32 -4
  13. data/lib/rsmp/collect/aggregated_status_collector.rb +1 -1
  14. data/lib/rsmp/collect/collector.rb +13 -6
  15. data/lib/rsmp/collect/command_response_collector.rb +1 -1
  16. data/lib/rsmp/collect/state_collector.rb +1 -1
  17. data/lib/rsmp/collect/status_collector.rb +2 -1
  18. data/lib/rsmp/components.rb +3 -3
  19. data/lib/rsmp/convert/export/json_schema.rb +4 -4
  20. data/lib/rsmp/convert/import/yaml.rb +1 -1
  21. data/lib/rsmp/deep_merge.rb +1 -0
  22. data/lib/rsmp/error.rb +0 -3
  23. data/lib/rsmp/inspect.rb +1 -1
  24. data/lib/rsmp/logger.rb +5 -5
  25. data/lib/rsmp/logging.rb +1 -1
  26. data/lib/rsmp/message.rb +1 -1
  27. data/lib/rsmp/node.rb +10 -45
  28. data/lib/rsmp/proxy.rb +184 -134
  29. data/lib/rsmp/rsmp.rb +1 -1
  30. data/lib/rsmp/site.rb +23 -60
  31. data/lib/rsmp/site_proxy.rb +33 -37
  32. data/lib/rsmp/supervisor.rb +25 -21
  33. data/lib/rsmp/supervisor_proxy.rb +58 -29
  34. data/lib/rsmp/task.rb +84 -0
  35. data/lib/rsmp/tlc/signal_group.rb +5 -3
  36. data/lib/rsmp/tlc/signal_plan.rb +2 -2
  37. data/lib/rsmp/tlc/traffic_controller.rb +97 -29
  38. data/lib/rsmp/tlc/traffic_controller_site.rb +43 -36
  39. data/lib/rsmp/version.rb +1 -1
  40. data/lib/rsmp.rb +1 -1
  41. data/rsmp.gemspec +7 -7
  42. metadata +21 -20
  43. data/lib/rsmp/site_proxy_wait.rb +0 -0
  44. data/lib/rsmp/wait.rb +0 -16
  45. data/test.rb +0 -27
@@ -3,7 +3,7 @@
3
3
  module RSMP
4
4
  module Components
5
5
  attr_reader :components
6
-
6
+
7
7
  def initialize_components
8
8
  @components = {}
9
9
  end
@@ -25,10 +25,10 @@ module RSMP
25
25
 
26
26
  def check_main_component settings
27
27
  unless settings['main'] && settings['main'].size >= 1
28
- raise ConfigurationError.new("main component must be defined")
28
+ raise ConfigurationError.new("main component must be defined")
29
29
  end
30
30
  if settings['main'].size > 1
31
- raise ConfigurationError.new("only one main component can be defined, found #{settings['main'].keys.join(', ')}")
31
+ raise ConfigurationError.new("only one main component can be defined, found #{settings['main'].keys.join(', ')}")
32
32
  end
33
33
  end
34
34
 
@@ -23,7 +23,7 @@ module RSMP
23
23
 
24
24
  def self.build_value item
25
25
  out = {}
26
-
26
+
27
27
  if item['description']
28
28
  out["description"] = item['description']
29
29
  end
@@ -95,7 +95,7 @@ module RSMP
95
95
  }
96
96
  end
97
97
  json = {
98
- "properties" => {
98
+ "properties" => {
99
99
  "aCId" => { "enum" => items.keys.sort },
100
100
  "rvs" => { "items" => { "allOf" => list } }
101
101
  }
@@ -175,7 +175,7 @@ module RSMP
175
175
  }
176
176
  ]
177
177
  }
178
- out["sxl.json"] = output_json json
178
+ out["sxl.json"] = output_json json
179
179
  end
180
180
 
181
181
  def self.generate sxl
@@ -192,7 +192,7 @@ module RSMP
192
192
  out.each_pair do |relative_path,str|
193
193
  path = File.join(folder, relative_path)
194
194
  FileUtils.mkdir_p File.dirname(path) # create folders if needed
195
- file = File.open(path, 'w+') # w+ means truncate or create new file
195
+ file = File.open(path, 'w+') # w+ means truncate or create new file
196
196
  file.puts str
197
197
  end
198
198
  end
@@ -24,7 +24,7 @@ module RSMP
24
24
  commands: {}
25
25
  }
26
26
 
27
- yaml['objects'].each_pair do |type,object|
27
+ yaml['objects'].each_pair do |type,object|
28
28
  object["alarms"].each { |id,item| sxl[:alarms][id] = item }
29
29
  object["statuses"].each { |id,item| sxl[:statuses][id] = item }
30
30
  object["commands"].each { |id,item| sxl[:commands][id] = item }
@@ -1,5 +1,6 @@
1
1
  class Hash
2
2
  def deep_merge(other_hash)
3
+ return self unless other_hash
3
4
  self.merge(other_hash) do |key, old, fresh|
4
5
  if old.is_a?(Hash) && fresh.is_a?(Hash)
5
6
  old.deep_merge(fresh)
data/lib/rsmp/error.rb CHANGED
@@ -64,7 +64,4 @@ module RSMP
64
64
 
65
65
  class RepeatedStatusError < Error
66
66
  end
67
-
68
- class TimestampError < Error
69
- end
70
67
  end
data/lib/rsmp/inspect.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # Costume inspect, to reduce noise
2
- #
2
+ #
3
3
  # Instance variables of classes starting with Async or RSMP are shown
4
4
  # with only their class name and object id, which reduces output,
5
5
  # especially for deep object structures.
data/lib/rsmp/logger.rb CHANGED
@@ -2,7 +2,7 @@ module RSMP
2
2
  class Logger
3
3
 
4
4
  attr_accessor :settings
5
-
5
+
6
6
  def initialize settings={}
7
7
  defaults = {
8
8
  'active'=>true,
@@ -115,7 +115,7 @@ module RSMP
115
115
  end
116
116
  end
117
117
  end
118
- return false if ack && @settings["acknowledgements"] == false &&
118
+ return false if ack && @settings["acknowledgements"] == false &&
119
119
  [:not_acknowledged,:warning,:error].include?(item[:level]) == false
120
120
  end
121
121
  true
@@ -159,7 +159,7 @@ module RSMP
159
159
 
160
160
  def log item, force:false
161
161
  if output?(item, force)
162
- output item[:level], build_output(item)
162
+ output item[:level], build_output(item)
163
163
  end
164
164
  end
165
165
 
@@ -169,7 +169,7 @@ module RSMP
169
169
  else
170
170
  ' '*length
171
171
  end
172
- end
172
+ end
173
173
 
174
174
  def dump archive, force:false, num:nil
175
175
  num ||= archive.items.size
@@ -183,7 +183,7 @@ module RSMP
183
183
  def build_part parts, item, key, &block
184
184
  skey = key.to_s
185
185
  return unless @settings[skey]
186
-
186
+
187
187
  part = item[key]
188
188
  part = yield part if block
189
189
  part = part.to_s
data/lib/rsmp/logging.rb CHANGED
@@ -8,7 +8,7 @@ module RSMP
8
8
 
9
9
  def initialize_logging options
10
10
  @archive = options[:archive] || RSMP::Archive.new
11
- @logger = options[:logger] || RSMP::Logger.new(options[:log_settings])
11
+ @logger = options[:logger] || RSMP::Logger.new(options[:log_settings])
12
12
  end
13
13
 
14
14
  def author
data/lib/rsmp/message.rb CHANGED
@@ -188,7 +188,7 @@ module RSMP
188
188
  class Unknown < Message
189
189
  end
190
190
 
191
- class AggregatedStatus < Message
191
+ class AggregatedStatus < Message
192
192
  def initialize attributes = {}
193
193
  super({
194
194
  "type" => "AggregatedStatus",
data/lib/rsmp/node.rb CHANGED
@@ -3,14 +3,14 @@
3
3
  module RSMP
4
4
  class Node
5
5
  include Logging
6
- include Wait
7
6
  include Inspect
7
+ include Task
8
8
 
9
9
  attr_reader :archive, :logger, :task, :deferred, :error_queue, :clock, :collector
10
10
 
11
11
  def initialize options
12
12
  initialize_logging options
13
- @task = options[:task]
13
+ initialize_task
14
14
  @deferred = []
15
15
  @clock = Clock.new
16
16
  @error_queue = Async::Queue.new
@@ -18,6 +18,13 @@ module RSMP
18
18
  @collect = options[:collect]
19
19
  end
20
20
 
21
+ # stop proxies, then call super
22
+ def stop_subtasks
23
+ @proxies.each { |proxy| proxy.stop }
24
+ @proxies.clear
25
+ super
26
+ end
27
+
21
28
  def ignore_errors classes, &block
22
29
  was, @ignore_errors = @ignore_errors, [classes].flatten
23
30
  yield
@@ -50,55 +57,13 @@ module RSMP
50
57
 
51
58
  def clear_deferred
52
59
  @deferred.clear
53
- end
54
-
55
- def do_start task
56
- task.annotate self.class.to_s
57
- @task = task
58
- start_action
59
- idle
60
- end
61
-
62
- def start
63
- starting
64
- if @task
65
- do_start @task
66
- else
67
- Async do |task|
68
- do_start task
69
- end
70
- end
71
- rescue Errno::EADDRINUSE => e
72
- log "Cannot start: #{e.to_s}", level: :error
73
- rescue SystemExit, SignalException, Interrupt
74
- @logger.unmute_all
75
- exiting
76
- end
77
-
78
- def idle
79
- loop do
80
- @task.sleep 60
81
- end
82
- end
83
-
84
- def stop
85
- @task.stop if @task
86
- end
87
-
88
- def restart
89
- stop
90
- start
91
- end
92
-
93
- def exiting
94
- log "Exiting", level: :info
95
60
  end
96
61
 
97
62
  def check_required_settings settings, required
98
63
  raise ArgumentError.new "Settings is empty" unless settings
99
64
  required.each do |setting|
100
65
  raise ArgumentError.new "Missing setting: #{setting}" unless settings.include? setting.to_s
101
- end
66
+ end
102
67
  end
103
68
 
104
69
  def author