Skip to content

Drop support for CIM14 #3375

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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,12 +129,7 @@ public List<Parameter> getParameters() {
public boolean exists(ReadOnlyDataSource ds) {
CgmesOnDataSource cds = new CgmesOnDataSource(ds);
try {
if (cds.exists()) {
return true;
}
// If we are configured to support CIM14,
// check if there is this CIM14 data
return IMPORT_CIM_14 && cds.existsCim14();
return cds.exists();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Expand Down Expand Up @@ -769,10 +764,4 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
private final PlatformConfig platformConfig;

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

// TODO Allow this property to be configurable
// Parameters of importers are only passed to importData method,
// but to decide if we are importers also for CIM 14 files
// we must implement the exists method, that has not access to parameters
private static final boolean IMPORT_CIM_14 = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public OperationalLimitConversion(PropertyBag l, Context context) {
equipmentId = l.getId("Equipment");
Terminal terminal = null;
if (limitSubclass == null || limitSubclass.equals(CgmesNames.ACTIVE_POWER_LIMIT) || limitSubclass.equals(CgmesNames.APPARENT_POWER_LIMIT) || limitSubclass.equals(CgmesNames.CURRENT_LIMIT)) {
if (limitSubclass == null) {
// Support for CIM14, all limits are assumed to be current
limitSubclass = CgmesNames.CURRENT_LIMIT;
}
if (terminalId != null) {
terminal = context.terminalMapping().findForFlowLimits(terminalId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public class SynchronousMachineConversion extends AbstractReactiveLimitsOwnerCon
public SynchronousMachineConversion(PropertyBag sm, Context context) {
super(CgmesNames.SYNCHRONOUS_MACHINE, sm, context);
String type = p.getLocal("type");
// CIM14 uses Type.condenser, CIM16 and CIM100 use Kind.condenser
isCondenser = type != null && type.endsWith(".condenser");
isCondenser = type.equals("SynchronousMachineKind.condenser");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isCondenser = type.equals("SynchronousMachineKind.condenser");
isCondenser = "SynchronousMachineKind.condenser".equals(type);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.powsybl.cgmes.conversion.elements.AbstractConductingEquipmentConversion;
import com.powsybl.cgmes.extensions.CgmesTapChangers;
import com.powsybl.cgmes.extensions.CgmesTapChangersAdder;
import com.powsybl.cgmes.model.WindingType;
import com.powsybl.iidm.network.*;
import com.powsybl.triplestore.api.PropertyBag;
import com.powsybl.triplestore.api.PropertyBags;
Expand All @@ -28,6 +27,8 @@
*/
abstract class AbstractTransformerConversion extends AbstractConductingEquipmentConversion {

protected static final String END_NUMBER = "endNumber";

AbstractTransformerConversion(String type, PropertyBags ends, Context context) {
super(type, ends, context);
}
Expand Down Expand Up @@ -117,21 +118,21 @@ protected void addAliasesAndProperties(Identifiable<?> identifiable) {
String aliasType;
for (PropertyBag end : ps) {
alias = end.getId("TransformerEnd");
aliasType = CGMES_PREFIX_ALIAS_PROPERTIES + TRANSFORMER_END + WindingType.endNumber(end);
aliasType = CGMES_PREFIX_ALIAS_PROPERTIES + TRANSFORMER_END + end.getLocal(END_NUMBER);
identifiable.addAlias(alias, aliasType);
}

// Add RatioTapChangers aliases
for (PropertyBag rtc : context.ratioTapChangers(identifiable.getId())) {
alias = rtc.getId("RatioTapChanger");
aliasType = CGMES_PREFIX_ALIAS_PROPERTIES + RATIO_TAP_CHANGER + WindingType.endNumber(rtc);
aliasType = CGMES_PREFIX_ALIAS_PROPERTIES + RATIO_TAP_CHANGER + rtc.getLocal(END_NUMBER);
identifiable.addAlias(alias, aliasType, context.config().isEnsureIdAliasUnicity());
}

// Add PhaseTapChangers aliases
for (PropertyBag ptc : context.phaseTapChangers(identifiable.getId())) {
alias = ptc.getId("PhaseTapChanger");
aliasType = CGMES_PREFIX_ALIAS_PROPERTIES + PHASE_TAP_CHANGER + WindingType.endNumber(ptc);
aliasType = CGMES_PREFIX_ALIAS_PROPERTIES + PHASE_TAP_CHANGER + ptc.getLocal(END_NUMBER);
identifiable.addAlias(alias, aliasType, context.config().isEnsureIdAliasUnicity());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public TapChanger build() {
// We keep the original type of tap changer (linear, symmetrical, asymmetrical)
// The type stored here will eventually be used to determine the class in the SSH export
// If only SSH export is written, the type used should match the original one
return super.build().setType(toClassTypeFromClassOrKind(type));
return super.build().setType(type);
}

private boolean validType() {
Expand Down Expand Up @@ -254,20 +254,4 @@ private double getXMin() {
private double getXMax() {
return p.asDouble(CgmesNames.X_STEP_MAX, p.asDouble(CgmesNames.X_MAX));
}

private static String toClassTypeFromClassOrKind(String type) {
// If type is obtained from CIM14 kind PhaseTapChanger.phaseTapChangerType
// It has the pattern PhaseTapChangerKind.<type>
// where type can be symmetrical, asymmetrical
if (type.startsWith("PhaseTapChangerKind.")) {
int idot = type.indexOf('.');
String kind = type.substring(idot + 1);
String camelKind = kind.substring(0, 1).toUpperCase() + kind.substring(1);
return "PhaseTapChanger" + camelKind;
}
// Otherwise, type has been read from the class name,
// we do not have to transform it
return type;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
import com.powsybl.cgmes.conformity.CgmesConformity1Catalog;
import com.powsybl.cgmes.conversion.CgmesExport;
import com.powsybl.cgmes.conversion.CgmesImport;
import com.powsybl.cgmes.conversion.CgmesModelExtension;
import com.powsybl.cgmes.model.CgmesModel;
import com.powsybl.cgmes.model.GridModelReference;
import com.powsybl.cgmes.model.test.Cim14SmallCasesCatalog;
import com.powsybl.commons.datasource.DataSource;
import com.powsybl.commons.datasource.DirectoryDataSource;
import com.powsybl.commons.datasource.ReadOnlyDataSource;
Expand All @@ -41,8 +41,8 @@ class ImportExportPerformanceTest {
// are equivalent to the original models

@Test
void smallcase1() throws IOException {
importExport(TripleStoreFactory.onlyDefaultImplementation(), Cim14SmallCasesCatalog.small1());
void microGridBaseCaseNL() throws IOException {
importExport(TripleStoreFactory.onlyDefaultImplementation(), CgmesConformity1Catalog.microGridBaseCaseNL());
}

private void importExport(List<String> tsImpls, GridModelReference gm) throws IOException {
Expand Down

This file was deleted.

Loading