Class: OrigenTesters::SmartestBasedTester::V93K_SMT8::LimitsWorkbook

Inherits:
Object
  • Object
show all
Includes:
Generator
Defined in:
lib/origen_testers/smartest_based_tester/v93k_smt8/limits_workbook.rb

Overview

Responsible for creating a limits workbook for each program generation run Each limits file will generate a sheet within this workbook

Instance Attribute Summary

Attributes included from Generator

#output_directory

Instance Method Summary collapse

Methods included from Generator

#close, #collection, #collection=, #compiler, #current_dir, #dont_diff=, execute_source, #file_extension, #file_pipeline, #filename, #filename=, #finalize, #identity_map, #import, #inhibit_output, #name, #on_close, original_reference_file, original_reference_file=, #output_file, #output_inhibited?, #platform, #reference_file, #render, #set_flow_description, #stats, #to_be_written?, #write_from_template

Constructor Details

#initialize(options = {}) ⇒ LimitsWorkbook

Returns a new instance of LimitsWorkbook.

[View source]

10
11
12
13
# File 'lib/origen_testers/smartest_based_tester/v93k_smt8/limits_workbook.rb', line 10

def initialize(options = {})
  @softbins = {}
  @bins = {}
end

Instance Method Details

#add_bin(number, options = {}) ⇒ Object

[View source]

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/origen_testers/smartest_based_tester/v93k_smt8/limits_workbook.rb', line 40

def add_bin(number, options = {})
  options = {
    name:   nil,
    result: 'FAIL'
  }.merge(options)

  attrs = @bins[number] || {}

  attrs[:name] = options[:name] if options[:name]
  if !attrs[:result] || (options[:result] && options[:result] != 'FAIL')
    attrs[:result] = options[:result]
  end

  @bins[number] = attrs
end

#add_bin_sheets(spreadsheet) ⇒ Object

[View source]

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
140
141
142
143
144
145
146
# File 'lib/origen_testers/smartest_based_tester/v93k_smt8/limits_workbook.rb', line 115

def add_bin_sheets(spreadsheet)
  table = spreadsheet.table 'Software_Bins'
  row = table.row
  row.cell 'Software Bin Name'
  row.cell 'Software Bin'
  row.cell 'Hardware Bin'
  row.cell 'Result'
  row.cell 'Color'
  row.cell 'Priority'
  @softbins.each do |sbin, attrs|
    row = table.row
    row.cell attrs[:name]
    row.cell sbin
    row.cell attrs[:bin]
    row.cell attrs[:result]
    row.cell attrs[:color]
    row.cell attrs[:priority]
  end

  # Write out the bin table
  table = spreadsheet.table 'Hardware_Bins'
  row = table.row
  row.cell 'Hardware Bin Name'
  row.cell 'Hardware Bin'
  row.cell 'Result'
  @bins.each do |bin, attrs|
    row = table.row
    row.cell attrs[:name]
    row.cell bin
    row.cell attrs[:result]
  end
end

#add_softbin(number, options = {}) ⇒ Object

[View source]

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/origen_testers/smartest_based_tester/v93k_smt8/limits_workbook.rb', line 15

def add_softbin(number, options = {})
  options = {
    name:     nil,
    bin:      nil,
    result:   'FAIL',
    color:    'RED',
    priority: 2
  }.merge(options)
  attrs = @softbins[number] || {}

  attrs[:name] = options[:name] if options[:name]
  attrs[:bin] = options[:bin] if options[:bin]
  if !attrs[:result] || (options[:result] && options[:result] != 'FAIL')
    attrs[:result] = options[:result]
  end
  if !attrs[:color] || (options[:color] && options[:color] != 'RED')
    attrs[:color] = options[:color]
  end
  if !attrs[:priority] || (options[:priority] && options[:priority] != 2)
    attrs[:priority] = options[:priority]
  end

  @softbins[number] = attrs
end

#fully_formatted_filenameObject

[View source]

56
57
58
# File 'lib/origen_testers/smartest_based_tester/v93k_smt8/limits_workbook.rb', line 56

def fully_formatted_filename
  'limits.ods'
end

#subdirectoryObject

[View source]

60
61
62
# File 'lib/origen_testers/smartest_based_tester/v93k_smt8/limits_workbook.rb', line 60

def subdirectory
  "#{tester.package_namespace}/common"
end

#write_to_file(options = {}) ⇒ Object

[View source]

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
# File 'lib/origen_testers/smartest_based_tester/v93k_smt8/limits_workbook.rb', line 64

def write_to_file(options = {})
  Origen.log.info "Writing... #{output_file}"
  spreadsheet = RODF::Spreadsheet.new
  Origen.interface.flow_sheets.each do |name, flow|
    if tester.create_limits_file
      if flow.limits_file
        limits_name = flow.limits_file.filename.sub('.csv', '')
        table = spreadsheet.table limits_name
        flow.limits_file.output_file.readlines.each_with_index do |line, i|
          # Need to fix the first row, SMT8 won't allow the Low/High limits cells not to be merged
          if i == 0
            row = table.row
            x = nil
            line.chomp.split(',').each do |word|
              if word == 'Low Limit'
                x = 0
              elsif word == 'High Limit'
                row.cell 'Low Limit', span: x + 1
                x = 0
              elsif word == 'Unit'
                row.cell 'High Limit', span: x + 1
                row.cell word
                x = nil
              elsif x
                x += 1
              else
                row.cell word
              end
            end
          else
            row = table.row
            line.chomp.split(',').each do |word|
              row.cell word
            end
          end
        end
      end
    end
  end
  if tester.separate_bins_file
    bins_file = output_file.sub('.ods', '_bins.ods')
    Origen.log.info "Writing... #{bins_file}"
    bins_ss = RODF::Spreadsheet.new
    add_bin_sheets(bins_ss)
    bins_ss.write_to(bins_file)
  else
    add_bin_sheets(spreadsheet)
  end
  spreadsheet.write_to(output_file)
end