Class: OpenC3::Processor
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ String
The processor name.
-
#results ⇒ Hash
The results of the most recent execution of the processor.
-
#value_type ⇒ Symbol
readonly
The value type for the processor.
Instance Method Summary collapse
- #as_json(*a) ⇒ Object
-
#call(packet, buffer) ⇒ Object
Perform processing on the packet.
-
#clone ⇒ Processor
(also: #dup)
Make a light weight clone of this processor.
-
#initialize(value_type = :CONVERTED) ⇒ Processor
constructor
Create a new Processor.
-
#reset ⇒ Object
Reset any state.
-
#to_config ⇒ Object
Convert to configuration file string.
-
#to_s ⇒ String
The processor class.
Constructor Details
#initialize(value_type = :CONVERTED) ⇒ Processor
Create a new Processor
36 37 38 39 40 41 42 43 |
# File 'lib/openc3/processors/processor.rb', line 36 def initialize(value_type = :CONVERTED) @name = self.class.to_s.upcase value_type = value_type.to_s.upcase.intern @value_type = value_type raise ArgumentError, "value_type must be RAW, CONVERTED, FORMATTED, or WITH_UNITS. Is #{@value_type}" unless Packet::VALUE_TYPES.include?(@value_type) @results = {} end |
Instance Attribute Details
#name ⇒ String
Returns The processor name.
29 30 31 |
# File 'lib/openc3/processors/processor.rb', line 29 def name @name end |
#results ⇒ Hash
Returns The results of the most recent execution of the processor.
32 33 34 |
# File 'lib/openc3/processors/processor.rb', line 32 def results @results end |
#value_type ⇒ Symbol (readonly)
Returns The value type for the processor.
26 27 28 |
# File 'lib/openc3/processors/processor.rb', line 26 def value_type @value_type end |
Instance Method Details
#as_json(*a) ⇒ Object
85 86 87 |
# File 'lib/openc3/processors/processor.rb', line 85 def as_json(*a) { 'name' => @name, 'class' => self.class.name, 'params' => [@value_type.to_s] } end |
#call(packet, buffer) ⇒ Object
Perform processing on the packet.
56 57 58 |
# File 'lib/openc3/processors/processor.rb', line 56 def call(packet, buffer) raise "call method must be defined by subclass" end |
#clone ⇒ Processor Also known as: dup
Make a light weight clone of this processor. This only creates a new hash of results
73 74 75 76 77 |
# File 'lib/openc3/processors/processor.rb', line 73 def clone processor = super() processor.results = processor.results.clone processor end |
#reset ⇒ Object
Reset any state
66 67 68 |
# File 'lib/openc3/processors/processor.rb', line 66 def reset # By default do nothing end |
#to_config ⇒ Object
Convert to configuration file string
81 82 83 |
# File 'lib/openc3/processors/processor.rb', line 81 def to_config " PROCESSOR #{@name} #{self.class.name.to_s.class_name_to_filename} #{@value_type}\n" end |
#to_s ⇒ String
Returns The processor class.
61 62 63 |
# File 'lib/openc3/processors/processor.rb', line 61 def to_s self.class.to_s.split('::')[-1] end |