Class: OpenC3::ProcessorConversion
- Inherits:
-
Conversion
- Object
- Conversion
- OpenC3::ProcessorConversion
- Defined in:
- lib/openc3/conversions/processor_conversion.rb
Overview
Retrieves the result from an item processor
Instance Attribute Summary
Attributes inherited from Conversion
#converted_array_size, #converted_bit_size, #converted_type, #params
Instance Method Summary collapse
-
#call(value, packet, buffer) ⇒ Varies
The result of the associated processor.
-
#initialize(processor_name, result_name, converted_type = nil, converted_bit_size = nil, converted_array_size = nil) ⇒ ProcessorConversion
constructor
A new instance of ProcessorConversion.
-
#to_config(read_or_write) ⇒ String
Config fragment for this conversion.
-
#to_s ⇒ String
The type of processor.
Methods inherited from Conversion
Constructor Details
#initialize(processor_name, result_name, converted_type = nil, converted_bit_size = nil, converted_array_size = nil) ⇒ ProcessorConversion
Returns a new instance of ProcessorConversion.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/openc3/conversions/processor_conversion.rb', line 33 def initialize(processor_name, result_name, converted_type = nil, converted_bit_size = nil, converted_array_size = nil) super() @processor_name = processor_name.to_s.upcase @result_name = result_name.to_s.upcase.intern @params = [@processor_name, @result_name] if ConfigParser.handle_nil(converted_type) @converted_type = converted_type.to_s.upcase.intern raise ArgumentError, "Unknown converted type: #{converted_type}" if !BinaryAccessor::DATA_TYPES.include?(@converted_type) @params << @converted_type end if ConfigParser.handle_nil(converted_bit_size) @converted_bit_size = Integer(converted_bit_size) @params << @converted_bit_size end if ConfigParser.handle_nil(converted_array_size) @converted_array_size = Integer(converted_array_size) @params << @converted_array_size end end |
Instance Method Details
#call(value, packet, buffer) ⇒ Varies
Returns The result of the associated processor.
55 56 57 |
# File 'lib/openc3/conversions/processor_conversion.rb', line 55 def call(value, packet, buffer) packet.processors[@processor_name].results[@result_name] || 0 # Never return nil end |
#to_config(read_or_write) ⇒ String
Returns Config fragment for this conversion.
66 67 68 69 70 71 72 73 |
# File 'lib/openc3/conversions/processor_conversion.rb', line 66 def to_config(read_or_write) config = " #{read_or_write}_CONVERSION #{self.class.name.class_name_to_filename} #{@processor_name} #{@result_name}" config << " #{@converted_type}" if @converted_type config << " #{@converted_bit_size}" if @converted_bit_size config << " #{@converted_array_size}" if @converted_array_size config << "\n" config end |
#to_s ⇒ String
Returns The type of processor.
60 61 62 |
# File 'lib/openc3/conversions/processor_conversion.rb', line 60 def to_s "ProcessorConversion #{@processor_name} #{@result_name}" end |