Class: OpenC3::LimitsResponseParser

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser, language = 'ruby') ⇒ LimitsResponseParser

Returns a new instance of LimitsResponseParser.

Parameters:



37
38
39
40
# File 'lib/openc3/packets/parsers/limits_response_parser.rb', line 37

def initialize(parser, language = 'ruby')
  @parser = parser
  @language = language
end

Class Method Details

.parse(parser, item, cmd_or_tlm, language = 'ruby') ⇒ Object

Parameters:

  • parser (ConfigParser)

    Configuration parser

  • item (Packet)

    The current item

  • cmd_or_tlm (String)

    Whether this is a command or telemetry packet



30
31
32
33
34
# File 'lib/openc3/packets/parsers/limits_response_parser.rb', line 30

def self.parse(parser, item, cmd_or_tlm, language = 'ruby')
  parser = LimitsResponseParser.new(parser, language)
  parser.verify_parameters(cmd_or_tlm)
  parser.create_limits_response(item)
end

Instance Method Details

#create_limits_response(item) ⇒ Object

Parameters:

  • item (PacketItem)

    The item the limits response should be added to



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/openc3/packets/parsers/limits_response_parser.rb', line 53

def create_limits_response(item)
  if @language == 'ruby'
    klass = OpenC3.require_class(@parser.parameters[0])

    if @parser.parameters[1]
      item.limits.response = klass.new(*@parser.parameters[1..(@parser.parameters.length - 1)])
    else
      item.limits.response = klass.new
    end
  else
    if @parser.parameters[1]
      item.limits.response = PythonProxy.new('LimitsResponse', @parser.parameters[0], *@parser.parameters[1..(@parser.parameters.length - 1)])
    else
      item.limits.response = PythonProxy.new('LimitsResponse', @parser.parameters[0], [])
    end
  end
end

#verify_parameters(cmd_or_tlm) ⇒ Object

Parameters:

  • cmd_or_tlm (String)

    Whether this is a command or telemetry packet



43
44
45
46
47
48
49
50
# File 'lib/openc3/packets/parsers/limits_response_parser.rb', line 43

def verify_parameters(cmd_or_tlm)
  if cmd_or_tlm == PacketConfig::COMMAND
    raise @parser.error("LIMITS_RESPONSE only applies to telemetry items")
  end

  @usage = "LIMITS_RESPONSE <RESPONSE CLASS FILENAME> <RESPONSE SPECIFIC OPTIONS>"
  @parser.verify_num_parameters(1, nil, @usage)
end