Skip to content

Commit

Permalink
Merge branch 'main' into fix_tck_tests_finding_terminals
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckLecuyer authored Dec 13, 2024
2 parents 4a3519d + de8b366 commit 589a1e7
Show file tree
Hide file tree
Showing 76 changed files with 1,132 additions and 303 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
push:
branches:
- 'main'
- 'release-v**'
tags:
- 'v[0-9]*'
pull_request:

jobs:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Patch

on:
workflow_dispatch:
inputs:
branchRef:
description: 'Patch branch (format: release-vX.Y.Z)'
required: true
type: string

jobs:
run-patch:
uses: powsybl/github-ci/.github/workflows/patch-backend-lib-generic.yml@859a4effdaa9c5e79684378f39778fd8d06df3c5
with:
githubappId: ${{ vars.POWSYBL_ACTIONS_APPID }}
branchRef: ${{ github.event.inputs.branchRef }}
secrets:
githubappPrivateKey: ${{ secrets.POWSYBL_ACTIONS_SECRET }}
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
workflow_dispatch:
inputs:
versionType:
description: 'Version type increment (major | minor)'
required: true
type: choice
options:
- major
- minor

jobs:
run-release:
uses: powsybl/github-ci/.github/workflows/release-backend-lib-generic.yml@859a4effdaa9c5e79684378f39778fd8d06df3c5
with:
githubappId: ${{ vars.POWSYBL_ACTIONS_APPID }}
versionType: ${{ github.event.inputs.versionType }}
secrets:
githubappPrivateKey: ${{ secrets.POWSYBL_ACTIONS_SECRET }}
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.20.0-SNAPSHOT</version>
<version>1.21.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.20.0-SNAPSHOT</version>
<version>1.21.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.20.0-SNAPSHOT</version>
<version>1.21.0-SNAPSHOT</version>
</parent>

<artifactId>powsybl-network-store-iidm-impl</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
*/
package com.powsybl.network.store.iidm.impl;

import com.powsybl.network.store.model.ExtensionAttributes;
import com.powsybl.network.store.model.IdentifiableAttributes;
import com.powsybl.network.store.model.InjectionAttributes;
import com.powsybl.network.store.model.Resource;
import com.powsybl.network.store.model.*;

import java.util.Map;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import com.powsybl.iidm.network.Injection;
import com.powsybl.iidm.network.Terminal;
import com.powsybl.iidm.network.ThreeSides;
import com.powsybl.iidm.network.ValidationUtil;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import com.powsybl.network.store.model.AbstractIdentifiableAttributes;
import com.powsybl.network.store.model.InjectionAttributes;
import com.powsybl.network.store.model.Resource;

