Class: RSMP::Component
- Inherits:
-
ComponentBase
- Object
- ComponentBase
- RSMP::Component
- Defined in:
- lib/rsmp/component.rb
Overview
RSMP component
Direct Known Subclasses
TLC::DetectorLogic, TLC::SignalGroup, TLC::TrafficController
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, #statuses
Instance Method Summary collapse
- #get_alarm_state(alarm_code) ⇒ Object
- #get_status(status_code, status_name = nil) ⇒ Object
- #handle_command(command_code, arg) ⇒ Object
-
#initialize(node:, id:, grouped: false) ⇒ Component
constructor
A new instance of Component.
- #resume_alarm(alarm_code) ⇒ Object
-
#send_alarm(code:, status:) ⇒ Object
send alarm.
- #suspend_alarm(alarm_code) ⇒ Object
Methods inherited from ComponentBase
#aggregated_status_changed, #clear_aggregated_status, #log, #set_aggregated_status, #set_aggregated_status_bools
Methods included from Inspect
Constructor Details
#initialize(node:, id:, grouped: false) ⇒ Component
Returns a new instance of Component.
6 7 8 |
# File 'lib/rsmp/component.rb', line 6 def initialize node:, id:, grouped: false super end |
Instance Method Details
#get_alarm_state(alarm_code) ⇒ Object
18 19 20 |
# File 'lib/rsmp/component.rb', line 18 def get_alarm_state alarm_code alarm = @alarms[alarm_code] ||= RSMP::AlarmState.new component_id: c_id, code: alarm_code end |
#get_status(status_code, status_name = nil) ⇒ Object
14 15 16 |
# File 'lib/rsmp/component.rb', line 14 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
10 11 12 |
# File 'lib/rsmp/component.rb', line 10 def handle_command command_code, arg raise UnknownCommand.new "Command #{command_code} not implemented by #{self.class}" end |
#resume_alarm(alarm_code) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rsmp/component.rb', line 33 def resume_alarm alarm_code alarm_state = get_alarm_state alarm_code if alarm.suspended log "Resuming alarm #{alarm_code}", level: :info alarm.resume @node.alarm_suspended_or_resumed alarm else log "Alarm #{alarm_code} not suspended", level: :info end end |
#send_alarm(code:, status:) ⇒ Object
send alarm
45 46 47 |
# File 'lib/rsmp/component.rb', line 45 def send_alarm code:, status: @node.alarm_changed self, alarm end |
#suspend_alarm(alarm_code) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rsmp/component.rb', line 22 def suspend_alarm alarm_code alarm_state = get_alarm_state alarm_code if alarm.suspended == false log "Suspending alarm #{alarm_code}", level: :info alarm.suspend @node.alarm_suspended_or_resumed alarm else log "Alarm #{alarm_code} already suspended", level: :info end end |