Class: OpenC3::XtceParser

Inherits:
Object show all
Defined in:
lib/openc3/packets/parsers/xtce_parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#current_target_name ⇒ Object

Returns the value of attribute current_target_name.



23
24
25
# File 'lib/openc3/packets/parsers/xtce_parser.rb', line 23

def current_target_name
  @current_target_name
end

#parsed_target_name ⇒ Object (readonly)

The target the file defined, still readable after parsing finishes. current_target_name is cleared by reset_processing_variables.



27
28
29
# File 'lib/openc3/packets/parsers/xtce_parser.rb', line 27

def parsed_target_name
  @parsed_target_name
end

Class Method Details

.process(commands, telemetry, warnings, filename, target_name = nil) ⇒ String

Processes a XTCE formatted OpenC3 configuration file

Parameters:

  • commands (Hash<String=>Packet>) —

    Hash of all the command packets keyed by the packet name.

  • telemetry (Hash<String=>Packet>) —

    Hash of all the telemetry packets keyed by the packet name.

  • warnings (Array<String>) —

    Array of strings listing all the warnings that were created while parsing the configuration

  • filename (String) —

    The name of the configuration file

  • target_name (String) (defaults to: nil) —

    Override the target name found in the XTCE file

Returns:

  • (String) —

    The target name the packets were added under. The caller needs this to build the ID lookup metadata for those packets.



41
42
43
# File 'lib/openc3/packets/parsers/xtce_parser.rb', line 41

def self.process(commands, telemetry, warnings, filename, target_name = nil)
  XtceParser.new(commands, telemetry, warnings, filename, target_name).parsed_target_name
end

.reverse_packet_order(target_name, cmd_or_tlm_hash) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/openc3/packets/parsers/xtce_parser.rb', line 45

def self.reverse_packet_order(target_name, cmd_or_tlm_hash)
  if cmd_or_tlm_hash[target_name]
    packets = []
    names_to_remove = []
    cmd_or_tlm_hash[target_name].each do |packet_name, packet|
      packets << packet
      names_to_remove << packet_name
    end
    cmd_or_tlm_hash[target_name].length.times do |i|
      cmd_or_tlm_hash[target_name].delete(names_to_remove[i])
    end
    packets.reverse_each do |packet|
      cmd_or_tlm_hash[target_name][packet.packet_name] = packet
    end
  end
end