Expand All @@ -26,13 +24,11 @@
*/
public abstract class AbstractInjectionImpl<I extends Injection<I>, D extends InjectionAttributes> extends AbstractConnectableImpl<I, D> implements Injection<I> {

protected final RegulatingPoint regulatingPoint;
protected final TerminalImpl<D> terminal;

protected AbstractInjectionImpl(NetworkObjectIndex index, Resource<D> resource) {
super(index, resource);
terminal = new TerminalImpl<>(index, this, Resource::getAttributes);
regulatingPoint = new RegulatingPoint(index, this, AbstractIdentifiableAttributes.class::cast);
}

protected abstract I getInjection();
Expand All @@ -58,19 +54,6 @@ public <E extends Extension<I>> E createConnectablePositionExtension() {
return extension;
}

protected void setRegTerminal(Terminal regulatingTerminal) {
ValidationUtil.checkRegulatingTerminal(this, regulatingTerminal, getNetwork());
if (regulatingTerminal instanceof TerminalImpl<?>) {
regulatingPoint.setRegulatingTerminal((TerminalImpl<?>) regulatingTerminal);
} else {
regulatingPoint.setRegulatingTerminalAsLocalTerminal();
}
}

public Terminal getRegulatingTerminal() {
return regulatingPoint.getRegulatingTerminal();
}

@Override
public <E extends Extension<I>> E getExtension(Class<? super E> type) {
E extension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@
*/
package com.powsybl.network.store.iidm.impl;

import com.powsybl.iidm.network.LoadingLimits;
import com.powsybl.iidm.network.ValidationLevel;
import com.powsybl.iidm.network.ValidationUtil;
import com.powsybl.iidm.network.*;
import com.powsybl.network.store.model.LimitsAttributes;
import com.powsybl.network.store.model.TemporaryLimitAttributes;

import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;

import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public abstract class AbstractLoadingLimits<S, O extends LimitsOwner<S>, T extends LoadingLimits> implements LoadingLimits {

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractLoadingLimits.class);

public static final class TemporaryLimitImpl implements LoadingLimits.TemporaryLimit {

private final TemporaryLimitAttributes attributes;
Expand Down Expand Up @@ -100,4 +99,52 @@ public double getTemporaryLimitValue(int acceptableDuration) {
LoadingLimits.TemporaryLimit tl = getTemporaryLimit(acceptableDuration);
return tl != null ? tl.getValue() : Double.NaN;
}

@Override
public T setTemporaryLimitValue(int acceptableDuration, double temporaryLimitValue) {
if (temporaryLimitValue < 0 || Double.isNaN(temporaryLimitValue)) {
throw new ValidationException(owner, "Temporary limit value must be a positive double");
}
TemporaryLimitAttributes identifiedLimit = attributes.getTemporaryLimits() == null ? null : attributes.getTemporaryLimits().get(acceptableDuration);
if (identifiedLimit == null) {
throw new ValidationException(owner, "No temporary limit found for the given acceptable duration");
}
TreeMap<Integer, TemporaryLimitAttributes> temporaryLimits = new TreeMap<>(attributes.getTemporaryLimits());
// Creation of index markers
Map.Entry<Integer, TemporaryLimitAttributes> biggerDurationEntry = temporaryLimits.lowerEntry(acceptableDuration);
Map.Entry<Integer, TemporaryLimitAttributes> smallerDurationEntry = temporaryLimits.higherEntry(acceptableDuration);

double previousValue = identifiedLimit.getValue();

if (isTemporaryLimitValueValid(biggerDurationEntry, smallerDurationEntry, acceptableDuration, temporaryLimitValue)) {
LOGGER.info("Temporary limit value changed from {} to {}", previousValue, temporaryLimitValue);
} else {
LOGGER.warn("Temporary limit value changed from {} to {}, but it is not valid", previousValue, temporaryLimitValue);
}
TemporaryLimitAttributes newTemporaryLimit = TemporaryLimitAttributes.builder()
.name(identifiedLimit.getName())
.value(temporaryLimitValue)
.acceptableDuration(acceptableDuration)
.operationalLimitsGroupId(identifiedLimit.getOperationalLimitsGroupId())
.limitType(identifiedLimit.getLimitType())
.build();
attributes.getTemporaryLimits().put(acceptableDuration, newTemporaryLimit);
return (T) this;
}

protected boolean isTemporaryLimitValueValid(Map.Entry<Integer, TemporaryLimitAttributes> biggerDurationEntry,
Map.Entry<Integer, TemporaryLimitAttributes> smallerDurationEntry,
int acceptableDuration,
double temporaryLimitValue) {

boolean checkAgainstSmaller = smallerDurationEntry == null
|| smallerDurationEntry.getValue() != null
&& smallerDurationEntry.getValue().getAcceptableDuration() < acceptableDuration
&& smallerDurationEntry.getValue().getValue() > temporaryLimitValue;
boolean checkAgainstBigger = biggerDurationEntry == null
|| biggerDurationEntry.getValue() != null
&& biggerDurationEntry.getValue().getAcceptableDuration() > acceptableDuration
&& biggerDurationEntry.getValue().getValue() < temporaryLimitValue;
return temporaryLimitValue > attributes.getPermanentLimit() && checkAgainstBigger && checkAgainstSmaller;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.network.store.iidm.impl;

import com.powsybl.iidm.network.Injection;
import com.powsybl.iidm.network.Terminal;
import com.powsybl.iidm.network.ValidationUtil;
import com.powsybl.network.store.model.AbstractRegulatingEquipmentAttributes;
import com.powsybl.network.store.model.InjectionAttributes;
import com.powsybl.network.store.model.Resource;
import lombok.Getter;
import lombok.Setter;

/**
* @author Etienne Lesot <etienne.lesot at rte-france.com>
*/
@Setter
@Getter
public abstract class AbstractRegulatingEquipment<I extends Injection<I>, D extends InjectionAttributes> extends AbstractInjectionImpl<I, D> implements Injection<I> {

protected final RegulatingPoint<I, D> regulatingPoint;

protected AbstractRegulatingEquipment(NetworkObjectIndex index, Resource<D> resource) {
super(index, resource);
regulatingPoint = new RegulatingPoint<>(index, this, AbstractRegulatingEquipmentAttributes.class::cast);
}

// should be setRegulatingTerminal but there is already a method with the same name in the regulating equipments
protected void setRegTerminal(Terminal regulatingTerminal) {
ValidationUtil.checkRegulatingTerminal(this, regulatingTerminal, getNetwork());
if (regulatingTerminal instanceof TerminalImpl<?>) {
regulatingPoint.setRegulatingTerminal((TerminalImpl<?>) regulatingTerminal);
} else {
regulatingPoint.setRegulatingTerminalAsLocalTerminalAndRemoveRegulation();
}
}

public Terminal getRegulatingTerminal() {
return regulatingPoint.getRegulatingTerminal();
}

public Boolean isRegulating() {
return regulatingPoint.isRegulating();
}

public void setRegulating(boolean regulating) {
regulatingPoint.setRegulating(regulating);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ abstract class AbstractTapChanger<H extends TapChangerParent, C extends Abstract
return parent.getTransformer();
}

protected H getParent() {
return parent;
}

protected Resource<?> getResource() {
return getTransformer().getResource();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import com.powsybl.iidm.network.Branch;
import com.powsybl.network.store.model.BranchAttributes;
import com.powsybl.network.store.model.ConnectablePositionAttributes;
import com.powsybl.network.store.model.ResourceType;

import java.util.Map;
import java.util.Objects;

/**
Expand Down Expand Up @@ -132,4 +134,14 @@ public void setPosition(ConnectablePositionAttributes position) {
attributes.setPosition2(position);
}
}

@Override
public Map<String, ResourceType> getRegulatingEquipments() {
return attributes.getRegulatingEquipments();
}

@Override
public void setRegulatingEquipments(Map<String, ResourceType> regulatingEquipments) {
attributes.setRegulatingEquipments(regulatingEquipments);
}
}
Loading

0 comments on commit 589a1e7

Please sign in to comment.