Class: OpenC3::TelemetryTopic

Inherits:
Topic show all
Defined in:
lib/openc3/topics/telemetry_topic.rb

Class Method Summary collapse

Methods inherited from Topic

clear_topics, get_cnt, method_missing

Class Method Details

.write_packet(packet, scope:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/openc3/topics/telemetry_topic.rb', line 27

def self.write_packet(packet, scope:)
  msg_hash = {
    :time => packet.packet_time.to_nsec_from_epoch,
    :received_time => packet.received_time.to_nsec_from_epoch,
    :stored => packet.stored.to_s,
    :target_name => packet.target_name,
    :packet_name => packet.packet_name,
    :received_count => packet.received_count,
    :buffer => packet.buffer(false)
  }
  msg_hash[:extra] = JSON.generate(packet.extra.as_json, allow_nan: true) if packet.extra
  Topic.write_topic("#{scope}__TELEMETRY__{#{packet.target_name}}__#{packet.packet_name}", msg_hash)
end