Method: OpenC3::SegmentedPolynomialConversion#call

Defined in:
lib/openc3/conversions/segmented_polynomial_conversion.rb

#call(value, packet, buffer) ⇒ Float

Returns The value with the polynomial applied.

Parameters:

  • value (Object)

    The value to convert

  • packet (Packet)

    The packet which contains the value. This can be useful to reach into the packet and use other values in the conversion.

  • buffer (String)

    The packet buffer

Returns:

  • (Float)

    The value with the polynomial applied



116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/openc3/conversions/segmented_polynomial_conversion.rb', line 116

def call(value, packet, buffer)
  # Try to find correct segment
  @segments.each do |segment|
    return segment.calculate(value) if value >= segment.lower_bound
  end

  # Default to using segment with smallest lower_bound
  segment = @segments[-1]
  if segment
    return @segments[-1].calculate(value)
  else
    return nil
  end
end