rsmp 0.37.0 → 0.38.0
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/.devcontainer/devcontainer.json +22 -0
- data/.github/workflows/rubocop.yaml +17 -0
- data/.gitignore +5 -6
- data/.rubocop.yml +80 -0
- data/Gemfile +13 -1
- data/Gemfile.lock +34 -1
- data/Rakefile +3 -3
- data/lib/rsmp/cli.rb +147 -124
- data/lib/rsmp/collect/ack_collector.rb +8 -7
- data/lib/rsmp/collect/aggregated_status_collector.rb +4 -4
- data/lib/rsmp/collect/alarm_collector.rb +31 -23
- data/lib/rsmp/collect/alarm_matcher.rb +3 -3
- data/lib/rsmp/collect/collector/logging.rb +17 -0
- data/lib/rsmp/collect/collector/reporting.rb +44 -0
- data/lib/rsmp/collect/collector/status.rb +34 -0
- data/lib/rsmp/collect/collector.rb +69 -150
- data/lib/rsmp/collect/command_matcher.rb +19 -6
- data/lib/rsmp/collect/command_response_collector.rb +7 -7
- data/lib/rsmp/collect/distributor.rb +14 -11
- data/lib/rsmp/collect/filter.rb +31 -15
- data/lib/rsmp/collect/matcher.rb +7 -11
- data/lib/rsmp/collect/queue.rb +4 -4
- data/lib/rsmp/collect/receiver.rb +10 -12
- data/lib/rsmp/collect/state_collector.rb +116 -77
- data/lib/rsmp/collect/status_collector.rb +6 -6
- data/lib/rsmp/collect/status_matcher.rb +17 -7
- data/lib/rsmp/{alarm_state.rb → component/alarm_state.rb} +76 -37
- data/lib/rsmp/{component.rb → component/component.rb} +15 -15
- data/lib/rsmp/component/component_base.rb +89 -0
- data/lib/rsmp/component/component_proxy.rb +75 -0
- data/lib/rsmp/component/components.rb +63 -0
- data/lib/rsmp/convert/export/json_schema.rb +116 -110
- data/lib/rsmp/convert/import/yaml.rb +21 -18
- data/lib/rsmp/{rsmp.rb → helpers/clock.rb} +5 -6
- data/lib/rsmp/{deep_merge.rb → helpers/deep_merge.rb} +2 -1
- data/lib/rsmp/helpers/error.rb +71 -0
- data/lib/rsmp/{inspect.rb → helpers/inspect.rb} +6 -10
- data/lib/rsmp/log/archive.rb +98 -0
- data/lib/rsmp/log/colorization.rb +41 -0
- data/lib/rsmp/log/filtering.rb +54 -0
- data/lib/rsmp/log/logger.rb +206 -0
- data/lib/rsmp/{logging.rb → log/logging.rb} +5 -7
- data/lib/rsmp/message.rb +159 -148
- data/lib/rsmp/{node.rb → node/node.rb} +19 -17
- data/lib/rsmp/{protocol.rb → node/protocol.rb} +5 -3
- data/lib/rsmp/node/site/site.rb +195 -0
- data/lib/rsmp/node/supervisor/modules/configuration.rb +59 -0
- data/lib/rsmp/node/supervisor/modules/connection.rb +140 -0
- data/lib/rsmp/node/supervisor/modules/sites.rb +64 -0
- data/lib/rsmp/node/supervisor/supervisor.rb +72 -0
- data/lib/rsmp/{task.rb → node/task.rb} +12 -14
- data/lib/rsmp/proxy/modules/acknowledgements.rb +144 -0
- data/lib/rsmp/proxy/modules/receive.rb +119 -0
- data/lib/rsmp/proxy/modules/send.rb +76 -0
- data/lib/rsmp/proxy/modules/state.rb +25 -0
- data/lib/rsmp/proxy/modules/tasks.rb +105 -0
- data/lib/rsmp/proxy/modules/versions.rb +69 -0
- data/lib/rsmp/proxy/modules/watchdogs.rb +66 -0
- data/lib/rsmp/proxy/proxy.rb +199 -0
- data/lib/rsmp/proxy/site/modules/aggregated_status.rb +52 -0
- data/lib/rsmp/proxy/site/modules/alarms.rb +27 -0
- data/lib/rsmp/proxy/site/modules/commands.rb +31 -0
- data/lib/rsmp/proxy/site/modules/status.rb +110 -0
- data/lib/rsmp/proxy/site/site_proxy.rb +205 -0
- data/lib/rsmp/proxy/supervisor/modules/aggregated_status.rb +47 -0
- data/lib/rsmp/proxy/supervisor/modules/alarms.rb +73 -0
- data/lib/rsmp/proxy/supervisor/modules/commands.rb +53 -0
- data/lib/rsmp/proxy/supervisor/modules/status.rb +204 -0
- data/lib/rsmp/proxy/supervisor/supervisor_proxy.rb +178 -0
- data/lib/rsmp/tlc/detector_logic.rb +18 -34
- data/lib/rsmp/tlc/input_states.rb +126 -0
- data/lib/rsmp/tlc/modules/detector_logics.rb +50 -0
- data/lib/rsmp/tlc/modules/display.rb +78 -0
- data/lib/rsmp/tlc/modules/helpers.rb +41 -0
- data/lib/rsmp/tlc/modules/inputs.rb +173 -0
- data/lib/rsmp/tlc/modules/modes.rb +253 -0
- data/lib/rsmp/tlc/modules/outputs.rb +30 -0
- data/lib/rsmp/tlc/modules/plans.rb +218 -0
- data/lib/rsmp/tlc/modules/signal_groups.rb +109 -0
- data/lib/rsmp/tlc/modules/startup_sequence.rb +22 -0
- data/lib/rsmp/tlc/modules/system.rb +140 -0
- data/lib/rsmp/tlc/modules/traffic_data.rb +49 -0
- data/lib/rsmp/tlc/signal_group.rb +37 -41
- data/lib/rsmp/tlc/signal_plan.rb +14 -11
- data/lib/rsmp/tlc/signal_priority.rb +39 -35
- data/lib/rsmp/tlc/startup_sequence.rb +59 -0
- data/lib/rsmp/tlc/traffic_controller.rb +38 -1010
- data/lib/rsmp/tlc/traffic_controller_site.rb +58 -57
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp.rb +82 -48
- data/rsmp.gemspec +24 -31
- metadata +79 -139
- data/lib/rsmp/archive.rb +0 -76
- data/lib/rsmp/collect/message_matchers.rb +0 -0
- data/lib/rsmp/component_base.rb +0 -87
- data/lib/rsmp/component_proxy.rb +0 -57
- data/lib/rsmp/components.rb +0 -65
- data/lib/rsmp/error.rb +0 -71
- data/lib/rsmp/logger.rb +0 -216
- data/lib/rsmp/proxy.rb +0 -693
- data/lib/rsmp/site.rb +0 -188
- data/lib/rsmp/site_proxy.rb +0 -389
- data/lib/rsmp/supervisor.rb +0 -302
- data/lib/rsmp/supervisor_proxy.rb +0 -510
- data/lib/rsmp/tlc/inputs.rb +0 -134
data/lib/rsmp/error.rb
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
module RSMP
|
|
2
|
-
class Error < StandardError
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
class InvalidPacket < Error
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
class MalformedMessage < Error
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
class SchemaError < Error
|
|
12
|
-
attr_accessor :schemas
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
class InvalidMessage < Error
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
class UnknownMessage < Error
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
class MissingAcknowledgment < Error
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
class MissingWatchdog < Error
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
class MessageRejected < Error
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class MissingAttribute < InvalidMessage
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
class FatalError < Error
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class HandshakeError < FatalError
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
class NotReady < Error
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
class TimeoutError < Error
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
class DisconnectError < Error
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
class ConnectionError < Error
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
class UnknownComponent < Error
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
class UnknownCommand < Error
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
class UnknownStatus < Error
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
class ConfigurationError < Error
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
class RepeatedAlarmError < Error
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
class RepeatedStatusError < Error
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
class TimestampError < Error
|
|
70
|
-
end
|
|
71
|
-
end
|
data/lib/rsmp/logger.rb
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
module RSMP
|
|
2
|
-
class Logger
|
|
3
|
-
|
|
4
|
-
attr_accessor :settings
|
|
5
|
-
|
|
6
|
-
def initialize settings={}
|
|
7
|
-
defaults = {
|
|
8
|
-
'active'=>true,
|
|
9
|
-
'path'=>nil,
|
|
10
|
-
'stream'=>nil,
|
|
11
|
-
'color'=>true,
|
|
12
|
-
'debug'=>false,
|
|
13
|
-
'statistics'=>false,
|
|
14
|
-
'hide_ip_and_port' => false,
|
|
15
|
-
'acknowledgements' => false,
|
|
16
|
-
'watchdogs' => false,
|
|
17
|
-
'alarms' => true,
|
|
18
|
-
'json'=>false,
|
|
19
|
-
'tabs'=>'-',
|
|
20
|
-
|
|
21
|
-
'prefix'=>false,
|
|
22
|
-
'index'=>false,
|
|
23
|
-
'author'=>false,
|
|
24
|
-
'timestamp'=>true,
|
|
25
|
-
'ip'=>false,
|
|
26
|
-
'port'=>false,
|
|
27
|
-
'site_id'=>true,
|
|
28
|
-
'component'=>true,
|
|
29
|
-
'direction'=>false,
|
|
30
|
-
'level'=>false,
|
|
31
|
-
'id'=>true,
|
|
32
|
-
'text'=>true,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
default_lengths = {
|
|
36
|
-
'index'=>7,
|
|
37
|
-
'author'=>13,
|
|
38
|
-
'timestamp'=>24,
|
|
39
|
-
'ip'=>22,
|
|
40
|
-
'port'=>5,
|
|
41
|
-
'site_id'=>19,
|
|
42
|
-
'component'=>19,
|
|
43
|
-
'direction'=>3,
|
|
44
|
-
'level'=>7,
|
|
45
|
-
'id'=>4,
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@ignorable = {
|
|
49
|
-
'versions' => ['Version'],
|
|
50
|
-
'statuses' => ['StatusRequest','StatusSubscribe','StatusUnsubscribe','StatusResponse','StatusUpdate'],
|
|
51
|
-
'commands' => ['CommandRequest','CommandResponse'],
|
|
52
|
-
'watchdogs' => 'Watchdog',
|
|
53
|
-
'alarms' => ['Alarm'],
|
|
54
|
-
'aggregated_status' => ['AggregatedStatus','AggregatedStatusRequest']
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if settings
|
|
58
|
-
@settings = defaults.merge settings
|
|
59
|
-
else
|
|
60
|
-
@settings = defaults
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# copy default length for items that are set to true
|
|
64
|
-
@settings = @settings.map do |key,value|
|
|
65
|
-
if value == true && default_lengths[key]
|
|
66
|
-
[ key, default_lengths[key] ]
|
|
67
|
-
else
|
|
68
|
-
[ key, value ]
|
|
69
|
-
end
|
|
70
|
-
end.to_h
|
|
71
|
-
|
|
72
|
-
@muted = {}
|
|
73
|
-
setup_output_destination
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def setup_output_destination
|
|
77
|
-
if @settings['stream']
|
|
78
|
-
@stream = @settings['stream']
|
|
79
|
-
elsif @settings['path']
|
|
80
|
-
@stream = File.open(@settings['path'],'a') # appending
|
|
81
|
-
else
|
|
82
|
-
@stream = $stdout
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def mute ip, port
|
|
87
|
-
@muted["#{ip}:#{port}"] = true
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def unmute ip, port
|
|
91
|
-
@muted.delete "#{ip}:#{port}"
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def unmute_all
|
|
95
|
-
@muted = {}
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def output? item, force=false
|
|
99
|
-
return false if item[:ip] && item[:port] && @muted["#{item[:ip]}:#{item[:port]}"]
|
|
100
|
-
return false if @settings["active"] == false && force != true
|
|
101
|
-
return false if @settings["info"] == false && item[:level] == :info
|
|
102
|
-
return false if @settings["debug"] != true && item[:level] == :debug
|
|
103
|
-
return false if @settings["statistics"] != true && item[:level] == :statistics
|
|
104
|
-
return false if @settings["test"] != true && item[:level] == :test
|
|
105
|
-
|
|
106
|
-
if item[:message]
|
|
107
|
-
type = item[:message].type
|
|
108
|
-
ack = (type == "MessageAck" || type == "MessageNotAck")
|
|
109
|
-
@ignorable.each_pair do |key,types|
|
|
110
|
-
ignore = [types].flatten
|
|
111
|
-
if @settings[key] == false
|
|
112
|
-
return false if ignore.include?(type)
|
|
113
|
-
if ack
|
|
114
|
-
return false if item[:message].original && ignore.include?(item[:message].original.type)
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
return false if ack && @settings["acknowledgements"] == false &&
|
|
119
|
-
[:not_acknowledged,:warning,:error].include?(item[:level]) == false
|
|
120
|
-
end
|
|
121
|
-
true
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def output level, str
|
|
125
|
-
return if str.empty? || /^\s+$/.match(str)
|
|
126
|
-
str = colorize level, str
|
|
127
|
-
@stream.puts str
|
|
128
|
-
@stream.flush
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def colorize level, str
|
|
132
|
-
if @settings["color"] == false || @settings["color"] == nil
|
|
133
|
-
str
|
|
134
|
-
elsif @settings["color"] == true || @settings["color"].is_a?(Hash)
|
|
135
|
-
colors = {
|
|
136
|
-
'info' => 'white',
|
|
137
|
-
'log' => 'light_blue',
|
|
138
|
-
'statistics' => 'light_black',
|
|
139
|
-
'warning' => 'light_yellow',
|
|
140
|
-
'error' => 'red',
|
|
141
|
-
'debug' => 'light_black',
|
|
142
|
-
'collect' => 'light_black'
|
|
143
|
-
}
|
|
144
|
-
colors.merge! @settings["color"] if @settings["color"].is_a?(Hash)
|
|
145
|
-
if colors[level.to_s]
|
|
146
|
-
str.colorize colors[level.to_s].to_sym
|
|
147
|
-
else
|
|
148
|
-
str
|
|
149
|
-
end
|
|
150
|
-
else
|
|
151
|
-
if level == :nack || level == :warning || level == :error
|
|
152
|
-
str.colorize(@settings["color"]).bold
|
|
153
|
-
else
|
|
154
|
-
str.colorize @settings["color"]
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def log item, force:false
|
|
160
|
-
if output?(item, force)
|
|
161
|
-
output item[:level], build_output(item)
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def self.shorten_message_id m_id, length=4
|
|
166
|
-
if m_id
|
|
167
|
-
m_id[0..length-1].ljust(length)
|
|
168
|
-
else
|
|
169
|
-
' '*length
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
def dump archive, force:false, num:nil
|
|
174
|
-
num ||= archive.items.size
|
|
175
|
-
log = archive.items.last(num).map do |item|
|
|
176
|
-
str = build_output item
|
|
177
|
-
str = colorize item[:level], str
|
|
178
|
-
end
|
|
179
|
-
log.join("\n")
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
def build_part parts, item, key, &block
|
|
183
|
-
skey = key.to_s
|
|
184
|
-
return unless @settings[skey]
|
|
185
|
-
|
|
186
|
-
part = item[key]
|
|
187
|
-
part = yield part if block
|
|
188
|
-
part = part.to_s
|
|
189
|
-
part = part.ljust @settings[skey] if @settings[skey].is_a?(Integer)
|
|
190
|
-
|
|
191
|
-
# replace the first char with a dash if string is all whitespace
|
|
192
|
-
part = @settings['tabs'].ljust(part.length) if @settings['tabs'] && part !~ /\S/
|
|
193
|
-
parts << part
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def build_output item
|
|
197
|
-
parts = []
|
|
198
|
-
build_part( parts, item, :prefix ) { @settings['prefix'] if @settings['prefix'] != false}
|
|
199
|
-
build_part( parts, item, :index )
|
|
200
|
-
build_part( parts, item, :author )
|
|
201
|
-
build_part( parts, item, :timestamp ) { |part| Clock.to_s part }
|
|
202
|
-
build_part( parts, item, :ip )
|
|
203
|
-
build_part( parts, item, :port )
|
|
204
|
-
build_part( parts, item, :site_id )
|
|
205
|
-
build_part( parts, item, :component )
|
|
206
|
-
build_part( parts, item, :direction ) { |part| {in:"In",out:"Out"}[part] }
|
|
207
|
-
build_part( parts, item, :level ) { |part| part.capitalize }
|
|
208
|
-
build_part( parts, item, :id ) { Logger.shorten_message_id(item[:message].m_id,4) if item[:message] }
|
|
209
|
-
build_part( parts, item, :text )
|
|
210
|
-
build_part( parts, item, :json ) { item[:message].json if item[:message] }
|
|
211
|
-
build_part( parts, item, :exception ) { |e| [e.class,e.backtrace].flatten.join("\n") }
|
|
212
|
-
|
|
213
|
-
parts.join(' ').chomp(@settings['tabs'].to_s).rstrip
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
end
|