Class DexpiXmlReader
java.lang.Object
neqsim.process.processmodel.dexpi.DexpiXmlReader
Utility for reading DEXPI XML files and converting them into NeqSim process models.
This reader recognises major equipment such as pumps, heat exchangers, tanks and control valves
as well as complex reactors, compressors and inline analysers. Piping segments are imported as
runnable DexpiStream units tagged with the source line number.
- Version:
- 1.0
- Author:
- NeqSim
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map<String, EquipmentEnum> private static final org.apache.logging.log4j.Loggerprivate static final Map<String, EquipmentEnum> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddDexpiStream(ProcessSystem processSystem, Element element, Stream templateStream, String baseName) private static voidaddDexpiUnit(ProcessSystem processSystem, Element element, EquipmentEnum equipmentEnum, String baseName, String componentClass) private static voidaddPipingSegments(Document document, ProcessSystem processSystem, Stream templateStream) private static voidaddUnits(Document document, ProcessSystem processSystem, String tagName, Map<String, EquipmentEnum> equipmentMap, String nameAttribute) private static voidapplyNumericAttribute(Element element, String valueAttribute, String unitAttribute, BiConsumer<Double, String> consumer, String defaultUnit) private static voidapplyStreamMetadata(Element element, DexpiStream stream) private static StringattributeValue(Element element, String attributeName) private static SystemInterfaceprivate static StreamdirectChildElements(Element element, String tagName) private static StringensureUniqueName(ProcessSystem processSystem, String candidate) private static StringfindAttributeInAncestors(Node node, String attributeName) private static StringfirstNonEmpty(String... candidates) private static StringgetGenericAttribute(Element element, String attributeName) private static booleanprivate static booleanisInsideShapeCatalogue(Node node) Checks whether the given node is inside a ShapeCatalogue element.static voidload(File file, ProcessSystem processSystem) Populates an existingProcessSystemwith units parsed from a DEXPI XML file.static voidload(File file, ProcessSystem processSystem, Stream templateStream) Populates an existingProcessSystemwith units parsed from a DEXPI XML file.static voidload(InputStream inputStream, ProcessSystem processSystem) Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.static voidload(InputStream inputStream, ProcessSystem processSystem, Stream templateStream) Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.static voidload(InputStream inputStream, ProcessSystem processSystem, Stream templateStream, boolean namespaceAware) Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.private static DocumentparseDocument(InputStream inputStream, boolean nsAware) private static List<DexpiInstrumentInfo> parseInstruments(Document document) Parses all ProcessInstrumentationFunction elements from the document, resolving loop and actuator associations.(package private) static List<DexpiInstrumentInfo> parseInstrumentsFromDocument(Document document) Parses instruments from an already-parsed DEXPI XML Document.private static DoubleparseNumeric(String valueText) private static StringprependLineOrFluid(Element element, String baseName) static ProcessSystemReads the provided DEXPI XML file and returns a populatedProcessSystem.static ProcessSystemReads the provided DEXPI XML file and returns a populatedProcessSystemusing a templateStreamfor generated piping segments.static ProcessSystemread(InputStream inputStream) Reads the provided DEXPI XML stream and returns a populatedProcessSystem.static ProcessSystemread(InputStream inputStream, Stream templateStream) Reads the provided DEXPI XML stream and returns a populatedProcessSystemusing a templateStreamfor any generated piping segments.static List<DexpiInstrumentInfo> readInstruments(File file) Reads instrument metadata from a DEXPI XML file.static List<DexpiInstrumentInfo> readInstruments(InputStream inputStream) Reads instrument metadata from a DEXPI XML stream.private static StreamtemplateOrDefault(Stream templateStream)
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
EQUIPMENT_CLASS_MAP
-
PIPING_COMPONENT_MAP
-
-
Constructor Details
-
DexpiXmlReader
private DexpiXmlReader()
-
-
Method Details
-
read
Reads the provided DEXPI XML file and returns a populatedProcessSystem.- Parameters:
file- DEXPI XML file- Returns:
- a process system populated with units found in the XML
- Throws:
IOException- if the file cannot be readDexpiXmlReaderException- if the file cannot be parsed
-
read
public static ProcessSystem read(File file, Stream templateStream) throws IOException, DexpiXmlReaderException Reads the provided DEXPI XML file and returns a populatedProcessSystemusing a templateStreamfor generated piping segments.- Parameters:
file- DEXPI XML filetemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.- Returns:
- a process system populated with units found in the XML
- Throws:
IOException- if the file cannot be readDexpiXmlReaderException- if the file cannot be parsed
-
read
public static ProcessSystem read(InputStream inputStream) throws IOException, DexpiXmlReaderException Reads the provided DEXPI XML stream and returns a populatedProcessSystem.- Parameters:
inputStream- stream containing DEXPI XML data- Returns:
- a process system populated with units found in the XML
- Throws:
IOException- if the stream cannot be readDexpiXmlReaderException- if the stream cannot be parsed
-
read
public static ProcessSystem read(InputStream inputStream, Stream templateStream) throws IOException, DexpiXmlReaderException Reads the provided DEXPI XML stream and returns a populatedProcessSystemusing a templateStreamfor any generated piping segments.- Parameters:
inputStream- stream containing DEXPI XML datatemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.- Returns:
- a process system populated with units found in the XML
- Throws:
IOException- if the stream cannot be readDexpiXmlReaderException- if the stream cannot be parsed
-
load
public static void load(File file, ProcessSystem processSystem) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML file.- Parameters:
file- XML file to parseprocessSystem- target process system- Throws:
IOException- if reading failsDexpiXmlReaderException- if the file cannot be parsed
-
load
public static void load(File file, ProcessSystem processSystem, Stream templateStream) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML file.- Parameters:
file- XML file to parseprocessSystem- target process systemtemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.- Throws:
IOException- if reading failsDexpiXmlReaderException- if the file cannot be parsed
-
load
public static void load(InputStream inputStream, ProcessSystem processSystem) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.- Parameters:
inputStream- XML input streamprocessSystem- target process system- Throws:
IOException- if reading failsDexpiXmlReaderException- if the stream cannot be parsed
-
load
public static void load(InputStream inputStream, ProcessSystem processSystem, Stream templateStream) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.- Parameters:
inputStream- XML input streamprocessSystem- target process systemtemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.- Throws:
IOException- if reading failsDexpiXmlReaderException- if the stream cannot be parsed
-
load
public static void load(InputStream inputStream, ProcessSystem processSystem, Stream templateStream, boolean namespaceAware) throws IOException, DexpiXmlReaderException Populates an existingProcessSystemwith units parsed from a DEXPI XML stream.- Parameters:
inputStream- XML input streamprocessSystem- target process systemtemplateStream- stream providing default fluid, temperature, pressure, and flow rate for generated piping segments. Ifnull, a methane/ethane default is used.namespaceAware- whether to enable namespace-aware XML parsing- Throws:
IOException- if reading failsDexpiXmlReaderException- if the stream cannot be parsed
-
readInstruments
public static List<DexpiInstrumentInfo> readInstruments(File file) throws IOException, DexpiXmlReaderException Reads instrument metadata from a DEXPI XML file. This returns structuredDexpiInstrumentInforecords that describe the P&ID instrumentation without creating live transmitter/controller objects (which require connected streams).- Parameters:
file- DEXPI XML file- Returns:
- list of instrument info records parsed from the file
- Throws:
IOException- if the file cannot be readDexpiXmlReaderException- if the file cannot be parsed
-
readInstruments
public static List<DexpiInstrumentInfo> readInstruments(InputStream inputStream) throws IOException, DexpiXmlReaderException Reads instrument metadata from a DEXPI XML stream.- Parameters:
inputStream- stream containing DEXPI XML data- Returns:
- list of instrument info records parsed from the stream
- Throws:
IOException- if the stream cannot be readDexpiXmlReaderException- if the stream cannot be parsed
-
parseInstrumentsFromDocument
Parses instruments from an already-parsed DEXPI XML Document. Package-visible for use byDexpiSimulationBuilder.- Parameters:
document- the parsed XML document- Returns:
- list of instrument info records
-
parseInstruments
Parses all ProcessInstrumentationFunction elements from the document, resolving loop and actuator associations.- Parameters:
document- the parsed XML document- Returns:
- list of instrument info records
-
parseDocument
private static Document parseDocument(InputStream inputStream, boolean nsAware) throws DexpiXmlReaderException - Throws:
DexpiXmlReaderException
-
addUnits
private static void addUnits(Document document, ProcessSystem processSystem, String tagName, Map<String, EquipmentEnum> equipmentMap, String nameAttribute) -
addPipingSegments
private static void addPipingSegments(Document document, ProcessSystem processSystem, Stream templateStream) -
addDexpiStream
private static void addDexpiStream(ProcessSystem processSystem, Element element, Stream templateStream, String baseName) -
addDexpiUnit
private static void addDexpiUnit(ProcessSystem processSystem, Element element, EquipmentEnum equipmentEnum, String baseName, String componentClass) -
prependLineOrFluid
-
ensureUniqueName
-
templateOrDefault
-
createDefaultTemplateStream
-
createDefaultFluid
-
getGenericAttribute
-
attributeValue
-
applyStreamMetadata
-
applyNumericAttribute
-
parseNumeric
-
directChildElements
-
findAttributeInAncestors
-
firstNonEmpty
-
isInsideShapeCatalogue
Checks whether the given node is inside a ShapeCatalogue element.- Parameters:
node- the XML node to check- Returns:
- true if the node has a ShapeCatalogue ancestor
-
isBlank
-