Skip to content

Commit

Permalink
Time-of-Use Controller: improvements (#2475)
Browse files Browse the repository at this point in the history
- Split ESS CHARGE power limit to "Grid Limit" and "Charge Power Limit"
  - also considers DC-side charging
  - ATTENTION: this requires manual adjustment for Swedish systems to avoid excess power
  - TODO: Grid Limit will eventually be moved to the global "PowerOptimizer" (derivate of Ess.Power)
- Fix error in calculation of sleep time for remainingExecutionLimit
- Improve log output:
  - add actual Params to log
  - nicely format schedule in a table
- Reduce EFFICIENCY_FACTOR to 1.15
- Improve UI visualization
  • Loading branch information
sfeilmeier authored Dec 30, 2023
1 parent 21bf0c0 commit 08cfbb2
Show file tree
Hide file tree
Showing 45 changed files with 1,941 additions and 874 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,33 @@ public enum OpenemsError {
JSON_NO_ARRAY_MEMBER(5007, "JSON [%s:%s] is not JSON-Array"), //
JSON_NO_DATE_MEMBER(5008, "JONS [%s:%s] is not a Date. Error: %s"), //
JSON_NO_STRING(5009, "JSON [%s] is not a String"), //
JSON_NO_STRING_MEMBER(5010, "JSON [%s:%s] is not a String"), //
JSON_NO_STRING_MEMBER(5010, "JSON [%s:%s] is not a String member"), //
JSON_NO_BOOLEAN(5011, "JSON [%s] is not a Boolean"), //
JSON_NO_BOOLEAN_MEMBER(5012, "JSON [%s:%s] is not a Boolean"), //
JSON_NO_BOOLEAN_MEMBER(5012, "JSON [%s:%s] is not a Boolean member"), //
JSON_NO_NUMBER(5013, "JSON [%s] is not a Number"), //
JSON_NO_NUMBER_MEMBER(5014, "JSON [%s:%s] is not a Number"), //
JSON_NO_NUMBER_MEMBER(5014, "JSON [%s:%s] is not a Number member"), //
JSON_PARSE_ELEMENT_FAILED(5015, "JSON failed to parse [%s]. %s: %s"), //
JSON_PARSE_FAILED(5016, "JSON failed to parse [%s]: %s"), //
JSON_NO_ENUM_MEMBER(5018, "JSON [%s:%s] is not an Enum"), //
JSON_NO_ENUM_MEMBER(5018, "JSON [%s:%s] is not an Enum member"), //
JSON_NO_INET4ADDRESS(5020, "JSON [%s] is not an IPv4 address"), //
JSON_NO_ENUM(5021, "JSON [%s] is not an Enum"), //
JSON_NO_FLOAT(5022, "JSON [%s] is not a Float"), //
JSON_NO_FLOAT_MEMBER(5030, "JSON [%s:%s] is not a Float"), //
JSON_NO_FLOAT_MEMBER(5030, "JSON [%s:%s] is not a Float member"), //
JSON_NO_SHORT(5023, "JSON [%s] is not a Short"), //
JSON_NO_SHORT_MEMBER(5024, "JSON [%s:%s] is not a Short"), //
JSON_NO_SHORT_MEMBER(5024, "JSON [%s:%s] is not a Short member"), //
JSON_NO_LONG(5025, "JSON [%s] is not a Short"), //
JSON_NO_LONG_MEMBER(5026, "JSON [%s:%s] is not a Short"), //
JSON_NO_LONG_MEMBER(5026, "JSON [%s:%s] is not a Short member"), //
JSON_NO_DOUBLE(5027, "JSON [%s] is not a Short"), //
JSON_NO_DOUBLE_MEMBER(5028, "JSON [%s:%s] is not a Short"), //
JSON_NO_DOUBLE_MEMBER(5028, "JSON [%s:%s] is not a Short member"), //
JSON_NO_STRING_ARRAY(5029, "JSON [%s] is not a String Array"), //
JSON_NO_INET4ADDRESS_MEMBER(5031, "JSON [%s:%s] is not a IPv4 address"), //
JSON_NO_INET4ADDRESS_MEMBER(5031, "JSON [%s:%s] is not a IPv4 address member"), //
JSON_NO_UUID(5032, "JSON [%s] is not a UUID"), //
JSON_NO_UUID_MEMBER(5033, "JSON [%s:%s] is not a UUID"), //
JSON_NO_UUID_MEMBER(5033, "JSON [%s:%s] is not a UUID member"), //
/*
* XML Errors. 6000-6999
*/
XML_HAS_NO_MEMBER(6000, "XML [%s] has no member [%s]"), //
XML_NO_STRING_MEMBER(6010, "XML [%s:%s] is not a String"), //
XML_NO_STRING_MEMBER(6010, "XML [%s:%s] is not a String member"), //
;

/**
Expand Down
67 changes: 67 additions & 0 deletions io.openems.common/src/io/openems/common/utils/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,58 @@ public static JsonObjectBuilder buildJsonObject(JsonObject j) {
return new JsonObjectBuilder(j);
}

/**
* Creates a JsonElement from the {@link Number} value.
*
* @param number the {@link Number}
* @return a {@link JsonPrimitive} or {@link JsonNull}
*/
public static JsonElement toJson(Number number) {
if (number == null) {
return JsonNull.INSTANCE;
}
return new JsonPrimitive(number);
}

/**
* Creates a JsonElement from the {@link Boolean} value.
*
* @param bool the {@link Boolean}
* @return a {@link JsonPrimitive} or {@link JsonNull}
*/
public static JsonElement toJson(Boolean bool) {
if (bool == null) {
return JsonNull.INSTANCE;
}
return new JsonPrimitive(bool);
}

/**
* Creates a JsonElement from the {@link Boolean} value.
*
* @param c the {@link Character}
* @return a {@link JsonPrimitive} or {@link JsonNull}
*/
public static JsonElement toJson(Character c) {
if (c == null) {
return JsonNull.INSTANCE;
}
return new JsonPrimitive(c);
}

/**
* Creates a JsonElement from the {@link Boolean} value.
*
* @param string the {@link String}
* @return a {@link JsonPrimitive} or {@link JsonNull}
*/
public static JsonElement toJson(String string) {
if (string == null) {
return JsonNull.INSTANCE;
}
return new JsonPrimitive(string);
}

/**
* Gets the {@link JsonElement} as {@link JsonPrimitive}.
*
Expand Down Expand Up @@ -1698,6 +1750,21 @@ public static JsonElement parse(String string) throws OpenemsNamedException {
}
}

/**
* Parses a string to a {@link Optional} {@link JsonElement}.
*
* @param string to be parsed
* @return the {@link Optional} of the result; {@link Optional#empty()} if the
* value can not be parsed
*/
public static Optional<JsonElement> parseOptional(String string) {
try {
return Optional.of(JsonParser.parseString(string));
} catch (JsonParseException e) {
return Optional.empty();
}
}

/**
* Parses a string to a {@link JsonObject}.
*
Expand Down
Loading

0 comments on commit 08cfbb2

Please sign in to comment.