Traffic Light Controller Subscription

Tests

Subscription can be turned on and off for S0001

Check that we can subscribe to status messages. The test subscribes to S0001 (signal group status), because it will usually change once per second, but otherwise the choice is arbitrary as we simply want to check that the subscription mechanism works.

  1. subscribe
  2. check that we receive a status update with a predefined time
  3. unsubscribe
View Source
Validator::Site.connected do |task,supervisor,site|
  log "Subscribe to status and wait for update"
  component = Validator.get_config('main_component')
  status_list = [{'sCI'=>'S0001','n'=>'signalgroupstatus','uRt'=>'1'}]
  status_list.map! { |item| item.merge!('sOc' => false) } if use_sOc?(site)
   site.subscribe_to_status component, status_list, collect!: {
    timeout: Validator.get_config('timeouts','status_update')
  }
ensure
  unsubscribe_list = status_list.map { |item| item.slice('sCI','n') }
  site.unsubscribe_to_status component, unsubscribe_list
end