45
46
47
48
49
50
51
52
53
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
93
94
95
96
97
98
99
|
# File 'lib/openc3/tools/table_manager/table_manager_core.rb', line 45
def self.report(binary, definition_filename, requested_table_name = nil)
report = StringIO.new
config = TableConfig.process_file(definition_filename)
begin
load_binary(config, binary)
rescue CoreError => err
report.puts "Error: #{err.message}\n"
end
config.tables.each do |table_name, table|
next if requested_table_name && table_name != requested_table_name
items = table.sorted_items
report.puts(table.table_name)
if table.type == :ROW_COLUMN
columns = ['Item']
table.num_columns.times.each do |x|
columns << items[x].name[0...-1]
end
report.puts columns.join(', ')
else
report.puts 'Label, Value'
end
(0...table.num_rows).each do |r|
if table.type == :ROW_COLUMN
rowtext = "#{r + 1}"
else
rowtext = items[r].name
end
report.write "#{rowtext}, "
(0...table.num_columns).each do |c|
if table.type == :ROW_COLUMN
table_item = items[c + r * table.num_columns]
else
table_item = items[r]
end
value = table.read(table_item.name, :FORMATTED)
if value.is_printable?
report.write "#{value}, "
else
report.write "#{value.simple_formatted}, "
end
end
report.write("\n") end
report.write("\n") end
report.string
end
|