Interface PdPublisherHandle
public interface PdPublisherHandle
Handle to a publisher registered with a
TrdpPdSession.
Provides data staging and immediate send operations.-
Method Summary
Modifier and TypeMethodDescriptionintgetComId()Returns the ComID of this publisher.longReturns the cyclic send interval in microseconds.longReturns the number of packets successfully sent.longReturns the number of send errors encountered.voidputData(byte[] data) Updates the current process data without sending immediately.voidputDataImmediate(byte[] data) Updates the data and immediately sends it to the configured destination.voidResets all statistics counters to zero.voidsetDataSupplier(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
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 fromputData(byte[]). This allows building dynamic data (e.g. incrementing counters) in sync with actual packet sends.Set to
nullto revert to static data staging viaputData(byte[]).- Parameters:
supplier- a supplier that returns the process data bytes, or null to disable
-
putDataImmediate
Updates the data and immediately sends it to the configured destination. Only allowed on non-cyclic publishers (intervalUs == 0). For cyclic publishers, useputData(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.
-