Class: OpenC3::Table
- Defined in:
- lib/openc3/tools/table_manager/table.rb
Overview
Table extends Packet by adding more attributes relative to displaying binary data in a gui.
Constant Summary collapse
- TARGET =
Define the target for tables as ‘TABLE’ since there is no target
'TABLE'
Constants inherited from Packet
Packet::ANY_STATE, Packet::RESERVED_ITEM_NAMES, Packet::VALUE_TYPES
Instance Attribute Summary collapse
-
#filename ⇒ String
readonly
File which contains the table definition.
-
#num_columns ⇒ Integer
Number of columns in the table.
-
#type ⇒ Symbol
readonly
Either :KEY_VALUE or :ROW_COLUMN.
Attributes inherited from Packet
#abstract, #cmd_or_tlm, #description, #disabled, #error_response, #extra, #given_values, #hazardous, #hazardous_description, #hidden, #ignore_overlap, #messages_disabled, #packet_name, #packet_rate, #raw, #received_count, #received_time, #related_items, #response, #screen, #stored, #target_name, #template, #validator, #virtual
Instance Method Summary collapse
-
#initialize(name, endianness, type, description, filename) ⇒ Table
constructor
Constructor for a TableDefinition.
-
#num_rows ⇒ Integer
Number of rows in the table.
- #num_rows=(num_rows) ⇒ Object
Methods inherited from Packet
#append_item, #as_json, #buffer=, #check_bit_offsets, #check_limits, #clear_all_non_derived_items, #clear_config_name, #clone, #config_name, #decom, #define, #define_item, #define_reserved_items, #disable_limits, #enable_limits, #formatted, from_json, #get_item, #id_items, #identified?, #identify?, #limits_change_callback=, #limits_items, #meta, #meta=, next_bit_offset, #out_of_limits, #packed?, #packet_time, #packet_time=, #process, #processors, #read, #read_all, #read_all_with_limits_states, #read_id_values, #read_item, #read_items, #reset, #restore_defaults, #set_received_time_fast, #to_config, #update_id_items, #update_limits_items_cache, #write, #write_item, #write_items
Constructor Details
#initialize(name, endianness, type, description, filename) ⇒ Table
Constructor for a TableDefinition
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/openc3/tools/table_manager/table.rb', line 45 def initialize(name, endianness, type, description, filename) super(TARGET, name, endianness, description, '', TableItem) # ONE_DIMENSIONAL and TWO_DIMENSIONAL are deprecated so translate type = :KEY_VALUE if type == :ONE_DIMENSIONAL type = :ROW_COLUMN if type == :TWO_DIMENSIONAL if type != :KEY_VALUE && type != :ROW_COLUMN raise ArgumentError, "Invalid type '#{type}' for table '#{name}'. Must be KEY_VALUE or ROW_COLUMN" end @type = type @filename = filename @num_rows = 0 @num_columns = (@type == :KEY_VALUE) ? 1 : 0 end |
Instance Attribute Details
#filename ⇒ String (readonly)
Returns File which contains the table definition.
37 38 39 |
# File 'lib/openc3/tools/table_manager/table.rb', line 37 def filename @filename end |
#num_columns ⇒ Integer
Returns Number of columns in the table.
40 41 42 |
# File 'lib/openc3/tools/table_manager/table.rb', line 40 def num_columns @num_columns end |
#type ⇒ Symbol (readonly)
Returns Either :KEY_VALUE or :ROW_COLUMN.
34 35 36 |
# File 'lib/openc3/tools/table_manager/table.rb', line 34 def type @type end |
Instance Method Details
#num_rows ⇒ Integer
Returns Number of rows in the table.
71 72 73 74 75 76 77 78 |
# File 'lib/openc3/tools/table_manager/table.rb', line 71 def num_rows case @type when :KEY_VALUE @sorted_items.count { |item| !item.hidden } when :ROW_COLUMN @num_rows end end |
#num_rows=(num_rows) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/openc3/tools/table_manager/table.rb', line 61 def num_rows=(num_rows) case @type when :KEY_VALUE raise 'Rows are fixed in a KEY_VALUE table' when :ROW_COLUMN @num_rows = num_rows end end |