Skip to content

Commit

Permalink
review bis
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
  • Loading branch information
EtienneLt committed Apr 22, 2024
1 parent 7e7234c commit ad3ff1a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ private boolean isOnlyMainCc() {
case ONLY_MAIN_CC, ONLY_MAIN_CC_AND_CONNECTABLE_GENERATORS_AND_SHUNTS, ONLY_MAIN_CC_AND_CONNECTABLE_GENERATORS_AND_SHUNTS_AND_ALL_LOADS ->
true;
case ALL -> false;
default -> throw new IllegalStateException();
};
}

Expand Down Expand Up @@ -331,11 +330,10 @@ private void writeLines(AmplExportContext context, TableFormatter formatter) thr
Terminal t2 = l.getTerminal2();
Bus bus1 = AmplUtil.getBus(t1);
Bus bus2 = AmplUtil.getBus(t2);
if (warnLineConnectedOnSameBus(context, t1, t2, bus1, bus2, l.getId())) {
continue;
if (!warnLineConnectedOnSameBus(context, t1, t2, bus1, bus2, l.getId())) {
columnsExporter.writeLinesToFormatter(formatter, l);
addExtensions(mapper.getInt(AmplSubset.BRANCH, l.getId()), l);
}
columnsExporter.writeLinesToFormatter(formatter, l);
addExtensions(mapper.getInt(AmplSubset.BRANCH, l.getId()), l);
}
}

Expand All @@ -360,11 +358,10 @@ private void writeTieLines(AmplExportContext context, TableFormatter formatter)
Terminal t2 = l.getDanglingLine2().getTerminal();
Bus bus1 = AmplUtil.getBus(t1);
Bus bus2 = AmplUtil.getBus(t2);
if (warnLineConnectedOnSameBus(context, t1, t2, bus1, bus2, l.getId())) {
continue;
if (!warnLineConnectedOnSameBus(context, t1, t2, bus1, bus2, l.getId())) {
columnsExporter.writeTieLineToFormatter(formatter, l);
addExtensions(mapper.getInt(AmplSubset.BRANCH, l.getId()), l);
}
columnsExporter.writeTieLineToFormatter(formatter, l);
addExtensions(mapper.getInt(AmplSubset.BRANCH, l.getId()), l);
}
}

Expand All @@ -376,16 +373,12 @@ private void writeTwoWindingsTransformers(AmplExportContext context, TableFormat
Bus bus2 = AmplUtil.getBus(t2);
if (bus1 != null && bus1 == bus2) {
LOGGER.warn("Skipping transformer '{}' connected to the same bus at both sides", twt.getId());
continue;
} else if (!(isOnlyMainCc() && !(isBusExported(context, AmplUtil.getBusId(bus1)) || isBusExported(context, AmplUtil.getBusId(bus2))))) {
context.voltageLevelIdsToExport.add(t1.getVoltageLevel().getId());
context.voltageLevelIdsToExport.add(t2.getVoltageLevel().getId());
columnsExporter.writeTwoWindingsTranformerToFormatter(formatter, twt);
addExtensions(mapper.getInt(AmplSubset.BRANCH, twt.getId()), twt);
}
if (isOnlyMainCc() && !(isBusExported(context, AmplUtil.getBusId(bus1)) || isBusExported(context,
AmplUtil.getBusId(bus2)))) {
continue;
}
context.voltageLevelIdsToExport.add(t1.getVoltageLevel().getId());
context.voltageLevelIdsToExport.add(t2.getVoltageLevel().getId());
columnsExporter.writeTwoWindingsTranformerToFormatter(formatter, twt);
addExtensions(mapper.getInt(AmplSubset.BRANCH, twt.getId()), twt);
}
}

