Traffic Light Controller Signal Priority
Tests
- Signal priority becomes completed when cancelled
- Signal priority becomes stale if not cancelled
- Signal priority can be requested with M0022
- Signal priority status can be fetched with S0033
- Signal priority status can be subscribed to with S0033
Signal priority becomes completed when cancelled
Validate that a signal priority completes when we cancel it.
- Given the site is connected
- And we subscribe to signal priority status
- When we send a signal priority request
- Then the request state should become ‘received’
- Then the request state should become ‘activated’
- When we cancel the request
- Then the state should become ‘completed’
View Source
Validator::Site.connected do |task,supervisor,site|
timeout = Validator.get_config('timeouts','priority_completion')
component = Validator.get_config('main_component')
signal_group_id = Validator.get_config('components','signal_group').keys.first
prio = Validator::StatusHelpers::SignalPriorityRequestHelper.new(
site,
component: component,
signal_group_id: signal_group_id,
timeout: timeout,
task: task
)
prio.run do
log "Before: Send unrelated signal priority request."
prio.request_unrelated
log "Send signal priority request, wait for reception."
prio.request
log "After: Send unrelated signal priority request."
prio.request_unrelated
prio.expect :received
log "Signal priority request was received, wait for activation."
prio.expect :activated
log "Signal priority request was activated, now cancel it and wait for completion."
prio.cancel
prio.expect :completed
log "Signal priority request was completed."
end
end
Signal priority becomes stale if not cancelled
Validate that a signal priority times out if not cancelled.
- Given the site is connected
- And we subscribe to signal priority status
- When we send a signal priority request
- Then the request state should become ‘received’
- Then the request state should become ‘activated’
- When we do not cancel the request
- Then the state should become ‘stale’
View Source
Validator::Site.connected do |task,supervisor,site|
timeout = Validator.get_config('timeouts','priority_completion')
component = Validator.get_config('main_component')
signal_group_id = Validator.get_config('components','signal_group').keys.first
prio = Validator::StatusHelpers::SignalPriorityRequestHelper.new(
site,
component: component,
signal_group_id: signal_group_id,
timeout: timeout,
task: task
)
prio.run do
log "Before: Send unrelated signal priority request."
prio.request_unrelated
log "Send signal priority request, wait for reception."
prio.request
log "After: Send unrelated signal priority request."
prio.request_unrelated
prio.expect :received
log "Signal priority request was received, wait for activation."
prio.expect :activated
log "Signal priority request was activated, wait for it to become stale."
# don't cancel request, it should then become stale by itself
prio.expect :stale
log "Signal priority request became stale."
end
end
Signal priority can be requested with M0022
Validate that a signal priority can be requested.
- Given the site is connected
- When we send a signal priority request
- Then we should receive an acknowledgement
View Source
Validator::Site.connected do |task,supervisor,site|
signal_group = Validator.get_config('components','signal_group').keys.first
command_list = build_command_list :M0022, :requestPriority, {
requestId: SecureRandom.uuid()[0..3],
signalGroupId: signal_group,
type: 'new',
level: 7,
eta: 10,
vehicleType: 'car'
}
prepare task, site
send_command_and_confirm @task, command_list,
"Request signal priority for signal group #{signal_group}"
end
Signal priority status can be fetched with S0033
Validate that signal priority status can be requested.
- Given the site is connected
- When we request signal priority status
- Then we should receive a status update
View Source
Validator::Site.connected do |task,supervisor,site|
request_status_and_confirm site, "signal group status",
{ S0033: [:status] }
end
Signal priority status can be subscribed to with S0033
Validate that we can subscribe signal priority status
- Given the site is connected
- And we subscribe to signal priority status updates
- Then we should receive an acknowledgement
- And we should reive a status updates
View Source
Validator::Site.connected do |task,supervisor,site|
prepare task, site
status_list = [{'sCI'=>'S0033','n'=>'status','uRt'=>'0'}]
status_list.map! { |item| item.merge!('sOc' => true) } if use_sOc?(site)
wait_for_status task, 'signal priority status', status_list
end