Method: OpenC3::TargetModel.packet_items

Defined in:
lib/openc3/models/target_model.rb

.packet_items(target_name, packet_name, items, type: :TLM, scope:) ⇒ Array<Hash>



261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/openc3/models/target_model.rb', line 261

def self.packet_items(target_name, packet_name, items, type: :TLM, scope:)
  packet = packet(target_name, packet_name, type: type, scope: scope)
  found = packet['items'].find_all { |item| items.map(&:to_s).include?(item['name']) }
  if found.length != items.length # we didn't find them all
    found_items = found.collect { |item| item['name'] }
    not_found = []
    (items - found_items).each do |item|
      not_found << "'#{target_name} #{packet_name} #{item}'"
    end
    # 'does not exist' not gramatically correct but we use it in every other exception
    raise "Item(s) #{not_found.join(', ')} does not exist"
  end
  found
end