Class ProcessDataPublisher

java.lang.Object
neqsim.process.streaming.ProcessDataPublisher
All Implemented Interfaces:
StreamingDataInterface

public class ProcessDataPublisher extends Object implements 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 Details

  • Constructor Details

    • ProcessDataPublisher

      public ProcessDataPublisher()
      Creates a new ProcessDataPublisher.
    • ProcessDataPublisher

      public ProcessDataPublisher(ProcessSystem processSystem)
      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

      public void setProcessSystem(ProcessSystem processSystem)
      Links this publisher to a ProcessSystem.
      Parameters:
      processSystem - the process system to monitor
    • addToStateVector

      public void addToStateVector(String tagId)
      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

      public void subscribeToUpdates(String tagId, Consumer<TimestampedValue> callback)
      Description copied from interface: StreamingDataInterface
      Subscribe to real-time updates for a specific tag.
      Specified by:
      subscribeToUpdates in interface StreamingDataInterface
      Parameters:
      tagId - the tag identifier (e.g., "PT-101", "FT-200")
      callback - function to call when new values arrive
    • unsubscribeFromUpdates

      public void unsubscribeFromUpdates(String tagId)
      Description copied from interface: StreamingDataInterface
      Unsubscribe from updates for a specific tag.
      Specified by:
      unsubscribeFromUpdates in interface StreamingDataInterface
      Parameters:
      tagId - the tag identifier
    • publishBatch

      public void publishBatch(Map<String, TimestampedValue> values)
      Description copied from interface: StreamingDataInterface
      Publish 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:
      publishBatch in interface StreamingDataInterface
      Parameters:
      values - map of tag IDs to their timestamped values
    • getStateVector

      public double[] getStateVector()
      Description copied from interface: StreamingDataInterface
      Get 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:
      getStateVector in interface StreamingDataInterface
      Returns:
      array of current state values
    • getStateVectorLabels

      public String[] getStateVectorLabels()
      Description copied from interface: StreamingDataInterface
      Get labels for state vector elements.
      Specified by:
      getStateVectorLabels in interface StreamingDataInterface
      Returns:
      array of tag IDs corresponding to state vector positions
    • getHistory

      public List<TimestampedValue> getHistory(String tagId, Duration lookback)
      Description copied from interface: StreamingDataInterface
      Get historical values for a tag.
      Specified by:
      getHistory in interface StreamingDataInterface
      Parameters:
      tagId - the tag identifier
      lookback - how far back to retrieve data
      Returns:
      list of timestamped values, ordered oldest to newest
    • getHistoryBatch

      public Map<String, List<TimestampedValue>> getHistoryBatch(List<String> tagIds, Duration lookback)
      Description copied from interface: StreamingDataInterface
      Get historical values for multiple tags aligned by timestamp.
      Specified by:
      getHistoryBatch in interface StreamingDataInterface
      Parameters:
      tagIds - list of tag identifiers
      lookback - how far back to retrieve data
      Returns:
      map of tag IDs to their historical values
    • getCurrentValue

      public TimestampedValue getCurrentValue(String tagId)
      Description copied from interface: StreamingDataInterface
      Get the current value for a tag.
      Specified by:
      getCurrentValue in interface StreamingDataInterface
      Parameters:
      tagId - the tag identifier
      Returns:
      the most recent value, or null if not available
    • isMonitored

      public boolean isMonitored(String tagId)
      Description copied from interface: StreamingDataInterface
      Check if a tag is being monitored.
      Specified by:
      isMonitored in interface StreamingDataInterface
      Parameters:
      tagId - the tag identifier
      Returns:
      true if the tag has subscribers or is being tracked
    • getMonitoredTags

      public List<String> getMonitoredTags()
      Description copied from interface: StreamingDataInterface
      Get all currently monitored tag IDs.
      Specified by:
      getMonitoredTags in interface StreamingDataInterface
      Returns:
      list of tag identifiers
    • setHistoryBufferSize

      public void setHistoryBufferSize(int maxSamples)
      Description copied from interface: StreamingDataInterface
      Set the buffer size for historical data.
      Specified by:
      setHistoryBufferSize in interface StreamingDataInterface
      Parameters:
      maxSamples - maximum number of samples to retain per tag
    • clearHistory

      public void clearHistory()
      Description copied from interface: StreamingDataInterface
      Clear all historical data.
      Specified by:
      clearHistory in interface StreamingDataInterface
    • getHistorySize

      public int getHistorySize(String tagId)
      Gets the number of stored samples for a tag.
      Parameters:
      tagId - the tag identifier
      Returns:
      number of samples in history
    • exportHistoryMatrix

      public double[][] exportHistoryMatrix(List<String> tagIds)
      Exports history as a 2D array for ML training.
      Parameters:
      tagIds - tags to include
      Returns:
      2D array where rows are time samples and columns are tags