Class: OrigenTesters::ATP::Processors::AddIDs

Inherits:
OrigenTesters::ATP::Processor show all
Defined in:
lib/origen_testers/atp/processors/add_ids.rb

Overview

Assigns an ID to all test nodes that don’t have one

Instance Method Summary collapse

Methods inherited from OrigenTesters::ATP::Processor

#clean_flag, #extract_volatiles, #handler_missing, #process, #process_all, #volatile?, #volatile_flags

Instance Method Details

#next_idObject



38
39
40
41
42
# File 'lib/origen_testers/atp/processors/add_ids.rb', line 38

def next_id
  @i += 1
  @i += 1 while @existing_ids.include?("t#{@i}")
  "t#{@i}"
end

#on_id(node) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/origen_testers/atp/processors/add_ids.rb', line 30

def on_id(node)
  if @add_ids
    unless node.value
      node.updated(nil, [next_id])
    end
  end
end

#on_test(node) ⇒ Object Also known as: on_group



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/origen_testers/atp/processors/add_ids.rb', line 17

def on_test(node)
  if @add_ids
    node = node.ensure_node_present(:id)
    node.updated(nil, process_all(node))
  else
    if id = node.find(:id)
      @existing_ids << id.value
    end
    process_all(node)
  end
end

#run(node) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/origen_testers/atp/processors/add_ids.rb', line 5

def run(node)
  @i = 0
  @existing_ids = []
  @add_ids = false
  # First collect all existing IDs, this is required to make sure
  # that a generated ID does not clash with an existing one
  process(node)
  # Now run again to fill in the blanks
  @add_ids = true
  process(node)
end