Class: RSMP::AlarmCollector
- Defined in:
- lib/rsmp/collect/alarm_collector.rb
Overview
Class for waiting for specific command responses
Instance Attribute Summary
Attributes inherited from Collector
#condition, #error, #messages, #status, #task
Instance Method Summary collapse
-
#describe_query ⇒ Object
return a string that describes what we’re collecting.
-
#initialize(proxy, options = {}) ⇒ AlarmCollector
constructor
A new instance of AlarmCollector.
-
#type_match?(message) ⇒ Boolean
match alarm attributes.
Methods inherited from Collector
#cancel, #cancelled?, #collect, #collect!, #collecting?, #complete, #describe, #describe_num_and_type, #describe_progress, #describe_types, #do_stop, #done?, #identifier, #incomplete, #ingoing?, #inspect, #keep, #log_complete, #log_incomplete, #log_start, #notify, #notify_disconnect, #notify_error, #notify_schema_error, #ok!, #ok?, #outgoing?, #perform_match, #ready?, #reject_not_ack, #reset, #start, #timeout?, #use_task, #wait, #wait!
Methods inherited from Listener
#change_notifier, #notify, #notify_error
Methods included from Inspect
Constructor Details
#initialize(proxy, options = {}) ⇒ AlarmCollector
Returns a new instance of AlarmCollector.
4 5 6 7 8 9 10 |
# File 'lib/rsmp/collect/alarm_collector.rb', line 4 def initialize proxy,={} @query = [:query] || {} super proxy, .merge( type: 'Alarm', title:'alarm' ) end |
Instance Method Details
#describe_query ⇒ Object
return a string that describes what we’re collecting
44 45 46 |
# File 'lib/rsmp/collect/alarm_collector.rb', line 44 def describe_query "#{describe_num_and_type} #{ {component: @options[:component]}.merge(@query).compact }" end |
#type_match?(message) ⇒ Boolean
match alarm attributes
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rsmp/collect/alarm_collector.rb', line 13 def type_match? return false if super() == false # match fixed attributes %w{aCId aSp ack aS sS cat pri}.each do |key| want = @query[key] got = .attribute(key) case want when Regexp return false if got !~ want when String return false if got != want end end # match rvs items if @query['rvs'] query_rvs = @query['rvs'] = .attributes['rvs'] return false unless return false unless query_rvs.all? do |query_item| return false unless .any? do || next ['n'] == query_item['n'] && ['v'] == query_item['v'] end next true end end true end |