Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move regulating from regulating equipment to regulatingPoint #85

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public class Mappings {
private static final String SELECTED_OPERATIONAL_LIMITS_GROUP_ID_COLUMN = "selectedOperationalLimitsGroupId";
private static final String SELECTED_OPERATIONAL_LIMITS_GROUP_ID1_COLUMN = "selectedOperationalLimitsGroupId1";
private static final String SELECTED_OPERATIONAL_LIMITS_GROUP_ID2_COLUMN = "selectedOperationalLimitsGroupId2";
private static final String VOLTAGE_REGULATOR_ON = "voltageRegulatorOn";
private static final String MINQ = "minQ";
private static final String MAXQ = "maxQ";
private static final String TIE_LINE_ID = "tieLineId";
Expand Down Expand Up @@ -216,7 +215,6 @@ private void createGeneratorMappings() {
generatorMappings.addColumnMapping("p", new ColumnMapping<>(Double.class, GeneratorAttributes::getP, GeneratorAttributes::setP));
generatorMappings.addColumnMapping("q", new ColumnMapping<>(Double.class, GeneratorAttributes::getQ, GeneratorAttributes::setQ));
generatorMappings.addColumnMapping(FICTITIOUS, new ColumnMapping<>(Boolean.class, GeneratorAttributes::isFictitious, GeneratorAttributes::setFictitious));
generatorMappings.addColumnMapping(VOLTAGE_REGULATOR_ON, new ColumnMapping<>(Boolean.class, GeneratorAttributes::isVoltageRegulatorOn, GeneratorAttributes::setVoltageRegulatorOn));
EtienneLt marked this conversation as resolved.
Show resolved Hide resolved
generatorMappings.addColumnMapping("targetP", new ColumnMapping<>(Double.class, GeneratorAttributes::getTargetP, GeneratorAttributes::setTargetP));
generatorMappings.addColumnMapping("targetQ", new ColumnMapping<>(Double.class, GeneratorAttributes::getTargetQ, GeneratorAttributes::setTargetQ));
generatorMappings.addColumnMapping("targetV", new ColumnMapping<>(Double.class, GeneratorAttributes::getTargetV, GeneratorAttributes::setTargetV));
Expand Down Expand Up @@ -483,7 +481,6 @@ private void createShuntCompensatorMappings() {
shuntCompensatorMappings.addColumnMapping("p", new ColumnMapping<>(Double.class, ShuntCompensatorAttributes::getP, ShuntCompensatorAttributes::setP));
shuntCompensatorMappings.addColumnMapping("q", new ColumnMapping<>(Double.class, ShuntCompensatorAttributes::getQ, ShuntCompensatorAttributes::setQ));
shuntCompensatorMappings.addColumnMapping(FICTITIOUS, new ColumnMapping<>(Boolean.class, ShuntCompensatorAttributes::isFictitious, ShuntCompensatorAttributes::setFictitious));
shuntCompensatorMappings.addColumnMapping(VOLTAGE_REGULATOR_ON, new ColumnMapping<>(Boolean.class, ShuntCompensatorAttributes::isVoltageRegulatorOn, ShuntCompensatorAttributes::setVoltageRegulatorOn));
shuntCompensatorMappings.addColumnMapping("targetV", new ColumnMapping<>(Double.class, ShuntCompensatorAttributes::getTargetV, ShuntCompensatorAttributes::setTargetV));
shuntCompensatorMappings.addColumnMapping("targetDeadband", new ColumnMapping<>(Double.class, ShuntCompensatorAttributes::getTargetDeadband, ShuntCompensatorAttributes::setTargetDeadband));
shuntCompensatorMappings.addColumnMapping("linearModel", new ColumnMapping<>(ShuntCompensatorModelAttributes.class, (ShuntCompensatorAttributes attributes) ->
Expand Down Expand Up @@ -517,7 +514,6 @@ private void createVscConverterStationMappings() {
vscConverterStationMappings.addColumnMapping(VOLTAGE_LEVEL_ID, new ColumnMapping<>(String.class, VscConverterStationAttributes::getVoltageLevelId, VscConverterStationAttributes::setVoltageLevelId));
vscConverterStationMappings.addColumnMapping("bus", new ColumnMapping<>(String.class, VscConverterStationAttributes::getBus, VscConverterStationAttributes::setBus));
vscConverterStationMappings.addColumnMapping(CONNECTABLE_BUS, new ColumnMapping<>(String.class, VscConverterStationAttributes::getConnectableBus, VscConverterStationAttributes::setConnectableBus));
vscConverterStationMappings.addColumnMapping(VOLTAGE_REGULATOR_ON, new ColumnMapping<>(Boolean.class, VscConverterStationAttributes::getVoltageRegulatorOn, VscConverterStationAttributes::setVoltageRegulatorOn));
vscConverterStationMappings.addColumnMapping("p", new ColumnMapping<>(Double.class, VscConverterStationAttributes::getP, VscConverterStationAttributes::setP));
vscConverterStationMappings.addColumnMapping("q", new ColumnMapping<>(Double.class, VscConverterStationAttributes::getQ, VscConverterStationAttributes::setQ));
vscConverterStationMappings.addColumnMapping("lossFactor", new ColumnMapping<>(Float.class, VscConverterStationAttributes::getLossFactor, VscConverterStationAttributes::setLossFactor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ private <T extends IdentifiableAttributes> void deletePermanentLimits(UUID netwo
public void insertRegulatingPoints(Map<OwnerInfo, RegulatingPointAttributes> regulatingPoints) {
try (var connection = dataSource.getConnection()) {
try (var preparedStmt = connection.prepareStatement(QueryCatalog.buildInsertRegulatingPointsQuery())) {
List<Object> values = new ArrayList<>(10);
List<Object> values = new ArrayList<>(11);
List<Map.Entry<OwnerInfo, RegulatingPointAttributes>> list = new ArrayList<>(regulatingPoints.entrySet());
for (List<Map.Entry<OwnerInfo, RegulatingPointAttributes>> subUnit : Lists.partition(list, BATCH_SIZE)) {
for (Map.Entry<OwnerInfo, RegulatingPointAttributes> attributes : subUnit) {
Expand All @@ -2124,12 +2124,15 @@ public void insertRegulatingPoints(Map<OwnerInfo, RegulatingPointAttributes> reg
values.add(attributes.getValue().getRegulatedResourceType() != null
? attributes.getValue().getRegulatedResourceType().toString()
: null);
values.add(attributes.getValue().getRegulating() != null
? attributes.getValue().getRegulating() : null);
} else {
values.add(null);
values.add(attributes.getKey().getEquipmentId());
for (int i = 0; i < 4; i++) {
values.add(null);
}
values.add(false);
}
bindValues(preparedStmt, values, mapper);
preparedStmt.addBatch();
Expand Down Expand Up @@ -2157,6 +2160,7 @@ public void updateRegulatingPoints(Map<OwnerInfo, RegulatingPointAttributes> reg
values.add(regulatingTerminal != null ? regulatingTerminal.getConnectableId() : null);
values.add(regulatingTerminal != null ? regulatingTerminal.getSide() : null);
values.add(attributes.getValue().getRegulatedResourceType() != null ? attributes.getValue().getRegulatedResourceType().toString() : null);
values.add(attributes.getValue().getRegulating());
// where values
values.add(attributes.getKey().getNetworkUuid());
values.add(attributes.getKey().getVariantNum());
Expand Down Expand Up @@ -2401,6 +2405,7 @@ private Map<OwnerInfo, RegulatingPointAttributes> innerGetRegulatingPoints(Prepa
if (regulatingConnectableId.isPresent()) {
regulatingPointAttributes.setRegulatingTerminal(new TerminalRefAttributes(resultSet.getString(7), resultSet.getString(8)));
}
regulatingPointAttributes.setRegulating(resultSet.getBoolean(9));
map.put(owner, regulatingPointAttributes);
}
return map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public final class QueryCatalog {
static final String REGULATION_MODE = "regulationMode";
static final String SIDE_COLUMN = "side";
static final String LIMIT_TYPE_COLUMN = "limitType";
static final String REGULATING = "regulating";

private QueryCatalog() {
}
Expand Down Expand Up @@ -496,16 +497,18 @@ public static String buildDeleteReactiveCapabilityCurvePointsQuery() {
public static String buildInsertRegulatingPointsQuery() {
return "insert into " + REGULATING_POINT_TABLE + " (" +
NETWORK_UUID_COLUMN + " ," + VARIANT_NUM_COLUMN + ", " + REGULATING_EQUIPMENT_ID + ", " + REGULATING_EQUIPMENT_TYPE_COLUMN + ", " +
REGULATION_MODE + ", localTerminalConnectableId, localTerminalSide, regulatingterminalconnectableid, regulatingterminalside, " + REGULATED_EQUIPMENT_TYPE_COLUMN + ")" +
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
REGULATION_MODE + ", localTerminalConnectableId, localTerminalSide, regulatingterminalconnectableid, regulatingterminalside, " +
REGULATED_EQUIPMENT_TYPE_COLUMN + ", " + REGULATING + ")" +
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
}

public static String buildUpdateRegulatingPointsQuery() {
return "Update " + REGULATING_POINT_TABLE +
" set " + REGULATION_MODE + " = ?, " +
"regulatingterminalconnectableid = ?, " +
"regulatingterminalside = ?, " +
REGULATED_EQUIPMENT_TYPE_COLUMN + " = ? " +
REGULATED_EQUIPMENT_TYPE_COLUMN + " = ?, " +
REGULATING + " = ? " +
"where " +
NETWORK_UUID_COLUMN + " = ? AND " +
VARIANT_NUM_COLUMN + " = ? AND " +
Expand All @@ -517,10 +520,10 @@ public static String buildCloneRegulatingPointsQuery() {
return "insert into " + REGULATING_POINT_TABLE + " (" + NETWORK_UUID_COLUMN + " ," + VARIANT_NUM_COLUMN + ", " +
REGULATING_EQUIPMENT_ID + ", " + REGULATING_EQUIPMENT_TYPE_COLUMN + ", " + REGULATION_MODE +
", localTerminalConnectableId, localTerminalSide, regulatingTerminalConnectableId, regulatingTerminalSide, " +
REGULATED_EQUIPMENT_TYPE_COLUMN + ") select ?, ?" + ", " + REGULATING_EQUIPMENT_ID + ", " +
REGULATED_EQUIPMENT_TYPE_COLUMN + ", " + REGULATING + ") select ?, ?" + ", " + REGULATING_EQUIPMENT_ID + ", " +
REGULATING_EQUIPMENT_TYPE_COLUMN + ", " + REGULATION_MODE +
", localTerminalConnectableId, localTerminalSide, regulatingTerminalConnectableId, regulatingTerminalSide, "
+ REGULATED_EQUIPMENT_TYPE_COLUMN + " from " + REGULATING_POINT_TABLE + " where " + NETWORK_UUID_COLUMN +
+ REGULATED_EQUIPMENT_TYPE_COLUMN + ", " + REGULATING + " from " + REGULATING_POINT_TABLE + " where " + NETWORK_UUID_COLUMN +
" = ? and " + VARIANT_NUM_COLUMN + " = ?";
}

Expand All @@ -529,7 +532,7 @@ public static String buildRegulatingPointsQuery() {
NETWORK_UUID_COLUMN + ", " +
VARIANT_NUM_COLUMN + ", " +
REGULATING_EQUIPMENT_ID + ", " + REGULATION_MODE + ", localterminalconnectableid, localterminalside, " +
"regulatingterminalconnectableid, regulatingterminalside, " + REGULATED_EQUIPMENT_TYPE_COLUMN +
"regulatingterminalconnectableid, regulatingterminalside, " + REGULATING +
" from " + REGULATING_POINT_TABLE + " where " +
NETWORK_UUID_COLUMN + " = ? and " +
VARIANT_NUM_COLUMN + " = ? and " +
Expand All @@ -543,7 +546,7 @@ public static String buildRegulatingPointsWithInClauseQuery(String columnNameFor
return "select " + NETWORK_UUID_COLUMN + ", " +
VARIANT_NUM_COLUMN + ", " +
REGULATING_EQUIPMENT_ID + ", " + REGULATION_MODE + ", localterminalconnectableid, localterminalside, " +
"regulatingterminalconnectableid, regulatingterminalside, " + REGULATED_EQUIPMENT_TYPE_COLUMN
"regulatingterminalconnectableid, regulatingterminalside, " + REGULATING
+ " from " + REGULATING_POINT_TABLE + " where " +
NETWORK_UUID_COLUMN + " = ? and " +
VARIANT_NUM_COLUMN + " = ? and " +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">

<changeSet id="2986331049275-6" author="lesoteti">
<addColumn tableName="regulatingpoint">
<column name="regulating" type="boolean"/>
</addColumn>
<sqlFile
path="move_regulating_to_regulationPoint_20241204T110000Z.sql"
relativeToChangelogFile="true"
splitStatements="true"
stripComments="true"/>
<dropColumn tableName="generator" columnName="voltageregulatoron"/>
<dropColumn tableName="vscconverterstation" columnName="voltageregulatoron"/>
<dropColumn tableName="shuntcompensator" columnName="voltageregulatoron"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- generator
update regulatingpoint
set regulating = (select generator.voltageregulatoron from generator
where regulatingpoint.regulatingequipmenttype = 'GENERATOR'
and regulatingpoint.regulatingequipmentid = generator.id
and regulatingpoint.networkuuid = generator.networkuuid
and regulatingpoint.variantnum = generator.variantnum)
where regulatingequipmenttype = 'GENERATOR';
-- vsc

update regulatingpoint
set regulating = (select vscconverterstation.voltageregulatoron from vscconverterstation
where regulatingpoint.regulatingequipmenttype = 'VSC_CONVERTER_STATION'
and regulatingpoint.regulatingequipmentid = vscconverterstation.id
and regulatingpoint.networkuuid = vscconverterstation.networkuuid
and regulatingpoint.variantnum = vscconverterstation.variantnum)
where regulatingequipmenttype = 'VSC_CONVERTER_STATION';
-- shunt
update regulatingpoint
set regulating = (select shuntcompensator.voltageregulatoron from shuntcompensator
where regulatingpoint.regulatingequipmenttype = 'SHUNT_COMPENSATOR'
and regulatingpoint.regulatingequipmentid = shuntcompensator.id
and regulatingpoint.networkuuid = shuntcompensator.networkuuid
and regulatingpoint.variantnum = shuntcompensator.variantnum)
where regulatingequipmenttype = 'SHUNT_COMPENSATOR';
-- svc
update regulatingpoint
set regulating = (CASE WHEN regulationmode = 'VOLTAGE'
THEN TRUE ELSE FALSE END)
where regulatingequipmenttype = 'STATIC_VAR_COMPENSATOR';
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ databaseChangeLog:
- include:
file: changesets/changelog_20241031T110000Z.xml
relativeToChangelogFile: true

- include:
file: changesets/changelog_20241204T110000Z.xml
relativeToChangelogFile: true
20 changes: 19 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<properties>
<sirocco.version>1.0</sirocco.version>
<powsybl-ws-dependencies.version>2.16.0</powsybl-ws-dependencies.version>

<powsybl-network-store.version>1.21.0-SNAPSHOT</powsybl-network-store.version>
<!-- FIXME : to remove when sonar version is updated on github actions -->
<!-- https://community.sonarsource.com/t/stackoverflowerror-at-defaultinputcomponent-equals/20324 -->
<!-- The versions are very different from this post. But the fix works again. Maybe a similar problem in sonar code -->
Expand Down Expand Up @@ -81,6 +81,24 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-client</artifactId>
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
<version>${powsybl-network-store.version}</version>
</dependency>
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-iidm-impl</artifactId>
<version>${powsybl-network-store.version}</version>
</dependency>
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-model</artifactId>
<version>${powsybl-network-store.version}</version>
</dependency>

<!-- project specific dependencies -->
<dependency>
Expand Down
Loading