com.powsybl.cgmes.conversion.export.elements.ModelDescriptionEq Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powsybl-cgmes-conversion Show documentation
Show all versions of powsybl-cgmes-conversion Show documentation
Conversion between CGMES and IIDM Network definitions
/**
* 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.cgmes.conversion.export.elements;
import com.powsybl.cgmes.conversion.export.CgmesExportContext;
import com.powsybl.cgmes.conversion.export.CgmesExportUtil;
import com.powsybl.cgmes.extensions.CgmesTopologyKind;
import com.powsybl.cgmes.model.CgmesNames;
import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import static com.powsybl.cgmes.model.CgmesNamespace.MD_NAMESPACE;
import static com.powsybl.cgmes.model.CgmesNamespace.RDF_NAMESPACE;
/**
* @author Marcos de Miguel
*/
public final class ModelDescriptionEq {
public static void write(XMLStreamWriter writer, CgmesExportContext.ModelDescription modelDescription, CgmesExportContext context) throws XMLStreamException {
writer.writeStartElement(MD_NAMESPACE, "FullModel");
String modelId = "urn:uuid:" + CgmesExportUtil.getUniqueId();
writer.writeAttribute(RDF_NAMESPACE, CgmesNames.ABOUT, modelId);
modelDescription.setIds(modelId);
context.updateDependencies();
writer.writeStartElement(MD_NAMESPACE, CgmesNames.SCENARIO_TIME);
writer.writeCharacters(ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().print(context.getScenarioTime()));
writer.writeEndElement();
writer.writeStartElement(MD_NAMESPACE, CgmesNames.CREATED);
writer.writeCharacters(ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().print(DateTime.now()));
writer.writeEndElement();
writer.writeStartElement(MD_NAMESPACE, CgmesNames.DESCRIPTION);
writer.writeCharacters(modelDescription.getDescription());
writer.writeEndElement();
writer.writeStartElement(MD_NAMESPACE, CgmesNames.VERSION);
writer.writeCharacters(CgmesExportUtil.format(modelDescription.getVersion()));
writer.writeEndElement();
for (String dependency : modelDescription.getDependencies()) {
writer.writeEmptyElement(MD_NAMESPACE, CgmesNames.DEPENDENT_ON);
writer.writeAttribute(RDF_NAMESPACE, CgmesNames.RESOURCE, dependency);
}
writer.writeStartElement(MD_NAMESPACE, CgmesNames.PROFILE);
writer.writeCharacters(modelDescription.getProfile());
writer.writeEndElement();
if (context.getTopologyKind().equals(CgmesTopologyKind.NODE_BREAKER) && context.getCimVersion() < 100) {
// From CGMES 3 EquipmentOperation is not required to write operational limits, connectivity nodes
writer.writeStartElement(MD_NAMESPACE, CgmesNames.PROFILE);
writer.writeCharacters(context.getCim().getProfileUri("EQ_OP"));
writer.writeEndElement();
}
writer.writeStartElement(MD_NAMESPACE, CgmesNames.MODELING_AUTHORITY_SET);
writer.writeCharacters(modelDescription.getModelingAuthoritySet());
writer.writeEndElement();
writer.writeEndElement();
}
private ModelDescriptionEq() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy