Class: RSMP::Component

Inherits:
ComponentBase show all
Defined in:
lib/rsmp/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, #get_alarm_state, #log, #set_aggregated_status, #set_aggregated_status_bools

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.rb', line 4

def initialize node:, id:, ntsOId: nil, xNId: nil, grouped: false
  super
end

Instance Method Details

#activate_alarm(alarm_code) ⇒ Object



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

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



43
44
45
46
47
48
# File 'lib/rsmp/component.rb', line 43

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) ⇒ Object



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

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

#handle_command(command_code, arg) ⇒ Object



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

def handle_command command_code, arg
  raise UnknownCommand.new "Command #{command_code} not implemented by #{self.class}"
end

#resume_alarm(alarm_code) ⇒ Object



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

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

#suspend_alarm(alarm_code) ⇒ Object



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

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