Skip to content

Commit

Permalink
Use 'network' tag instead of 'subnetwork'
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
  • Loading branch information
olperr1 committed Aug 31, 2023
1 parent 40141da commit e712559
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public final class NetworkXml {

private static final String EXTENSION_CATEGORY_NAME = "network";
static final String NETWORK_ROOT_ELEMENT_NAME = "network";
static final String SUBNETWORK_ROOT_ELEMENT_NAME = "subnetwork";
private static final String EXTENSION_ELEMENT_NAME = "extension";
private static final String CASE_DATE = "caseDate";
private static final String FORECAST_DISTANCE = "forecastDistance";
Expand Down Expand Up @@ -268,10 +267,9 @@ private static void writeRootElement(Network n, NetworkXmlWriterContext context)
String namespaceUri = version.getNamespaceURI(n.getValidationLevel() == ValidationLevel.STEADY_STATE_HYPOTHESIS);
IidmXmlUtil.assertMinimumVersionIfNotDefault(n.getValidationLevel() != ValidationLevel.STEADY_STATE_HYPOTHESIS, NETWORK_ROOT_ELEMENT_NAME, MINIMUM_VALIDATION_LEVEL, IidmXmlUtil.ErrorMessage.NOT_SUPPORTED, IidmXmlVersion.V_1_7, version);

boolean isSubnetwork = n.getParentNetwork() != n;
context.getWriter().setPrefix(IIDM_PREFIX, namespaceUri);
context.getWriter().writeStartElement(namespaceUri, isSubnetwork ? SUBNETWORK_ROOT_ELEMENT_NAME : NETWORK_ROOT_ELEMENT_NAME);
if (!isSubnetwork) {
context.getWriter().writeStartElement(namespaceUri, NETWORK_ROOT_ELEMENT_NAME);
if (n.getParentNetwork() == n) { // is root network
context.getWriter().writeNamespace(IIDM_PREFIX, namespaceUri);
if (!options.withNoExtension()) {
writeExtensionNamespaces(n, context);
Expand Down Expand Up @@ -507,8 +505,8 @@ private static void readElements(NetworkFactory networkFactory, XMLStreamReader
PropertiesXml.read(networks.peek(), context);
break;

case SUBNETWORK_ROOT_ELEMENT_NAME:
IidmXmlUtil.assertMinimumVersion(NETWORK_ROOT_ELEMENT_NAME, SUBNETWORK_ROOT_ELEMENT_NAME,
case NETWORK_ROOT_ELEMENT_NAME:
IidmXmlUtil.assertMinimumVersion(NETWORK_ROOT_ELEMENT_NAME, NETWORK_ROOT_ELEMENT_NAME,
IidmXmlUtil.ErrorMessage.NOT_SUPPORTED, IidmXmlVersion.V_1_11, context);
if (networks.size() > 1) {
throw new PowsyblException("Only one level of subnetworks is currently supported.");
Expand All @@ -517,7 +515,7 @@ private static void readElements(NetworkFactory networkFactory, XMLStreamReader
Network subnetwork = initNetwork(networkFactory, context, reader, networks.peek());
networks.push(subnetwork);
// Read subnetwork content
XmlUtil.readUntilEndElement(SUBNETWORK_ROOT_ELEMENT_NAME, reader,
XmlUtil.readUntilEndElement(NETWORK_ROOT_ELEMENT_NAME, reader,
() -> readElements(networkFactory, reader, context, networks, extensionNamesNotFound));
// Pop the subnetwork. We will now work with its parent.
networks.pop();
Expand Down Expand Up @@ -707,7 +705,7 @@ public static void update(Network network, InputStream is) {
break;

case HvdcLineXml.ROOT_ELEMENT_NAME:
case NetworkXml.SUBNETWORK_ROOT_ELEMENT_NAME:
case NetworkXml.NETWORK_ROOT_ELEMENT_NAME:
// Nothing to do
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<xs:sequence>
<xs:element name="alias" type="iidm:Alias" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="property" type="iidm:Property" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="subnetwork" type="iidm:Network" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="network" type="iidm:Network" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="voltageLevel" type="iidm:VoltageLevel" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="substation" type="iidm:Substation" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<xs:sequence>
<xs:element name="alias" type="iidm:Alias" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="property" type="iidm:Property" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="subnetwork" type="iidm:Network" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="network" type="iidm:Network" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="voltageLevel" type="iidm:VoltageLevel" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="substation" type="iidm:Substation" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" id="Merged" caseDate="2013-01-15T18:40:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:subnetwork id="Network-1" caseDate="2013-01-15T18:41:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:subnetwork id="Network-2" caseDate="2013-01-15T18:42:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network id="Network-1" caseDate="2013-01-15T18:41:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network id="Network-2" caseDate="2013-01-15T18:42:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="s2" country="FR">
<iidm:voltageLevel id="vl2" nominalV="380.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand All @@ -11,7 +11,7 @@
<iidm:danglingLine id="dl2" name="dl2_name" p0="0.0" q0="0.0" r="1.0" x="2.0" g="4.0" b="5.0" ucteXnodeCode="code" bus="b2" connectableBus="b2"/>
</iidm:voltageLevel>
</iidm:substation>
</iidm:subnetwork>
</iidm:network>
<iidm:substation id="s1" country="FR">
<iidm:voltageLevel id="vl1" nominalV="380.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand All @@ -24,5 +24,5 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:tieLine id="dl1 + dl2" name="dl1_name + dl2_name" danglingLineId1="dl1" danglingLineId2="dl2"/>
</iidm:subnetwork>
</iidm:network>
</iidm:network>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:mock="http://www.powsybl.org/schema/iidm/ext/terminal_mock/1_11" xmlns:extNetworkSource="http://www.itesla_project.eu/schema/iidm/ext/networksource/1_0" id="Merged" caseDate="2013-01-15T18:40:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:subnetwork id="Network-1" caseDate="2013-01-15T18:41:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network id="Network-1" caseDate="2013-01-15T18:41:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="s1" country="FR">
<iidm:voltageLevel id="vl1" nominalV="380.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand All @@ -15,8 +15,8 @@
<iidm:extension id="Network-1">
<extNetworkSource:networkSource sourceData="Source_1"/>
</iidm:extension>
</iidm:subnetwork>
<iidm:subnetwork id="Network-2" caseDate="2013-01-15T18:42:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
</iidm:network>
<iidm:network id="Network-2" caseDate="2013-01-15T18:42:00.000+01:00" forecastDistance="0" sourceFormat="format" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="s2" country="FR">
<iidm:voltageLevel id="vl2" nominalV="380.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand All @@ -34,7 +34,7 @@
<iidm:extension id="Network-2">
<extNetworkSource:networkSource sourceData="Source_2"/>
</iidm:extension>
</iidm:subnetwork>
</iidm:network>
<iidm:tieLine id="dl1 + dl2" name="dl1_name + dl2_name" danglingLineId1="dl1" danglingLineId2="dl2"/>
<iidm:extension id="Merged">
<extNetworkSource:networkSource sourceData="Source_0"/>
Expand Down

0 comments on commit e712559

Please sign in to comment.