Method: OpenC3::TargetModel.packet
- Defined in:
- lib/openc3/models/target_model.rb
.packet(target_name, packet_name, type: :TLM, scope:) ⇒ Hash
Returns Packet hash or raises an exception.
230 231 232 233 234 235 236 237 238 |
# File 'lib/openc3/models/target_model.rb', line 230 def self.packet(target_name, packet_name, type: :TLM, scope:) raise "Unknown type #{type} for #{target_name} #{packet_name}" unless VALID_TYPES.include?(type) # Assume it exists and just try to get it to avoid an extra call to Store.exist? json = Store.hget("#{scope}__openc3#{type.to_s.downcase}__#{target_name}", packet_name) raise "Packet '#{target_name} #{packet_name}' does not exist" if json.nil? JSON.parse(json, :allow_nan => true, :create_additions => true) end |