Class: OpenC3::WatermarkProcessor
- Defined in:
- lib/openc3/processors/watermark_processor.rb
Instance Attribute Summary
Attributes inherited from Processor
Instance Method Summary collapse
- #as_json(*a) ⇒ Object
-
#call(packet, buffer) ⇒ Object
Run watermarks on the item.
-
#initialize(item_name, value_type = :CONVERTED) ⇒ WatermarkProcessor
constructor
A new instance of WatermarkProcessor.
-
#reset ⇒ Object
Reset any state.
-
#to_config ⇒ Object
Convert to configuration file string.
Methods inherited from Processor
Constructor Details
#initialize(item_name, value_type = :CONVERTED) ⇒ WatermarkProcessor
Returns a new instance of WatermarkProcessor.
29 30 31 32 33 |
# File 'lib/openc3/processors/watermark_processor.rb', line 29 def initialize(item_name, value_type = :CONVERTED) super(value_type) @item_name = item_name.to_s.upcase reset() end |
Instance Method Details
#as_json(*a) ⇒ Object
57 58 59 |
# File 'lib/openc3/processors/watermark_processor.rb', line 57 def as_json(*a) { 'name' => @name, 'class' => self.class.name, 'params' => [@item_name, @value_type.to_s] } end |
#call(packet, buffer) ⇒ Object
Run watermarks on the item
See Processor#call
38 39 40 41 42 43 44 |
# File 'lib/openc3/processors/watermark_processor.rb', line 38 def call(packet, buffer) value = packet.read(@item_name, @value_type, buffer) high_water = @results[:HIGH_WATER] @results[:HIGH_WATER] = value if !high_water or value > high_water low_water = @results[:LOW_WATER] @results[:LOW_WATER] = value if !low_water or value < low_water end |
#reset ⇒ Object
Reset any state
47 48 49 50 |
# File 'lib/openc3/processors/watermark_processor.rb', line 47 def reset @results[:HIGH_WATER] = nil @results[:LOW_WATER] = nil end |
#to_config ⇒ Object
Convert to configuration file string
53 54 55 |
# File 'lib/openc3/processors/watermark_processor.rb', line 53 def to_config " PROCESSOR #{@name} #{self.class.name.to_s.class_name_to_filename} #{@item_name} #{@value_type}\n" end |