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(task, c_id:, a_c_id:, collect: false) ⇒ Object
Send an AlarmResume message and optionally collect the confirming response.
- #send_alarm_acknowledgement(component, alarm_code, options = {}) ⇒ Object
-
#suspend_alarm(task, c_id:, a_c_id:, collect: false) ⇒ Object
Send an AlarmSuspend message and optionally collect the confirming response.
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(task, c_id:, a_c_id:, collect: false) ⇒ Object
Send an AlarmResume message and optionally collect the confirming response. When collect: true, returns [message, response]; when collect: false, returns message.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 56 def resume_alarm(task, 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 collect_task = task.async do RSMP::AlarmCollector.new(self, m_id: .m_id, num: 1, matcher: { 'cId' => c_id, 'aCI' => a_c_id, 'aSp' => 'Suspend', 'sS' => /^notSuspended/i }, timeout: node.supervisor_settings.dig('default', 'timeouts', 'alarm')).collect! end [, collect_task.wait.first] else end end |
#send_alarm_acknowledgement(component, alarm_code, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# 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] end |
#suspend_alarm(task, c_id:, a_c_id:, collect: false) ⇒ Object
Send an AlarmSuspend message and optionally collect the confirming response. When collect: true, returns [message, response]; when collect: false, returns message.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 27 def suspend_alarm(task, 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 collect_task = task.async do RSMP::AlarmCollector.new(self, m_id: .m_id, num: 1, matcher: { 'cId' => c_id, 'aCI' => a_c_id, 'aSp' => 'Suspend', 'sS' => /^Suspended/i }, timeout: node.supervisor_settings.dig('default', 'timeouts', 'alarm')).collect! end [, collect_task.wait.first] else end end |