Skip to content

Commit

Permalink
Merge branch 'main' into fixsyncv
Browse files Browse the repository at this point in the history
  • Loading branch information
jonenst authored Jan 8, 2025
2 parents 101cb6f + 6362071 commit a824b15
Show file tree
Hide file tree
Showing 62 changed files with 996 additions and 240 deletions.
2 changes: 1 addition & 1 deletion network-store-client-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-client-parent</artifactId>
<version>1.21.0-SNAPSHOT</version>
<version>1.22.0-SNAPSHOT</version>
</parent>

<artifactId>powsybl-network-store-client-distribution</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion network-store-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-client-parent</artifactId>
<version>1.21.0-SNAPSHOT</version>
<version>1.22.0-SNAPSHOT</version>
</parent>

<artifactId>powsybl-network-store-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion network-store-iidm-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<artifactId>powsybl-network-store-client-parent</artifactId>
<groupId>com.powsybl</groupId>
<version>1.21.0-SNAPSHOT</version>
<version>1.22.0-SNAPSHOT</version>
</parent>

<artifactId>powsybl-network-store-iidm-impl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,8 @@ public TwoSides getSide(Terminal terminal) {
}
}

public void notifyUpdate(String attribute, Object oldValue, Object newValue, boolean withVariantId) {
if (withVariantId) {
index.notifyUpdate(this, attribute, index.getNetwork().getVariantManager().getWorkingVariantId(), oldValue, newValue);
} else {
index.notifyUpdate(this, attribute, oldValue, newValue);
}
public void notifyUpdate(String attribute, Object oldValue, Object newValue) {
index.notifyUpdate(this, attribute, index.getNetwork().getVariantManager().getWorkingVariantId(), oldValue, newValue);
}

private String getSelectedOperationalLimitsGroupId(TwoSides side) {
Expand All @@ -110,14 +106,14 @@ public void setCurrentLimits(TwoSides side, LimitsAttributes currentLimits, Stri
var oldCurrentLimits = operationalLimitsGroup != null ? operationalLimitsGroup.getCurrentLimits() : null;
if (currentLimits != oldCurrentLimits) {
updateResource(res -> res.getAttributes().getOrCreateOperationalLimitsGroup1(operationalLimitsGroupId).setCurrentLimits(currentLimits));
index.notifyUpdate(this, "currentLimits1", oldCurrentLimits, currentLimits);
index.notifyUpdate(this, "currentLimits1", index.getNetwork().getVariantManager().getWorkingVariantId(), oldCurrentLimits, currentLimits);
}
} else if (side == TwoSides.TWO) {
var operationalLimitsGroup = attributes.getOperationalLimitsGroup2(operationalLimitsGroupId);
var oldCurrentLimits = operationalLimitsGroup != null ? operationalLimitsGroup.getCurrentLimits() : null;
if (currentLimits != oldCurrentLimits) {
updateResource(res -> res.getAttributes().getOrCreateOperationalLimitsGroup2(operationalLimitsGroupId).setCurrentLimits(currentLimits));
index.notifyUpdate(this, "currentLimits2", oldCurrentLimits, currentLimits);
index.notifyUpdate(this, "currentLimits2", index.getNetwork().getVariantManager().getWorkingVariantId(), oldCurrentLimits, currentLimits);
}
}
}
Expand Down Expand Up @@ -198,14 +194,14 @@ public void setApparentPowerLimits(TwoSides side, LimitsAttributes apparentPower
var oldApparentPowerLimits = operationalLimitsGroup != null ? operationalLimitsGroup.getApparentPowerLimits() : null;
if (apparentPowerLimitsAttributes != oldApparentPowerLimits) {
updateResource(res -> res.getAttributes().getOrCreateOperationalLimitsGroup1(operationalLimitsGroupId).setApparentPowerLimits(apparentPowerLimitsAttributes));
index.notifyUpdate(this, "apparentPowerLimits1", oldApparentPowerLimits, apparentPowerLimitsAttributes);
index.notifyUpdate(this, "apparentPowerLimits1", index.getNetwork().getVariantManager().getWorkingVariantId(), oldApparentPowerLimits, apparentPowerLimitsAttributes);
}
} else if (side == TwoSides.TWO) {
var operationalLimitsGroup = attributes.getOperationalLimitsGroup2(operationalLimitsGroupId);
var oldApparentPowerLimits = operationalLimitsGroup != null ? operationalLimitsGroup.getApparentPowerLimits() : null;
if (apparentPowerLimitsAttributes != oldApparentPowerLimits) {
updateResource(res -> res.getAttributes().getOrCreateOperationalLimitsGroup2(operationalLimitsGroupId).setApparentPowerLimits(apparentPowerLimitsAttributes));
index.notifyUpdate(this, "apparentPowerLimits2", oldApparentPowerLimits, apparentPowerLimitsAttributes);
index.notifyUpdate(this, "apparentPowerLimits2", index.getNetwork().getVariantManager().getWorkingVariantId(), oldApparentPowerLimits, apparentPowerLimitsAttributes);
}
}
}
Expand Down Expand Up @@ -278,14 +274,14 @@ public void setActivePowerLimits(TwoSides side, LimitsAttributes activePowerLimi
var oldActivePowerLimits = operationalLimitsGroup != null ? operationalLimitsGroup.getActivePowerLimits() : null;
if (activePowerLimitsAttributes != oldActivePowerLimits) {
updateResource(res -> res.getAttributes().getOrCreateOperationalLimitsGroup1(operationalLimitsGroupId).setActivePowerLimits(activePowerLimitsAttributes));
index.notifyUpdate(this, "activePowerLimits1", oldActivePowerLimits, activePowerLimitsAttributes);
index.notifyUpdate(this, "activePowerLimits1", index.getNetwork().getVariantManager().getWorkingVariantId(), oldActivePowerLimits, activePowerLimitsAttributes);
}
} else if (side == TwoSides.TWO) {
var operationalLimitsGroup = attributes.getOperationalLimitsGroup2(operationalLimitsGroupId);
var oldActivePowerLimits = operationalLimitsGroup != null ? operationalLimitsGroup.getActivePowerLimits() : null;
if (activePowerLimitsAttributes != oldActivePowerLimits) {
updateResource(res -> res.getAttributes().getOrCreateOperationalLimitsGroup2(operationalLimitsGroupId).setActivePowerLimits(activePowerLimitsAttributes));
index.notifyUpdate(this, "activePowerLimits2", oldActivePowerLimits, activePowerLimitsAttributes);
index.notifyUpdate(this, "activePowerLimits2", index.getNetwork().getVariantManager().getWorkingVariantId(), oldActivePowerLimits, activePowerLimitsAttributes);
}
}
}
Expand Down Expand Up @@ -367,7 +363,7 @@ public void setSelectedOperationalLimitsGroup1(String id) {
String oldValue = resource.getAttributes().getSelectedOperationalLimitsGroupId1();
if (!id.equals(oldValue)) {
updateResource(res -> res.getAttributes().setSelectedOperationalLimitsGroupId1(id));
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID1, oldValue, id);
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID1, index.getNetwork().getVariantManager().getWorkingVariantId(), oldValue, id);
}
}

