Class: OpenC3::TableItem

Inherits:
PacketItem show all
Defined in:
lib/openc3/tools/table_manager/table_item.rb

Overview

Implements the attributes that are unique to a TableItem such as editable and hidden. All other functionality is inherited from PacketItem.

Constant Summary

Constants inherited from PacketItem

PacketItem::STATE_COLORS

Instance Attribute Summary collapse

Attributes inherited from PacketItem

#default, #description, #format_string, #hazardous, #id_value, #limits, #messages_disabled, #range, #read_conversion, #required, #state_colors, #states, #units, #units_full, #write_conversion

Instance Method Summary collapse

Methods inherited from PacketItem

#calculate_range, #check_default_and_range_data_types, from_json, #meta, #meta=, #to_config, #to_hash

Constructor Details

#initialize(name, bit_offset, bit_size, data_type, endianness, array_size = nil, overflow = :ERROR) ⇒ TableItem

Create a StructureItem by setting all the attributes. It calls all the setter routines to do the attribute verification and then verifies the overall integrity.

It also initializes the attributes of the PacketItem.

Parameters:

  • name (String)

    The item name

  • bit_offset (Integer)

    Offset to the item starting at 0

  • bit_size (Integer)

    Size of the items in bits

  • data_type (Symbol)

    DATA_TYPES

  • endianness (Symbol)
  • array_size (Integer, nil) (defaults to: nil)

    Size of the array item in bits. For example, if the bit_size is 8, an array_size of 16 holds two values.

  • overflow (Symbol) (defaults to: :ERROR)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/openc3/tools/table_manager/table_item.rb', line 36

def initialize(
  name,
  bit_offset,
  bit_size,
  data_type,
  endianness,
  array_size = nil,
  overflow = :ERROR
)
  super(
    name,
    bit_offset,
    bit_size,
    data_type,
    endianness,
    array_size,
    overflow,
  )
  @display_type = nil
  @editable = true
  @hidden = false
end

Instance Attribute Details

#editableBoolean

Returns Whether this item is editable.

Returns:

  • (Boolean)

    Whether this item is editable



30
31
32
# File 'lib/openc3/tools/table_manager/table_item.rb', line 30

def editable
  @editable
end

#hiddenBoolean

Returns Whether this item is hidden (not displayed).

Returns:

  • (Boolean)

    Whether this item is hidden (not displayed)



33
34
35
# File 'lib/openc3/tools/table_manager/table_item.rb', line 33

def hidden
  @hidden
end

Instance Method Details

#as_json(*a) ⇒ Object

Create a hash of this item’s attributes



86
87
88
89
90
91
# File 'lib/openc3/tools/table_manager/table_item.rb', line 86

def as_json(*a)
  hash = super()
  hash['editable'] = self.editable
  hash['hidden'] = self.hidden
  hash
end

#cloneObject Also known as: dup

Make a light weight clone of this item



78
79
80
81
82
# File 'lib/openc3/tools/table_manager/table_item.rb', line 78

def clone
  item = super()
  item.editable = self.editable
  item
end