Class ControllerDataExchange
java.lang.Object
neqsim.process.mpc.ControllerDataExchange
- All Implemented Interfaces:
Serializable
Provides a real-time data exchange interface between NeqSim MPC and external control systems.
This class enables bidirectional communication with industrial control systems by providing a standardized interface for reading process values, writing setpoints and constraints, and exchanging model data. The interface is designed to work with common industrial protocols and data historians.
Key features:
- Timestamped data vectors for MVs, CVs, and DVs
- Status flags for variable quality (good, bad, uncertain)
- Setpoint and constraint updates from external sources
- Model refresh triggers for adaptive control
- Execution status and diagnostics
The data exchange pattern supports both push and pull models:
- Push: Call
updateInputs(double[], double[], double[])to provide new process data - Pull: Call
getOutputs()to retrieve calculated control moves
Example integration with an external control system:
// Create data exchange interface
ControllerDataExchange exchange = mpc.createDataExchange();
// Periodic execution loop
while (running) {
// Read current values from plant (via OPC, historian, etc.)
double[] mvValues = readMVsFromPlant();
double[] cvValues = readCVsFromPlant();
double[] dvValues = readDVsFromPlant();
// Update controller inputs
exchange.updateInputs(mvValues, cvValues, dvValues);
// Check for setpoint changes from operator
if (operatorChangedSetpoints) {
exchange.updateSetpoints(newSetpoints);
}
// Execute control calculation
exchange.execute();
// Get outputs and write to plant
ControllerOutput output = exchange.getOutputs();
writeMVsToPlant(output.getMvTargets());
// Wait for next sample
Thread.sleep(sampleTimeMs);
}
- Since:
- 3.0
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContainer for controller output data.static enumExecution status.static enumQuality status flags. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ProcessLinkedMPCThe linked MPC controller.private double[]CV high limits.private double[]CV low limits.private double[][]Predicted CV trajectories.private ControllerDataExchange.QualityStatus[]CV quality flags.private double[]Current CV values.private ControllerDataExchange.QualityStatus[]DV quality flags.private double[]Current DV values.private longExecution count.private StringLast execution message.Last execution status.private InstantLast execution timestamp.private InstantLast input update timestamp.private ControllerDataExchange.QualityStatus[]MV quality flags.private double[]Calculated MV targets.private double[]Current MV values.private static final longprivate double[]Current setpoints. -
Constructor Summary
ConstructorsConstructorDescriptionControllerDataExchange(ProcessLinkedMPC controller) Construct a data exchange interface for a controller. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanbooleanexecute()Execute the control calculation.longGet the execution count.Get the execution message.Get the execution status.Get the last execution time.Get the last input update time.double[]Get the MV target values.Get the controller outputs.double[]Get the current setpoints.Get complete status for external monitoring.Get variable names for external system configuration.private voidvoidupdateInputs(double[] mvValues, double[] cvValues, double[] dvValues) Update input values from external source.voidupdateInputsWithQuality(double[] mvValues, double[] cvValues, double[] dvValues, ControllerDataExchange.QualityStatus[] mvQuality, ControllerDataExchange.QualityStatus[] cvQuality, ControllerDataExchange.QualityStatus[] dvQuality) Update input values with quality flags.voidupdateLimits(double[] lowLimits, double[] highLimits) Update CV limits from external source.voidupdateSetpoints(double[] setpoints) Update setpoints from external source.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
controller
The linked MPC controller. -
mvValues
private double[] mvValuesCurrent MV values. -
cvValues
private double[] cvValuesCurrent CV values. -
dvValues
private double[] dvValuesCurrent DV values. -
mvQuality
MV quality flags. -
cvQuality
CV quality flags. -
dvQuality
DV quality flags. -
setpoints
private double[] setpointsCurrent setpoints. -
cvLowLimits
private double[] cvLowLimitsCV low limits. -
cvHighLimits
private double[] cvHighLimitsCV high limits. -
lastInputUpdate
Last input update timestamp. -
lastExecution
Last execution timestamp. -
executionStatus
Last execution status. -
executionMessage
Last execution message. -
mvTargets
private double[] mvTargetsCalculated MV targets. -
cvPredictions
private double[][] cvPredictionsPredicted CV trajectories. -
executionCount
private long executionCountExecution count.
-
-
Constructor Details
-
ControllerDataExchange
Construct a data exchange interface for a controller.- Parameters:
controller- the MPC controller
-
-
Method Details
-
initialize
private void initialize() -
updateInputs
public void updateInputs(double[] mvValues, double[] cvValues, double[] dvValues) Update input values from external source.- Parameters:
mvValues- current MV valuescvValues- current CV valuesdvValues- current DV values (can be null if no DVs)
-
updateInputsWithQuality
public void updateInputsWithQuality(double[] mvValues, double[] cvValues, double[] dvValues, ControllerDataExchange.QualityStatus[] mvQuality, ControllerDataExchange.QualityStatus[] cvQuality, ControllerDataExchange.QualityStatus[] dvQuality) Update input values with quality flags.- Parameters:
mvValues- current MV valuescvValues- current CV valuesdvValues- current DV valuesmvQuality- MV quality flagscvQuality- CV quality flagsdvQuality- DV quality flags
-
updateSetpoints
public void updateSetpoints(double[] setpoints) Update setpoints from external source.- Parameters:
setpoints- new setpoint values
-
updateLimits
public void updateLimits(double[] lowLimits, double[] highLimits) Update CV limits from external source.- Parameters:
lowLimits- new low limitshighLimits- new high limits
-
execute
public boolean execute()Execute the control calculation.- Returns:
- true if execution was successful
-
checkDataQuality
private boolean checkDataQuality() -
getOutputs
Get the controller outputs.- Returns:
- a ControllerOutput object with targets and status
-
getMvTargets
public double[] getMvTargets()Get the MV target values.- Returns:
- copy of MV target values
-
getSetpoints
public double[] getSetpoints()Get the current setpoints.- Returns:
- copy of setpoint values
-
getExecutionStatus
Get the execution status.- Returns:
- the current execution status
-
getExecutionMessage
-
getExecutionCount
public long getExecutionCount()Get the execution count.- Returns:
- number of executions since creation
-
getLastInputUpdate
Get the last input update time.- Returns:
- timestamp of last input update
-
getLastExecution
-
getVariableNames
-
getStatus
-