cim1.model.ShuntCompensator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powsybl-cim1-model Show documentation
Show all versions of powsybl-cim1-model Show documentation
CIM ENTSO-E V1 model generated by CIM Gateway tool
/**
* Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium)
* 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 cim1.model;
import cim1.exc.InterpretationException;
import cim1.exc.LinkageException;
import java.util.BitSet;
import java.util.Map;
import java.util.EnumMap;
import javax.xml.stream.XMLStreamException;
import cim1.CIMURI;
import javax.xml.stream.XMLStreamWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* This file has been automatically generated by CIMGateway
*
* Description :
*
* This class "ShuntCompensator.java" represents the
* class ShuntCompensator extends RegulatingCondEq
* + SvShuntCompensatorSections 0..1 SvShuntCompensatorSections
* + gPerSection 1..1 float
* + bPerSection 1..1 float
* + g0PerSection 0..1 float
* + b0PerSection 0..1 float
* + maximumSections 1..1 int
*/
public class ShuntCompensator extends RegulatingCondEq {
private static Logger LOGGER = LoggerFactory.getLogger(ShuntCompensator.class);
/**
* Attribute "svShuntCompensatorSections"
*
* Comment from profile:
* The state for the number of shunt compensator sections in service.
*/
public SvShuntCompensatorSections svShuntCompensatorSections;
/**
* The id of the attribute "svShuntCompensatorSections"
* This id is mainly used to resolve links after parsing an instance
*/
public String idSvShuntCompensatorSections;
/**
* Attribute "gPerSection"
*
* Comment from profile:
* Positive sequence shunt (charging) conductance per section
*/
public float gPerSection;
/**
* Attribute "bPerSection"
*
* Comment from profile:
* Positive sequence shunt (charging) susceptance per section
*/
public float bPerSection;
/**
* Attribute "g0PerSection"
*
* Comment from profile:
* Zero sequence shunt (charging) conductance per sectionThis is for Short Circuit only.
*/
public float g0PerSection;
/**
* Attribute "b0PerSection"
*
* Comment from profile:
* Zero sequence shunt (charging) susceptance per sectionThis is for Short Circuit only.
*/
public float b0PerSection;
/**
* Attribute "maximumSections"
*
* Comment from profile:
* For a capacitor bank, the maximum number of sections that may be switched in.
*/
public int maximumSections;
/**
* The current bitset describing the state of each CIM attribute of this
* class
*/
private BitSet currentBitset = new BitSet();
/**
* The bitset describing which CIM attributes of this class have to set to
* be consistent within a "merged" context
*/
private final BitSet minBitset = new BitSet();
/**
* The Map of subset<=>bitset describing which CIM attributes of this class
* have to set to be consistent within a specific subset context
*/
private final Map minBitsets
= new EnumMap(Subset.class);
/**
* Utility to return the "svShuntCompensatorSections"
*
* @return the value of the attribute "svShuntCompensatorSections"
*/
public SvShuntCompensatorSections getSvShuntCompensatorSections() {
return this.svShuntCompensatorSections;
}
/**
* Utility to test if the value of "svShuntCompensatorSections" has been set
*
* @return boolean
* if true the attribute "svShuntCompensatorSections" is already set
* if false it isn't yet
*/
public boolean svShuntCompensatorSectionsIsSet() {
return this.currentBitset.get(0);
}
/**
* Utility to set the "svShuntCompensatorSectionsValue"
*
* @param svShuntCompensatorSectionsValue
* instance to set
* @param setInverse
* boolean to specify whether to set the inverse association
* or not
* @throws LinkageException
*/
public void setSvShuntCompensatorSections(
SvShuntCompensatorSections svShuntCompensatorSectionsValue,
boolean setInverse) throws LinkageException {
this.svShuntCompensatorSections = svShuntCompensatorSectionsValue;
this.currentBitset.set(0);
if (setInverse) {
if (svShuntCompensatorSectionsValue != null) {
svShuntCompensatorSectionsValue.setShuntCompensator(this, false);
}
}
}
/**
* Utility to return the "gPerSection" value
*
* @return the value of the attribute "gPerSection"
*/
public float getGPerSection() {
return this.gPerSection;
}
/**
* Utility to set the "gPerSection" value
*
* @param gPerSectionValue
* value to set
*/
public void setGPerSection(float gPerSectionValue) {
this.gPerSection = gPerSectionValue;
this.currentBitset.set(1);
}
/**
* Utility to test if the value of "gPerSection" has been set
*
* @return boolean
* if true the attribute "gPerSection" is already set
* if false isn't yet
*/
public boolean gPerSectionIsSet() {
return this.currentBitset.get(1);
}
/**
* Utility to return the "bPerSection" value
*
* @return the value of the attribute "bPerSection"
*/
public float getBPerSection() {
return this.bPerSection;
}
/**
* Utility to set the "bPerSection" value
*
* @param bPerSectionValue
* value to set
*/
public void setBPerSection(float bPerSectionValue) {
this.bPerSection = bPerSectionValue;
this.currentBitset.set(2);
}
/**
* Utility to test if the value of "bPerSection" has been set
*
* @return boolean
* if true the attribute "bPerSection" is already set
* if false isn't yet
*/
public boolean bPerSectionIsSet() {
return this.currentBitset.get(2);
}
/**
* Utility to return the "g0PerSection" value
*
* @return the value of the attribute "g0PerSection"
*/
public float getG0PerSection() {
return this.g0PerSection;
}
/**
* Utility to set the "g0PerSection" value
*
* @param g0PerSectionValue
* value to set
*/
public void setG0PerSection(float g0PerSectionValue) {
this.g0PerSection = g0PerSectionValue;
this.currentBitset.set(3);
}
/**
* Utility to test if the value of "g0PerSection" has been set
*
* @return boolean
* if true the attribute "g0PerSection" is already set
* if false isn't yet
*/
public boolean g0PerSectionIsSet() {
return this.currentBitset.get(3);
}
/**
* Utility to return the "b0PerSection" value
*
* @return the value of the attribute "b0PerSection"
*/
public float getB0PerSection() {
return this.b0PerSection;
}
/**
* Utility to set the "b0PerSection" value
*
* @param b0PerSectionValue
* value to set
*/
public void setB0PerSection(float b0PerSectionValue) {
this.b0PerSection = b0PerSectionValue;
this.currentBitset.set(4);
}
/**
* Utility to test if the value of "b0PerSection" has been set
*
* @return boolean
* if true the attribute "b0PerSection" is already set
* if false isn't yet
*/
public boolean b0PerSectionIsSet() {
return this.currentBitset.get(4);
}
/**
* Utility to return the "maximumSections" value
*
* @return the value of the attribute "maximumSections"
*/
public int getMaximumSections() {
return this.maximumSections;
}
/**
* Utility to set the "maximumSections" value
*
* @param maximumSectionsValue
* value to set
*/
public void setMaximumSections(int maximumSectionsValue) {
this.maximumSections = maximumSectionsValue;
this.currentBitset.set(5);
}
/**
* Utility to test if the value of "maximumSections" has been set
*
* @return boolean
* if true the attribute "maximumSections" is already set
* if false isn't yet
*/
public boolean maximumSectionsIsSet() {
return this.currentBitset.get(5);
}
/**
* Factory of the class
*
* @param id
* id of the class ShuntCompensator to create
* @return the class created
*/
public static ShuntCompensator create(final String id) {
ShuntCompensator newShuntCompensator = new ShuntCompensator();
newShuntCompensator.setId(id);
return newShuntCompensator;
}
/**
* Utility to "clear" the content of a class when a subset is invalidated
*
* @param subset subset to clean
*/
@Override
public void clearContent(Subset subset) {
// First of all, we clear the associations:
this.clearAssociations(subset);
switch (subset) {
default: // nothing to clear
}
}
/**
* Utility to read an attribute
* This function is called by the CIMModel
*
* @param class_name
* the read name of class
* @param attr_name
* the read name of attribute
* @param value
* the read value of the attribute
* @param model
* the interface to the model this class belongs to
* @throws InterpretationException
*/
@Override
public void readAttribute(final String class_name, final String attr_name,
final String value, CIMModel model) throws InterpretationException {
if (class_name.equals("ShuntCompensator")) {
if (attr_name.equals("gPerSection")) {
if (!(model.isCurrentSubsetSet())
|| (model.getCurrentSubset() == Subset.Equipment)) {
float typedValue;
if (!value.isEmpty()) {
try {
if (value.equalsIgnoreCase("NaN")) {
throw new NumberFormatException();
}
typedValue = Float
.parseFloat(value);
} catch(NumberFormatException e) {
throw new InterpretationException("The attribute gPerSection in class "
+ "ShuntCompensator is supposed to be a Float"
+ " but has not the expected NumberFormat");
}
} else {
throw new InterpretationException("The field of float"
+ " in ShuntCompensator was found empty");
}
this.setGPerSection(typedValue);
return;
} else {
StringBuilder errorMessage
= new StringBuilder("The attribute \"");
errorMessage.append(attr_name);
errorMessage.append("\" in class \"");
errorMessage.append(class_name);
errorMessage.append("\" cannot be defined in a file ");
errorMessage.append("describing an other subset than ");
errorMessage.append("\"Equipment\".");
throw new InterpretationException(errorMessage.toString());
}
}
if (attr_name.equals("bPerSection")) {
if (!(model.isCurrentSubsetSet())
|| (model.getCurrentSubset() == Subset.Equipment)) {
float typedValue;
if (!value.isEmpty()) {
try {
if (value.equalsIgnoreCase("NaN")) {
throw new NumberFormatException();
}
typedValue = Float
.parseFloat(value);
} catch(NumberFormatException e) {
throw new InterpretationException("The attribute bPerSection in class "
+ "ShuntCompensator is supposed to be a Float"
+ " but has not the expected NumberFormat");
}
} else {
throw new InterpretationException("The field of float"
+ " in ShuntCompensator was found empty");
}
this.setBPerSection(typedValue);
return;
} else {
StringBuilder errorMessage
= new StringBuilder("The attribute \"");
errorMessage.append(attr_name);
errorMessage.append("\" in class \"");
errorMessage.append(class_name);
errorMessage.append("\" cannot be defined in a file ");
errorMessage.append("describing an other subset than ");
errorMessage.append("\"Equipment\".");
throw new InterpretationException(errorMessage.toString());
}
}
if (attr_name.equals("g0PerSection")) {
if (!(model.isCurrentSubsetSet())
|| (model.getCurrentSubset() == Subset.Equipment)) {
float typedValue;
if (!value.isEmpty()) {
try {
if (value.equalsIgnoreCase("NaN")) {
throw new NumberFormatException();
}
typedValue = Float
.parseFloat(value);
} catch(NumberFormatException e) {
throw new InterpretationException("The attribute g0PerSection in class "
+ "ShuntCompensator is supposed to be a Float"
+ " but has not the expected NumberFormat");
}
} else {
throw new InterpretationException("The field of float"
+ " in ShuntCompensator was found empty");
}
this.setG0PerSection(typedValue);
return;
} else {
StringBuilder errorMessage
= new StringBuilder("The attribute \"");
errorMessage.append(attr_name);
errorMessage.append("\" in class \"");
errorMessage.append(class_name);
errorMessage.append("\" cannot be defined in a file ");
errorMessage.append("describing an other subset than ");
errorMessage.append("\"Equipment\".");
throw new InterpretationException(errorMessage.toString());
}
}
if (attr_name.equals("b0PerSection")) {
if (!(model.isCurrentSubsetSet())
|| (model.getCurrentSubset() == Subset.Equipment)) {
float typedValue;
if (!value.isEmpty()) {
try {
if (value.equalsIgnoreCase("NaN")) {
throw new NumberFormatException();
}
typedValue = Float
.parseFloat(value);
} catch(NumberFormatException e) {
throw new InterpretationException("The attribute b0PerSection in class "
+ "ShuntCompensator is supposed to be a Float"
+ " but has not the expected NumberFormat");
}
} else {
throw new InterpretationException("The field of float"
+ " in ShuntCompensator was found empty");
}
this.setB0PerSection(typedValue);
return;
} else {
StringBuilder errorMessage
= new StringBuilder("The attribute \"");
errorMessage.append(attr_name);
errorMessage.append("\" in class \"");
errorMessage.append(class_name);
errorMessage.append("\" cannot be defined in a file ");
errorMessage.append("describing an other subset than ");
errorMessage.append("\"Equipment\".");
throw new InterpretationException(errorMessage.toString());
}
}
if (attr_name.equals("maximumSections")) {
if (!(model.isCurrentSubsetSet())
|| (model.getCurrentSubset() == Subset.Equipment)) {
int typedValue;
if (!value.isEmpty()) {
try {
typedValue = Integer.parseInt(value);
} catch(NumberFormatException e) {
StringBuilder errorMessage
= new StringBuilder ("The attribute");
errorMessage
.append("maximumSections in class ");
errorMessage
.append("ShuntCompensator is supposed to");
errorMessage
.append(" be an Integer but has not");
errorMessage
.append(" the expected NumberFormat");
throw new InterpretationException(errorMessage
.toString());
}
} else {
throw new InterpretationException("The field of int"
+ " in ShuntCompensator was found empty");
}
this.setMaximumSections(typedValue);
return;
} else {
StringBuilder errorMessage
= new StringBuilder("The attribute \"");
errorMessage.append(attr_name);
errorMessage.append("\" in class \"");
errorMessage.append(class_name);
errorMessage.append("\" cannot be defined in a file ");
errorMessage.append("describing an other subset than ");
errorMessage.append("\"Equipment\".");
throw new InterpretationException(errorMessage.toString());
}
}
StringBuilder errorMessage = new StringBuilder("The attribute \"");
errorMessage.append(attr_name);
errorMessage.append("\" in class \"");
errorMessage.append(class_name);
errorMessage
.append("\" could not be found in the model !");
throw new InterpretationException(errorMessage.toString());
} else {
// We do not check if we are in the proper subset
// to call the function on
// the parent class
super.readAttribute(class_name, attr_name, value, model);
}
}
/**
* Utility to read a reference to a resource
* This function is called by the CIMModel
*
* @param class_name
* the read name of class
* @param resource_name
* the read name of the associated resource
* @param id
* the id of the associated resource
* @param model
* the model this class belongs to
* @throws InterpretationException
*/
@Override
public void readResource(final String class_name,
final String resource_name, final String id, CIMModel model)
throws InterpretationException, LinkageException {
if (class_name.equals("ShuntCompensator")) {
if (resource_name.equals("SvShuntCompensatorSections")) {
if (!(model.isCurrentSubsetSet())
|| (model.getCurrentSubset() == Subset.Equipment)) {
idSvShuntCompensatorSections = id.substring(1);
if (!super.isAddedToUnresolved()) {
model.addUnresolved();
super.addToUnresolved();
}
return;
} else {
StringBuilder errorMessage
= new StringBuilder("The association \"");
errorMessage.append(resource_name);
errorMessage.append("\" in class");
errorMessage.append("\""+class_name+" \"");
errorMessage.append("is not supposed to be in the subset \"");
errorMessage.append(model.getCurrentSubset().getIdentifier());
errorMessage.append("\"");
throw new InterpretationException(errorMessage.toString());
}
}
StringBuilder errorMessage = new StringBuilder("The association \"");
errorMessage.append(resource_name);
errorMessage.append("\" in class \"");
errorMessage.append(class_name);
errorMessage.append("\" could not be found in the model !");
throw new InterpretationException(errorMessage.toString());
} else {
super.readResource(class_name, resource_name, id, model);
}
}
/**
* Utility to write the content into the CIM XML format
*
* @param writeID
* specifies whether to write the XML "id" attribute (this is used for describing concrete class)
* @param xmlsw
* XMLStreamWriter where are stored the elements to write
*/
@Override
public void write(XMLStreamWriter xmlsw, boolean writeID) {
/*
* In previous versions, we used to check the consistency
* of the instance in the context but this task is now
* performed by the model before attempting to write.
* Therefore each instance can now be written even if
* it is not consistent !
*/
if (writeID) {
try {
xmlsw.writeStartElement(CIMURI.CIMURI, "ShuntCompensator");
xmlsw.writeAttribute(CIMModel.rdfURI, "ID", getId());
// xmlsw.writeCharacters("\n");
} catch (XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the class ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
writeClass(xmlsw);
super.write(xmlsw, false);
if (writeID) {
try {
xmlsw.writeEndElement();
// xmlsw.writeCharacters("\n");
} catch (XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the end Element of the class ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
return;
}
/**
* Utility to write the content this class into the CIM/XML format according
* to a subset
*
* @param subset
* the subset defining the context in which to write this class
* @param writeID
* specifies whether to write the XML "id" attribute (this is used for describing concrete class)
* @param xmlsw
* the stream in which are stored the elements to write
*/
@Override
public void write(XMLStreamWriter xmlsw, final Subset subset,
boolean writeID) {
/*
* In previous versions, we used to check the consistency
* of the instance in the context but this task is now
* performed by the model before attempting to write.
* Therefore each instance can now be written even if
* it is not consistent !
*/
switch (subset) {
case Equipment: {
if (writeID) {
try {
xmlsw.writeStartElement(CIMURI.CIMURI, "ShuntCompensator");
xmlsw.writeAttribute(CIMModel.rdfURI, "ID", getId());
// xmlsw.writeCharacters("\n");
} catch (XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the class ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
errorMessage.append(" in the subset ");
errorMessage.append("Equipment");
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
writeClass(xmlsw);
super.write(xmlsw, subset, false);
if (writeID) {
try {
xmlsw.writeEndElement();
// xmlsw.writeCharacters("\n");
} catch (XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write end element of ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
errorMessage.append(" in the subset ");
errorMessage.append("Equipment");
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
break;
}
default: {// Do nothing !
}
}
return;
}
/**
* Utility to resolve the links at the end of parsing
*
* @param model
* the model this class belongs to
* @param boundaryModel
* the model that gather data about the boundarySet, used
* as a resource force links resolving
* @throws Linkage Exception
*/
@Override
public void resolveLinks(CIMModel model, CIMModel boundaryModel) throws LinkageException {
if (idSvShuntCompensatorSections != null) {
SvShuntCompensatorSections attributeToSet =
model.searchSvShuntCompensatorSections
(idSvShuntCompensatorSections);
if (attributeToSet != null) {
boolean setInverse = true;
try {
this.setSvShuntCompensatorSections(attributeToSet, setInverse);
} catch(LinkageException e) {
LOGGER.error(e.toString(), e);
throw new LinkageException(e.getMessage());
}
} else if (boundaryModel != null) {
SvShuntCompensatorSections attributeToSetFromBoundary = boundaryModel.searchSvShuntCompensatorSections(idSvShuntCompensatorSections);
if(attributeToSetFromBoundary != null) {
attributeToSetFromBoundary.setFromBoundary(true);
try {
model.createSvShuntCompensatorSections(idSvShuntCompensatorSections, attributeToSetFromBoundary);
} catch (InterpretationException e) {
LOGGER.error(e.toString(), e);
}
boolean setInverse = true;
try {
this.setSvShuntCompensatorSections(attributeToSetFromBoundary, setInverse);
} catch(LinkageException e) {
LOGGER.error(e.toString(), e);
throw new LinkageException(e.getMessage());
}
attributeToSetFromBoundary.resolveLinks(model, boundaryModel);
} else {
StringBuilder errorMessage = new StringBuilder(
"Could not find the reference to object of type \"SvShuntCompensatorSections\" and id \"");
errorMessage.append(idSvShuntCompensatorSections);
errorMessage.append("\" in \"ShuntCompensator\" of id \"");
errorMessage.append(this.getId());
errorMessage.append("\" !");
throw new LinkageException(errorMessage.toString());
}
} else {
StringBuilder errorMessage = new StringBuilder(
"Could not find the reference to object of type \"SvShuntCompensatorSections\" and id \"");
errorMessage.append(idSvShuntCompensatorSections);
errorMessage.append("\" in \"ShuntCompensator\" of id \"");
errorMessage.append(this.getId());
errorMessage.append("\" !");
throw new LinkageException(errorMessage.toString());
}
}
super.resolveLinks(model, boundaryModel);
removeFromUnresolved();
}
/**
* Utility to check whether this class is consistent according to a subset
*
* @param subset
* the subset defining the context in which to check whether this class is consistent
* @return a ConsistencyCheck instance whose boolean attribute (consistent)
* indicates if this class is consistent and whose String attribute
* (message)
* indicates why this class is not consistent if it is not
*/
@Override
public ConsistencyCheck modelConsistency(final Subset subset) {
BitSet intersection = new BitSet(this.minBitsets.get(subset).length());
intersection.or(this.minBitsets.get(subset));
// we create a copy of minBitsets.get(subset)
intersection.and(this.currentBitset);
boolean consistent = (this.minBitsets.get(subset).equals(intersection));
StringBuilder message = new StringBuilder("");
if (!consistent) {
message.append(getMessageForConsistency(this.minBitsets.get(subset)));
}
// consistent = (super.modelConsistency().getLeft()) ? (consistent &&
// (true)):(consistent && (false))
// message.append((super.modelConsistency(subset)).getRight());
if (super.modelConsistency().isConsistent()) {
consistent = consistent && (true);
message.append((super.modelConsistency(subset)).getMessage());
} else {
consistent = consistent && (false);
message.append((super.modelConsistency(subset)).getMessage());
}
return new ConsistencyCheck(consistent, message.toString());
}
/**
* Utility to check whether this class is consistent in a "merged" context
*
* @return a ConsistencyCheck instance whose boolean attribute (consistent)
* indicates if this class is consistent and whose String attribute
* (message)
* indicates why this class is not consistent if it is not
*/
@Override
public ConsistencyCheck modelConsistency() {
BitSet intersection = new BitSet(this.minBitset.length());
intersection.or(this.minBitset);
// we create a copy of minBitSet
intersection.and(this.currentBitset);
boolean consistent = (this.minBitset.equals(intersection));
StringBuilder message = new StringBuilder("");
if (!consistent) {
message.append(getMessageForConsistency(this.minBitset));
}
// consistent = (super.modelConsistency().getLeft()) ? (consistent &&
// (true)):(consistent && (false))
// message += (super.modelConsistency(subset)).getRight();
if (super.modelConsistency().isConsistent()) {
consistent = consistent && (true);
message.append((super.modelConsistency()).getMessage());
} else {
consistent = consistent && (false);
message.append((super.modelConsistency()).getMessage());
}
return new ConsistencyCheck(consistent, message.toString());
}
/**
* Utility to copy the "base" of an other instance of the same class
* This utility does not copy the associations with other instances from
* the instance to copy
*
* @param otherShuntCompensator
* the instance to copy
*/
public void copyBase(final ShuntCompensator otherShuntCompensator) {
float newgPerSection;
// assigning primitive type :
if (otherShuntCompensator.currentBitset.get(1)) {
newgPerSection = otherShuntCompensator.getGPerSection();
this.setGPerSection(newgPerSection);
}
float newbPerSection;
// assigning primitive type :
if (otherShuntCompensator.currentBitset.get(2)) {
newbPerSection = otherShuntCompensator.getBPerSection();
this.setBPerSection(newbPerSection);
}
float newg0PerSection;
// assigning primitive type :
if (otherShuntCompensator.currentBitset.get(3)) {
newg0PerSection = otherShuntCompensator.getG0PerSection();
this.setG0PerSection(newg0PerSection);
}
float newb0PerSection;
// assigning primitive type :
if (otherShuntCompensator.currentBitset.get(4)) {
newb0PerSection = otherShuntCompensator.getB0PerSection();
this.setB0PerSection(newb0PerSection);
}
int newmaximumSections;
// assigning primitive type :
if (otherShuntCompensator.currentBitset.get(5)) {
newmaximumSections = otherShuntCompensator.getMaximumSections();
this.setMaximumSections(newmaximumSections);
}
// Memory allocation has done successfully !
// Dropping "old" objects...
// This part may change : we do nothing to allow the user to access
// object by their id from the global model.
if (otherShuntCompensator.currentBitset.get(0)) {
SvShuntCompensatorSections svShuntCompensatorSectionsAssociation = otherShuntCompensator.getSvShuntCompensatorSections();
//this.idSvShuntCompensatorSections = (svShuntCompensatorSectionsAssociation != null) ? svShuntCompensatorSectionsAssociation.getId() : "";
if (svShuntCompensatorSectionsAssociation != null) {
this.idSvShuntCompensatorSections = svShuntCompensatorSectionsAssociation.getId();
// the proper bit will be set when the setter is called
} else {
this.idSvShuntCompensatorSections = "";
}
}
// TODO : Call the parent copy constructor instead ?
super.copyBase(otherShuntCompensator);
}
/**
* Utility to return the content of this class into the CIM XML format
*
* @param xmlsw
* the stream in which are stored the elements to write
*/
private void writeClass(XMLStreamWriter xmlsw) {
if (currentBitset.get(0)) {
/*
* We write nothing for the association with
* "SvShuntCompensatorSections" because it belongs to a "lower"
* subset !
* Equipment> StateVariables
*/
}
if (currentBitset.get(1)) {
try {
// xmlsw.writeCharacters("\t");
xmlsw.writeStartElement(CIMURI.CIMURI,
"ShuntCompensator.gPerSection");
xmlsw.writeCharacters(String.valueOf(getGPerSection()));
xmlsw.writeEndElement();
// xmlsw.writeCharacters("\n");
} catch(XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the value of the attribute ");
errorMessage.append("GPerSection");
errorMessage.append(" in class ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
if (currentBitset.get(2)) {
try {
// xmlsw.writeCharacters("\t");
xmlsw.writeStartElement(CIMURI.CIMURI,
"ShuntCompensator.bPerSection");
xmlsw.writeCharacters(String.valueOf(getBPerSection()));
xmlsw.writeEndElement();
// xmlsw.writeCharacters("\n");
} catch(XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the value of the attribute ");
errorMessage.append("BPerSection");
errorMessage.append(" in class ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
if (currentBitset.get(3)) {
try {
// xmlsw.writeCharacters("\t");
xmlsw.writeStartElement(CIMURI.CIMURI,
"ShuntCompensator.g0PerSection");
xmlsw.writeCharacters(String.valueOf(getG0PerSection()));
xmlsw.writeEndElement();
// xmlsw.writeCharacters("\n");
} catch(XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the value of the attribute ");
errorMessage.append("G0PerSection");
errorMessage.append(" in class ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
if (currentBitset.get(4)) {
try {
// xmlsw.writeCharacters("\t");
xmlsw.writeStartElement(CIMURI.CIMURI,
"ShuntCompensator.b0PerSection");
xmlsw.writeCharacters(String.valueOf(getB0PerSection()));
xmlsw.writeEndElement();
// xmlsw.writeCharacters("\n");
} catch(XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the value of the attribute ");
errorMessage.append("B0PerSection");
errorMessage.append(" in class ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
if (currentBitset.get(5)) {
try {
// xmlsw.writeCharacters("\t");
xmlsw.writeStartElement(CIMURI.CIMURI,
"ShuntCompensator.maximumSections");
xmlsw.writeCharacters(String.valueOf(getMaximumSections()));
xmlsw.writeEndElement();
// xmlsw.writeCharacters("\n");
} catch(XMLStreamException e) {
StringBuilder errorMessage = new StringBuilder(
"Error while trying to write the value of the attribute ");
errorMessage.append("MaximumSections");
errorMessage.append(" in class ");
errorMessage.append("ShuntCompensator ");
errorMessage.append("which ID has been initialized to : ");
errorMessage.append(getId());
LOGGER.error(errorMessage.toString());
LOGGER.error(e.toString(), e);
}
}
return;
}
/**
* Utility in charge of creating the message when the class is not
* consistent within a specific context
*
* @param minBitset
* bitset describing which CIM attributes of this class have
* to be set so that it is consistent within a
* specific subset context
* @return the message explaining what is not consistent
*/
private String getMessageForConsistency(final BitSet minBitset) {
StringBuilder message = new StringBuilder(
"Instance of \"ShuntCompensator\" of id \"");
message.append(this.getId());
message.append("\" is not consistent in this context:\n");
/*
* XOR and then AND
* The result is :
* "1" : has not been set and need to be
* "0" : has been set or is not mandatory
*/
BitSet isNotSet = new BitSet(minBitset.length());
isNotSet.or(minBitset);
// we create a copy of minBitset
isNotSet.xor(this.currentBitset);
isNotSet.and(minBitset);
if (isNotSet.get(0)) {
message.append("\t\"SvShuntCompensatorSections\" needs to be set\n");
}
if (isNotSet.get(1)) {
message.append("\t\"gPerSection\" needs to be set\n");
}
if (isNotSet.get(2)) {
message.append("\t\"bPerSection\" needs to be set\n");
}
if (isNotSet.get(3)) {
message.append("\t\"g0PerSection\" needs to be set\n");
}
if (isNotSet.get(4)) {
message.append("\t\"b0PerSection\" needs to be set\n");
}
if (isNotSet.get(5)) {
message.append("\t\"maximumSections\" needs to be set\n");
}
return message.toString();
}
/**
* Copy constructor
* The associations with other objects are not copied
*
* @param ShuntCompensator
* the reference to the class to copy
* @return the class constructed
*/
private ShuntCompensator(final ShuntCompensator otherShuntCompensator) {
// TODO : check exception safe
this.copyBase(otherShuntCompensator);
}
/**
* Constructor of the class ShuntCompensator
*/
protected ShuntCompensator() {
super.subset = Subset.Equipment;
this.minBitsets.put(Subset.StateVariables, new BitSet(6));
this.minBitsets.put(Subset.Topology, new BitSet(6));
BitSet classBitset = new BitSet(6);
classBitset.set(1);
classBitset.set(2);
classBitset.set(5);
this.minBitsets.put(Subset.Equipment, classBitset);
}
/**
* Utility to clear the associations of this class belonging to a
* specific subset
*
* @param subset
* the subset from which to clear the associations of this class
*/
@Override
protected void clearAssociations(final Subset subset) {
switch (subset) {
case StateVariables: {
// reset the Reference
svShuntCompensatorSections = null;
idSvShuntCompensatorSections = "";
this.currentBitset.clear(0);
super.clearAssociations(subset);
break;
}
case Topology: {
super.clearAssociations(subset);
break;
}
case Equipment: {
super.clearAssociations(subset);
break;
}
default: // nothing to clear
}
}
/**
* Utility returning a copy of the "base" of this instance
* This utility does not copy the associations with other instances
*
* @return a clone of this instance
*/
public ShuntCompensator clone() {
ShuntCompensator newInstance = new ShuntCompensator(this);
ShuntCompensator newInstanceSP = newInstance;
return newInstanceSP;
}
}