Expand All @@ -380,7 +376,7 @@ public void removeOperationalLimitsGroup1(String id) {

if (id.equals(resource.getAttributes().getSelectedOperationalLimitsGroupId1())) {
resource.getAttributes().setSelectedOperationalLimitsGroupId1(null);
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID1, id, null);
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID1, index.getNetwork().getVariantManager().getWorkingVariantId(), id, null);
}
updateResource(res -> res.getAttributes().getOperationalLimitsGroups1().remove(id));
}
Expand All @@ -391,7 +387,7 @@ public void cancelSelectedOperationalLimitsGroup1() {
String oldValue = resource.getAttributes().getSelectedOperationalLimitsGroupId1();
if (oldValue != null) {
updateResource(res -> res.getAttributes().setSelectedOperationalLimitsGroupId1(null));
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID1, oldValue, null);
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID1, index.getNetwork().getVariantManager().getWorkingVariantId(), oldValue, null);
}
}

Expand Down Expand Up @@ -433,7 +429,7 @@ public void setSelectedOperationalLimitsGroup2(String id) {
String oldValue = resource.getAttributes().getSelectedOperationalLimitsGroupId2();
if (!id.equals(oldValue)) {
updateResource(res -> res.getAttributes().setSelectedOperationalLimitsGroupId2(id));
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID2, oldValue, id);
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID2, index.getNetwork().getVariantManager().getWorkingVariantId(), oldValue, id);
}
}

Expand All @@ -445,7 +441,7 @@ public void removeOperationalLimitsGroup2(String id) {
}
if (id.equals(resource.getAttributes().getSelectedOperationalLimitsGroupId2())) {
resource.getAttributes().setSelectedOperationalLimitsGroupId2(null);
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID2, id, null);
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID2, index.getNetwork().getVariantManager().getWorkingVariantId(), id, null);
}
updateResource(res -> res.getAttributes().getOperationalLimitsGroups2().remove(id));

