Module: RSMP::SupervisorProxy::Modules::Alarms

Included in:
RSMP::SupervisorProxy
Defined in:
lib/rsmp/proxy/supervisor/modules/alarms.rb

Overview

Alarm handling

Instance Method Summary collapse

Instance Method Details

#handle_alarm_acknowledge(message) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/rsmp/proxy/supervisor/modules/alarms.rb', line 38

def handle_alarm_acknowledge(message)
  component_id = message.attributes['cId']
  component = @site.find_component component_id
  alarm_code = message.attribute('aCId')
  log "Received #{message.type} #{alarm_code} acknowledgement", message: message, level: :log
  acknowledge message
  component.acknowledge_alarm alarm_code
end

#handle_alarm_request(message) ⇒ Object



65
66
67
68
69
# File 'lib/rsmp/proxy/supervisor/modules/alarms.rb', line 65

def handle_alarm_request(message)
  log "Received #{message.type}", message: message, level: :log
  acknowledge message
  send_active_alarms
end

#handle_alarm_resume(message) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/rsmp/proxy/supervisor/modules/alarms.rb', line 56

def handle_alarm_resume(message)
  component_id = message.attributes['cId']
  component = @site.find_component component_id
  alarm_code = message.attribute('aCId')
  log "Received #{message.type} #{alarm_code} resume", message: message, level: :log
  acknowledge message
  component.resume_alarm alarm_code
end

#handle_alarm_suspend(message) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/rsmp/proxy/supervisor/modules/alarms.rb', line 47

def handle_alarm_suspend(message)
  component_id = message.attributes['cId']
  component = @site.find_component component_id
  alarm_code = message.attribute('aCId')
  log "Received #{message.type} #{alarm_code} suspend", message: message, level: :log
  acknowledge message
  component.suspend_alarm alarm_code
end

#process_alarm(message) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rsmp/proxy/supervisor/modules/alarms.rb', line 23

def process_alarm(message)
  case message
  when AlarmAcknowledge
    handle_alarm_acknowledge message
  when AlarmSuspend
    handle_alarm_suspend message
  when AlarmResume
    handle_alarm_resume message
  when AlarmRequest
    handle_alarm_request message
  else
    dont_acknowledge message, 'Invalid alarm message type'
  end
end

#send_active_alarmsObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/rsmp/proxy/supervisor/modules/alarms.rb', line 12

def send_active_alarms
  @site.components.each_pair do |_c_id, component|
    component.alarms.each_pair do |_alarm_code, alarm_state|
      if alarm_state.active
        alarm = AlarmIssue.new(alarm_state.to_hash.merge('aSp' => 'Issue'))
        send_message alarm
      end
    end
  end
end

#send_alarm(_component, alarm, options = {}) ⇒ Object



6
7
8
9
10
# File 'lib/rsmp/proxy/supervisor/modules/alarms.rb', line 6

def send_alarm(_component, alarm, options = {})
  send_and_optionally_collect alarm, options do |collect_options|
    Collector.new self, collect_options.merge(task: @task, type: 'MessageAck')
  end
end