Class: RSMP::TLC::DetectorLogic
- Defined in:
- lib/rsmp/tlc/detector_logic.rb
Constant Summary
Constants inherited from Component
Component::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 Component
#aggregated_status, #aggregated_status_bools, #alarms, #c_id, #grouped, #node, #statuses
Instance Method Summary collapse
- #force_detector_logic(forced, value) ⇒ Object
- #get_status(code, name = nil) ⇒ Object
- #handle_command(command_code, arg) ⇒ Object
- #handle_m0008(arg) ⇒ Object
- #handle_s0201(status_code, status_name = nil) ⇒ Object
- #handle_s0202(status_code, status_name = nil) ⇒ Object
- #handle_s0203(status_code, status_name = nil) ⇒ Object
- #handle_s0204(status_code, status_name = nil) ⇒ Object
-
#initialize(node:, id:) ⇒ DetectorLogic
constructor
A new instance of DetectorLogic.
Methods inherited from Component
#aggregated_status_changed, #clear_aggregated_status, #handle_alarm, #handle_status_response, #handle_status_subscribe, #handle_status_unsubscribe, #handle_status_update, #log, #set_aggregated_status, #set_aggregated_status_bools, #store_status
Methods included from Inspect
Constructor Details
#initialize(node:, id:) ⇒ DetectorLogic
Returns a new instance of DetectorLogic.
6 7 8 9 10 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 6 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.
4 5 6 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 4 def forced @forced end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 4 def value @value end |
Instance Method Details
#force_detector_logic(forced, value) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 90 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) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 12 def get_status code, name=nil case code when 'S0201', 'S0202', 'S0203', 'S0204' return send("handle_#{code.downcase}", code, name) else raise InvalidMessage.new "unknown status code #{code}" end end |
#handle_command(command_code, arg) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 73 def handle_command command_code, arg case command_code when 'M0008' handle_m0008 arg else raise UnknownCommand.new "Unknown command #{command_code}" end end |
#handle_m0008(arg) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 82 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) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 21 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) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 30 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) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 39 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) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rsmp/tlc/detector_logic.rb', line 48 def handle_s0204 status_code, status_name=nil case status_name when 'starttime' TrafficControllerSite.make_status @node.clock.to_s when 'P' TrafficControllerSite.make_status 0 when 'PS' TrafficControllerSite.make_status 0 when 'L' TrafficControllerSite.make_status 0 when 'LS' TrafficControllerSite.make_status 0 when 'B' TrafficControllerSite.make_status 0 when 'SP' TrafficControllerSite.make_status 0 when 'MC' TrafficControllerSite.make_status 0 when 'C' TrafficControllerSite.make_status 0 when 'F' TrafficControllerSite.make_status 0 end end |