Class ReferenceDesignationGenerator

java.lang.Object
neqsim.process.equipment.iec81346.ReferenceDesignationGenerator
All Implemented Interfaces:
Serializable

public class ReferenceDesignationGenerator extends Object implements Serializable
Generates IEC 81346 reference designations for all elements in a ProcessSystem or ProcessModel.

The generator walks the process topology and automatically assigns reference designations based on the three IEC 81346 aspects:

  • Function aspect (=): Derived from the process area name or a user-defined prefix. In a ProcessModel, each process area becomes a function sub-level.
  • Product aspect (-): Derived from the IEC 81346-2 letter code (mapped from equipment type) and a sequence number within that category.
  • Location aspect (+): User-defined location prefix, e.g. "P1" for Platform 1.

Usage example — single ProcessSystem:

ReferenceDesignationGenerator gen = new ReferenceDesignationGenerator(process);
gen.setFunctionPrefix("A1");
gen.setLocationPrefix("P1.M1");
gen.generate();

// Each equipment now has a reference designation:
String ref = process.getUnit("HP Sep").getReferenceDesignationString();
// e.g. "=A1-B1+P1.M1"

// Export report as JSON:
String json = gen.toJson();

Usage example — multi-area ProcessModel:

ReferenceDesignationGenerator gen = new ReferenceDesignationGenerator(plant);
gen.setLocationPrefix("P1");
gen.generate();

