Class: RSMP::TLC::DetectorLogic
- Inherits:
-
Component
- Object
- ComponentBase
- Component
- RSMP::TLC::DetectorLogic
- Defined in:
- lib/rsmp/tlc/detector_logic.rb
Overview
Detector logic component for the TLC.
Constant Summary
Constants inherited from ComponentBase
ComponentBase::AGGREGATED_STATUS_KEYS
Instance Attribute Summary collapse
-
#forced ⇒ Object
readonly
Returns the value of attribute forced.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from ComponentBase
#aggregated_status, #aggregated_status_bools, #alarms, #c_id, #grouped, #node, #ntsoid, #statuses, #xnid
Instance Method Summary collapse
- #force_detector_logic(forced, value) ⇒ Object
- #get_status(code, name = nil, _options = {}) ⇒ Object
- #handle_command(command_code, arg, _options = {}) ⇒ Object
- #handle_m0008(arg, _options = {}) ⇒ Object
- #handle_s0201(_status_code, status_name = nil, _options = {}) ⇒ Object
- #handle_s0202(_status_code, status_name = nil, _options = {}) ⇒ Object
- #handle_s0203(_status_code, status_name = nil, _options = {}) ⇒ Object
- #handle_s0204(_status_code, status_name = nil, _options = {}) ⇒ Object
-
#initialize(node:, id:) ⇒ DetectorLogic
constructor
A new instance of DetectorLogic.
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
Methods included from Inspect
Constructor Details
#initialize(node:, id:) ⇒ DetectorLogic
Returns a new instance of DetectorLogic.
7 8 9 10 11 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 7 def initialize(node:, id:) super(node: node, id: id, grouped: false) @forced = 0 @value = 0 end |
Instance Attribute Details
#forced ⇒ Object (readonly)
Returns the value of attribute forced.
5 6 7 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 5 def forced @forced end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 5 def value @value end |
Instance Method Details
#force_detector_logic(forced, value) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 75 def force_detector_logic(forced, value) @forced = forced @value = value if @forced log "Forcing to #{value}", level: :info else log 'Releasing', level: :info end end |
#get_status(code, name = nil, _options = {}) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 13 def get_status(code, name = nil, = {}) case code when 'S0201', 'S0202', 'S0203', 'S0204' send("handle_#{code.downcase}", code, name) else raise InvalidMessage, "unknown status code #{code}" end end |
#handle_command(command_code, arg, _options = {}) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 58 def handle_command(command_code, arg, = {}) case command_code when 'M0008' handle_m0008 arg else raise UnknownCommand, "Unknown command #{command_code}" end end |
#handle_m0008(arg, _options = {}) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 67 def handle_m0008(arg, = {}) @node.verify_security_code 2, arg['securityCode'] status = arg['status'] == 'True' mode = arg['mode'] == 'True' force_detector_logic status, mode arg end |
#handle_s0201(_status_code, status_name = nil, _options = {}) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 22 def handle_s0201(_status_code, status_name = nil, = {}) case status_name when 'starttime' TrafficControllerSite.make_status @node.clock.to_s when 'vehicles' TrafficControllerSite.make_status 0 end end |
#handle_s0202(_status_code, status_name = nil, _options = {}) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 31 def handle_s0202(_status_code, status_name = nil, = {}) case status_name when 'starttime' TrafficControllerSite.make_status @node.clock.to_s when 'speed' TrafficControllerSite.make_status 0 end end |
#handle_s0203(_status_code, status_name = nil, _options = {}) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 40 def handle_s0203(_status_code, status_name = nil, = {}) case status_name when 'starttime' TrafficControllerSite.make_status @node.clock.to_s when 'occupancy' TrafficControllerSite.make_status 0 end end |
#handle_s0204(_status_code, status_name = nil, _options = {}) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 49 def handle_s0204(_status_code, status_name = nil, = {}) case status_name when 'starttime' TrafficControllerSite.make_status @node.clock.to_s when 'P', 'PS', 'L', 'LS', 'B', 'SP', 'MC', 'C', 'F' TrafficControllerSite.make_status 0 end end |