java.lang.Object
io.openems.edge.common.linecharacteristic.PolyLine

public class PolyLine extends Object
Defines a polyline built of multiple points defined by a JsonArray.

This class can be used e.g. to build Q-by-U characteristics Controllers.

  • Constructor Details

    • PolyLine

      public PolyLine(Double y)
      Creates a static PolyLine, i.e. the 'y' value is the same for each 'x'.
      Parameters:
      y - 'y' value
    • PolyLine

      public PolyLine(double x1, Double y1, double x2, Double y2)
      Creates a PolyLine from two points.
      Parameters:
      x1 - 'x' value of point 1
      y1 - 'y' value of point 1
      x2 - 'x' value of point 2
      y2 - 'y' value of point 2
    • PolyLine

      public PolyLine(TreeMap<Double,Double> points)
      Creates a PolyLine from a map of points.
      Parameters:
      points - a map of points
    • PolyLine

      public PolyLine(String x, String y, String lineConfig) throws OpenemsError.OpenemsNamedException
      Creates a PolyLine from a JSON line configuration.
      Parameters:
      x - the name of the 'x' value inside the Json-Array
      y - the name of the 'y' value inside the Json-Array
      lineConfig - the configured x and y coordinates values; parsed to a Json-Array
      Throws:
      OpenemsError.OpenemsNamedException - on error
    • PolyLine

      public PolyLine(String x, String y, com.google.gson.JsonArray lineConfig) throws OpenemsError.OpenemsNamedException
      Creates a PolyLine from a JSON line configuration.

      Parse the given JSON line format to x and y parameters.

       [
        { "x": 0.9,  "y":-4000 },
        { "x": 0.93, "y":-1000 },
        { "x": 1.07, "y":1000 },
        { "x": 1.1,  "y":4000 }
       ]
       
      Parameters:
      x - the name of the 'x' value inside the Json-Array
      y - the name of the 'y' value inside the Json-Array
      lineConfig - the configured x and y coordinates values
      Throws:
      OpenemsError.OpenemsNamedException - on error
  • Method Details

    • create

      public static PolyLine.Builder create()
      Create a PolyLine builder.
      Returns:
      a PolyLine.Builder
    • empty

      public static PolyLine empty()
      Create a PolyLine that returns null for every 'x'.
      Returns:
      a PolyLine
    • getValue

      public Double getValue(Double x)
      Gets the Y-value for the given X.
      Parameters:
      x - the 'x' value, possibly null
      Returns:
      the 'y' value, possibly null
    • getValue

      public Double getValue(Float x)
      Gets the Y-value for the given X. Convenience method that internally converts the Float to a Double.
      Parameters:
      x - the 'x' value, possibly null
      Returns:
      the 'y' value, possibly null
    • getValue

      public Double getValue(Integer x)
      Gets the Y-value for the given X. Convenience method that internally converts the Integer to a Double.
      Parameters:
      x - the 'x' value, possibly null
      Returns:
      the 'y' value, possibly null
    • printAsCsv

      public static void printAsCsv(PolyLine polyLine)
      Prints a PolyLine in CSV format.

      Use this method to visualize the PolyLine in a spreadsheet.

      Parameters:
      polyLine - the PolyLine