Class: OpenC3::BufferedPacketLogReader

Inherits:
PacketLogReader show all
Defined in:
lib/openc3/logs/buffered_packet_log_reader.rb

Overview

Buffers files so small time differences can be read in time order

Constant Summary

Constants inherited from PacketLogReader

PacketLogReader::MAX_READ_SIZE

Constants included from PacketLogConstants

PacketLogConstants::COSMOS2_FILE_HEADER, PacketLogConstants::COSMOS4_FILE_HEADER, PacketLogConstants::OPENC3_CBOR_FLAG_MASK, PacketLogConstants::OPENC3_CMD_FLAG_MASK, PacketLogConstants::OPENC3_ENTRY_TYPE_MASK, PacketLogConstants::OPENC3_EXTRA_FLAG_MASK, PacketLogConstants::OPENC3_EXTRA_LENGTH_FIXED_SIZE, PacketLogConstants::OPENC3_EXTRA_LENGTH_PACK_DIRECTIVE, PacketLogConstants::OPENC3_EXTRA_LENGTH_PACK_ITEMS, PacketLogConstants::OPENC3_FILE_HEADER, PacketLogConstants::OPENC3_HEADER_LENGTH, PacketLogConstants::OPENC3_ID_FIXED_SIZE, PacketLogConstants::OPENC3_ID_FLAG_MASK, PacketLogConstants::OPENC3_INDEX_HEADER, PacketLogConstants::OPENC3_JSON_PACKET_ENTRY_TYPE_MASK, PacketLogConstants::OPENC3_KEY_MAP_ENTRY_TYPE_MASK, PacketLogConstants::OPENC3_KEY_MAP_PACK_DIRECTIVE, PacketLogConstants::OPENC3_KEY_MAP_PACK_ITEMS, PacketLogConstants::OPENC3_KEY_MAP_SECONDARY_FIXED_SIZE, PacketLogConstants::OPENC3_MAX_PACKET_INDEX, PacketLogConstants::OPENC3_MAX_TARGET_INDEX, PacketLogConstants::OPENC3_OFFSET_MARKER_ENTRY_TYPE_MASK, PacketLogConstants::OPENC3_OFFSET_MARKER_PACK_DIRECTIVE, PacketLogConstants::OPENC3_OFFSET_MARKER_PACK_ITEMS, PacketLogConstants::OPENC3_OFFSET_MARKER_SECONDARY_FIXED_SIZE, PacketLogConstants::OPENC3_PACKET_DECLARATION_ENTRY_TYPE_MASK, PacketLogConstants::OPENC3_PACKET_DECLARATION_PACK_DIRECTIVE, PacketLogConstants::OPENC3_PACKET_DECLARATION_PACK_ITEMS, PacketLogConstants::OPENC3_PACKET_DECLARATION_SECONDARY_FIXED_SIZE, PacketLogConstants::OPENC3_PACKET_PACK_DIRECTIVE, PacketLogConstants::OPENC3_PACKET_PACK_ITEMS, PacketLogConstants::OPENC3_PACKET_SECONDARY_FIXED_SIZE, PacketLogConstants::OPENC3_PRIMARY_FIXED_SIZE, PacketLogConstants::OPENC3_RAW_PACKET_ENTRY_TYPE_MASK, PacketLogConstants::OPENC3_RECEIVED_TIME_FIXED_SIZE, PacketLogConstants::OPENC3_RECEIVED_TIME_FLAG_MASK, PacketLogConstants::OPENC3_RECEIVED_TIME_PACK_DIRECTIVE, PacketLogConstants::OPENC3_RECEIVED_TIME_PACK_ITEMS, PacketLogConstants::OPENC3_STORED_FLAG_MASK, PacketLogConstants::OPENC3_TARGET_DECLARATION_ENTRY_TYPE_MASK, PacketLogConstants::OPENC3_TARGET_DECLARATION_PACK_DIRECTIVE, PacketLogConstants::OPENC3_TARGET_DECLARATION_PACK_ITEMS, PacketLogConstants::OPENC3_TARGET_DECLARATION_SECONDARY_FIXED_SIZE

Instance Attribute Summary collapse

Attributes inherited from PacketLogReader

#filename, #last_offsets, #redis_offset

Instance Method Summary collapse

Methods inherited from PacketLogReader

#bytes_read, #close, #each, #open, #read, #size

Constructor Details

#initialize(bucket_file = nil, buffer_depth = 10) ⇒ BufferedPacketLogReader

Returns a new instance of BufferedPacketLogReader.



28
29
30
31
32
# File 'lib/openc3/logs/buffered_packet_log_reader.rb', line 28

def initialize(bucket_file = nil, buffer_depth = 10)
  super()
  @bucket_file = bucket_file
  @buffer_depth = buffer_depth
end

Instance Attribute Details

#bucket_fileObject (readonly)

Returns the value of attribute bucket_file.



26
27
28
# File 'lib/openc3/logs/buffered_packet_log_reader.rb', line 26

def bucket_file
  @bucket_file
end

Instance Method Details

#buffered_read(identify_and_define = true) ⇒ Object



41
42
43
44
# File 'lib/openc3/logs/buffered_packet_log_reader.rb', line 41

def buffered_read(identify_and_define = true)
  fill_buffer(identify_and_define)
  return @buffer.shift
end

#next_packet_time(identify_and_define = true) ⇒ Object



34
35
36
37
38
39
# File 'lib/openc3/logs/buffered_packet_log_reader.rb', line 34

def next_packet_time(identify_and_define = true)
  fill_buffer(identify_and_define)
  packet = @buffer[0]
  return packet.packet_time if packet
  return nil
end