Expand All @@ -457,7 +453,7 @@ public void cancelSelectedOperationalLimitsGroup2() {
String oldValue = resource.getAttributes().getSelectedOperationalLimitsGroupId2();
if (oldValue != null) {
updateResource(res -> res.getAttributes().setSelectedOperationalLimitsGroupId2(null));
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID2, oldValue, null);
index.notifyUpdate(this, SELECTED_OPERATIONAL_LIMITS_GROUP_ID2, index.getNetwork().getVariantManager().getWorkingVariantId(), oldValue, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public I setName(String name) {
String oldName = getResource().getAttributes().getName();
if (!Objects.equals(oldName, name)) {
updateResource(r -> r.getAttributes().setName(name));
index.notifyUpdate(this, "name", oldName, name);
index.notifyUpdate(this, "name", getNetwork().getVariantManager().getWorkingVariantId(), oldName, name);
}
return (I) this;
}
Expand Down Expand Up @@ -255,9 +255,9 @@ public String setProperty(String key, String value) {
});

if (Objects.isNull(oldValue.getValue())) {
index.notifyElementAdded(this, () -> "properties[" + key + "]", value);
index.notifyPropertyAdded(this, () -> "properties[" + key + "]", value);
} else {
index.notifyElementReplaced(this, () -> "properties[" + key + "]", oldValue.getValue(), value);
index.notifyPropertyReplaced(this, () -> "properties[" + key + "]", oldValue.getValue(), value);
}
return oldValue.getValue();
}
Expand All @@ -278,7 +278,7 @@ public boolean removeProperty(String key) {
if (properties != null && properties.containsKey(key)) {
String oldValue = properties.get(key);
updateResource(r -> r.getAttributes().getProperties().remove(key));
index.notifyElementRemoved(this, () -> "properties[" + key + "]", oldValue);
index.notifyPropertyRemoved(this, () -> "properties[" + key + "]", oldValue);
return true;
}
return false;
Expand Down Expand Up @@ -321,6 +321,7 @@ public <E extends Extension<I>> boolean removeExtension(Class<E> type) {
if (extension == null) {
return false;
}
extension.cleanup();
index.notifyExtensionBeforeRemoval(extension);
index.removeExtensionAttributes(resource.getType(), resource.getId(), extension.getName());
index.notifyExtensionAfterRemoval(this, extension.getName());
Expand Down Expand Up @@ -355,7 +356,7 @@ public void setFictitious(boolean fictitious) {
boolean oldValue = getResource().getAttributes().isFictitious();
if (fictitious != oldValue) {
updateResource(r -> r.getAttributes().setFictitious(fictitious));
index.notifyUpdate(this, "fictitious", oldValue, fictitious);
index.notifyUpdate(this, "fictitious", getNetwork().getVariantManager().getWorkingVariantId(), oldValue, fictitious);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ protected Resource<?> getResource() {

protected abstract TapChangerAttributes getAttributes(Resource<?> resource);

protected void notifyUpdate(Supplier<String> attribute, Object oldValue, Object newValue) {
notifyUpdate(attribute.get(), oldValue, newValue);
}

protected void notifyUpdate(String attribute, Object oldValue, Object newValue) {
index.notifyUpdate(getTransformer(), attribute, oldValue, newValue);
}

protected void notifyUpdate(Supplier<String> attribute, String variantId, Object oldValue, Object newValue) {
index.notifyUpdate(getTransformer(), attribute.get(), variantId, oldValue, newValue);
}
Expand All @@ -73,7 +65,7 @@ public C setLowTapPosition(int lowTapPosition) {
int oldValue = getAttributes().getLowTapPosition();
if (lowTapPosition != oldValue) {
getTransformer().updateResource(res -> getAttributes(res).setLowTapPosition(lowTapPosition));
notifyUpdate(() -> getTapChangerAttribute() + ".lowTapPosition", oldValue, lowTapPosition);
notifyUpdate(() -> getTapChangerAttribute() + ".lowTapPosition", index.getNetwork().getVariantManager().getWorkingVariantId(), oldValue, lowTapPosition);
}
return (C) this;
}
Expand Down Expand Up @@ -122,7 +114,7 @@ public C setRegulationTerminal(Terminal regulatingTerminal) {
}
TerminalRefAttributes oldValue = getAttributes().getRegulatingTerminal();
getTransformer().updateResource(res -> getAttributes(res).setRegulatingTerminal(TerminalRefUtils.getTerminalRefAttributes(regulatingTerminal)));
notifyUpdate(() -> getTapChangerAttribute() + ".regulationTerminal", oldValue, TerminalRefUtils.getTerminalRefAttributes(regulatingTerminal));
notifyUpdate(() -> getTapChangerAttribute() + ".regulationTerminal", index.getNetwork().getVariantManager().getWorkingVariantId(), oldValue, TerminalRefUtils.getTerminalRefAttributes(regulatingTerminal));
return (C) this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public Battery setMinP(double minP) {
double oldValue = getResource().getAttributes().getMinP();
if (minP != oldValue) {
updateResource(res -> res.getAttributes().setMinP(minP));
index.notifyUpdate(this, "minP", oldValue, minP);
String variantId = getNetwork().getVariantManager().getWorkingVariantId();
index.notifyUpdate(this, "minP", variantId, oldValue, minP);
}
return this;

Expand All @@ -94,7 +95,8 @@ public Battery setMaxP(double maxP) {
double oldValue = getResource().getAttributes().getMaxP();
if (maxP != oldValue) {
updateResource(res -> res.getAttributes().setMaxP(maxP));
index.notifyUpdate(this, "maxP", oldValue, maxP);
String variantId = getNetwork().getVariantManager().getWorkingVariantId();
index.notifyUpdate(this, "maxP", variantId, oldValue, maxP);
}
return this;

Expand All @@ -106,7 +108,8 @@ public void setReactiveLimits(ReactiveLimitsAttributes reactiveLimits) {
ReactiveLimitsAttributes oldValue = resource.getAttributes().getReactiveLimits();
resource.getAttributes().setReactiveLimits(reactiveLimits);
updateResource(res -> res.getAttributes().setReactiveLimits(reactiveLimits));
index.notifyUpdate(this, "reactiveLimits", oldValue, reactiveLimits);
String variantId = getNetwork().getVariantManager().getWorkingVariantId();
index.notifyUpdate(this, "reactiveLimits", variantId, oldValue, reactiveLimits);
}

@Override
Expand Down Expand Up @@ -150,6 +153,7 @@ public void remove() {
index.notifyBeforeRemoval(this);
for (Terminal terminal : getTerminals()) {
((TerminalImpl<?>) terminal).removeAsRegulatingPoint();
((TerminalImpl<?>) terminal).getReferrerManager().notifyOfRemoval();
}
// invalidate calculated buses before removal otherwise voltage levels won't be accessible anymore for topology invalidation!
invalidateCalculatedBuses(getTerminals());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public void setP(double p) {
if (side1) {
double oldValue = attributes.getP1();
attributes.setP1(p);
branch.notifyUpdate("p1", oldValue, p, true);
branch.notifyUpdate("p1", oldValue, p);
} else {
double oldValue = attributes.getP2();
attributes.setP2(p);
branch.notifyUpdate("p2", oldValue, p, true);
branch.notifyUpdate("p2", oldValue, p);
}
}

Expand All @@ -113,11 +113,11 @@ public void setQ(double q) {
if (side1) {
double oldValue = attributes.getQ1();
attributes.setQ1(q);
branch.notifyUpdate("q1", oldValue, q, true);
branch.notifyUpdate("q1", oldValue, q);
} else {
double oldValue = attributes.getQ2();
attributes.setQ2(q);
branch.notifyUpdate("q2", oldValue, q, true);
branch.notifyUpdate("q2", oldValue, q);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void remove() {
index.notifyBeforeRemoval(this);
for (Terminal terminalImpl : getTerminals()) {
((TerminalImpl<?>) terminalImpl).removeAsRegulatingPoint();
((TerminalImpl<?>) terminalImpl).getReferrerManager().notifyOfRemoval();
}
// invalidate calculated buses before removal otherwise voltage levels won't be accessible anymore for topology invalidation!
invalidateCalculatedBuses(getTerminals());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public static void closeSwitches(NetworkObjectIndex index, Set<SwitchImpl> switc
// Update the resource
index.updateSwitchResource(switchImpl.getResource());
// Notify update
index.notifyUpdate(index.getSwitch(switchImpl.getResource().getId()).orElseThrow(), "open", true, false);
index.notifyUpdate(index.getSwitch(switchImpl.getResource().getId()).orElseThrow(),
"open", index.getNetwork().getVariantManager().getWorkingVariantId(), true, false);
});
}

Expand Down Expand Up @@ -168,7 +169,8 @@ public static void openSwitches(NetworkObjectIndex index, Set<SwitchImpl> switch
// Update the resource
index.updateSwitchResource(switchImpl.getResource());
// Notify update
index.notifyUpdate(index.getSwitch(switchImpl.getResource().getId()).orElseThrow(), "open", false, true);
index.notifyUpdate(index.getSwitch(switchImpl.getResource().getId()).orElseThrow(),
"open", index.getNetwork().getVariantManager().getWorkingVariantId(), false, true);
});
}
}
Expand Down
Loading

0 comments on commit a824b15

Please sign in to comment.