Expand Down Expand Up @@ -421,17 +414,17 @@ private void writeThreeWindingsTransformers(AmplExportContext context, TableForm

if (!isOnlyMainCc() || isBusExported(context, middleBusId) || isBusExported(context, bus1Id)) {
columnsExporter.writeThreeWindingsTransformerLegToFormatter(formatter, twt, middleBusNum, middleVlNum,
ThreeSides.ONE);
ThreeSides.ONE);
addExtensions(num1, twt);
}
if (!isOnlyMainCc() || isBusExported(context, middleBusId) || isBusExported(context, bus2Id)) {
columnsExporter.writeThreeWindingsTransformerLegToFormatter(formatter, twt, middleBusNum, middleVlNum,
ThreeSides.TWO);
ThreeSides.TWO);
addExtensions(num2, twt);
}
if (!isOnlyMainCc() || isBusExported(context, middleBusId) || isBusExported(context, bus3Id)) {
columnsExporter.writeThreeWindingsTransformerLegToFormatter(formatter, twt, middleBusNum, middleVlNum,
ThreeSides.THREE);
ThreeSides.THREE);
addExtensions(num3, twt);
}
}
Expand All @@ -443,15 +436,14 @@ private void writeDanglingLines(AmplExportContext context, TableFormatter format
Bus bus1 = AmplUtil.getBus(t);
String bus1Id = AmplUtil.getBusId(bus1);
String middleBusId = AmplUtil.getDanglingLineMiddleBusId(dl);
if (isOnlyMainCc() && !(isBusExported(context, bus1Id) || isBusExported(context, middleBusId))) {
continue;
if (!(isOnlyMainCc() && !(isBusExported(context, bus1Id) || isBusExported(context, middleBusId)))) {
VoltageLevel vl = t.getVoltageLevel();
String middleVlId = AmplUtil.getDanglingLineMiddleVoltageLevelId(dl);
context.voltageLevelIdsToExport.add(vl.getId());
context.voltageLevelIdsToExport.add(middleVlId);
columnsExporter.writeDanglingLineToFormatter(formatter, dl);
addExtensions(mapper.getInt(AmplSubset.BRANCH, dl.getId()), dl);
}
VoltageLevel vl = t.getVoltageLevel();
String middleVlId = AmplUtil.getDanglingLineMiddleVoltageLevelId(dl);
context.voltageLevelIdsToExport.add(vl.getId());
context.voltageLevelIdsToExport.add(middleVlId);
columnsExporter.writeDanglingLineToFormatter(formatter, dl);
addExtensions(mapper.getInt(AmplSubset.BRANCH, dl.getId()), dl);
}
}

Expand Down Expand Up @@ -535,20 +527,19 @@ private void writeLoads(AmplExportContext context) throws IOException {
}
if (!exportLoad(context, busId)) {
skipped.add(l.getId());
continue;
} else {
context.loadsToExport.add(l.getId());
columnsExporter.writeLoadtoFormatter(formatter, l);
addExtensions(mapper.getInt(AmplSubset.LOAD, l.getId()), l);
}
context.loadsToExport.add(l.getId());

columnsExporter.writeLoadtoFormatter(formatter, l);
addExtensions(mapper.getInt(AmplSubset.LOAD, l.getId()), l);
}
for (DanglingLine dl : getSortedIdentifiables(network.getDanglingLineStream(DanglingLineFilter.UNPAIRED))) {
String middleBusId = AmplUtil.getDanglingLineMiddleBusId(dl);
if (!exportLoad(context, middleBusId)) {
skipped.add(dl.getId());
continue;
} else {
columnsExporter.writeDanglingLineLoadToFormatter(formatter, dl);
}
columnsExporter.writeDanglingLineLoadToFormatter(formatter, dl);
}
if (!skipped.isEmpty()) {
LOGGER.trace("Skip loads {} because not connected and not connectable", skipped);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ A getChunk2() {
/**
* Append the chunk with the one given in argument, and return the result. "This" dataChunk and the one in argument remain unchanged.
* The two chunks have to be successive, i.e : this.getOffset() + this.length() = otherChunk.getOffset()
* @param otherChunk : the chunk to append with this object. It has to be the same implementation as this object.
* @param otherChunk the chunk to append with this object. It has to be the same implementation as this object.
*/
A append(A otherChunk);

Expand Down

0 comments on commit ad3ff1a

Please sign in to comment.