Class: OpenC3::UnixTimeSecondsConversion

Inherits:
UnixTimeConversion show all
Defined in:
lib/openc3/conversions/unix_time_seconds_conversion.rb

Overview

Converts a unix format time: Epoch Jan 1 1970, seconds and microseconds, into a floating point number.

Instance Attribute Summary

Attributes inherited from Conversion

#converted_array_size, #converted_bit_size, #converted_type

Instance Method Summary collapse

Methods inherited from UnixTimeConversion

#as_json, #to_config

Methods inherited from Conversion

#as_json, #to_config

Constructor Details

#initialize(seconds_item_name, microseconds_item_name = nil) ⇒ UnixTimeSecondsConversion

Initializes converted_type to :FLOAT and converted_bit_size to 64

Parameters:

  • seconds_item_name (String)

    The telemetry item in the packet which represents the number of seconds since the UNIX time epoch

  • microseconds_item_name (String) (defaults to: nil)

    The telemetry item in the packet which represents microseconds



35
36
37
38
39
# File 'lib/openc3/conversions/unix_time_seconds_conversion.rb', line 35

def initialize(seconds_item_name, microseconds_item_name = nil)
  super(seconds_item_name, microseconds_item_name)
  @converted_type = :FLOAT
  @converted_bit_size = 64
end

Instance Method Details

#call(value, packet, buffer) ⇒ Float

Returns Packet time in seconds since UNIX epoch.

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:

  • (Float)

    Packet time in seconds since UNIX epoch



43
44
45
# File 'lib/openc3/conversions/unix_time_seconds_conversion.rb', line 43

def call(value, packet, buffer)
  super.to_f
end

#to_sString

Returns The name of the class followed by the time conversion.

Returns:

  • (String)

    The name of the class followed by the time conversion



48
49
50
# File 'lib/openc3/conversions/unix_time_seconds_conversion.rb', line 48

def to_s
  super << ".to_f"
end