Class PolyLine
java.lang.Object
io.openems.edge.common.linecharacteristic.PolyLine
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.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionCreates a PolyLine from two points.Creates a static PolyLine, i.e.Creates a PolyLine from a JSON line configuration.Creates a PolyLine from a JSON line configuration.Creates a PolyLine from a map of points. -
Method Summary
Modifier and TypeMethodDescriptionstatic PolyLine.Builder
create()
Create a PolyLine builder.static PolyLine
empty()
Create a PolyLine that returns null for every 'x'.Gets the Y-value for the given X.Gets the Y-value for the given X.Gets the Y-value for the given X.static void
printAsCsv
(PolyLine polyLine) Prints aPolyLine
in CSV format.
-
Constructor Details
-
PolyLine
Creates a static PolyLine, i.e. the 'y' value is the same for each 'x'.- Parameters:
y
- 'y' value
-
PolyLine
Creates a PolyLine from two points.- Parameters:
x1
- 'x' value of point 1y1
- 'y' value of point 1x2
- 'x' value of point 2y2
- 'y' value of point 2
-
PolyLine
Creates a PolyLine from a map of points.- Parameters:
points
- a map of points
-
PolyLine
Creates a PolyLine from a JSON line configuration.- Parameters:
x
- the name of the 'x' value inside the Json-Arrayy
- the name of the 'y' value inside the Json-ArraylineConfig
- 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-Arrayy
- the name of the 'y' value inside the Json-ArraylineConfig
- the configured x and y coordinates values- Throws:
OpenemsError.OpenemsNamedException
- on error
-
-
Method Details
-
create
Create a PolyLine builder.- Returns:
- a
PolyLine.Builder
-
empty
Create a PolyLine that returns null for every 'x'.- Returns:
- a
PolyLine
-
getValue
Gets the Y-value for the given X.- Parameters:
x
- the 'x' value, possibly null- Returns:
- the 'y' value, possibly null
-
getValue
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
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
- Parameters:
polyLine
- thePolyLine
-