Skip to content

Commit

Permalink
Fix OverloadManagementSystem binary serialization error when having t…
Browse files Browse the repository at this point in the history
…rippings without name (#3176)

* fix: OverloadManagementSystem did not serialize to binary when a tripping had no name
* refactor: change error message from exception part to comment

Signed-off-by: CHIQUET Benoit <[email protected]>
  • Loading branch information
bc-rte authored Nov 7, 2024
1 parent dcb2338 commit 6bab812
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private String readString() {
}
byte[] stringBytes = dis.readNBytes(stringNbBytes);
if (stringBytes.length != stringNbBytes) {
// this may happen when the attribute wasn't written in the first place, causing string length to be an aberrant number
throw new PowsyblException("Cannot read the full string, bytes missing: " + (stringNbBytes - stringBytes.length));
}
return new String(stringBytes, StandardCharsets.UTF_8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ private void writeTrippingCommonAttributes(OverloadManagementSystem.Tripping tri
String nameOrKey = tripping.getNameOrKey();
if (nameOrKey != null && !nameOrKey.equals(tripping.getKey())) {
context.getWriter().writeStringAttribute("name", nameOrKey);
} else {
context.getWriter().writeStringAttribute("name", null);
}
context.getWriter().writeDoubleAttribute("currentLimit", tripping.getCurrentLimit());
context.getWriter().writeBooleanAttribute("openAction", tripping.isOpenAction());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ private static Network createNetwork() {
.setOpenAction(true)
.setSwitchToOperateId("S1_400_LINE_2_BREAKER")
.add()
.newSwitchTripping()
.setKey("trippingWithNoName")
.setCurrentLimit(800)
.setOpenAction(true)
.setSwitchToOperateId("S1_400_LINE_2_BREAKER")
.add()
.add();

// Create an overload management system monitoring "LINE_1" with a tripping on "LINE_2".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<iidm:branchTripping key="tripping1" name="1st tripping name" currentLimit="1200.0" openAction="true" branchId="2WT" side="ONE"/>
<iidm:threeWindingsTransformerTripping key="tripping2" name="2nd tripping name" currentLimit="1000.0" openAction="false" threeWindingsTransformerId="3WT" side="ONE"/>
<iidm:switchTripping key="tripping3" name="3rd tripping name" currentLimit="1000.0" openAction="true" switchId="S1_400_LINE_2_BREAKER"/>
<iidm:switchTripping key="trippingWithNoName" currentLimit="800.0" openAction="true" switchId="S1_400_LINE_2_BREAKER"/>
</iidm:overloadManagementSystem>
<iidm:overloadManagementSystem id="OMS2" name="2nd OMS" enabled="true" monitoredElementId="LINE_1" side="ONE">
<iidm:branchTripping key="tripping" name="tripping name" currentLimit="1300.0" openAction="true" branchId="LINE_2" side="ONE"/>
Expand Down

0 comments on commit 6bab812

Please sign in to comment.