Class ProcessDataPublisher
java.lang.Object
neqsim.process.streaming.ProcessDataPublisher
- All Implemented Interfaces:
StreamingDataInterface
Implementation of StreamingDataInterface for publishing process simulation data.
This class bridges NeqSim process simulations with AI-based production optimization platforms and real-time digital twin systems.
Features:
- Automatic tag discovery from ProcessSystem measurement devices
- Configurable history buffer for ML training data
- Thread-safe subscription management
- Batch publishing for high-throughput scenarios
- Version:
- 1.0
- Author:
- ESOL
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<String, TimestampedValue> private static final intprivate final Map<String, LinkedList<TimestampedValue>> private intprivate ProcessSystemprivate final Map<String, List<Consumer<TimestampedValue>>> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ProcessDataPublisher.ProcessDataPublisher(ProcessSystem processSystem) Creates a new ProcessDataPublisher linked to a ProcessSystem. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToStateVector(String tagId) Adds a tag to the state vector.voidClear all historical data.private voidDiscovers tags from the linked ProcessSystem's unit operations.double[][]exportHistoryMatrix(List<String> tagIds) Exports history as a 2D array for ML training.getCurrentValue(String tagId) Get the current value for a tag.getHistory(String tagId, Duration lookback) Get historical values for a tag.getHistoryBatch(List<String> tagIds, Duration lookback) Get historical values for multiple tags aligned by timestamp.intgetHistorySize(String tagId) Gets the number of stored samples for a tag.Get all currently monitored tag IDs.double[]Get current state vector for ML model input.String[]Get labels for state vector elements.booleanisMonitored(String tagId) Check if a tag is being monitored.voidpublishBatch(Map<String, TimestampedValue> values) Publish a batch of values for multiple tags efficiently.voidPublishes current values from all unit operations in the ProcessSystem.voidsetHistoryBufferSize(int maxSamples) Set the buffer size for historical data.voidsetProcessSystem(ProcessSystem processSystem) Links this publisher to a ProcessSystem.voidsubscribeToUpdates(String tagId, Consumer<TimestampedValue> callback) Subscribe to real-time updates for a specific tag.voidunsubscribeFromUpdates(String tagId) Unsubscribe from updates for a specific tag.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface StreamingDataInterface
publish
-
Field Details
-
DEFAULT_HISTORY_SIZE
private static final int DEFAULT_HISTORY_SIZE- See Also:
-
subscribers
-
history
-
currentValues
-
stateVectorTags
-
historyBufferSize
private int historyBufferSize -
processSystem
-
-
Constructor Details
-
ProcessDataPublisher
public ProcessDataPublisher()Creates a new ProcessDataPublisher. -
ProcessDataPublisher
Creates a new ProcessDataPublisher linked to a ProcessSystem.- Parameters:
processSystem- the process system to monitor
-
-
Method Details
-
discoverTags
private void discoverTags()Discovers tags from the linked ProcessSystem's unit operations. -
setProcessSystem
Links this publisher to a ProcessSystem.- Parameters:
processSystem- the process system to monitor
-
addToStateVector
Adds a tag to the state vector.- Parameters:
tagId- the tag identifier to add
-
publishFromProcessSystem
public void publishFromProcessSystem()Publishes current values from all unit operations in the ProcessSystem. -
subscribeToUpdates
Description copied from interface:StreamingDataInterfaceSubscribe to real-time updates for a specific tag.- Specified by:
subscribeToUpdatesin interfaceStreamingDataInterface- Parameters:
tagId- the tag identifier (e.g., "PT-101", "FT-200")callback- function to call when new values arrive
-
unsubscribeFromUpdates
Description copied from interface:StreamingDataInterfaceUnsubscribe from updates for a specific tag.- Specified by:
unsubscribeFromUpdatesin interfaceStreamingDataInterface- Parameters:
tagId- the tag identifier
-
publishBatch
Description copied from interface:StreamingDataInterfacePublish a batch of values for multiple tags efficiently.This method is optimized for high-throughput scenarios where many values need to be published simultaneously.
- Specified by:
publishBatchin interfaceStreamingDataInterface- Parameters:
values- map of tag IDs to their timestamped values
-
getStateVector
public double[] getStateVector()Description copied from interface:StreamingDataInterfaceGet current state vector for ML model input.Returns a numeric array representing the current state of all monitored variables. The order and meaning of elements is defined by
StreamingDataInterface.getStateVectorLabels().- Specified by:
getStateVectorin interfaceStreamingDataInterface- Returns:
- array of current state values
-
getStateVectorLabels
Description copied from interface:StreamingDataInterfaceGet labels for state vector elements.- Specified by:
getStateVectorLabelsin interfaceStreamingDataInterface- Returns:
- array of tag IDs corresponding to state vector positions
-
getHistory
Description copied from interface:StreamingDataInterfaceGet historical values for a tag.- Specified by:
getHistoryin interfaceStreamingDataInterface- Parameters:
tagId- the tag identifierlookback- how far back to retrieve data- Returns:
- list of timestamped values, ordered oldest to newest
-
getHistoryBatch
Description copied from interface:StreamingDataInterfaceGet historical values for multiple tags aligned by timestamp.- Specified by:
getHistoryBatchin interfaceStreamingDataInterface- Parameters:
tagIds- list of tag identifierslookback- how far back to retrieve data- Returns:
- map of tag IDs to their historical values
-
getCurrentValue
Description copied from interface:StreamingDataInterfaceGet the current value for a tag.- Specified by:
getCurrentValuein interfaceStreamingDataInterface- Parameters:
tagId- the tag identifier- Returns:
- the most recent value, or null if not available
-
isMonitored
Description copied from interface:StreamingDataInterfaceCheck if a tag is being monitored.- Specified by:
isMonitoredin interfaceStreamingDataInterface- Parameters:
tagId- the tag identifier- Returns:
- true if the tag has subscribers or is being tracked
-
getMonitoredTags
Description copied from interface:StreamingDataInterfaceGet all currently monitored tag IDs.- Specified by:
getMonitoredTagsin interfaceStreamingDataInterface- Returns:
- list of tag identifiers
-
setHistoryBufferSize
public void setHistoryBufferSize(int maxSamples) Description copied from interface:StreamingDataInterfaceSet the buffer size for historical data.- Specified by:
setHistoryBufferSizein interfaceStreamingDataInterface- Parameters:
maxSamples- maximum number of samples to retain per tag
-
clearHistory
public void clearHistory()Description copied from interface:StreamingDataInterfaceClear all historical data.- Specified by:
clearHistoryin interfaceStreamingDataInterface
-
getHistorySize
Gets the number of stored samples for a tag.- Parameters:
tagId- the tag identifier- Returns:
- number of samples in history
-
exportHistoryMatrix
-