Class: Cosmos::NewPacketLogConversion

Inherits:
Conversion show all
Defined in:
lib/cosmos/conversions/new_packet_log_conversion.rb

Overview

Creates new packet logs whenever it executes

Instance Attribute Summary

Attributes inherited from Conversion

#converted_bit_size, #converted_type

Instance Method Summary collapse

Constructor Details

#initialize(packet_log_writer_name = 'ALL') ⇒ NewPacketLogConversion

Initializes converted_type to :FLOAT and converted_bit_size to 64

Parameters:

  • packet_log_writer_name (String) (defaults to: 'ALL')

    Name of the packet log writer to start new logs on



23
24
25
# File 'lib/cosmos/conversions/new_packet_log_conversion.rb', line 23

def initialize(packet_log_writer_name = 'ALL')
  @packet_log_writer_name = packet_log_writer_name
end

Instance Method Details

#call(value, packet, buffer) ⇒ Varies

Returns The value given.

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:

  • (Varies)

    The value given



29
30
31
32
33
34
# File 'lib/cosmos/conversions/new_packet_log_conversion.rb', line 29

def call(value, packet, buffer)
  if CmdTlmServer.instance and CmdTlmServer.packet_logging
    CmdTlmServer.instance.start_logging(@packet_log_writer_name)
  end
  value
end

#to_sString

Returns The name of the class and the associated packet log writer name.

Returns:

  • (String)

    The name of the class and the associated packet log writer name



37
38
39
40
41
# File 'lib/cosmos/conversions/new_packet_log_conversion.rb', line 37

def to_s
  result = super()
  result << " (#{@packet_log_writer_name})"
  result
end