Class: RSMP::TLC::TrafficControllerProxy

Inherits:
SiteProxy show all
Includes:
Proxy::Control, Proxy::Detectors, Proxy::IO, Proxy::Plans, Proxy::Status, Proxy::System
Defined in:
lib/rsmp/tlc/traffic_controller_proxy.rb

Overview

Proxy for handling communication with a remote traffic light controller.

Constant Summary

Constants inherited from Proxy

Proxy::WRAPPING_DELIMITER

Instance Attribute Summary collapse

Attributes inherited from SiteProxy

#site_id, #supervisor

Attributes included from Components

#components, #main

Attributes inherited from Proxy

#archive, #collector, #connection_info, #core_version, #ip, #node, #port, #state, #sxl

Attributes included from RSMP::Task

#task

Attributes included from Distributor

#receivers

Attributes included from Logging

#archive, #logger

Instance Method Summary collapse

Methods included from Proxy::System

#set_clock, #set_security_code

Methods included from Proxy::Detectors

#force_detector_logic, #set_trigger_level

Methods included from Proxy::Status

#fetch_signal_plan, #read_current_plan, #read_cycle_times, #read_dynamic_band, #wait_for_groups, #wait_for_normal_control, #wait_for_status

Methods included from Proxy::Plans

#order_signal_start, #order_signal_stop, #set_cycle_time, #set_day_table, #set_dynamic_bands, #set_dynamic_bands_timeout, #set_offset, #set_timeplan, #set_week_table

Methods included from Proxy::IO

#force_input, #force_output, #set_input, #set_inputs

Methods included from Proxy::Control

#set_emergency_route, #set_fixed_time, #set_functional_position, #set_traffic_situation, #unset_traffic_situation

Methods inherited from SiteProxy

#acknowledged_first_ingoing, #acknowledged_first_outgoing, #build_component, #check_site_ids, #check_sxl_version, #find_site_settings, #handled_by_parent?, #handshake_complete, #infer_component_type, #inspect, #node, #process_message, #process_version, #receive_error, #revive, #run, #setup_site_settings, #site_ids_changed, #sxl_version, #validate_ready, #version_accepted, #version_acknowledged, #watchdog_interval=

Methods included from SiteProxy::Modules::Commands

#process_command_response, #send_command, #send_command_and_collect

Methods included from SiteProxy::Modules::Alarms

#process_alarm, #resume_alarm, #send_alarm_acknowledgement, #suspend_alarm

Methods included from SiteProxy::Modules::AggregatedStatus

#aggregated_status_changed, #process_aggregated_status, #request_aggregated_status, #request_aggregated_status_and_collect, #validate_aggregated_status

Methods included from SiteProxy::Modules::Status

#ensure_subscription_path, #process_status_response, #remove_subscription_item, #request_status, #request_status_and_collect, #subscribe_to_status, #subscribe_to_status_and_collect, #unsubscribe_from_all, #unsubscribe_to_status, #update_subscription

Methods included from Components

#add_component, #aggregated_status_changed, #check_main_component, #clear_alarm_timestamps, #find_component, #infer_component_type, #initialize_components, #setup_components

Methods inherited from Proxy

#author, #clear, #clock, #close, #close_socket, #close_stream, #connected?, #disconnect, #disconnected?, #inspect, #log, #now, #ready?, #receive_error, #revive, #schemas, #setup, #state_changed, #stop_reader, #stop_subtasks, #stop_task, #stop_timer, version_meets_requirement?, #wait_for_reader

Methods included from Proxy::Modules::Tasks

#read_line, #run_reader, #run_timer, #start_reader, #start_timer, #timer

Methods included from Proxy::Modules::Versions

#check_core_version, #core_versions, #extraneous_version, #process_version, #send_version, #version_acknowledged, version_meets_requirement?

Methods included from Proxy::Modules::Receive

#expect_version_message, #handle_fatal_error, #handle_invalid_message, #handle_invalid_packet, #handle_malformed_message, #handle_schema_error, #process_deferred, #process_message, #process_packet, #should_validate_ingoing_message?, #verify_sequence, #will_not_handle

Methods included from Proxy::Modules::Send

#apply_nts_message_attributes, #buffer_message, #handle_send_schema_error, #log_send, #send_message, #send_message_and_collect

