Module: RSMP::TLC::Proxy::Control

Included in:
SupervisorInterface
Defined in:
lib/rsmp/tlc/proxy/control.rb

Overview

Command methods for operational control of a remote TLC. Covers functional position, emergency routes, I/O modes, signal group orders, and system settings.

Instance Method Summary collapse

Instance Method Details

#set_emergency_route(route:, active:, within:) ⇒ Object

M0005 - Set or clear an emergency route.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rsmp/tlc/proxy/control.rb', line 28

def set_emergency_route(route:, active:, within:)
  readiness = validate_ready 'set emergency route'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  security_code = security_code_for(2)

  command_list = [{
    'cCI' => 'M0005',
    'cO' => 'setEmergency',
    'n' => 'status',
    'v' => command_value('M0005', 'status', active)
  }, {
    'cCI' => 'M0005',
    'cO' => 'setEmergency',
    'n' => 'securityCode',
    'v' => security_code.to_s
  }, {
    'cCI' => 'M0005',
    'cO' => 'setEmergency',
    'n' => 'emergencyroute',
    'v' => command_value('M0005', 'emergencyroute', route)
  }]

  send_command_and_collect(command_list, within: within)
end

#set_emergency_route!Object



56
57
58
# File 'lib/rsmp/tlc/proxy/control.rb', line 56

def set_emergency_route!(...)
  set_emergency_route(...).value!
end

#set_fixed_time(status, within:) ⇒ Object

M0007 - Enable or disable fixed-time control.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/rsmp/tlc/proxy/control.rb', line 61

def set_fixed_time(status, within:)
  readiness = validate_ready 'set fixed time'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  security_code = security_code_for(2)

  command_list = [{
    'cCI' => 'M0007',
    'cO' => 'setFixedTime',
    'n' => 'status',
    'v' => command_value('M0007', 'status', status)
  }, {
    'cCI' => 'M0007',
    'cO' => 'setFixedTime',
    'n' => 'securityCode',
    'v' => security_code.to_s
  }]

  confirm_status = [{ 'sCI' => 'S0009', 'n' => 'status', 's' => [boolean_value(status)] }]
  send_command_and_collect(command_list, within: within).and_then do |exchange|
    wait_for_status("fixed time #{status}", confirm_status, timeout: within).map { exchange }
  end
end

#set_fixed_time!Object



87
88
89
# File 'lib/rsmp/tlc/proxy/control.rb', line 87

def set_fixed_time!(...)
  set_fixed_time(...).value!
end

#set_functional_position(status, within:, timeout_minutes: 0) ⇒ Object

M0001 - Set functional position (NormalControl, YellowFlash, Dark).



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rsmp/tlc/proxy/control.rb', line 8

def set_functional_position(status, within:, timeout_minutes: 0)
  readiness = validate_ready 'set functional position'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  command_list = functional_position_command_list(status, timeout_minutes)
  confirm_status = functional_position_confirm_status(status)
  send_command_and_collect(command_list, within: within).and_then do |exchange|
    next Result.success(exchange) if confirm_status.empty?

    wait_for_status("functional position #{status}", confirm_status, timeout: within).map { exchange }
  end
end

#set_functional_position!Object



23
24
25
# File 'lib/rsmp/tlc/proxy/control.rb', line 23

def set_functional_position!(...)
  set_functional_position(...).value!
end

#set_traffic_situation(situation, within:) ⇒ Object

M0003 - Set traffic situation (activate a specific situation number).



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/rsmp/tlc/proxy/control.rb', line 92

def set_traffic_situation(situation, within:)
  readiness = validate_ready 'set traffic situation'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  security_code = security_code_for(2)

  command_list = [{
    'cCI' => 'M0003',
    'cO' => 'setTrafficSituation',
    'n' => 'status',
    'v' => command_value('M0003', 'status', true)
  }, {
    'cCI' => 'M0003',
    'cO' => 'setTrafficSituation',
    'n' => 'securityCode',
    'v' => security_code.to_s
  }, {
    'cCI' => 'M0003',
    'cO' => 'setTrafficSituation',
    'n' => 'traficsituation',
    'v' => command_value('M0003', 'traficsituation', situation)
  }]

  confirm_status = [{ 'sCI' => 'S0015', 'n' => 'status', 's' => integer_value(situation) }]
  send_command_and_collect(command_list, within: within).and_then do |exchange|
    wait_for_status("traffic situation #{situation}", confirm_status, timeout: within).map { exchange }
  end
end

#set_traffic_situation!Object



123
124
125
# File 'lib/rsmp/tlc/proxy/control.rb', line 123

def set_traffic_situation!(...)
  set_traffic_situation(...).value!
end

#unset_traffic_situation(within:) ⇒ Object

M0003 - Clear the active traffic situation.



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/rsmp/tlc/proxy/control.rb', line 128

def unset_traffic_situation(within:)
  readiness = validate_ready 'unset traffic situation'
  return readiness if readiness.failure?

  raise 'TLC main component not found' unless main

  security_code = security_code_for(2)

  command_list = [{
    'cCI' => 'M0003',
    'cO' => 'setTrafficSituation',
    'n' => 'status',
    'v' => command_value('M0003', 'status', false)
  }, {
    'cCI' => 'M0003',
    'cO' => 'setTrafficSituation',
    'n' => 'securityCode',
    'v' => security_code.to_s
  }, {
    'cCI' => 'M0003',
    'cO' => 'setTrafficSituation',
    'n' => 'traficsituation',
    'v' => command_value('M0003', 'traficsituation', 1)
  }]

  confirm_status = [{ 'sCI' => 'S0015', 'n' => 'status', 's' => 1 }]
  send_command_and_collect(command_list, within: within).and_then do |exchange|
    wait_for_status('traffic situation unset', confirm_status, timeout: within).map { exchange }
  end
end

#unset_traffic_situation!Object



159
160
161
# File 'lib/rsmp/tlc/proxy/control.rb', line 159

def unset_traffic_situation!(...)
  unset_traffic_situation(...).value!
end