com.powsybl.openrao.data.cracio.commons.ucte.UcteHvdcElementHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of open-rao-crac-io-commons Show documentation
Show all versions of open-rao-crac-io-commons Show documentation
Utilitary methods for crac creation
The newest version!
/*
* Copyright (c) 2021, 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.openrao.data.cracio.commons.ucte;
import com.powsybl.openrao.data.cracio.commons.HvdcElementHelper;
import com.powsybl.iidm.network.Identifiable;
import static java.lang.String.format;
/**
* UcteHvdcElementHelper is a utility class which manages HVDC defined with the UCTE
* convention
*
* This utility class has been designed so as to be used in CRAC creators whose format
* is based on a UCTE network and whose CRAC identifies network elements with the following
* information: a "from node", a "to node" and a suffix. Either identified in separate fields,
* or in a common concatenated id such as "FROMNODE TO__NODE SUFFIX".
*
* @author Baptiste Seguinot{@literal }
*/
public class UcteHvdcElementHelper extends AbstractUcteConnectableHelper implements HvdcElementHelper {
private boolean isInvertedInNetwork = false;
/**
* Constructor, based on a separate fields.
*
* @param fromNode, UCTE-id of the origin extremity of the branch
* @param toNode, UCTE-id of the destination extremity of the branch
* @param suffix, suffix of the branch, either an order code or an elementName
* @param ucteNetworkAnalyzer, UcteNetworkAnalyzer object built upon the network
*/
public UcteHvdcElementHelper(String fromNode, String toNode, String suffix, UcteNetworkAnalyzer ucteNetworkAnalyzer) {
super(fromNode, toNode, suffix);
if (isValid) {
interpretWithNetworkAnalyzer(ucteNetworkAnalyzer);
}
}
/**
* Constructor, based on a separate fields. Either the order code, or the element name must be
* non-null. If the two are defined, the suffix which will be used by default is the order code.
*
* @param fromNode, UCTE-id of the origin extremity of the branch
* @param toNode, UCTE-id of the destination extremity of the branch
* @param orderCode, order code of the branch
* @param elementName, element name of the branch
* @param ucteNetworkAnalyzer, UcteNetworkAnalyzer object built upon the network
*/
public UcteHvdcElementHelper(String fromNode, String toNode, String orderCode, String elementName, UcteNetworkAnalyzer ucteNetworkAnalyzer) {
super(fromNode, toNode, orderCode, elementName);
if (isValid) {
interpretWithNetworkAnalyzer(ucteNetworkAnalyzer);
}
}
/**
* Constructor, based on a concatenated id.
*
* @param ucteBranchId, concatenated UCTE branch id, of the form "FROMNODE TO__NODE SUFFIX"
* @param ucteNetworkAnalyzer, UcteNetworkAnalyzer object built upon the network
*/
public UcteHvdcElementHelper(String ucteBranchId, UcteNetworkAnalyzer ucteNetworkAnalyzer) {
super(ucteBranchId);
if (isValid) {
interpretWithNetworkAnalyzer(ucteNetworkAnalyzer);
}
}
/**
* If the branch is valid, returns a boolean indicating whether or not the from/to are
* inverted in the network, compared to the values originally used in the constructor
* of the UcteBranchHelper
*/
@Override
public boolean isInvertedInNetwork() {
return isInvertedInNetwork;
}
protected void interpretWithNetworkAnalyzer(UcteNetworkAnalyzer networkAnalyzer) {
UcteMatchingResult ucteMatchingResult = networkAnalyzer.findHvdcElement(from, to, suffix);
if (ucteMatchingResult.getStatus() == UcteMatchingResult.MatchStatus.NOT_FOUND) {
invalidate(format("HVDC was not found in the Network (from: %s, to: %s, suffix: %s)", from, to, suffix));
return;
}
if (ucteMatchingResult.getStatus() == UcteMatchingResult.MatchStatus.SEVERAL_MATCH) {
invalidate(format("several HVDCs were found in the Network which match the description(from: %s, to: %s, suffix: %s)", from, to, suffix));
return;
}
this.isInvertedInNetwork = ucteMatchingResult.isInverted();
Identifiable> networkElement = ucteMatchingResult.getIidmIdentifiable();
this.connectableIdInNetwork = networkElement.getId();
}
}