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, queued: false, scope:) ⇒ Object



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

def self.write_packet(packet, queued: false, 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
  if queued
    EphemeralStoreQueued.write_topic("#{scope}__TELEMETRY__{#{packet.target_name}}__#{packet.packet_name}", msg_hash)
  else
    Topic.write_topic("#{scope}__TELEMETRY__{#{packet.target_name}}__#{packet.packet_name}", msg_hash)
  end
end