Class: Cosmos::PacketLogging

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmos/tools/cmd_tlm_server/packet_logging.rb

Overview

Controls the packet loggers which were configured by CmdTlmServerConfig. This includes starting and stopping both command and telemetry logging.

Instance Method Summary collapse

Constructor Details

#initialize(cmd_tlm_server_config) ⇒ PacketLogging

Returns a new instance of PacketLogging.

Parameters:

  • cmd_tlm_server_config (CmdTlmServerConfig)

    The configuration which defines the packet loggers



18
19
20
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 18

def initialize(cmd_tlm_server_config)
  @config = cmd_tlm_server_config
end

Instance Method Details

#allHash<String, PacketLogWriterPair>

Returns Packet log writer hash. Each pair encapsulates a command and telemetry log writer.

Returns:



126
127
128
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 126

def all
  @config.packet_log_writer_pairs
end

#cmd_filename(packet_log_writer_name = 'DEFAULT') ⇒ String

Returns The command log writer filename.

Parameters:

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

    The name of the command log writer

Returns:

  • (String)

    The command log writer filename



110
111
112
113
114
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 110

def cmd_filename(packet_log_writer_name = 'DEFAULT')
  packet_log_writer_pair = @config.packet_log_writer_pairs[packet_log_writer_name.upcase]
  raise "Unknown packet log writer: #{packet_log_writer_name}" unless packet_log_writer_pair
  return packet_log_writer_pair.cmd_log_writer.filename
end

#shutdownObject

Stop packet logging and kill the logger threads!



39
40
41
42
43
44
45
46
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 39

def shutdown
  @config.packet_log_writer_pairs.each do |name, packet_log_writer_pair|
    packet_log_writer_pair.cmd_log_writer.shutdown
  end
  @config.packet_log_writer_pairs.each do |name, packet_log_writer_pair|
    packet_log_writer_pair.tlm_log_writer.shutdown
  end
end

#start(packet_log_writer_name = 'ALL', label = nil) ⇒ Object

Parameters:

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

    The name of the log writer to start or 'ALL' to start all command and telemetry log writers

  • label (String|nil) (defaults to: nil)

    Label to append to the log file name. See Cosmos::PacketLogWriter#start for more information.



26
27
28
29
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 26

def start(packet_log_writer_name = 'ALL', label = nil)
  start_cmd(packet_log_writer_name, label)
  start_tlm(packet_log_writer_name, label)
end

#start_cmd(packet_log_writer_name = 'ALL', label = nil) ⇒ Object

Parameters:

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

    The name of the log writer to start or 'ALL' to start all command log writers

  • label (String|nil) (defaults to: nil)

    Label to append to the log file name. See Cosmos::PacketLogWriter#start for more information.



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 52

def start_cmd(packet_log_writer_name = 'ALL', label = nil)
  if packet_log_writer_name.upcase == 'ALL'
    @config.packet_log_writer_pairs.each do |name, packet_log_writer_pair|
      packet_log_writer_pair.cmd_log_writer.start(label)
    end
  else
    packet_log_writer_pair = @config.packet_log_writer_pairs[packet_log_writer_name.upcase]
    raise "Unknown packet log writer: #{packet_log_writer_name}" unless packet_log_writer_pair
    packet_log_writer_pair.cmd_log_writer.start(label)
  end
end

#start_tlm(packet_log_writer_name = 'ALL', label = nil) ⇒ Object

Parameters:

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

    The name of the log writer to start or 'ALL' to start all telemetry log writers

  • label (String|nil) (defaults to: nil)

    Label to append to the log file name. See Cosmos::PacketLogWriter#start for more information.



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 68

def start_tlm(packet_log_writer_name = 'ALL', label = nil)
  if packet_log_writer_name.upcase == 'ALL'
    @config.packet_log_writer_pairs.each do |name, packet_log_writer_pair|
      packet_log_writer_pair.tlm_log_writer.start(label)
    end
  else
    packet_log_writer_pair = @config.packet_log_writer_pairs[packet_log_writer_name.upcase]
    raise "Unknown packet log writer: #{packet_log_writer_name}" unless packet_log_writer_pair
    packet_log_writer_pair.tlm_log_writer.start(label)
  end
end

#stop(packet_log_writer_name = 'ALL') ⇒ Object

Parameters:

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

    The name of the log writer to stop or 'ALL' to stop all command and telemetry log writers



33
34
35
36
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 33

def stop(packet_log_writer_name = 'ALL')
  stop_cmd(packet_log_writer_name)
  stop_tlm(packet_log_writer_name)
end

#stop_cmd(packet_log_writer_name = 'ALL') ⇒ Object

Parameters:

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

    The name of the log writer to stop or 'ALL' to stop all command log writers



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 82

def stop_cmd(packet_log_writer_name = 'ALL')
  if packet_log_writer_name.upcase == 'ALL'
    @config.packet_log_writer_pairs.each do |name, packet_log_writer_pair|
      packet_log_writer_pair.cmd_log_writer.stop
    end
  else
    packet_log_writer_pair = @config.packet_log_writer_pairs[packet_log_writer_name.upcase]
    raise "Unknown packet log writer: #{packet_log_writer_name}" unless packet_log_writer_pair
    packet_log_writer_pair.cmd_log_writer.stop
  end
end

#stop_tlm(packet_log_writer_name = 'ALL') ⇒ Object

Parameters:

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

    The name of the log writer to stop or 'ALL' to stop all telemetry log writers



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 96

def stop_tlm(packet_log_writer_name = 'ALL')
  if packet_log_writer_name.upcase == 'ALL'
    @config.packet_log_writer_pairs.each do |name, packet_log_writer_pair|
      packet_log_writer_pair.tlm_log_writer.stop
    end
  else
    packet_log_writer_pair = @config.packet_log_writer_pairs[packet_log_writer_name.upcase]
    raise "Unknown packet log writer: #{packet_log_writer_name}" unless packet_log_writer_pair
    packet_log_writer_pair.tlm_log_writer.stop
  end
end

#tlm_filename(packet_log_writer_name = 'DEFAULT') ⇒ String

Returns The telemetry log writer filename.

Parameters:

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

    The name of the telemetry log writer

Returns:

  • (String)

    The telemetry log writer filename



118
119
120
121
122
# File 'lib/cosmos/tools/cmd_tlm_server/packet_logging.rb', line 118

def tlm_filename(packet_log_writer_name = 'DEFAULT')
  packet_log_writer_pair = @config.packet_log_writer_pairs[packet_log_writer_name.upcase]
  raise "Unknown packet log writer: #{packet_log_writer_name}" unless packet_log_writer_pair
  return packet_log_writer_pair.tlm_log_writer.filename
end