Method: OpenC3::Structure#define_item

Defined in:
lib/openc3/packets/structure.rb

#define_item(name, bit_offset, bit_size, data_type, array_size = nil, endianness = @default_endianness, overflow = :ERROR) ⇒ StrutureItem

Define an item in the structure. This creates a new instance of the item_class as given in the constructor and adds it to the items hash. It also resizes the buffer to accomodate the new item.

Parameters:

  • name (String)

    Name of the item. Used by the items hash to retrieve the item.

  • bit_offset (Integer)

    Bit offset of the item in the raw buffer

  • bit_size (Integer)

    Bit size of the item in the raw buffer

  • data_type (Symbol)

    Type of data contained by the item. This is dependant on the item_class but by default see StructureItem.

  • array_size (Integer) (defaults to: nil)

    Set to a non nil value if the item is to represented as an array.

  • endianness (Symbol) (defaults to: @default_endianness)

    Endianness of this item. By default the endianness as set in the constructure is used.

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

    How to handle value overflows. This is dependant on the item_class but by default see StructureItem.

Returns:

  • (StrutureItem)

    The struture item defined



206
207
208
209
210
# File 'lib/openc3/packets/structure.rb', line 206

def define_item(name, bit_offset, bit_size, data_type, array_size = nil, endianness = @default_endianness, overflow = :ERROR)
  # Create the item
  item = @item_class.new(name, bit_offset, bit_size, data_type, endianness, array_size, overflow)
  define(item)
end