Method: OpenC3::TargetModel.packets

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

.packets(target_name, type: :TLM, scope:) ⇒ Array

Returns Hash>] All packet hashes under the target_name.

Returns:

  • (Array)

    Hash>] All packet hashes under the target_name



224
225
226
227
228
229
230
231
232
233
234
# File 'lib/openc3/models/target_model.rb', line 224

def self.packets(target_name, type: :TLM, scope:)
  raise "Unknown type #{type} for #{target_name}" unless VALID_TYPES.include?(type)
  raise "Target '#{target_name}' does not exist" unless get(name: target_name, scope: scope)

  result = []
  packets = Store.hgetall("#{scope}__openc3#{type.to_s.downcase}__#{target_name}")
  packets.sort.each do |packet_name, packet_json|
    result << JSON.parse(packet_json, :allow_nan => true, :create_additions => true)
  end
  result
end