Class: RSMP::TLC::SignalGroup
- Inherits:
-
Component
- Object
- ComponentBase
- Component
- RSMP::TLC::SignalGroup
- Defined in:
- lib/rsmp/tlc/signal_group.rb
Constant Summary
Constants inherited from ComponentBase
ComponentBase::AGGREGATED_STATUS_KEYS
Instance Attribute Summary collapse
-
#plan ⇒ Object
readonly
Returns the value of attribute plan.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Attributes inherited from ComponentBase
#aggregated_status, #aggregated_status_bools, #alarms, #c_id, #grouped, #node, #ntsOId, #statuses, #xNId
Instance Method Summary collapse
- #compute_state ⇒ Object
- #get_status(code, name = nil, options = {}) ⇒ Object
- #handle_command(command_code, arg, options = {}) ⇒ Object
-
#handle_m0010(arg, options = {}) ⇒ Object
Start of signal group.
-
#handle_m0011(arg, options = {}) ⇒ Object
Stop of signal group.
- #handle_s0025(status_code, status_name = nil, options = {}) ⇒ Object
-
#initialize(node:, id:) ⇒ SignalGroup
constructor
plan is a string, with each character representing a signal phase at a particular second in the cycle.
- #timer ⇒ Object
Methods inherited from Component
#acknowledge_alarm, #activate_alarm, #deactivate_alarm, #resume_alarm, #status_updates_sent, #suspend_alarm
Methods inherited from ComponentBase
#aggregated_status_changed, #clear_aggregated_status, #clear_alarm_timestamps, #get_alarm_state, #log, #now, #set_aggregated_status, #set_aggregated_status_bools
Methods included from Inspect
Constructor Details
#initialize(node:, id:) ⇒ SignalGroup
plan is a string, with each character representing a signal phase at a particular second in the cycle
7 8 9 |
# File 'lib/rsmp/tlc/signal_group.rb', line 7 def initialize node:, id: super node: node, id: id, grouped: false end |
Instance Attribute Details
#plan ⇒ Object (readonly)
Returns the value of attribute plan.
4 5 6 |
# File 'lib/rsmp/tlc/signal_group.rb', line 4 def plan @plan end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
4 5 6 |
# File 'lib/rsmp/tlc/signal_group.rb', line 4 def state @state end |
Instance Method Details
#compute_state ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rsmp/tlc/signal_group.rb', line 15 def compute_state return 'a' if node.main.dark? return 'c' if node.main.yellow_flash? cycle_counter = node.main.cycle_counter if node.main.startup_sequence_active return node.main.startup_state || 'a' end default = 'a' # phase a means disabled/dark plan = node.main.current_plan return default unless plan return default unless plan.states states = plan.states[c_id] return default unless states state = states[cycle_counter] return default unless state =~ /[a-hA-G0-9N-P]/ # valid signal group states state end |
#get_status(code, name = nil, options = {}) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/rsmp/tlc/signal_group.rb', line 63 def get_status code, name=nil, ={} case code when 'S0025' return send("handle_#{code.downcase}", code, name) else raise InvalidMessage.new "unknown status code #{code}" end end |
#handle_command(command_code, arg, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/rsmp/tlc/signal_group.rb', line 38 def handle_command command_code, arg, ={} case command_code when 'M0010', 'M0011' return send("handle_#{command_code.downcase}", arg, ) else raise UnknownCommand.new "Unknown command #{command_code}" end end |
#handle_m0010(arg, options = {}) ⇒ Object
Start of signal group. Orders a signal group to green
48 49 50 51 52 53 |
# File 'lib/rsmp/tlc/signal_group.rb', line 48 def handle_m0010 arg, ={} @node.verify_security_code 2, arg['securityCode'] if TrafficControllerSite.from_rsmp_bool arg['status'] log "Start signal group #{c_id}, go to green", level: :info end end |
#handle_m0011(arg, options = {}) ⇒ Object
Stop of signal group. Orders a signal group to red
56 57 58 59 60 61 |
# File 'lib/rsmp/tlc/signal_group.rb', line 56 def handle_m0011 arg, ={} @node.verify_security_code 2, arg['securityCode'] if TrafficControllerSite.from_rsmp_bool arg['status'] log "Stop signal group #{c_id}, go to red", level: :info end end |
#handle_s0025(status_code, status_name = nil, options = {}) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rsmp/tlc/signal_group.rb', line 72 def handle_s0025 status_code, status_name=nil, ={} now = @node.clock.to_s case status_name when 'minToGEstimate' TrafficControllerSite.make_status now when 'maxToGEstimate' TrafficControllerSite.make_status now when 'likelyToGEstimate' TrafficControllerSite.make_status now when 'ToGConfidence' TrafficControllerSite.make_status 0 when 'minToREstimate' TrafficControllerSite.make_status now when 'maxToREstimate' TrafficControllerSite.make_status now when 'likelyToREstimate' TrafficControllerSite.make_status now when 'ToRConfidence' TrafficControllerSite.make_status 0 end end |
#timer ⇒ Object
11 12 13 |
# File 'lib/rsmp/tlc/signal_group.rb', line 11 def timer @state = compute_state end |