Module: RSMP::SiteProxy::Modules::Alarms
- Included in:
- RSMP::SiteProxy
- Defined in:
- lib/rsmp/proxy/site/modules/alarms.rb
Overview
Handles alarm messages
Instance Method Summary collapse
- #process_alarm(message) ⇒ Object
-
#resume_alarm(c_id:, a_c_id:, collect: false) ⇒ Object
Send an AlarmResume message and optionally collect the confirming response.
- #resume_alarm! ⇒ Object
- #send_alarm_acknowledgement(component, alarm_code, options = {}) ⇒ Object
- #send_alarm_acknowledgement! ⇒ Object
-
#suspend_alarm(c_id:, a_c_id:, collect: false) ⇒ Object
Send an AlarmSuspend message and optionally collect the confirming response.
- #suspend_alarm! ⇒ Object
Instance Method Details
#process_alarm(message) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 6 def process_alarm() component = find_component .attribute('cId') status = %w[ack aS sS].map { |key| .attribute(key) }.join(',') component.handle_alarm alarm_code = .attribute('aCId') asp = .attribute('aSp') log "Received #{.type}, #{alarm_code} #{asp} [#{status}]", message: , level: :log acknowledge end |
#resume_alarm(c_id:, a_c_id:, collect: false) ⇒ Object
Send an AlarmResume message and optionally collect the confirming response.
Returns Result
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 61 def resume_alarm(c_id:, a_c_id:, collect: false) = RSMP::AlarmResume.new( 'mId' => RSMP::Message.make_m_id, 'cId' => c_id, 'aCId' => a_c_id ) if collect collector = RSMP::AlarmCollector.new( self, m_id: .m_id, num: 1, matcher: { 'cId' => c_id, 'aCId' => a_c_id, 'aSp' => 'Suspend', 'sS' => /^notSuspended/i }, timeout: node.supervisor_settings.dig('default', 'timeouts', 'alarm') ) (, collector) else ().map(&:message) end end |
#resume_alarm! ⇒ Object
86 87 88 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 86 def resume_alarm!(...) resume_alarm(...).value! end |
#send_alarm_acknowledgement(component, alarm_code, options = {}) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 16 def send_alarm_acknowledgement(component, alarm_code, = {}) = RSMP::AlarmAcknowledged.new({ 'cId' => component, 'aCId' => alarm_code }) (, validate: [:validate]).map(&:message) end |
#send_alarm_acknowledgement! ⇒ Object
24 25 26 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 24 def send_alarm_acknowledgement!(...) send_alarm_acknowledgement(...).value! end |
#suspend_alarm(c_id:, a_c_id:, collect: false) ⇒ Object
Send an AlarmSuspend message and optionally collect the confirming response.
Returns Result
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 30 def suspend_alarm(c_id:, a_c_id:, collect: false) = RSMP::AlarmSuspend.new( 'mId' => RSMP::Message.make_m_id, 'cId' => c_id, 'aCId' => a_c_id ) if collect collector = RSMP::AlarmCollector.new( self, m_id: .m_id, num: 1, matcher: { 'cId' => c_id, 'aCId' => a_c_id, 'aSp' => 'Suspend', 'sS' => /^Suspended/i }, timeout: node.supervisor_settings.dig('default', 'timeouts', 'alarm') ) (, collector) else ().map(&:message) end end |
#suspend_alarm! ⇒ Object
55 56 57 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 55 def suspend_alarm!(...) suspend_alarm(...).value! end |