Class: OpenC3::PacketTimeFormattedConversion

Inherits:
Conversion show all
Defined in:
lib/openc3/conversions/packet_time_formatted_conversion.rb

Overview

Converts the packet received time object into a formatted string.

Instance Attribute Summary

Attributes inherited from Conversion

#converted_array_size, #converted_bit_size, #converted_type

Instance Method Summary collapse

Methods inherited from Conversion

#as_json, #to_config, #to_s

Constructor Details

#initializePacketTimeFormattedConversion

Initializes converted_type to :STRING and converted_bit_size to 0



29
30
31
32
33
# File 'lib/openc3/conversions/packet_time_formatted_conversion.rb', line 29

def initialize
  super()
  @converted_type = :STRING
  @converted_bit_size = 0
end

Instance Method Details

#call(value, packet, buffer) ⇒ String

Returns Formatted packet time.

Parameters:

  • value (Object)

    The value to convert

  • packet (Packet)

    The packet which contains the value. This can be useful to reach into the packet and use other values in the conversion.

  • buffer (String)

    The packet buffer

Returns:

  • (String)

    Formatted packet time



37
38
39
40
41
42
43
44
# File 'lib/openc3/conversions/packet_time_formatted_conversion.rb', line 37

def call(value, packet, buffer)
  packet_time = packet.packet_time
  if packet_time
    return packet_time.formatted
  else
    return 'No Packet Time'
  end
end