Skip to content

Commit

Permalink
Add voltage level id in bus modifications
Browse files Browse the repository at this point in the history
Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
  • Loading branch information
FranckLecuyer committed Jul 9, 2024
1 parent 60ed855 commit 5adc0ea
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
@Getter
@Setter
public class BusModificationInfos {
private String voltageLevelId;

private String busId;

@JsonInclude(JsonInclude.Include.NON_NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
@AllArgsConstructor
@NoArgsConstructor
public class BusVoltage {
private String voltageLevelId;

private String busId;

private double v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
@NoArgsConstructor
@Embeddable
public class BusVoltageEmbeddable {
@Column
private String voltageLevelId;

@Column
private String busId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public UUID createVoltageInitModificationGroup(Network network, OpenReacResult r
Bus bus = network.getBusView().getBus(busId);
if (bus != null) {
BusModificationInfos.BusModificationInfosBuilder builder = BusModificationInfos.builder()
.voltageLevelId(bus.getVoltageLevel().getId())
.busId(busId)
.v(voltage.getFirst() * bus.getVoltageLevel().getNominalV())
.angle(Math.toDegrees(voltage.getSecond()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static VoltageInitResultEntity toVoltageInitResultEntity(UUID resultUuid
.map(vp -> {
Bus b = networkBuses.get(vp.getKey());
if (b != null) {
return new BusVoltageEmbeddable(vp.getKey(),
return new BusVoltageEmbeddable(b.getVoltageLevel().getId(), vp.getKey(),
vp.getValue().getFirst() * b.getVoltageLevel().getNominalV(),
Math.toDegrees(vp.getValue().getSecond()));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private static VoltageInitResult fromEntity(VoltageInitResultEntity resultEntity
.map(slack -> new ReactiveSlack(slack.getBusId(), slack.getSlack()))
.toList();
List<BusVoltage> busVoltages = resultEntity.getBusVoltages().stream()
.map(bv -> new BusVoltage(bv.getBusId(), bv.getV(), bv.getAngle()))
.map(bv -> new BusVoltage(bv.getVoltageLevelId(), bv.getBusId(), bv.getV(), bv.getAngle()))
.toList();
return new VoltageInitResult(resultEntity.getResultUuid(), resultEntity.getWriteTimeStamp(), sortedIndicators,
reactiveSlacks, busVoltages, resultEntity.getModificationsGroupUuid(), resultEntity.isReactiveSlacksOverThreshold(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="lecuyerfra (generated)" id="1720514658234-5">
<addColumn tableName="voltage_init_result_entity_bus_voltages">
<column name="voltage_level_id" type="varchar(255)"/>
</addColumn>
</changeSet>
</databaseChangeLog>
3 changes: 3 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ databaseChangeLog:
- include:
file: changesets/changelog_20240529T153656Z.xml
relativeToChangelogFile: true
- include:
file: changesets/changelog_20240709T084348Z.xml
relativeToChangelogFile: true

0 comments on commit 5adc0ea

Please sign in to comment.