Specifications:

    • »

      • » »

        • Traffic Light Controller IO Input is read with S0003

          Verify that we can read input status with S0003

          1. Given the site is connected

          2. When we read input with S0029

          3. Then we should receive a valid response

          
          
          14
          15
          16
          17
          # File 'spec/site/tlc/io_spec.rb', line 14
          
          Validator::Site.connected do |task,supervisor,site|
                    request_status_and_confirm site, "input status",
                      { S0003: [:inputstatus] }
                  end
        • Traffic Light Controller IO Input is read with S0003

          Verify that we can read input status with S0003

          1. Given the site is connected

          2. When we read input with S0029

          3. Then we should receive a valid response

          
          
          14
          15
          16
          17
          # File 'spec/site/tlc/io_spec.rb', line 14
          
          Validator::Site.connected do |task,supervisor,site|
                    request_status_and_confirm site, "input status",
                      { S0003: [:inputstatus] }
                  end
        • Traffic Light Controller IO Input forcing is read with S0029

          Verify that we can read forced input status with S0029

          1. Given the site is connected

          2. When we read input with S0029

          3. Then we should receive a valid response

          
          
          37
          38
          39
          40
          # File 'spec/site/tlc/io_spec.rb', line 37
          
          Validator::Site.connected do |task,supervisor,site|
                    request_status_and_confirm site, "forced input status",
                      { S0029: [:status] }
                  end
        • Traffic Light Controller IO Input forcing is set with M0019

          Verify that we can force input with M0019

          1. Given the site is connected

          2. And the input is forced off

          3. When we force the input on

          4. Then S0003 should show the input on

          
          
          50
          51
          52
          53
          54
          55
          56
          57
          58
          59
          60
          # File 'spec/site/tlc/io_spec.rb', line 50
          
          Validator::Site.connected do |task,supervisor,site|
                    prepare task, site
                    inputs = Validator.get_config('items','inputs')
                    skip("No inputs configured") if inputs.nil? || inputs.empty?
                    inputs.each do |input|
                      force_input input: input, status: 'True', value: 'False'
                      force_input input: input, status: 'True', value: 'True'
                    ensure
                      force_input input: input, status: 'False', validate: false
                    end
                  end
        • Traffic Light Controller IO Input is activated with M0006

          Verify that we can activate input with M0006

          1. Given the site is connected

          2. When we activate input with M0006

          3. Then S0003 should show the input is active

          4. When we deactivate input with M0006

          5. Then S0003 should show the input is inactive

          
          
          71
          72
          73
          74
          75
          76
          77
          # File 'spec/site/tlc/io_spec.rb', line 71
          
          Validator::Site.connected do |task,supervisor,site|
                    prepare task, site
                    inputs = Validator.get_config('items','inputs')
                    skip("No inputs configured") if inputs.nil? || inputs.empty?
                    prepare task, site
                    inputs.each { |input| switch_input input }
                  end
        • Traffic Light Controller IO Input series is activated with M0013

          Verify that we can acticate/deactivate a series of inputs with M0013

          1. Given the site is connected

          2. Send control command to set a serie of input

          3. Wait for status = true

          
          
          85
          86
          87
          88
          89
          90
          91
          # File 'spec/site/tlc/io_spec.rb', line 85
          
          Validator::Site.connected do |task,supervisor,site|
                    prepare task, site
                    inputs = Validator.get_config('items','inputs')
                    skip("No inputs configured") if inputs.nil? || inputs.empty?
                    status = "1,3,12;5,5,10"
                    set_series_of_inputs status
                  end
        • Traffic Light Controller IO Input sensitivity is set with M0021

          Verify that input sensitivity can be set with M0021

          1. Given the site is connected

          2. When we set sensitivity with M0021

          3. Then we receive a confirmation

          
          
          99
          100
          101
          102
          103
          # File 'spec/site/tlc/io_spec.rb', line 99
          
          Validator::Site.connected do |task,supervisor,site|
                    prepare task, site
                    status = '1-50'
                    set_trigger_level status
                  end
      • » »

        • Traffic Light Controller IO Output is read with S0004

          Verify that output status can be read with S0004

          1. Given the site is connected

          2. When we subscribe to S0004

          3. We should receive a status updated

          4. And the outputstatus attribute should be a digit string

          
          
          114
          115
          116
          117
          118
          # File 'spec/site/tlc/io_spec.rb', line 114
          
          Validator::Site.connected do |task,supervisor,site|
                    prepare task, site
                    request_status_and_confirm site, "output status",
                      { S0004: [:outputstatus] }
                  end
        • Traffic Light Controller IO Output is read with S0004

          Verify that output status can be read with S0004

          1. Given the site is connected

          2. When we subscribe to S0004

          3. We should receive a status updated

          4. And the outputstatus attribute should be a digit string

          
          
          114
          115
          116
          117
          118
          # File 'spec/site/tlc/io_spec.rb', line 114
          
          Validator::Site.connected do |task,supervisor,site|
                    prepare task, site
                    request_status_and_confirm site, "output status",
                      { S0004: [:outputstatus] }
                  end
        • Traffic Light Controller IO Output forcing is read with S0030

          Verify that forced output status can be read with S0030

          1. Given the site is connected

          2. Request status

          3. Expect status response before timeout

          
          
          139
          140
          141
          142
          143
          # File 'spec/site/tlc/io_spec.rb', line 139
          
          Validator::Site.connected do |task,supervisor,site|
                    prepare task, site
                    request_status_and_confirm site, "forced output status",
                      { S0030: [:status] }
                  end
        • Traffic Light Controller IO Output forcing is set with M0020

          Verify that output can be forced with M0020

          1. Given the site is connected

          2. When we force output with M0020

          3. Wait for status = true

          
          
          151
          152
          153
          154
          155
          156
          157
          158
          159
          160
          161
          # File 'spec/site/tlc/io_spec.rb', line 151
          
          Validator::Site.connected do |task,supervisor,site|
                    prepare task, site
                    outputs = Validator.get_config('items','outputs')
                    skip("No outputs configured") if outputs.nil? || outputs.empty?
                    outputs.each do |output|
                      force_output output: output, status:'True', value:'True'
                      force_output output: output, status:'True', value:'False'
                    ensure
                      force_output output: output, status:'False', validate: false
                    end
                 end
    • »

      • Traffic Light Controller Alarm Alarm A0302 is raised when input is activated

        Validate that a detector logic fault A0302 is raises and cleared.

        The test requires that the device is programmed so that the alarm is raise when a specific input is activated, as specified in the test configuration.

        1. Given the site is connected

        2. When we force the input to True

        3. Then an alarm should be raised, with a timestamp close to now

        4. When we force the input to False

        5. Then the alarm issue should become inactive, with a timestamp close to now

        
        
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        # File 'spec/site/tlc/alarm_spec.rb', line 29
        
        Validator::Site.connected do |task,supervisor,site|
                alarm_code_id = 'A0302'
                prepare task, site
                def verify_timestamp alarm, duration=1.minute
                  alarm_time = Time.parse(alarm.attributes["aTs"])
                  expect(alarm_time).to be_within(duration).of Time.now.utc
                end
                deactivated, component_id = with_alarm_activated(task, site, alarm_code_id) do |alarm,component_id|   # raise alarm, by activating input
                  verify_timestamp alarm
                  log "Alarm #{alarm_code_id} is now Active on component #{component_id}"
                end
                verify_timestamp deactivated
                log "Alarm #{alarm_code_id} is now Inactive on component #{component_id}"
              end
      • Traffic Light Controller Alarm A0302 can be raised

        Validate that a detector logic fault A0302 is raises and cleared.

        The test requires that the device is programmed so that the alarm is raise when a specific input is activated, as specified in the test configuration.

        1. Given the site is connected

        2. When we force the input to True

        3. Then an alarm should be raised, with a timestamp close to now

        4. When we force the input to False

        5. Then the alarm issue should become inactive, with a timestamp close to now

        
        
        58
        59
        60
        61
        62
        63
        64
        65
        66
        67
        68
        69
        70
        71
        # File 'spec/site/tlc/alarm_spec.rb', line 58
        
        Validator::Site.connected do |task,supervisor,site|
                alarm_code_id = 'A0302'
                prepare task, site
                def verify_timestamp alarm, duration=1.minute
                  alarm_time = Time.parse(alarm.attributes["aTs"])
                  expect(alarm_time).to be_within(duration).of Time.now.utc
                end
                deactivate, component_id = with_alarm_activated(task, site, alarm_code_id) do |alarm,component_id|   # raise alarm, by activating input
                  verify_timestamp alarm
                  log "Alarm #{alarm_code_id} is now Active on component #{component_id}"
                end
                verify_timestamp deactivate
                log "Alarm #{alarm_code_id} is now Inactive on component #{component_id}"
              end
      • Traffic Light Controller Alarm A0302 can be acknowledged

        Validate that an alarm can be acknowledged.

        The test expects that the TLC is programmed so that an detector logic fault alarm A0302 is raised and can be acknowledged when a specific input is activated. The alarm code and input nr is read from the test configuration.

        1. Given the site is connected

        2. When we trigger an alarm

        3. Then we should receive an unacknowledged alarm issue

        4. When we acknowledge the alarm

        5. Then we should recieve an acknowledged alarm issue

        
        
        87
        88
        89
        90
        91
        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
        122
        123
        124
        125
        # File 'spec/site/tlc/alarm_spec.rb', line 87
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                alarm_code_id = 'A0302'   # what alarm to expect
                timeout  = Validator.get_config('timeouts','alarm')
        
                log "Activating alarm #{alarm_code_id}"
                deactivate, component_id = with_alarm_activated(task, site, alarm_code_id) do |alarm, component_id|   # raise alarm, by activating input
                  log "Alarm #{alarm_code_id} is now active on component #{component_id}"
        
                  # verify timestamp
                  alarm_time = Time.parse(alarm.attributes["aTs"])
                  expect(alarm_time).to be_within(1.minute).of Time.now.utc
        
                  # test acknowledge and confirm
                  log "Acknowledge alarm #{alarm_code_id}"
        
                  collect_task = task.async do
                    RSMP::AlarmCollector.new(site,
                      num: 1,
                      query: {
                        'aCId' => alarm_code_id,
                        'aSp' => /Acknowledge/i,
                        'ack' => /Acknowledged/i,
                        'aS' => /Active/i
                      },
                      timeout: timeout
                    ).collect!
                  end
        
                  site.send_message RSMP::AlarmAcknowledge.new(
                    'cId' => component_id,
                    'aTs' => site.clock.to_s,
                    'aCId' => alarm_code_id
                  )
                  messages = collect_task.wait
                  expect(messages).to be_an(Array)
                  expect(messages.first).to be_a(RSMP::Alarm)
                end
              end
      • Traffic Light Controller Alarm A0302 can be suspended and resumed

        Validate that alarms can be suspended. We’re using A0302 in this test.

        1. Given the site is connected

        2. And the alarm is resumed

        3. When we suspend the alarm

        4. Then we should received an alarm suspended messsage

        5. When we resume the alarm

        6. Then we should receive an alarm resumed message

        
        
        138
        139
        140
        141
        142
        143
        144
        145
        146
        147
        148
        149
        150
        151
        152
        153
        154
        155
        156
        157
        158
        159
        160
        # File 'spec/site/tlc/alarm_spec.rb', line 138
        
        Validator::Site.connected do |task,supervisor,site|
                alarm_code_id = 'A0302'
                action = Validator.config.dig('alarms', alarm_code_id)
                skip "alarm #{alarm_code_id} is not configured" unless action
                component_id = action['component']
                skip "alarm #{alarm_code_id} has no component configured" unless component_id
        
                # first resume alarm to make sure something happens when we suspend
                resume_alarm site, task, cId: component_id, aCId: alarm_code_id, collect: false
        
                begin
                  # suspend alarm
                  request, response = suspend_alarm site, task, cId: component_id, aCId: alarm_code_id, collect: true
                  expect(response).to be_a(RSMP::AlarmSuspended)
        
                  # resume alarm
                  request, response = resume_alarm site, task, cId: component_id, aCId: alarm_code_id, collect: true
                  expect(response).to be_a(RSMP::AlarmResumed)
                ensure
                  # always end with resuming alarm
                  resume_alarm site, task, cId: component_id, aCId: alarm_code_id, collect: false
                end
              end
    • »

      • Traffic Light Controller Clock can be read with S0096

        Verify status 0096 current date and time

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        # File 'spec/site/tlc/clock_spec.rb', line 21
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "current date and time",
                  { S0096: [
                    :year,
                    :month,
                    :day,
                    :hour,
                    :minute,
                    :second,
                  ] }
              end
      • Traffic Light Controller Clock can be set with M0104

        Verify that the controller responds to M0104

        1. Given the site is connected

        2. Send command

        3. Expect status response before timeout

        
        
        40
        41
        42
        43
        # File 'spec/site/tlc/clock_spec.rb', line 40
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                set_clock(CLOCK)
              end
      • Traffic Light Controller Clock is used for S0096 status response

        Verify status S0096 clock after changing clock

        1. Given the site is connected

        2. Send control command to set_clock

        3. Request status S0096

        4. Compare set_clock and status timestamp

        5. Expect the difference to be within max_diff

        
        
        54
        55
        56
        57
        58
        59
        60
        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
        86
        87
        88
        89
        90
        91
        92
        # File 'spec/site/tlc/clock_spec.rb', line 54
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                site.with_watchdog_disabled do  # avoid time synchronization by disabling watchdogs
                  with_clock_set site, CLOCK do
                    status_list = { S0096: [
                      :year,
                      :month,
                      :day,
                      :hour,
                      :minute,
                      :second,
                    ] }
                    result = site.request_status Validator.get_config('main_component'), convert_status_list(status_list), collect!: {
                      timeout: Validator.get_config('timeouts','status_update')
                    }
                    collector = result[:collector]
                    status = status_list.keys.first.to_s
        
                    received = Time.new(
                      collector.query_result( {"sCI" => status, "n" => "year"} )['s'],
                      collector.query_result( {"sCI" => status, "n" => "month"} )['s'],
                      collector.query_result( {"sCI" => status, "n" => "day"} )['s'],
                      collector.query_result( {"sCI" => status, "n" => "hour"} )['s'],
                      collector.query_result( {"sCI" => status, "n" => "minute"} )['s'],
                      collector.query_result( {"sCI" => status, "n" => "second"} )['s'],
                      'UTC'
                    )
        
                    max_diff =
                      Validator.get_config('timeouts','command_response') +
                      Validator.get_config('timeouts','status_response')
        
                    diff = received - CLOCK
                    diff = diff.round
                    expect(diff.abs).to be <= max_diff,
                      "Clock reported by S0096 is off by #{diff}s, should be within #{max_diff}s"
                  end
                end
              end
      • Traffic Light Controller Clock is used for S0096 response timestamp

        Verify status response timestamp after changing clock

        1. Given the site is connected

        2. Send control command to set_clock

        3. Request status S0096

        4. Compare set_clock and response timestamp

        5. Expect the difference to be within max_diff

        
        
        103
        104
        105
        106
        107
        108
        109
        110
        111
        112
        113
        114
        115
        116
        117
        118
        119
        120
        121
        122
        123
        124
        125
        126
        127
        128
        129
        130
        # File 'spec/site/tlc/clock_spec.rb', line 103
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                site.with_watchdog_disabled do  # avoid time synchronization by disabling watchdogs
                  with_clock_set site, CLOCK do
                    status_list = { S0096: [
                      :year,
                      :month,
                      :day,
                      :hour,
                      :minute,
                      :second,
                    ] }
        
                    result = site.request_status Validator.get_config('main_component'),
                      convert_status_list(status_list),
                      collect!: {
                        timeout: Validator.get_config('timeouts','status_response')
                      }
                    collector = result[:collector]
        
                    max_diff = Validator.get_config('timeouts','command_response') + Validator.get_config('timeouts','status_response')
                    diff = Time.parse(collector.messages.first.attributes['sTs']) - CLOCK
                    diff = diff.round
                    expect(diff.abs).to be <= max_diff,
                      "Timestamp of S0096 is off by #{diff}s, should be within #{max_diff}s"
                  end
                end
              end
      • Traffic Light Controller Clock is used for aggregated status timestamp

        Verify aggregated status response timestamp after changing clock

        1. Given the site is connected

        2. Send control command to set clock

        3. Wait for status = true

        4. Request aggregated status

        5. Compare set_clock and response timestamp

        6. Expect the difference to be within max_diff

        
        
        142
        143
        144
        145
        146
        147
        148
        149
        150
        151
        152
        153
        154
        155
        156
        157
        # File 'spec/site/tlc/clock_spec.rb', line 142
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                site.with_watchdog_disabled do  # avoid time synchronization by disabling watchdogs
                  with_clock_set site, CLOCK do
                    result = site.request_aggregated_status Validator.get_config('main_component'), collect!: {
                      timeout: Validator.get_config('timeouts','status_response')
                    }
                    collector = result[:collector]
                    max_diff = Validator.get_config('timeouts','command_response') + Validator.get_config('timeouts','status_response')
                    diff = Time.parse(collector.messages.first.attributes['aSTS']) - CLOCK
                    diff = diff.round
                    expect(diff.abs).to be <= max_diff,
                      "Timestamp of aggregated status is off by #{diff}s, should be within #{max_diff}s"
                  end
                end
              end
      • Traffic Light Controller Clock is used for M0001 response timestamp

        Verify command response timestamp after changing clock

        1. Given the site is connected

        2. Send control command to set clock

        3. Send command to set functional position

        4. Compare set_clock and response timestamp

        5. Expect the difference to be within max_diff

        
        
        168
        169
        170
        171
        172
        173
        174
        175
        176
        177
        178
        179
        180
        181
        # File 'spec/site/tlc/clock_spec.rb', line 168
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                site.with_watchdog_disabled do  # avoid time synchronization by disabling watchdogs
                  with_clock_set site, CLOCK do
                    result = set_functional_position 'NormalControl'
                    collector = result[:collector]
                    max_diff = Validator.get_config('timeouts','command_response') * 2
                    diff = Time.parse(collector.messages.first.attributes['cTS']) - CLOCK
                    diff = diff.round
                    expect(diff.abs).to be <= max_diff,
                      "Timestamp of command response is off by #{diff}s, should be within #{max_diff}s"
                  end
                end
              end
      • Traffic Light Controller Clock is used for M0104 response timestamp

        Verify command response timestamp after changing clock

        1. Given the site is connected

        2. Send control command to set clock

        3. Send command to set functional position

        4. Compare set_clock and response timestamp

        5. Expect the difference to be within max_diff

        
        
        192
        193
        194
        195
        196
        197
        198
        199
        200
        201
        202
        203
        204
        205
        # File 'spec/site/tlc/clock_spec.rb', line 192
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                site.with_watchdog_disabled do  # avoid time synchronization by disabling watchdogs
                  with_clock_set site, CLOCK do
                    result = set_functional_position 'NormalControl'
                    collector = result[:collector]
                    max_diff = Validator.get_config('timeouts','command_response')
                    diff = Time.parse(collector.messages.first.attributes['cTS']) - CLOCK
                    diff = diff.round
                    expect(diff.abs).to be <= max_diff,
                      "Timestamp of command response is off by #{diff}s, should be within #{max_diff}s"
                  end
                end
              end
      • Traffic Light Controller Clock is used for alarm timestamp

        Verify timestamp of alarm after changing clock The test requires the device to be programmed so that a A0302 alarm can be raise by activating a specific input, as configuted in the test config.

        1. Given the site is connected

        2. When we send a command to change the clock

        3. And we raise an alarm, by acticate an input

        4. Then we should receive an alarm

        5. And the alarm timestamp should be close to the time set the clock to

        
        
        220
        221
        222
        223
        224
        225
        226
        227
        228
        229
        230
        231
        232
        233
        # File 'spec/site/tlc/clock_spec.rb', line 220
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                site.with_watchdog_disabled do  # avoid time synchronization by disabling watchdogs
                  with_clock_set site, CLOCK do                           # set clock
                    with_alarm_activated(task, site, 'A0302') do |alarm|   # raise alarm, by activating input
                      alarm_time = Time.parse( alarm.attributes["aTs"] )
                      max_diff = Validator.get_config('timeouts','command_response') + Validator.get_config('timeouts','status_response')
                      diff = alarm_time - CLOCK
                      expect(diff.round.abs).to be <= max_diff,
                        "Timestamp of alarm is off by #{diff}s, should be within #{max_diff}s"
                    end
                  end
                end
              end
      • Traffic Light Controller Clock is used for watchdog timestamp

        Verify timestamp of watchdog after changing clock

        1. Given the site is connected

        2. Send control command to setset_clock

        3. Wait for Watchdog

        4. Compare set_clock and alarm response timestamp

        5. Expect the difference to be within max_diff

        
        
        244
        245
        246
        247
        248
        249
        250
        251
        252
        253
        254
        255
        256
        257
        258
        # File 'spec/site/tlc/clock_spec.rb', line 244
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                site.with_watchdog_disabled do  # avoid time synchronization by disabling watchdogs
                  with_clock_set site, CLOCK do
                    log "Checking watchdog timestamp"
                    collector = RSMP::Collector.new site, task:task, type: "Watchdog", num: 1, timeout: Validator.get_config('timeouts','watchdog')
                    collector.collect!
                    max_diff = Validator.get_config('timeouts','command_response') + Validator.get_config('timeouts','status_response')
                    diff = Time.parse(collector.messages.first.attributes['wTs']) - CLOCK
                    diff = diff.round
                    expect(diff.abs).to be <= max_diff,
                      "Timestamp of watchdog is off by #{diff}s, should be within #{max_diff}s"
                  end
                end
              end
    • »

      • Traffic Light Controller Operational control mode is read with S0020

        Verify status S0020 control mode

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        11
        12
        13
        14
        # File 'spec/site/tlc/modes_spec.rb', line 11
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "control mode",
                  { S0020: [:controlmode,:intersection] }
              end
      • Traffic Light Controller Operational startup status is read with S0005

        Verify status S0005 traffic controller starting by intersection

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        23
        24
        25
        26
        # File 'spec/site/tlc/modes_spec.rb', line 23
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic controller starting (true/false)",
                  { S0005: [:statusByIntersection] }
              end
      • Traffic Light Controller Operational startup status is read with S0005

        Verify status S0005 traffic controller starting by intersection

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        23
        24
        25
        26
        # File 'spec/site/tlc/modes_spec.rb', line 23
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic controller starting (true/false)",
                  { S0005: [:statusByIntersection] }
              end
      • Traffic Light Controller Operational switched on is read with S0007

        Verify status S0007 controller switched on, source attribute

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        47
        48
        49
        50
        # File 'spec/site/tlc/modes_spec.rb', line 47
        
        Validator::Site.connected do |task,supervisor,site|
                status_list = { S0007: [:status,:intersection,:source] }
                request_status_and_confirm site, "controller switch on (dark mode=off)", status_list
              end
      • Traffic Light Controller Operational switched on is read with S0007

        Verify status S0007 controller switched on, source attribute

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        47
        48
        49
        50
        # File 'spec/site/tlc/modes_spec.rb', line 47
        
        Validator::Site.connected do |task,supervisor,site|
                status_list = { S0007: [:status,:intersection,:source] }
                request_status_and_confirm site, "controller switch on (dark mode=off)", status_list
              end
      • Traffic Light Controller Operational manual control is read with S0008

        Verify status S0008 manual control

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        71
        72
        73
        74
        75
        76
        77
        78
        # File 'spec/site/tlc/modes_spec.rb', line 71
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0008: [:status,:intersection,:source] }
                else
                  status_list = { S0008: [:status,:intersection] }
                end
                request_status_and_confirm site, "manual control status", status_list
              end
      • Traffic Light Controller Operational fixed time control is read with S0009

        Verify status S0009 fixed time control

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        87
        88
        89
        90
        91
        92
        93
        94
        # File 'spec/site/tlc/modes_spec.rb', line 87
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0009: [:status,:intersection,:source] }
                else
                  status_list = { S0009: [:status,:intersection] }
                end
                request_status_and_confirm site, "fixed time control status", status_list
              end
      • Traffic Light Controller Operational fixed time control can be activated with M0007

        Verify command M0007 fixed time control

        1. Verify connection

        2. Send command to switch to fixed time = true

        3. Wait for status = true

        4. Send command to switch to fixed time = false

        5. Wait for status = false

        
        
        105
        106
        107
        108
        109
        # File 'spec/site/tlc/modes_spec.rb', line 105
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                switch_fixed_time 'True'
                switch_fixed_time 'False'
              end
      • Traffic Light Controller Operational isolated control is read with S0010

        Verify status S0010 isolated control

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        118
        119
        120
        121
        122
        123
        124
        125
        # File 'spec/site/tlc/modes_spec.rb', line 118
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0010: [:status,:intersection,:source] }
                else
                  status_list = { S0010: [:status,:intersection] }
                end
                request_status_and_confirm site, "isolated control status", status_list
              end
      • Traffic Light Controller Operational coordinated control is read with S0032

        Verify status S0032 coordinated control

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        134
        135
        136
        137
        # File 'spec/site/tlc/modes_spec.rb', line 134
        
        Validator::Site.connected do |task,supervisor,site|
                status_list = { S0032: [:status,:intersection,:source] }
                request_status_and_confirm site, "coordinated control status", status_list
              end
      • Traffic Light Controller Operational yellow flash can be read with S0011

        Verify status S0011 yellow flash

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        146
        147
        148
        149
        150
        151
        152
        153
        # File 'spec/site/tlc/modes_spec.rb', line 146
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0011: [:status,:intersection,:source] }
                else
                  status_list = { S0011: [:status,:intersection] }
                end
                request_status_and_confirm site, "yellow flash status", status_list
              end
      • Traffic Light Controller Operational yellow flash can be activated with M0001

        Verify that we can activate yellow flash

        1. Given the site is connected

        2. Send the control command to switch to Yellow flash

        3. Wait for status Yellow flash

        4. Send command to switch to normal control

        5. Wait for status “Yellow flash” = false, “Controller starting”= false, “Controller on”= true“

        
        
        164
        165
        166
        167
        168
        # File 'spec/site/tlc/modes_spec.rb', line 164
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                switch_yellow_flash
                switch_normal_control
              end
      • Traffic Light Controller Operational yellow flash affects all signal groups

        Verify that we can yellow flash causes all groups to go to state ‘c’

        1. Given the site is connected

        2. Send the control command to switch to Yellow flash

        3. Wait for all groups to go to group ‘c’

        4. Send command to switch to normal control

        5. Wait for all groups to switch do something else that ‘c’

        
        
        179
        180
        181
        182
        183
        184
        185
        186
        187
        188
        # File 'spec/site/tlc/modes_spec.rb', line 179
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                timeout =  Validator.get_config('timeouts','yellow_flash')
        
                switch_yellow_flash
                wait_for_groups 'c', timeout: timeout      # c mean s yellow flash
        
                switch_normal_control
                wait_for_groups '[^c]', timeout: timeout   # not c, ie. not yellow flash
              end
      • Traffic Light Controller Operational all red can be read with S0012

        Verify status S0012 all red

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        197
        198
        199
        200
        201
        202
        203
        204
        # File 'spec/site/tlc/modes_spec.rb', line 197
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0012: [:status,:intersection,:source] }
                else
                  status_list = { S0012: [:status,:intersection] }
                end
                request_status_and_confirm site, "all-red status", status_list
              end
      • Traffic Light Controller Operational police key can be read with S0013

        Verify status S0013 police key

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        213
        214
        215
        216
        # File 'spec/site/tlc/modes_spec.rb', line 213
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "police key",
                  { S0013: [:status] }
              end
      • Traffic Light Controller Operational dark mode can be activated with M0001

        Verify that we can activate dark mode

        1. Given the site is connected

        2. Send the control command to switch todarkmode

        3. Wait for status“Controller on” = false

        4. Send command to switch to normal control

        5. Wait for status “Yellow flash” = false, “Controller starting”= false, “Controller on”= true“

        
        
        227
        228
        229
        230
        231
        # File 'spec/site/tlc/modes_spec.rb', line 227
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                switch_dark_mode
                switch_normal_control
              end
      • Traffic Light Controller Operational yellow flash be used with a timeout of one minute

        Verify that we can activate yellow flash and after 1 minute goes back to NormalControl

        1. Given the site is connected

        2. Send the control command to switch to Normal Control, and wait for this

        3. Send the control command to switch to Yellow flash

        4. Wait for status Yellow flash

        5. Wait for automatic revert to Normal Control

        
        
        242
        243
        244
        245
        246
        247
        248
        # File 'spec/site/tlc/modes_spec.rb', line 242
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                switch_normal_control
                minutes = 1
                switch_yellow_flash timeout_minutes: minutes
                wait_normal_control timeout: minutes*60 + Validator.get_config('timeouts','functional_position')
              end
    • »

      • Traffic Light Controller System operator logged in/out of OP-panel is read with S0091

        Verify status S0091 operator logged in/out OP-panel

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        11
        12
        13
        14
        15
        16
        17
        18
        # File 'spec/site/tlc/system_spec.rb', line 11
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0091: [:user] }
                else
                  status_list = { S0091: [:user, :status] }
                end
                request_status_and_confirm site, "operator logged in/out OP-panel", status_list
              end
      • Traffic Light Controller System operator logged in/out of web-interface is read with S0092

        Verify status S0092 operator logged in/out web-interface

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        27
        28
        29
        30
        31
        32
        33
        34
        # File 'spec/site/tlc/system_spec.rb', line 27
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0092: [:user] }
                else
                  status_list = { S0092: [:user, :status] }
                end
                request_status_and_confirm site, "operator logged in/out web-interface", status_list
              end
      • Traffic Light Controller System version is read with S0095

        Verify status S0095 version of traffic controller

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        43
        44
        45
        46
        # File 'spec/site/tlc/system_spec.rb', line 43
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "version of traffic controller",
                { S0095: [:status] }
              end
      • Traffic Light Controller System security code is set with M0103
        1. Verify connection

        2. Send control command to set securitycode_level

        3. Wait for status = true

        4. Send control command to setsecuritycode_level

        5. Wait for status = true

        
        
        55
        56
        57
        58
        59
        # File 'spec/site/tlc/system_spec.rb', line 55
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                set_security_code 1
                set_security_code 2
              end
      • Traffic Light Controller System security code is rejected when incorrect

        Verify that the site responds with NotAck if we send incorrect security cdoes. RThis hehaviour is defined in SXL >= 1.1. For earlier versions, The behaviour is undefined.

        1. Given the site is connected

        2. When we send a M0008 command with incorrect security codes

        3. Then we should received a NotAck

        
        
        69
        70
        71
        72
        # File 'spec/site/tlc/system_spec.rb', line 69
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                expect { wrong_security_code }.to raise_error(RSMP::MessageRejected)
              end
    • »

      • Traffic Light Controller 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

        
        
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        # File 'spec/site/tlc/subscribe_spec.rb', line 15
        
        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
    • »

      • Traffic Light Controller Signal Plan currently active is read with S0014

        Verify status S0014 current time plan

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        11
        12
        13
        14
        15
        16
        17
        18
        # File 'spec/site/tlc/signal_plans_spec.rb', line 11
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0014: [:status,:source] }
                else
                  status_list = { S0014: [:status] }
                end
                request_status_and_confirm site, "current time plan", status_list
              end
      • Traffic Light Controller Signal Plan currently active is set with M0002

        Verify that we change time plan (signal program) We try switching all programs configured

        1. Given the site is connected

        2. Verify that there is a Validator.get_config(‘validator’) with a time plan

        3. Send command to switch time plan

        4. Wait for status “Current timeplan” = requested time plan

        
        
        29
        30
        31
        32
        33
        34
        # File 'spec/site/tlc/signal_plans_spec.rb', line 29
        
        plans = Validator.get_config('items','plans')
              skip("No time plans configured") if plans.nil? || plans.empty?
              Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                plans.each { |plan| switch_plan plan }
              end
      • Traffic Light Controller Signal Plan list size is read with S0018

        Verify status S0018 number of time plans Deprecated from 1.2, use S0022 instead.

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        44
        45
        46
        47
        # File 'spec/site/tlc/signal_plans_spec.rb', line 44
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "number of time plans",
                  { S0018: [:number] }
              end
      • Traffic Light Controller Signal Plan list is read with S0022

        Verify status S0022 list of time plans

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        56
        57
        58
        59
        # File 'spec/site/tlc/signal_plans_spec.rb', line 56
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "list of time plans",
                  { S0022: [:status] }
              end
      • Traffic Light Controller Signal Plan week table is read with S0026

        Verify status S0026 week time table

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        68
        69
        70
        71
        # File 'spec/site/tlc/signal_plans_spec.rb', line 68
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "week time table",
                  { S0026: [:status] }
              end
      • Traffic Light Controller Signal Plan week table is set with M0016
        1. Verify connection

        2. Send control command to set week_table

        3. Wait for status = true

        
        
        78
        79
        80
        81
        82
        # File 'spec/site/tlc/signal_plans_spec.rb', line 78
        
        Validator::Site.connected do |task,supervisor,site|
                status = "0-1,6-2"
                prepare task, site
                set_week_table status
              end
      • Traffic Light Controller Signal Plan day table is read with S0027

        Verify status S0027 time tables

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        91
        92
        93
        94
        # File 'spec/site/tlc/signal_plans_spec.rb', line 91
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "command table",
                  { S0027: [:status] }
              end
      • Traffic Light Controller Signal Plan day table is set with M0017
        1. Verify connection

        2. Send control command to set time_table

        3. Wait for status = true

        
        
        101
        102
        103
        104
        105
        # File 'spec/site/tlc/signal_plans_spec.rb', line 101
        
        Validator::Site.connected do |task,supervisor,site|
                status = "12-1-12-59,1-0-23-12"
                prepare task, site
                set_day_table status
              end
      • Traffic Light Controller Signal Plan version is read with S0097

        Verify status S0097 version of traffic program

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        114
        115
        116
        117
        # File 'spec/site/tlc/signal_plans_spec.rb', line 114
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "version of traffic program",
                  { S0097: [:timestamp,:checksum] }
              end
      • Traffic Light Controller Signal Plan M0018 set cycle time
        1. Verify connection

        2. Send control command to set cycle time

        3. Wait for status = true

        
        
        124
        125
        126
        127
        128
        129
        # File 'spec/site/tlc/signal_plans_spec.rb', line 124
        
        Validator::Site.connected do |task,supervisor,site|
                status = 5
                plan = 0
                prepare task, site
                set_cycle_time status, plan
              end
      • Traffic Light Controller Signal Plan dynamic bands are read with S0023

        Verify status S0023 command table

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        138
        139
        140
        141
        # File 'spec/site/tlc/signal_plans_spec.rb', line 138
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "command table",
                  { S0023: [:status] }
              end
      • Traffic Light Controller Signal Plan dynamic bands are set with M0014
        1. Verify connection

        2. Send control command to set dynamic_bands

        3. Wait for status = true

        
        
        148
        149
        150
        151
        152
        153
        # File 'spec/site/tlc/signal_plans_spec.rb', line 148
        
        Validator::Site.connected do |task,supervisor,site|
                plan = "1"
                status = "1-12"
                prepare task, site
                set_dynamic_bands plan, status
              end
      • Traffic Light Controller Signal Plan dynamic bands values can be changed and read back
        1. Given the site is connected

        2. Read dynamic band

        3. Set dynamic band to 2x previous value

        4. Read band to confirm

        5. Set dynamic band to previous value

        6. Read dynamic band to confirm

        
        
        164
        165
        166
        167
        168
        169
        170
        171
        172
        173
        174
        175
        176
        177
        178
        179
        # File 'spec/site/tlc/signal_plans_spec.rb', line 164
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                plan = 1
                band = 3
        
                value = get_dynamic_bands(plan, band) || 0
                expect( value ).to be_a(Integer)
        
                new_value = value + 1
                
                set_dynamic_bands plan, "#{band}-#{new_value}"
                expect( get_dynamic_bands(plan, band) ).to eq(new_value)
        
                set_dynamic_bands plan, "#{band}-#{value}"
                expect( get_dynamic_bands(plan, band) ).to eq(value)
              end
      • Traffic Light Controller Signal Plan timeout for dynamic bands is set with M0023

        Verify command M0023 timeout of dynamic bands

        1. Verify connection

        2. When we send command to set timeout

        3. Then we should get a confirmation

        4. When we send command to disable timeout

        5. Then we should get a confirmation

        
        
        190
        191
        192
        193
        194
        195
        196
        # File 'spec/site/tlc/signal_plans_spec.rb', line 190
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                status = 10
                set_timeout_for_dynamic_bands status
                status = 0
                set_timeout_for_dynamic_bands status
              end
      • Traffic Light Controller Signal Plan offset is read with S0024

        Verify status S0024 offset time

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        205
        206
        207
        208
        # File 'spec/site/tlc/signal_plans_spec.rb', line 205
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "offset time",
                  { S0024: [:status] }
              end
      • Traffic Light Controller Signal Plan offset is set with M0015
        1. Verify connection

        2. Send control command to set dynamic_bands

        3. Wait for status = true

        
        
        215
        216
        217
        218
        219
        220
        # File 'spec/site/tlc/signal_plans_spec.rb', line 215
        
        Validator::Site.connected do |task,supervisor,site|
                plan = 1
                status = 99
                prepare task, site
                set_offset status, plan
              end
      • Traffic Light Controller Signal Plan cycle time is read with S0028

        Verify status S0028 cycle time

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        229
        230
        231
        232
        # File 'spec/site/tlc/signal_plans_spec.rb', line 229
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "cycle time",
                  { S0028: [:status] }
              end
      • Traffic Light Controller Signal Plan cycle time is set with M0018
        1. Verify connection

        2. Send control command to set cycle time

        3. Wait for status = true

        
        
        239
        240
        241
        242
        243
        244
        # File 'spec/site/tlc/signal_plans_spec.rb', line 239
        
        Validator::Site.connected do |task,supervisor,site|
                status = 5
                plan = 0
                prepare task, site
                set_cycle_time status, plan
              end
    • »

      • Traffic Light Controller Traffic Data number of vehicles for a single detector is read with S0201

        Verify status S0201 traffic counting: number of vehicles

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        10
        11
        12
        13
        14
        # File 'spec/site/tlc/traffic_data_spec.rb', line 10
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic counting: number of vehicles",
                  { S0201: [:starttime,:vehicles] },
                  Validator.get_config('components','detector_logic').keys.first
              end
      • Traffic Light Controller Traffic Data number of vehicles for all detectors is read with S0205

        Verify status S0205 traffic counting: number of vehicles

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        23
        24
        25
        26
        # File 'spec/site/tlc/traffic_data_spec.rb', line 23
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic counting: number of vehicles",
                  { S0205: [:start,:vehicles] }
              end
      • Traffic Light Controller Traffic Data vehicle speed for a single detector is read with S0202

        Verify status S0202 traffic counting: vehicle speed

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        35
        36
        37
        38
        39
        # File 'spec/site/tlc/traffic_data_spec.rb', line 35
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic counting: vehicle speed",
                  { S0202: [:starttime,:speed] },
                  Validator.get_config('components','detector_logic').keys.first
              end
      • Traffic Light Controller Traffic Data vehicle speed for all detectors is read with S0206

        Verify status S0206 traffic counting: vehicle speed

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        48
        49
        50
        51
        # File 'spec/site/tlc/traffic_data_spec.rb', line 48
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic counting: vehicle speed",
                  { S0206: [:start,:speed] }
              end
      • Traffic Light Controller Traffic Data occupancy for a single detector is read with S0203

        Verify status S0203 traffic counting: occupancy

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        60
        61
        62
        63
        64
        # File 'spec/site/tlc/traffic_data_spec.rb', line 60
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic counting: occupancy",
                  { S0203: [:starttime,:occupancy] },
                  Validator.get_config('components','detector_logic').keys.first
              end
      • Traffic Light Controller Traffic Data occupancy for all detectors is read with S0207

        Verify status S0207 traffic counting: occupancy

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        73
        74
        75
        76
        # File 'spec/site/tlc/traffic_data_spec.rb', line 73
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic counting: occupancy",
                  { S0207: [:start,:occupancy] }
              end
      • Traffic Light Controller Traffic Data classification for a single detector is read with S0204

        Verify status S0204 traffic counting: classification

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        85
        86
        87
        88
        89
        90
        91
        92
        93
        94
        95
        96
        97
        98
        99
        100
        # File 'spec/site/tlc/traffic_data_spec.rb', line 85
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic counting: classification",
                  { S0204: [
                      :starttime,
                      :P,
                      :PS,
                      :L,
                      :LS,
                      :B,
                      :SP,
                      :MC,
                      :C,
                      :F
                  ] },
                  Validator.get_config('components','detector_logic').keys.first
              end
      • Traffic Light Controller Traffic Data classification for all detectors is read with S0208

        Verify status S0208 traffic counting: classification

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        109
        110
        111
        112
        113
        114
        115
        116
        117
        118
        119
        120
        121
        122
        123
        # File 'spec/site/tlc/traffic_data_spec.rb', line 109
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "traffic counting: classification",
                  { S0208: [
                      :start,
                      :P,
                      :PS,
                      :L,
                      :LS,
                      :B,
                      :SP,
                      :MC,
                      :C,
                      :F
                  ] }
              end
    • »

      • Traffic Light Controller Signal Group is ordered to green with M0010

        Validate that a signal group can be ordered to green using the M0010 command.

        1. Verify connection

        2. Send control command to start signalgrup, set_signal_start= true, include security_code

        3. Wait for status = true

        
        
        11
        12
        13
        14
        # File 'spec/site/tlc/signal_groups_spec.rb', line 11
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                set_signal_start
              end
      • Traffic Light Controller Signal Group is ordered to red with M0011
        1. Verify connection

        2. Send control command to stop signalgrup, set_signal_start= false, include security_code

        3. Wait for status = true

        
        
        21
        22
        23
        24
        # File 'spec/site/tlc/signal_groups_spec.rb', line 21
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                set_signal_stop
              end
      • Traffic Light Controller Signal Group state is read with S0001

        Verify that signal group status can be read with S0001.

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        33
        34
        35
        36
        # File 'spec/site/tlc/signal_groups_spec.rb', line 33
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "signal group status",
                  { S0001: [:signalgroupstatus, :cyclecounter, :basecyclecounter, :stage] }
              end
      • Traffic Light Controller Signal Group red/green predictions is read with S0025

        Verify that time-of-green/time-of-red can be read with S0025.

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        45
        46
        47
        48
        49
        50
        51
        52
        53
        54
        55
        56
        57
        # File 'spec/site/tlc/signal_groups_spec.rb', line 45
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "time-of-green/time-of-red",
                  { S0025: [
                      :minToGEstimate,
                      :maxToGEstimate,
                      :likelyToGEstimate,
                      :ToGConfidence,
                      :minToREstimate,
                      :maxToREstimate,
                      :likelyToREstimate
                  ] },
                  Validator.get_config('components','signal_group').keys.first
              end
      • Traffic Light Controller Signal Group series can be started/stopped with M0012
        1. Verify connection

        2. Send control command to start or stop a serie of signalgroups

        3. Wait for status = true

        
        
        64
        65
        66
        67
        # File 'spec/site/tlc/signal_groups_spec.rb', line 64
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                set_signal_start_or_stop '5,4134,65;5,11'
              end
      • Traffic Light Controller Signal Group list size is read with S0017

        Verify status S0017 number of signal groups

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        76
        77
        78
        79
        # File 'spec/site/tlc/signal_groups_spec.rb', line 76
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "number of signal groups",
                  { S0017: [:number] }
              end
      • Traffic Light Controller Signal Group follow startup sequence after yellow flash

        Verify that we can activate normal control after yellow flash mode is turned off

        1. Given the site is connected and in yellow flash mode

        2. When we activate normal control

        3. All signal groups should go through e, f and g

        
        
        88
        89
        90
        91
        92
        93
        94
        95
        # File 'spec/site/tlc/signal_groups_spec.rb', line 88
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                verify_startup_sequence do
                  switch_yellow_flash
                  set_functional_position 'NormalControl'
                end
                set_functional_position 'NormalControl'
              end
    • »

      • Traffic Light Controller Detector Logic list size is read with S0016

        Verify status S0016 number of detector logics

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        11
        12
        13
        14
        # File 'spec/site/tlc/detector_logics_spec.rb', line 11
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "number of detector logics",
                  { S0016: [:number] }
              end
      • Traffic Light Controller Detector Logic status is read with S0002

        Verify status S0002 detector logic status

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        23
        24
        25
        26
        # File 'spec/site/tlc/detector_logics_spec.rb', line 23
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "detector logic status",
                  { S0002: [:detectorlogicstatus] }
              end
      • Traffic Light Controller Detector Logic forcing is read with S0021

        Verify status S0021 manually set detector logic

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        35
        36
        37
        38
        # File 'spec/site/tlc/detector_logics_spec.rb', line 35
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "detector logic forcing",
                  { S0021: [:detectorlogics] }
              end
      • Traffic Light Controller Detector Logic forcing is set with M0008
        1. Verify connection

        2. Send control command to switch detector_logic= true

        3. Wait for status = true

        
        
        45
        46
        47
        48
        49
        50
        51
        52
        53
        54
        55
        56
        57
        58
        59
        60
        61
        # File 'spec/site/tlc/detector_logics_spec.rb', line 45
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
        
                Validator.get_config('components','detector_logic').keys.each_with_index do |component, indx|
                  force_detector_logic component, mode:'True'
                  wait_for_status(@task,
                    "detector logic #{component} to be True",
                    [{'sCI'=>'S0002','n'=>'detectorlogicstatus','s'=>/^.{#{indx}}1/}]
                  )
                  
                  force_detector_logic component, mode:'False'
                  wait_for_status(@task,
                    "detector logic #{component} to be False",
                    [{'sCI'=>'S0002','n'=>'detectorlogicstatus','s'=>/^.{#{indx}}0/}]
                  )
                end
              end
      • Traffic Light Controller Detector Logic sensitivity is read with S0031

        Verify status S0031 trigger level sensitivity for loop detector

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        70
        71
        72
        73
        # File 'spec/site/tlc/detector_logics_spec.rb', line 70
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "loop detector sensitivity",
                  { S0031: [:status] }
              end
    • »

      • Traffic Light Controller Signal Priority can be requested with M0022

        Validate that a signal priority can be requested.

        1. Given the site is connected

        2. When we send a signal priority request

        3. Then we should receive an acknowledgement

        
        
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        # File 'spec/site/tlc/signal_priority_spec.rb', line 11
        
        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
      • Traffic Light Controller Signal Priority status can be fetched with S0033

        Validate that signal priority status can be requested.

        1. Given the site is connected

        2. When we request signal priority status

        3. Then we should receive a status update

        
        
        33
        34
        35
        36
        # File 'spec/site/tlc/signal_priority_spec.rb', line 33
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "signal group status",
                  { S0033: [:status] }
              end
      • Traffic Light Controller Signal Priority status can be subscribed to with S0033

        Validate that we can subscribe signal priority status

        1. Given the site is connected

        2. And we subscribe to signal priority status updates

        3. Then we should receive an acknowledgement

        4. And we should reive a status updates

        
        
        46
        47
        48
        49
        50
        51
        # File 'spec/site/tlc/signal_priority_spec.rb', line 46
        
        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
      • Traffic Light Controller Signal Priority state goes through received, activated, completed

        Validate that signal priority status are send when priorty is requested

        1. Given the site is connected

        2. And we subscribe to signal priority status

        3. When we send a signal priority request

        4. Then we should receive status updates

        
        
        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
        86
        87
        88
        89
        90
        91
        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
        122
        123
        124
        125
        126
        127
        128
        129
        130
        131
        132
        133
        134
        135
        136
        137
        138
        139
        # File 'spec/site/tlc/signal_priority_spec.rb', line 61
        
        Validator::Site.connected do |task,supervisor,site|
                sequence = ['received','activated','completed']
                # subscribe
                component = Validator.get_config('main_component')
                log "Subscribing to signal priority request status updates"
                status_list = [{'sCI'=>'S0033','n'=>'status','uRt'=>'0'}]
                status_list.map! { |item| item.merge!('sOc' => true) } if use_sOc?(site)
                site.subscribe_to_status component, status_list
        
                # start collector
                request_id = SecureRandom.uuid()[0..3]    # make a message id
                num = sequence.length
                states = []
                result = nil
                collector = nil
                collect_task = task.async do
                  collector = RSMP::Collector.new(
                    site,
                    type: "StatusUpdate",
                    num: num,
                    timeout: Validator.get_config('timeouts','priority_completion'),
                    component: component
                  )
        
                  def search_for_request_state request_id, message, states
                    message.attribute('sS').each do |status|
                      return nil unless status['sCI'] == 'S0033' && status['n'] == 'status'
                      status['s'].each do |priority|
                        next unless priority['r'] == request_id  # is this our request
                        state = priority['s']
                        next unless state != states.last  # did the state change?
                        log "Priority request reached state '#{state}'"
                        return state
                      end
                    end
                    nil
                  end
        
                  result = collector.collect do |message|
                    state = search_for_request_state request_id, message, states
                    next unless state
                    states << state
                    :keep
                  end
                end
        
                def send_priority_request log, id:nil, site:, component:
                  # send an unrelated request before our request, to check that it does not interfere
                  log log
                  signal_group = Validator.get_config('components','signal_group').keys.first
                  command_list = build_command_list :M0022, :requestPriority, {
                    requestId: (id || SecureRandom.uuid()[0..3]),
                    signalGroupId: signal_group,
                    type: 'new',
                    level: 7,
                    eta: 2,
                    vehicleType: 'car'
                  }
                  site.send_command component, command_list
                end
        
                send_priority_request "Send an unrelated signal priority request before",
                  site: site, component: component
                send_priority_request "Send our signal priority request",
                  site: site, component: component, id: request_id
                send_priority_request "Send an unrelated signal priority request after",
                  site: site, component: component
        
                # wait for collector to complete and check result
                collect_task.wait
                expect(result).to eq(:ok)
                expect(collector.messages).to be_an(Array)
                expect(collector.messages.size).to eq(num)
                expect(states).to eq(sequence), "Expected state sequence #{sequence}, got #{states}"
              ensure
                # unsubcribe
                unsubscribe_list = status_list.map { |item| item.slice('sCI','n') }
                site.unsubscribe_to_status component, unsubscribe_list
              end
    • »

      • Traffic Light Controller Emergency Route emergency route is read with S0006

        Verify that current emergency route can be read with S0006. Depreciated from 1.2, use S0035 instead.

        1. Given the site is connected.

        2. When we request S0006.

        3. Then we should receive a status response.

        
        
        12
        13
        14
        15
        # File 'spec/site/tlc/emergency_routes_spec.rb', line 12
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "emergency route status",
                  { S0006: [:status,:emergencystage] }
              end
      • Traffic Light Controller Emergency Route emergency route is read with S0035

        Verify that current emergency routes can be read with S0035.

        1. Given the site is connected.

        2. When we request S0035.

        3. Then we should receive a status response.

        
        
        23
        24
        25
        26
        # File 'spec/site/tlc/emergency_routes_spec.rb', line 23
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "emergency route status",
                  { S0035: [:emergencyroutes] }
              end
      • Traffic Light Controller Emergency Route can be activated with M0005 and read with S0006

        Verify that emergency routes can be activated with M0005. S0006 should reflect the last route enabled/disabled.

        1. Given the site is connected.

        2. When we send M0005 to set emergency route.

        3. Then we should get a command responds confirming the change.

        
        
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        53
        54
        55
        56
        57
        58
        # File 'spec/site/tlc/emergency_routes_spec.rb', line 35
        
        emergency_routes = Validator.get_config('items','emergency_routes')
              skip("No emergency routes configured") if emergency_routes.nil? || emergency_routes.empty?
        
              def set_emergency_states task, emergency_routes, state
                emergency_routes.each do |emergency_route|
                  set_emergency_route emergency_route.to_s, state
                end
                wait_for_status(task, "emergency route #{emergency_routes.last} to be enabled",
                  [
                    {'sCI'=>'S0006','n'=>'status','s'=>(state ? 'True' : 'False')},
                    {'sCI'=>'S0006','n'=>'emergencystage','s'=>(state ? emergency_routes.last.to_s : '0')}
                  ]
                )
             end
        
              Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                set_emergency_states task, emergency_routes, false
                begin
                  set_emergency_states task, emergency_routes, true
                ensure
                  set_emergency_states task, emergency_routes, false
                end
              end
      • Traffic Light Controller Emergency Route emergency routes can be activated with M0005 and read with S0035

        Verify that emergency routes can be activated with M0005. S0035 should show all active routes.

        1. Given the site is connected.

        2. When we send M0005 to set emergency route.

        3. Then we should get a command responds confirming the change.

        4. When we request the current emergency routes with S035.

        5. Then we should receive the list of active routes.

        
        
        70
        71
        72
        73
        74
        75
        76
        77
        78
        79
        80
        81
        82
        83
        84
        85
        86
        87
        88
        89
        90
        91
        92
        93
        94
        95
        96
        97
        98
        # File 'spec/site/tlc/emergency_routes_spec.rb', line 70
        
        def enable_routes task, emergency_routes
                emergency_routes.each { |emergency_route| set_emergency_route emergency_route.to_s, true }
                routes = emergency_routes.map {|i| {'id'=>i.to_s} }
                wait_for_status(task, "emergency routes #{emergency_routes.to_s} to be enabled",
                  [ {'sCI'=>'S0035','n'=>'emergencyroutes','s'=>routes} ]
                )
              end
        
              def disable_routes task, emergency_routes
                emergency_routes.each { |emergency_route| set_emergency_route emergency_route.to_s, false }
                routes = []
                wait_for_status(task, "all emergency routes to be disabled",
                  [ {'sCI'=>'S0035','n'=>'emergencyroutes','s'=>routes} ]
                )
              end
        
              emergency_routes = Validator.get_config('items','emergency_routes')
        
              skip("No emergency routes configured") if emergency_routes.nil? || emergency_routes.empty?
        
              Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                disable_routes task, emergency_routes
                begin
                  enable_routes task, emergency_routes
                ensure
                  disable_routes task, emergency_routes
                end
              end
    • »

      • Traffic Light Controller Traffic Situation is read with S0015

        Verify status S0015 current traffic situation

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        11
        12
        13
        14
        15
        16
        17
        18
        # File 'spec/site/tlc/traffic_situations_spec.rb', line 11
        
        Validator::Site.connected do |task,supervisor,site|
                if RSMP::Proxy.version_meets_requirement?( site.sxl_version, '>=1.1' )
                  status_list = { S0015: [:status,:source] }
                else
                  status_list = { S0015: [:status] }
                end
                request_status_and_confirm site, "current traffic situation", status_list
              end
      • Traffic Light Controller Traffic Situation is set with M0003

        Verify that we change traffic situation

        1. Given the site is connected

        2. Verify that there is a Validator.get_config(‘validator’) with a traffic situation

        3. Send the control command to switch traffic situation for each traffic situation

        4. Wait for status “Current traffic situation” = requested traffic situation

        
        
        28
        29
        30
        31
        32
        33
        34
        35
        # File 'spec/site/tlc/traffic_situations_spec.rb', line 28
        
        situations = Validator.get_config('items','traffic_situations')
              skip("No traffic situations configured") if situations.nil? || situations.empty?
              Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                situations.each { |traffic_situation| switch_traffic_situation traffic_situation.to_s }
              ensure
                unset_traffic_situation
              end
      • Traffic Light Controller Traffic Situation list size is read with S0019

        Verify status S0019 number of traffic situations

        1. Given the site is connected

        2. Request status

        3. Expect status response before timeout

        
        
        44
        45
        46
        47
        # File 'spec/site/tlc/traffic_situations_spec.rb', line 44
        
        Validator::Site.connected do |task,supervisor,site|
                request_status_and_confirm site, "number of traffic situations",
                  { S0019: [:number] }
              end
    • »

      • Core Connection Sequence is correct for rsmp version 3.1.1

        Verify the connection sequence when using rsmp core 3.1.1

        1. Given the site is connected and using core 3.1.1

        2. When handshake messages are sent and received

        3. Then the handshake messages should be in the specified sequence corresponding to version 3.1.1

        4. And the connection sequence should be complete

        
        
        11
        # File 'spec/site/core/connect_spec.rb', line 11
        
        check_sequence '3.1.1'
      • Core Connection Sequence is correct for rsmp version 3.1.2

        Verify the connection sequence when using rsmp core 3.1.2

        1. Given the site is connected and using core 3.1.2

        2. When handshake messages are sent and received

        3. Then the handshake messages should be in the specified sequence corresponding to version 3.1.2

        4. And the connection sequence should be complete

        
        
        21
        # File 'spec/site/core/connect_spec.rb', line 21
        
        check_sequence '3.1.2'
      • Core Connection Sequence is correct for rsmp version 3.1.3

        Verify the connection sequence when using rsmp core 3.1.3

        1. Given the site is connected and using core 3.1.3

        2. When handshake messages are sent and received

        3. Then the handshake messages should be in the specified sequence corresponding to version 3.1.3

        4. And the connection sequence should be complete

        
        
        31
        # File 'spec/site/core/connect_spec.rb', line 31
        
        check_sequence '3.1.3'
      • Core Connection Sequence is correct for rsmp version 3.1.4

        Verify the connection sequence when using rsmp core 3.1.4

        1. Given the site is connected and using core 3.1.4

        2. When handshake messages are sent and received

        3. Then the handshake messages should be in the specified sequence corresponding to version 3.1.4

        4. And the connection sequence should be complete

        
        
        41
        # File 'spec/site/core/connect_spec.rb', line 41
        
        check_sequence '3.1.4'
      • Core Connection Sequence is correct for rsmp version 3.1.5

        Verify the connection sequence when using rsmp core 3.1.5

        1. Given the site is connected and using core 3.1.5

        2. When handshake messages are sent and received

        3. Then the handshake messages should be in the specified sequence corresponding to version 3.1.5

        4. And the connection sequence should be complete

        
        
        51
        # File 'spec/site/core/connect_spec.rb', line 51
        
        check_sequence '3.1.5'
      • Core Connection Sequence is correct for rsmp version 3.2

        Verify the connection sequence when using rsmp core 3.2

        1. Given the site is connected and using core 3.1.5

        2. When handshake messages are sent and received

        3. Then the handshake messages should be in the specified sequence corresponding to version 3.1.5

        4. And the connection sequence should be complete

        
        
        61
        # File 'spec/site/core/connect_spec.rb', line 61
        
        check_sequence '3.2'
    • »

      • Core Connection is closed if watchdogs are not acknowledged
        1. Given the site has just connected

        2. When our supervisor does not acknowledge watchdogs

        3. Then the site should disconnect

        
        
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        # File 'spec/site/core/disconnect_spec.rb', line 16
        
        timeout = Validator.get_config('timeouts','disconnect')
              Validator::Site.isolated do |task,supervisor,site_proxy|
                supervisor.ignore_errors RSMP::DisconnectError do
                  log "Disabling watchdog acknowledgements, site should disconnect"
                  def site_proxy.acknowledge original
                    if original.is_a? RSMP::Watchdog
                      log "Not acknowledgning watchdog", message: original
                    else
                      super
                    end
                  end
                  site_proxy.wait_for_state :disconnected, timeout: timeout
                end
              rescue RSMP::TimeoutError
                raise "Site did not disconnect within #{timeout}s"
              end
      • Core Connection is not closed if watchdogs are not received
        1. Given the site has just connected

        2. When our supervisor stops sending watchdogs

        3. Then the site should not disconnect

        
        
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        # File 'spec/site/core/disconnect_spec.rb', line 38
        
        Validator::Site.isolated do |task,supervisor,site|
                timeout = Validator.get_config('timeouts','disconnect')
        
                wait_task = task.async do
                  site.wait_for_state :disconnected, timeout: timeout
                  raise RSMP::DisconnectError
                rescue RSMP::TimeoutError
                  # ok, no disconnect happened
                end
        
                log "Stop sending watchdogs, site should not disconnect"
                site.with_watchdog_disabled do
                  wait_task.wait
                end
              end
    • »

      • Core Aggregated Status can be requested

        Verify that the controller responds to an aggregated status request.

        1. Given the site is connected

        2. Request aggregated status

        3. Expect aggregated status response before timeout

        
        
        10
        11
        12
        13
        14
        15
        16
        # File 'spec/site/core/aggregated_status_spec.rb', line 10
        
        Validator::Site.connected do |task,supervisor,site|
                prepare task, site
                log "Request aggregated status"
                result = site.request_aggregated_status Validator.get_config('main_component'), collect!: {
                  timeout: Validator.get_config('timeouts','status_response')
                }
              end