Methods included from Proxy::Modules::Acknowledgements

#acknowledge, #acknowledged_first_ingoing, #acknowledged_first_outgoing, #check_ack_timeout, #check_ingoing_acknowledged, #check_outgoing_acknowledged, #dont_acknowledge, #dont_expect_acknowledgement, #expect_acknowledgement, #find_original_for_message, #log_acknowledgement_for_original, #log_acknowledgement_for_unknown, #process_ack, #process_not_ack, #status_subscribe_acknowledged

Methods included from Proxy::Modules::Watchdogs

#check_watchdog_timeout, #process_watchdog, #send_watchdog, #start_watchdog, #stop_watchdog, #watchdog_send_timer, #with_watchdog_disabled

Methods included from Proxy::Modules::State

#handshake_complete, #wait_for_state

Methods included from RSMP::Task

#initialize_task, #restart, #run, #start, #stop, #stop_subtasks, #stop_task, #task_status, #wait, #wait_for_condition

Methods included from Inspect

#inspect, #inspector

Methods included from Distributor

#add_receiver, #clear_deferred_distribution, #distribute, #distribute_error, #distribute_immediately, #distribute_queued, #initialize_distributor, #inspect, #remove_receiver, #with_deferred_distribution

Methods included from Logging

#author, #initialize_logging, #log

Constructor Details

#initialize(options) ⇒ TrafficControllerProxy

Returns a new instance of TrafficControllerProxy.



28
29
30
31
32
33
34
35
36
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 28

def initialize(options)
  super
  @timeplan_source = nil
  @timeplan = nil
  @functional_position = nil
  @yellow_flash = nil
  @traffic_situation = nil
  @timeouts = node.supervisor_settings.dig('default', 'timeouts') || {}
end

Instance Attribute Details

#functional_positionObject (readonly)

Returns the value of attribute functional_position.



16
17
18
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 16

def functional_position
  @functional_position
end

#timeoutsObject (readonly)

Returns the value of attribute timeouts.



16
17
18
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 16

def timeouts
  @timeouts
end

#timeplanObject (readonly)

Returns the value of attribute timeplan.



16
17
18
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 16

def timeplan
  @timeplan
end

#timeplan_sourceObject (readonly)

Returns the value of attribute timeplan_source.



16
17
18
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 16

def timeplan_source
  @timeplan_source
end

#traffic_situationObject (readonly)

Returns the value of attribute traffic_situation.



16
17
18
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 16

def traffic_situation
  @traffic_situation
end

#yellow_flashObject (readonly)

Returns the value of attribute yellow_flash.



16
17
18
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 16

def yellow_flash
  @yellow_flash
end

Instance Method Details

#current_planObject

Backwards-compatible accessors expected by tests and callers



20
21
22
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 20

def current_plan
  @timeplan
end

#plan_sourceObject



24
25
26
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 24

def plan_source
  @timeplan_source
end

#process_status_update(message) ⇒ Object

Override status update processing to automatically store cached status values.



53
54
55
56
57
58
59
60
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 53

def process_status_update(message)
  super

  status_values = message.attribute('sS')
  return unless status_values

  status_values.each { |item| cache_status_item(item) }
end

#subscribe_to_timeplanObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 38

def subscribe_to_timeplan
  validate_ready 'subscribe to timeplan'

  status_list = [
    { 'sCI' => 'S0014', 'n' => 'status', 'uRt' => '0' },
    { 'sCI' => 'S0014', 'n' => 'source', 'uRt' => '0' }
  ]
  status_list.each { |item| item['sOc'] = true } if use_soc?

  raise 'TLC main component not found' unless main

  subscribe_to_status status_list, component: main.c_id
end

#timeplan_attributesObject

Get all timeplan attributes stored in the main ComponentProxy.



63
64
65
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 63

def timeplan_attributes
  main&.statuses&.dig('S0014') || {}
end

#use_soc?Boolean

Returns true if sOc (send on change) should be used. sOc is supported in RSMP core version 3.1.5 and later.

Returns:

  • (Boolean)


69
70
71
72
73
# File 'lib/rsmp/tlc/traffic_controller_proxy.rb', line 69

def use_soc?
  return false unless core_version

  RSMP::Proxy.version_meets_requirement?(core_version, '>=3.1.5')
end