Class: OpenC3::ProcessorParser
- Defined in:
- lib/openc3/packets/parsers/processor_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_processor(packet) ⇒ Object
-
#initialize(parser) ⇒ ProcessorParser
constructor
A new instance of ProcessorParser.
- #verify_parameters(cmd_or_tlm) ⇒ Object
Constructor Details
#initialize(parser) ⇒ ProcessorParser
Returns a new instance of ProcessorParser.
37 38 39 |
# File 'lib/openc3/packets/parsers/processor_parser.rb', line 37 def initialize(parser) @parser = parser end |
Class Method Details
.parse(parser, packet, cmd_or_tlm) ⇒ Object
30 31 32 33 34 |
# File 'lib/openc3/packets/parsers/processor_parser.rb', line 30 def self.parse(parser, packet, cmd_or_tlm) @parser = ProcessorParser.new(parser) @parser.verify_parameters(cmd_or_tlm) @parser.create_processor(packet) end |
Instance Method Details
#create_processor(packet) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/openc3/packets/parsers/processor_parser.rb', line 52 def create_processor(packet) # require should be performed in target.txt klass = OpenC3.require_class(@parser.parameters[1]) if @parser.parameters[2] processor = klass.new(*@parser.parameters[2..(@parser.parameters.length - 1)]) else processor = klass.new end raise ArgumentError, "processor must be a OpenC3::Processor but is a #{processor.class}" unless OpenC3::Processor === processor processor.name = get_processor_name() packet.processors[processor.name] = processor rescue Exception => err raise @parser.error(err, @usage) end |
#verify_parameters(cmd_or_tlm) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/openc3/packets/parsers/processor_parser.rb', line 42 def verify_parameters(cmd_or_tlm) if cmd_or_tlm == PacketConfig::COMMAND raise @parser.error("PROCESSOR only applies to telemetry packets") end @usage = "PROCESSOR <PROCESSOR NAME> <PROCESSOR CLASS FILENAME> <PROCESSOR SPECIFIC OPTIONS>" @parser.verify_num_parameters(2, nil, @usage) end |