Specifications:

  • 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 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

    
    
    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
    93
    94
    95
    96
    # File 'spec/site/tlc/alarm_spec.rb', line 58
    
    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,
                  matcher: {
                    '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

    
    
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    # File 'spec/site/tlc/alarm_spec.rb', line 109
    
    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