Class ProcessAutomation
ProcessSystem or ProcessModel. Variables in the simulation are reachable through
stable dot-notation paths such as "separator-1.gasOutStream.temperature", removing the
need to navigate Java objects directly.
When backed by a ProcessModel (multi-area plant), addresses use area-qualified syntax:
"AreaName::UnitName.property" or "AreaName::UnitName.port.property".
The core operations are:
getUnitList()— list all unit operation namesgetAreaList()— list all process area names (ProcessModel only)getUnitList(String)— list units in a specific areagetVariableList(String)— list all variables for a unitgetVariableValue(String, String)— read a variable by addresssetVariableValue(String, double, String)— write an input variable
Address format: unitName.property or
unitName.streamPort.property
Example usage:
// Single ProcessSystem
ProcessAutomation auto = new ProcessAutomation(process);
// List all units
List<String> units = auto.getUnitList();
// List variables for a separator
List<SimulationVariable> vars = auto.getVariableList("HP Sep");
// Read a value
double temp = auto.getVariableValue("HP Sep.gasOutStream.temperature", "C");
// Set an input
auto.setVariableValue("Compressor.outletPressure", 120.0, "bara");
// Multi-area ProcessModel
ProcessAutomation plantAuto = new ProcessAutomation(plantModel);
List<String> areas = plantAuto.getAreaList();
List<String> areaUnits = plantAuto.getUnitList("Separation");
double p = plantAuto.getVariableValue("Separation::HP Sep.pressure", "bara");
- Version:
- 1.0
- Author:
- Even Solbraa
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classHolds a resolved unit and its address prefix for variable naming. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSeparator between area name and unit address in multi-area mode.private final AutomationDiagnosticsprivate final ProcessModelprivate final ProcessSystem -
Constructor Summary
ConstructorsConstructorDescriptionProcessAutomation(ProcessModel processModel) Creates an automation facade for a multi-area process model.ProcessAutomation(ProcessSystem processSystem) Creates an automation facade for a single process system. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddOutletStreamVariables(List<SimulationVariable> vars, String unitName, ProcessEquipmentInterface unit) Adds outlet stream variables for single-outlet equipment.private voidaddStreamOutputVariables(List<SimulationVariable> vars, String prefix, StreamInterface stream) Adds read-only stream variables for an output stream.private voidaddStreamVariables(List<SimulationVariable> vars, String prefix, StreamInterface stream, boolean isInput) Adds stream variables (temperature, pressure, flowRate) with appropriate INPUT/OUTPUT type.private StringbuildAutoCorrectedJson(String originalAddress, String correctedAddress, double value, String unit, AutomationDiagnostics.DiagnosticResult diag) Builds a JSON response for a successful auto-corrected get operation.private StringbuildAutoCorrectedSetJson(String originalAddress, String correctedAddress, double value, String unit, AutomationDiagnostics.DiagnosticResult diag) Builds a JSON response for a successful auto-corrected set operation.private StringbuildSetSuccessJson(String address, double value, String unit, String warningJson) Builds a success JSON response for a set operation.private StringbuildSuccessJson(String address, double value, String unit) Builds a success JSON response for a get operation.private List<SimulationVariable> buildVariableList(String unitName, ProcessEquipmentInterface unit) Builds the list of variables exposed by a unit operation.diagnoseAndAttemptRecovery(String address, IllegalArgumentException error) Diagnoses an address resolution failure and attempts recovery via fuzzy matching.private StringextractPropertyName(String address) Extracts the property name from an address (the last dot-separated segment).private ProcessEquipmentInterfacefindByReferenceDesignation(String areaName, String refDesString) Finds a unit by its IEC 81346 reference designation string.private ProcessEquipmentInterfaceFinds a unit by name, optionally scoped to a specific area.Returns the names of all process areas.Returns the diagnostics instance for this automation facade.private doublegetEquipmentProperty(ProcessEquipmentInterface unit, String property, String uom) Gets a property value directly from an equipment object.getEquipmentType(String unitName) Returns the simple class name (equipment type) of a unit operation.Gets plain (non-area-qualified) unit names from a ProcessSystem.private doublegetStreamProperty(StreamInterface stream, String property, String uom) Gets a property value from a stream.Returns the names of all unit operations.getUnitList(String areaName) Returns the names of unit operations in a specific process area.getVariableList(String unitName) Returns all available variables for the named unit operation.getVariableList(String unitName, SimulationVariable.VariableType type) Returns variables for the named unit, filtered by type.doublegetVariableValue(String address, String unitOfMeasure) Reads the current value of a simulation variable.getVariableValueSafe(String address, String unitOfMeasure) Reads a variable value with self-healing: if the exact address fails, attempts auto-correction via fuzzy matching against known unit names and variable addresses.booleanReturns whether this automation facade is backed by aProcessModel(multi-area).private StreamInterfaceresolveStreamPort(ProcessEquipmentInterface unit, String portName) Resolves a stream port name to the actual stream object.private ProcessAutomation.ResolvedUnitresolveUnit(String unitName) Resolves a unit name (optionally area-qualified) to the equipment and its address prefix.private ProcessEquipmentInterfacesearchByRefDes(ProcessSystem ps, String refDesString) Searches a process system for equipment matching a reference designation string.private voidsetEquipmentProperty(ProcessEquipmentInterface unit, String property, double value, String uom) Sets a property value directly on an equipment object.private voidsetStreamProperty(StreamInterface stream, String property, double value, String uom) Sets a property value on a stream.voidsetVariableValue(String address, double value, String unitOfMeasure) Sets the value of a simulation input variable.setVariableValueSafe(String address, double value, String unitOfMeasure) Sets a variable value with self-healing: if the exact address fails, attempts auto-correction via fuzzy matching.
-
Field Details
-
AREA_SEPARATOR
Separator between area name and unit address in multi-area mode.- See Also:
-
processSystem
-
processModel
-
diagnostics
-
-
Constructor Details
-
ProcessAutomation
Creates an automation facade for a single process system.- Parameters:
processSystem- the process system to automate
-
ProcessAutomation
Creates an automation facade for a multi-area process model.In this mode, addresses use area-qualified syntax:
"AreaName::UnitName.property".- Parameters:
processModel- the process model to automate
-
-
Method Details
-
isMultiArea
public boolean isMultiArea()Returns whether this automation facade is backed by aProcessModel(multi-area).- Returns:
- true if backed by a ProcessModel, false if backed by a single ProcessSystem
-
getDiagnostics
Returns the diagnostics instance for this automation facade. The diagnostics provide fuzzy name matching, auto-correction, physical value validation, and operation history tracking.- Returns:
- the automation diagnostics
-
getVariableValueSafe
Reads a variable value with self-healing: if the exact address fails, attempts auto-correction via fuzzy matching against known unit names and variable addresses. Returns a JSON string with the value on success, or a diagnostic result with suggestions on failure.- Parameters:
address- the dot-notation address, e.g. "separator-1.gasOutStream.temperature"unitOfMeasure- the desired unit- Returns:
- JSON result string with either value or diagnostic information
-
setVariableValueSafe
Sets a variable value with self-healing: if the exact address fails, attempts auto-correction via fuzzy matching. Also validates the value against physical bounds before setting.- Parameters:
address- the dot-notation addressvalue- the value to setunitOfMeasure- the unit of the value- Returns:
- JSON result string with either success or diagnostic information
-
getAreaList
Returns the names of all process areas. Only available when backed by aProcessModel.- Returns:
- unmodifiable list of area names in insertion order
- Throws:
IllegalStateException- if backed by a single ProcessSystem
-
getUnitList
Returns the names of all unit operations. When backed by aProcessModel, returns area-qualified names in the format"AreaName::UnitName".- Returns:
- unmodifiable list of unit operation names
-
getUnitList
Returns the names of unit operations in a specific process area. Only available when backed by aProcessModel.- Parameters:
areaName- the name of the process area- Returns:
- unmodifiable list of unit operation names (without area prefix)
- Throws:
IllegalStateException- if backed by a single ProcessSystemIllegalArgumentException- if the area is not found
-
getVariableList
Returns all available variables for the named unit operation.- Parameters:
unitName- the name of the unit operation- Returns:
- list of variable descriptors
- Throws:
IllegalArgumentException- if the unit is not found
-
getVariableList
public List<SimulationVariable> getVariableList(String unitName, SimulationVariable.VariableType type) Returns variables for the named unit, filtered by type.When backed by a
ProcessModel, theunitNamemay be area-qualified:"AreaName::UnitName".- Parameters:
unitName- the name of the unit operation, optionally area-qualifiedtype- the variable type filter, or null for all variables- Returns:
- list of variable descriptors matching the filter
- Throws:
IllegalArgumentException- if the unit is not found
-
getEquipmentType
Returns the simple class name (equipment type) of a unit operation. Useful for discovering what kind of equipment a unit is, e.g. "Compressor", "Separator", "PipeBeggsAndBrills".- Parameters:
unitName- the name of the unit operation, optionally area-qualified- Returns:
- the simple class name of the equipment
- Throws:
IllegalArgumentException- if the unit is not found
-
getVariableValue
Reads the current value of a simulation variable.When backed by a
ProcessModel, the address must be area-qualified:"AreaName::unitName.property"or"AreaName::unitName.streamPort.property".- Parameters:
address- the dot-notation address, e.g. "separator-1.gasOutStream.temperature" or "Separation::separator-1.gasOutStream.temperature"unitOfMeasure- the desired unit, e.g. "C", "bara", "kg/hr". Pass null or empty for default units- Returns:
- the variable value in the requested unit
- Throws:
IllegalArgumentException- if the address cannot be resolved
-
setVariableValue
Sets the value of a simulation input variable. Only variables withINPUTtype can be set.When backed by a
ProcessModel, the address must be area-qualified:"AreaName::Compressor.outletPressure".- Parameters:
address- the dot-notation address, e.g. "Compressor.outletPressure" or "Compression::Compressor.outletPressure"value- the value to setunitOfMeasure- the unit of the provided value, e.g. "bara", "C". Pass null or empty for default units- Throws:
IllegalArgumentException- if the address cannot be resolved or the variable is read-only
-
resolveUnit
Resolves a unit name (optionally area-qualified) to the equipment and its address prefix.- Parameters:
unitName- the unit name, optionally with area prefix "AreaName::UnitName"- Returns:
- the resolved unit and address prefix
- Throws:
IllegalArgumentException- if the unit is not found
-
findUnit
Finds a unit by name, optionally scoped to a specific area.- Parameters:
areaName- the area name, or null to search the single ProcessSystem (or all areas)unitName- the unit name- Returns:
- the equipment
- Throws:
IllegalArgumentException- if the unit is not found
-
getPlainUnitNames
Gets plain (non-area-qualified) unit names from a ProcessSystem.- Parameters:
ps- the process system- Returns:
- list of unit names
-
findByReferenceDesignation
Finds a unit by its IEC 81346 reference designation string.Searches all equipment in the relevant process system(s) for a matching reference designation. This enables addressing equipment by their IEC 81346 codes, e.g. "=A1-B1" or "-K2".
- Parameters:
areaName- the area name to search within (null to search all)refDesString- the reference designation string to match- Returns:
- the matching equipment, or null if not found
-
searchByRefDes
Searches a process system for equipment matching a reference designation string.- Parameters:
ps- the process system to searchrefDesString- the reference designation to match- Returns:
- the matching equipment, or null if not found
-
buildVariableList
Builds the list of variables exposed by a unit operation.- Parameters:
unitName- the unit name (used as address prefix)unit- the unit operation- Returns:
- list of variables
-
addStreamVariables
private void addStreamVariables(List<SimulationVariable> vars, String prefix, StreamInterface stream, boolean isInput) Adds stream variables (temperature, pressure, flowRate) with appropriate INPUT/OUTPUT type.- Parameters:
vars- the list to add toprefix- the address prefixstream- the streamisInput- whether the stream properties are settable
-
addStreamOutputVariables
private void addStreamOutputVariables(List<SimulationVariable> vars, String prefix, StreamInterface stream) Adds read-only stream variables for an output stream.- Parameters:
vars- the list to add toprefix- the address prefix including port namestream- the stream
-
addOutletStreamVariables
private void addOutletStreamVariables(List<SimulationVariable> vars, String unitName, ProcessEquipmentInterface unit) Adds outlet stream variables for single-outlet equipment.- Parameters:
vars- the list to add tounitName- the unit nameunit- the equipment
-
getEquipmentProperty
Gets a property value directly from an equipment object.- Parameters:
unit- the equipmentproperty- the property nameuom- the desired unit of measure- Returns:
- the property value
-
setEquipmentProperty
private void setEquipmentProperty(ProcessEquipmentInterface unit, String property, double value, String uom) Sets a property value directly on an equipment object.- Parameters:
unit- the equipmentproperty- the property namevalue- the value to setuom- the unit of measure for the value
-
resolveStreamPort
Resolves a stream port name to the actual stream object.- Parameters:
unit- the equipmentportName- the port name, e.g. "gasOutStream", "liquidOutStream", "outletStream"- Returns:
- the resolved stream, or null if not found
-
getStreamProperty
Gets a property value from a stream.- Parameters:
stream- the streamproperty- the property nameuom- the desired unit of measure- Returns:
- the property value
-
setStreamProperty
Sets a property value on a stream.- Parameters:
stream- the streamproperty- the property namevalue- the value to setuom- the unit of measure
-
diagnoseAndAttemptRecovery
private AutomationDiagnostics.DiagnosticResult diagnoseAndAttemptRecovery(String address, IllegalArgumentException error) Diagnoses an address resolution failure and attempts recovery via fuzzy matching.- Parameters:
address- the failed addresserror- the caught exception- Returns:
- a diagnostic result with suggestions and possible auto-correction
-
extractPropertyName
-
buildSuccessJson
-
buildAutoCorrectedJson
private String buildAutoCorrectedJson(String originalAddress, String correctedAddress, double value, String unit, AutomationDiagnostics.DiagnosticResult diag) Builds a JSON response for a successful auto-corrected get operation.- Parameters:
originalAddress- the original address that failedcorrectedAddress- the corrected address that succeededvalue- the value readunit- the unit of measurediag- the diagnostic result- Returns:
- JSON string
-
buildSetSuccessJson
Builds a success JSON response for a set operation.- Parameters:
address- the addressvalue- the value setunit- the unit of measurewarningJson- JSON warning from bounds validation, or null- Returns:
- JSON string
-
buildAutoCorrectedSetJson
private String buildAutoCorrectedSetJson(String originalAddress, String correctedAddress, double value, String unit, AutomationDiagnostics.DiagnosticResult diag) Builds a JSON response for a successful auto-corrected set operation.- Parameters:
originalAddress- the original address that failedcorrectedAddress- the corrected address that succeededvalue- the value setunit- the unit of measurediag- the diagnostic result- Returns:
- JSON string
-