mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[ntcore] Add sub option for local vs remote changes (#4731)
This is the subscriber readQueue version of the local value listener flag.
This commit is contained in:
@@ -95,6 +95,7 @@ enum NT_PubSubOptionType {
|
||||
NT_PUBSUB_TOPICSONLY, /* only send topic changes, no value changes */
|
||||
NT_PUBSUB_POLLSTORAGE, /* polling storage for subscription */
|
||||
NT_PUBSUB_KEEPDUPLICATES, /* preserve duplicate values */
|
||||
NT_PUBSUB_LOCALREMOTE, /* local, remote, or any value changes */
|
||||
};
|
||||
|
||||
/** Event notification flags. */
|
||||
@@ -287,7 +288,8 @@ struct NT_PubSubOption {
|
||||
|
||||
/**
|
||||
* Option value. 1 (true) or 0 (false) for immediate and logging options,
|
||||
* time between updates, in seconds, for periodic option.
|
||||
* time between updates, in seconds, for periodic option. For local/remote
|
||||
* option, 1=local only, 2=remote only, 0 or 3=both local and remote.
|
||||
*/
|
||||
double value;
|
||||
};
|
||||
|
||||
@@ -314,7 +314,7 @@ class PubSubOption {
|
||||
|
||||
/**
|
||||
* Polling storage for subscription. Specifies the maximum number of updates
|
||||
* NetworkTables should store between calls to the subscriber's poll()
|
||||
* NetworkTables should store between calls to the subscriber's ReadQueue()
|
||||
* function. Defaults to 1 if SendAll is false, 20 if SendAll is true.
|
||||
*
|
||||
* @param depth number of entries to save for polling.
|
||||
@@ -324,6 +324,39 @@ class PubSubOption {
|
||||
return PubSubOption{NT_PUBSUB_POLLSTORAGE, static_cast<double>(depth)};
|
||||
}
|
||||
|
||||
/**
|
||||
* If only local value updates should be queued for ReadQueue(). See also
|
||||
* RemoteOnly() and AllUpdates(). Default is AllUpdates. Only has an effect on
|
||||
* subscriptions.
|
||||
*
|
||||
* @return option
|
||||
*/
|
||||
static constexpr PubSubOption LocalOnly() {
|
||||
return PubSubOption{NT_PUBSUB_LOCALREMOTE, 1.0};
|
||||
}
|
||||
|
||||
/**
|
||||
* If only remote value updates should be queued for ReadQueue(). See also
|
||||
* LocalOnly() and AllUpdates(). Default is AllUpdates. Only has an effect on
|
||||
* subscriptions.
|
||||
*
|
||||
* @return option
|
||||
*/
|
||||
static constexpr PubSubOption RemoteOnly() {
|
||||
return PubSubOption{NT_PUBSUB_LOCALREMOTE, 2.0};
|
||||
}
|
||||
|
||||
/**
|
||||
* If both local and remote value updates should be queued for ReadQueue().
|
||||
* See also LocalOnly() and RemoteOnly(). Default is AllUpdates. Only has an
|
||||
* effect on subscriptions.
|
||||
*
|
||||
* @return option
|
||||
*/
|
||||
static constexpr PubSubOption AllUpdates() {
|
||||
return PubSubOption{NT_PUBSUB_LOCALREMOTE, 0.0};
|
||||
}
|
||||
|
||||
NT_PubSubOptionType type;
|
||||
double value;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user