Interface PdPublisherHandle


public interface PdPublisherHandle
Handle to a publisher registered with a TrdpPdSession. Provides data staging and immediate send operations.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the ComID of this publisher.
    long
    Returns the cyclic send interval in microseconds.
    long
    Returns the number of packets successfully sent.
    long
    Returns the number of send errors encountered.
    void
    putData(byte[] data)
    Updates the current process data without sending immediately.
    void
    putDataImmediate(byte[] data)
    Updates the data and immediately sends it to the configured destination.
    void
    Resets all statistics counters to zero.
    void
    setDataSupplier(Supplier<byte[]> supplier)
    Sets a supplier that provides fresh data for each cyclic send.
  • Method Details

    • putData

      void putData(byte[] data)
      Updates the current process data without sending immediately. The data will be sent on the next cyclic interval (if configured) or in response to a pull request.
      Parameters:
      data - The process data to stage.
      Throws:
      IllegalArgumentException - if data exceeds maximum PD data size.
    • setDataSupplier

      void setDataSupplier(Supplier<byte[]> supplier)
      Sets a supplier that provides fresh data for each cyclic send. When set, the supplier is called before each cyclic send instead of using the static data from putData(byte[]). This allows building dynamic data (e.g. incrementing counters) in sync with actual packet sends.

      Set to null to revert to static data staging via putData(byte[]).

      Parameters:
      supplier - a supplier that returns the process data bytes, or null to disable
    • putDataImmediate

      void putDataImmediate(byte[] data) throws IOException
      Updates the data and immediately sends it to the configured destination. Only allowed on non-cyclic publishers (intervalUs == 0). For cyclic publishers, use putData(byte[]) to stage data for the next cyclic send.
      Parameters:
      data - The process data to send.
      Throws:
      IOException - If sending fails.
      IllegalStateException - if called on a cyclic publisher (intervalUs > 0).
      IllegalArgumentException - if data exceeds maximum PD data size.
    • getComId

      int getComId()
      Returns the ComID of this publisher.
    • getIntervalUs

      long getIntervalUs()
      Returns the cyclic send interval in microseconds. 0 means no cyclic send.
    • getPacketsSent

      long getPacketsSent()
      Returns the number of packets successfully sent.
    • getSendErrors

      long getSendErrors()
      Returns the number of send errors encountered.
    • resetStatistics

      void resetStatistics()
      Resets all statistics counters to zero.