Class: RSMP::Component

Inherits:
ComponentBase show all
Defined in:
lib/rsmp/component/component.rb

Overview

RSMP component

Constant Summary

Constants inherited from ComponentBase

RSMP::ComponentBase::AGGREGATED_STATUS_KEYS

Instance Attribute Summary

Attributes inherited from ComponentBase

#aggregated_status, #aggregated_status_bools, #alarms, #c_id, #grouped, #node, #ntsoid, #statuses, #xnid

Instance Method Summary collapse

Methods inherited from ComponentBase

#aggregated_status_changed, #clear_aggregated_status, #clear_alarm_timestamps, #get_alarm_state, #log, #now, #set_aggregated_status

Methods included from Inspect

#inspect, #inspector

Constructor Details

#initialize(node:, id:, ntsoid: nil, xnid: nil, grouped: false) ⇒ Component

Returns a new instance of Component.



4
5
6
# File 'lib/rsmp/component/component.rb', line 4

def initialize(node:, id:, ntsoid: nil, xnid: nil, grouped: false)
  super
end

Instance Method Details

#acknowledge_alarm(alarm_code) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/rsmp/component/component.rb', line 16

def acknowledge_alarm(alarm_code)
  alarm = get_alarm_state alarm_code
  if alarm.acknowledge
    log "Acknowledging alarm #{alarm_code}", level: :info
    @node.alarm_acknowledged alarm
  else
    log "Alarm #{alarm_code} already acknowledged", level: :info
  end
end

#activate_alarm(alarm_code) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/rsmp/component/component.rb', line 46

def activate_alarm(alarm_code)
  alarm = get_alarm_state alarm_code
  return unless alarm.activate

  log "Activating alarm #{alarm_code}", level: :info
  @node.alarm_activated_or_deactivated alarm
end

#deactivate_alarm(alarm_code) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/rsmp/component/component.rb', line 54

def deactivate_alarm(alarm_code)
  alarm = get_alarm_state alarm_code
  return unless alarm.deactivate

  log "Deactivating alarm #{alarm_code}", level: :info
  @node.alarm_activated_or_deactivated alarm
end

#get_status(status_code, status_name = nil, _options = {}) ⇒ Object

Raises:



12
13
14
# File 'lib/rsmp/component/component.rb', line 12

def get_status(status_code, status_name = nil, _options = {})
  raise UnknownStatus, "Status #{status_code}/#{status_name} not implemented by #{self.class}"
end

#handle_command(command_code, _arg) ⇒ Object

Raises:



8
9
10
# File 'lib/rsmp/component/component.rb', line 8

def handle_command(command_code, _arg)
  raise UnknownCommand, "Command #{command_code} not implemented by #{self.class}"
end

#resume_alarm(alarm_code) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/rsmp/component/component.rb', line 36

def resume_alarm(alarm_code)
  alarm = get_alarm_state alarm_code
  if alarm.resume
    log "Resuming alarm #{alarm_code}", level: :info
    @node.alarm_suspended_or_resumed alarm
  else
    log "Alarm #{alarm_code} already resumed", level: :info
  end
end

#status_updates_sentObject



62
# File 'lib/rsmp/component/component.rb', line 62

def status_updates_sent; end

#suspend_alarm(alarm_code) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/rsmp/component/component.rb', line 26

def suspend_alarm(alarm_code)
  alarm = get_alarm_state alarm_code
  if alarm.suspend
    log "Suspending alarm #{alarm_code}", level: :info
    @node.alarm_suspended_or_resumed alarm
  else
    log "Alarm #{alarm_code} already suspended", level: :info
  end
end