// Area names are used as function sub-levels:
// "Separation" area → =A1 (first area)
// "Compression" area → =A2 (second area)
// Equipment in Separation: =A1-B1, =A1-B2, =A1-K1
// Equipment in Compression: =A2-K1, =A2-K2
Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • processSystem

      private ProcessSystem processSystem
      The single process system to generate designations for (null if multi-area).
    • processModel

      private ProcessModel processModel
      The multi-area process model to generate designations for (null if single-area).
    • functionPrefix

      private String functionPrefix
      User-defined function prefix (without =), e.g. "A1".
    • locationPrefix

      private String locationPrefix
      User-defined location prefix (without +), e.g. "P1.M1".
    • includeStreams

      private boolean includeStreams
      Whether to assign designations to stream objects.
    • includeMeasurementDevices

      private boolean includeMeasurementDevices
      Whether to assign designations to measurement devices.
    • useHierarchicalFunctions

      private boolean useHierarchicalFunctions
      Whether to use hierarchical function designations in multi-area models. When true, each area function prefix is formed by appending to the top-level function prefix with a dot separator (e.g. "A1.A1", "A1.A2"). When false (default), areas use flat numbering ("A1", "A2").
    • generated

      private boolean generated
      Whether generation has been run.
    • entries

      The generated designation entries, in order.
  • Constructor Details

    • ReferenceDesignationGenerator

      public ReferenceDesignationGenerator(ProcessSystem processSystem)
      Creates a generator for a single process system.
      Parameters:
      processSystem - the process system to generate designations for
    • ReferenceDesignationGenerator

      public ReferenceDesignationGenerator(ProcessModel processModel)
      Creates a generator for a multi-area process model.
      Parameters:
      processModel - the process model to generate designations for
    • ReferenceDesignationGenerator

      public ReferenceDesignationGenerator()
      Creates a generator with no bound system. Use with generate(ProcessSystem) or generate(ProcessModel) to bind a system at generation time.
  • Method Details

    • setFunctionPrefix

      public void setFunctionPrefix(String functionPrefix)
      Sets the function prefix for the top-level function aspect.

      For a single ProcessSystem, this is used directly (e.g. "A1" produces "=A1"). For a ProcessModel, each area gets a sub-level (e.g. first area becomes "A1", second "A2").

      Parameters:
      functionPrefix - the function prefix without the = character
    • getFunctionPrefix

      public String getFunctionPrefix()
      Returns the current function prefix.
      Returns:
      the function prefix without the = character
    • setLocationPrefix

      public void setLocationPrefix(String locationPrefix)
      Sets the location prefix for the location aspect.
      Parameters:
      locationPrefix - the location prefix without the + character, e.g. "P1.M1"
    • getLocationPrefix

      public String getLocationPrefix()
      Returns the current location prefix.
      Returns:
      the location prefix without the + character
    • setIncludeStreams

      public void setIncludeStreams(boolean includeStreams)
      Sets whether to include stream objects in designation generation.
      Parameters:
      includeStreams - true to assign designations to streams
    • isIncludeStreams

      public boolean isIncludeStreams()
      Returns whether stream objects are included in designation generation.
      Returns:
      true if streams are included
    • setIncludeMeasurementDevices

      public void setIncludeMeasurementDevices(boolean includeMeasurementDevices)
      Sets whether to include measurement devices in designation generation.
      Parameters:
      includeMeasurementDevices - true to assign designations to measurement devices
    • isIncludeMeasurementDevices

      public boolean isIncludeMeasurementDevices()
      Returns whether measurement devices are included in designation generation.
      Returns:
      true if measurement devices are included
    • setUseHierarchicalFunctions

      public void setUseHierarchicalFunctions(boolean useHierarchicalFunctions)
      Sets whether to use hierarchical function designations in multi-area models. When true, each area function prefix is formed by appending to the top-level function prefix with a dot (e.g. "A1.A1", "A1.A2"). When false (default), areas use flat numbering ("A1", "A2").
      Parameters:
      useHierarchicalFunctions - true for hierarchical, false for flat
    • isUseHierarchicalFunctions

      public boolean isUseHierarchicalFunctions()
      Returns whether hierarchical function designations are used.
      Returns:
      true if hierarchical mode is enabled
    • generate

      public void generate()
      Generates IEC 81346 reference designations for all elements.

      After calling this method, each equipment object in the process system or model will have its ReferenceDesignation set. The generated designations can be retrieved with ProcessEquipmentInterface.getReferenceDesignation().

      Calling this method multiple times will regenerate all designations.

    • generate

      public void generate(ProcessSystem system)
      Binds the given process system and generates designations for it.
      Parameters:
      system - the process system to generate designations for
    • generate

      public void generate(ProcessModel model)
      Binds the given process model and generates designations for it.
      Parameters:
      model - the process model to generate designations for
    • generateForModel

      private void generateForModel()
      Generates designations for a multi-area process model.
    • generateForSystem

      private void generateForSystem(ProcessSystem system, String funcPrefix, String locPrefix)
      Generates designations for a single process system.
      Parameters:
      system - the process system
      funcPrefix - the function prefix for this system
      locPrefix - the location prefix for this system
    • enrichConnections

      private void enrichConnections(ProcessSystem system)
      Enriches any explicit ProcessConnection objects in the given process system with IEC 81346 reference designation strings. For each connection, the source and target equipment names are looked up and their reference designation strings are copied to the connection metadata.
      Parameters:
      system - the process system whose connections should be enriched
    • generateForMeasurementDevices

      private void generateForMeasurementDevices(ProcessSystem system, String funcPrefix, String locPrefix, Map<IEC81346LetterCode, Integer> counters)
      Generates designations for measurement devices in a process system.
      Parameters:
      system - the process system
      funcPrefix - the function prefix
      locPrefix - the location prefix
      counters - the letter code counters (shared with equipment)
    • incrementCounter

      private int incrementCounter(Map<IEC81346LetterCode, Integer> counters, IEC81346LetterCode letterCode)
      Increments and returns the counter for a given letter code.
      Parameters:
      counters - the counter map
      letterCode - the letter code to increment
      Returns:
      the new sequence number (1-based)
    • getEntries

      Returns the list of all generated designation entries.
      Returns:
      unmodifiable list of designation entries
    • getDesignationCount

      public int getDesignationCount()
      Returns the number of generated designations.
      Returns:
      the number of entries
    • isGenerated

      public boolean isGenerated()
      Checks if generation has been performed.
      Returns:
      true if generate() has been called
    • findByName

      public ReferenceDesignationGenerator.DesignationEntry findByName(String equipmentName)
      Finds a designation entry by equipment name.
      Parameters:
      equipmentName - the equipment name to search for
      Returns:
      the designation entry, or null if not found
    • findByDesignation

      public ReferenceDesignationGenerator.DesignationEntry findByDesignation(String referenceDesignation)
      Finds a designation entry by reference designation string.
      Parameters:
      referenceDesignation - the reference designation string to search for
      Returns:
      the designation entry, or null if not found
    • findByLetterCode

      Returns all designation entries for a given IEC 81346-2 letter code.
      Parameters:
      letterCode - the letter code to filter by
      Returns:
      unmodifiable list of matching entries
    • getLetterCodeSummary

      public Map<IEC81346LetterCode, Integer> getLetterCodeSummary()
      Returns a summary map of letter code counts.
      Returns:
      map of letter code to count of equipment with that code
    • getNameToDesignationMap

      public Map<String,String> getNameToDesignationMap()
      Returns a cross-reference mapping from equipment name to reference designation string.
      Returns:
      unmodifiable map of equipment name to reference designation
    • getDesignationToNameMap

      public Map<String,String> getDesignationToNameMap()
      Returns a cross-reference mapping from reference designation string to equipment name.
      Returns:
      unmodifiable map of reference designation to equipment name
    • toJson

      public String toJson()
      Exports the generated designations as a JSON string.

      The JSON structure contains:

      • standard: "IEC 81346"
      • functionPrefix: The function prefix used
      • locationPrefix: The location prefix used
      • designationCount: Number of generated designations
      • letterCodeSummary: Count per letter code
      • designations: Array of designation entries with name, type, designation, letterCode, and description
      Returns:
      JSON string representation of all generated designations