[ntcore] Rename constants to all caps style (#8676)

This commit is contained in:
Peter Johnson
2026-03-15 20:44:45 -07:00
committed by GitHub
parent 86dd3ca2b7
commit ab7e4766f6
99 changed files with 736 additions and 732 deletions

View File

@@ -8,31 +8,31 @@ package org.wpilib.networktables;
@SuppressWarnings("MemberName")
public final class LogMessage {
/** Critical logging level. */
public static final int kCritical = 50;
public static final int CRITICAL = 50;
/** Error logging level. */
public static final int kError = 40;
public static final int ERR = 40;
/** Warning log level. */
public static final int kWarning = 30;
public static final int WARNING = 30;
/** Info log level. */
public static final int kInfo = 20;
public static final int INFO = 20;
/** Debug log level. */
public static final int kDebug = 10;
public static final int DEBUG = 10;
/** Debug log level 1. */
public static final int kDebug1 = 9;
public static final int DEBUG_1 = 9;
/** Debug log level 2. */
public static final int kDebug2 = 8;
public static final int DEBUG_2 = 8;
/** Debug log level 3. */
public static final int kDebug3 = 7;
public static final int DEBUG_3 = 7;
/** Debug log level 4. */
public static final int kDebug4 = 6;
public static final int DEBUG_4 = 6;
/** Log level of the message. */
public final int level;

View File

@@ -572,7 +572,7 @@ public final class NetworkTable {
return m_inst.addListener(
new String[] {m_pathWithSep},
EnumSet.of(NetworkTableEvent.Kind.kPublish, NetworkTableEvent.Kind.kImmediate),
EnumSet.of(NetworkTableEvent.Kind.PUBLISH, NetworkTableEvent.Kind.IMMEDIATE),
new Consumer<>() {
final Set<String> m_notifiedTables = new HashSet<>();

View File

@@ -18,43 +18,43 @@ public final class NetworkTableEvent {
* Initial listener addition. Set this to receive immediate notification of matches to other
* criteria.
*/
kImmediate(0x0001),
IMMEDIATE(0x0001),
/** Client connected (on server, any client connected). */
kConnected(0x0002),
CONNECTED(0x0002),
/** Client disconnected (on server, any client disconnected). */
kDisconnected(0x0004),
DISCONNECTED(0x0004),
/** Any connection event (connect or disconnect). */
kConnection(0x0004 | 0x0002),
CONNECTION(0x0004 | 0x0002),
/** New topic published. */
kPublish(0x0008),
PUBLISH(0x0008),
/** Topic unpublished. */
kUnpublish(0x0010),
UNPUBLISH(0x0010),
/** Topic properties changed. */
kProperties(0x0020),
PROPERTIES(0x0020),
/** Any topic event (publish, unpublish, or properties changed). */
kTopic(0x0020 | 0x0010 | 0x0008),
TOPIC(0x0020 | 0x0010 | 0x0008),
/** Topic value updated (via network). */
kValueRemote(0x0040),
VALUE_REMOTE(0x0040),
/** Topic value updated (local). */
kValueLocal(0x0080),
VALUE_LOCAL(0x0080),
/** Topic value updated (network or local). */
kValueAll(0x0080 | 0x0040),
VALUE_ALL(0x0080 | 0x0040),
/** Log message. */
kLogMessage(0x0100),
LOG_MESSAGE(0x0100),
/** Time synchronized with server. */
kTimeSync(0x0200);
TIME_SYNC(0x0200);
private final int value;

View File

@@ -87,9 +87,9 @@ public final class NetworkTableListenerPoller implements AutoCloseable {
* @return Listener handle
*/
public int addConnectionListener(boolean immediateNotify) {
EnumSet<NetworkTableEvent.Kind> eventKinds = EnumSet.of(NetworkTableEvent.Kind.kConnection);
EnumSet<NetworkTableEvent.Kind> eventKinds = EnumSet.of(NetworkTableEvent.Kind.CONNECTION);
if (immediateNotify) {
eventKinds.add(NetworkTableEvent.Kind.kImmediate);
eventKinds.add(NetworkTableEvent.Kind.IMMEDIATE);
}
return NetworkTablesJNI.addListener(m_handle, m_inst.getHandle(), eventKinds);
}
@@ -103,9 +103,9 @@ public final class NetworkTableListenerPoller implements AutoCloseable {
* @return Listener handle
*/
public int addTimeSyncListener(boolean immediateNotify) {
EnumSet<NetworkTableEvent.Kind> eventKinds = EnumSet.of(NetworkTableEvent.Kind.kTimeSync);
EnumSet<NetworkTableEvent.Kind> eventKinds = EnumSet.of(NetworkTableEvent.Kind.TIME_SYNC);
if (immediateNotify) {
eventKinds.add(NetworkTableEvent.Kind.kImmediate);
eventKinds.add(NetworkTableEvent.Kind.IMMEDIATE);
}
return NetworkTablesJNI.addListener(m_handle, m_inst.getHandle(), eventKinds);
}

View File

@@ -7,29 +7,29 @@ package org.wpilib.networktables;
/** Network table data types. */
public enum NetworkTableType {
/** Unassigned data type. */
kUnassigned(0, ""),
UNASSIGNED(0, ""),
/** Boolean data type. */
kBoolean(0x01, "boolean"),
BOOLEAN(0x01, "boolean"),
/** Double precision floating-point data type. */
kDouble(0x02, "double"),
DOUBLE(0x02, "double"),
/** String data type. */
kString(0x04, "string"),
STRING(0x04, "string"),
/** Raw data type. */
kRaw(0x08, "raw"),
RAW(0x08, "raw"),
/** Boolean array data type. */
kBooleanArray(0x10, "boolean[]"),
BOOLEAN_ARRAY(0x10, "boolean[]"),
/** Double precision floating-point array data type. */
kDoubleArray(0x20, "double[]"),
DOUBLE_ARRAY(0x20, "double[]"),
/** String array data type. */
kStringArray(0x40, "string[]"),
STRING_ARRAY(0x40, "string[]"),
/** Integer data type. */
kInteger(0x100, "int"),
INTEGER(0x100, "int"),
/** Single precision floating-point data type. */
kFloat(0x200, "float"),
FLOAT(0x200, "float"),
/** Integer array data type. */
kIntegerArray(0x400, "int[]"),
INTEGER_ARRAY(0x400, "int[]"),
/** Single precision floating-point array data type. */
kFloatArray(0x800, "float[]");
FLOAT_ARRAY(0x800, "float[]");
private final int m_value;
private final String m_valueStr;
@@ -65,18 +65,18 @@ public enum NetworkTableType {
*/
public static NetworkTableType getFromInt(int value) {
return switch (value) {
case 0x01 -> kBoolean;
case 0x02 -> kDouble;
case 0x04 -> kString;
case 0x08 -> kRaw;
case 0x10 -> kBooleanArray;
case 0x20 -> kDoubleArray;
case 0x40 -> kStringArray;
case 0x100 -> kInteger;
case 0x200 -> kFloat;
case 0x400 -> kIntegerArray;
case 0x800 -> kFloatArray;
default -> kUnassigned;
case 0x01 -> BOOLEAN;
case 0x02 -> DOUBLE;
case 0x04 -> STRING;
case 0x08 -> RAW;
case 0x10 -> BOOLEAN_ARRAY;
case 0x20 -> DOUBLE_ARRAY;
case 0x40 -> STRING_ARRAY;
case 0x100 -> INTEGER;
case 0x200 -> FLOAT;
case 0x400 -> INTEGER_ARRAY;
case 0x800 -> FLOAT_ARRAY;
default -> UNASSIGNED;
};
}
@@ -88,18 +88,18 @@ public enum NetworkTableType {
*/
public static NetworkTableType getFromString(String typeString) {
return switch (typeString) {
case "boolean" -> kBoolean;
case "double" -> kDouble;
case "float" -> kFloat;
case "int" -> kInteger;
case "string", "json" -> kString;
case "boolean[]" -> kBooleanArray;
case "double[]" -> kDoubleArray;
case "float[]" -> kFloatArray;
case "int[]" -> kIntegerArray;
case "string[]" -> kStringArray;
case "" -> kUnassigned;
default -> kRaw;
case "boolean" -> BOOLEAN;
case "double" -> DOUBLE;
case "float" -> FLOAT;
case "int" -> INTEGER;
case "string", "json" -> STRING;
case "boolean[]" -> BOOLEAN_ARRAY;
case "double[]" -> DOUBLE_ARRAY;
case "float[]" -> FLOAT_ARRAY;
case "int[]" -> INTEGER_ARRAY;
case "string[]" -> STRING_ARRAY;
case "" -> UNASSIGNED;
default -> RAW;
};
}

View File

@@ -67,7 +67,7 @@ public final class ProtobufTopic<T> extends Topic {
this,
ProtobufBuffer.create(m_proto),
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kRaw.getValue(), m_proto.getTypeString(), options),
m_handle, NetworkTableType.RAW.getValue(), m_proto.getTypeString(), options),
defaultValue,
false);
}
@@ -91,7 +91,7 @@ public final class ProtobufTopic<T> extends Topic {
this,
ProtobufBuffer.create(m_proto),
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kRaw.getValue(), m_proto.getTypeString(), options),
m_handle, NetworkTableType.RAW.getValue(), m_proto.getTypeString(), options),
null,
true);
}
@@ -118,7 +118,7 @@ public final class ProtobufTopic<T> extends Topic {
ProtobufBuffer.create(m_proto),
NetworkTablesJNI.publishEx(
m_handle,
NetworkTableType.kRaw.getValue(),
NetworkTableType.RAW.getValue(),
m_proto.getTypeString(),
properties,
options),
@@ -148,7 +148,7 @@ public final class ProtobufTopic<T> extends Topic {
this,
ProtobufBuffer.create(m_proto),
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kRaw.getValue(), m_proto.getTypeString(), options),
m_handle, NetworkTableType.RAW.getValue(), m_proto.getTypeString(), options),
defaultValue,
false);
}

View File

@@ -67,7 +67,7 @@ public final class StructArrayTopic<T> extends Topic {
this,
StructBuffer.create(m_struct),
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kRaw.getValue(), m_struct.getTypeString() + "[]", options),
m_handle, NetworkTableType.RAW.getValue(), m_struct.getTypeString() + "[]", options),
defaultValue,
false);
}
@@ -91,7 +91,7 @@ public final class StructArrayTopic<T> extends Topic {
this,
StructBuffer.create(m_struct),
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kRaw.getValue(), m_struct.getTypeString() + "[]", options),
m_handle, NetworkTableType.RAW.getValue(), m_struct.getTypeString() + "[]", options),
null,
true);
}
@@ -118,7 +118,7 @@ public final class StructArrayTopic<T> extends Topic {
StructBuffer.create(m_struct),
NetworkTablesJNI.publishEx(
m_handle,
NetworkTableType.kRaw.getValue(),
NetworkTableType.RAW.getValue(),
m_struct.getTypeString() + "[]",
properties,
options),
@@ -148,7 +148,7 @@ public final class StructArrayTopic<T> extends Topic {
this,
StructBuffer.create(m_struct),
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kRaw.getValue(), m_struct.getTypeString() + "[]", options),
m_handle, NetworkTableType.RAW.getValue(), m_struct.getTypeString() + "[]", options),
defaultValue,
false);
}

View File

@@ -66,7 +66,7 @@ public final class StructTopic<T> extends Topic {
this,
StructBuffer.create(m_struct),
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kRaw.getValue(), m_struct.getTypeString(), options),
m_handle, NetworkTableType.RAW.getValue(), m_struct.getTypeString(), options),
defaultValue,
false);
}
@@ -90,7 +90,7 @@ public final class StructTopic<T> extends Topic {
this,
StructBuffer.create(m_struct),
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kRaw.getValue(), m_struct.getTypeString(), options),
m_handle, NetworkTableType.RAW.getValue(), m_struct.getTypeString(), options),
null,
true);
}
@@ -117,7 +117,7 @@ public final class StructTopic<T> extends Topic {
StructBuffer.create(m_struct),
NetworkTablesJNI.publishEx(
m_handle,
NetworkTableType.kRaw.getValue(),
NetworkTableType.RAW.getValue(),
m_struct.getTypeString(),
properties,
options),
@@ -147,7 +147,7 @@ public final class StructTopic<T> extends Topic {
this,
StructBuffer.create(m_struct),
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kRaw.getValue(), m_struct.getTypeString(), options),
m_handle, NetworkTableType.RAW.getValue(), m_struct.getTypeString(), options),
defaultValue,
false);
}

View File

@@ -119,7 +119,7 @@ void InstanceImpl::StartServer(std::string_view persistFilename,
}
});
networkMode = NT_NET_MODE_SERVER | NT_NET_MODE_STARTING;
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIMESYNC, 0, 0, true);
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIME_SYNC, 0, 0, true);
m_serverTimeOffset = 0;
m_rtt2 = 0;
}
@@ -133,7 +133,7 @@ void InstanceImpl::StopServer() {
}
server = std::move(m_networkServer);
networkMode = NT_NET_MODE_NONE;
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIMESYNC, 0, 0, false);
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIME_SYNC, 0, 0, false);
m_serverTimeOffset.reset();
m_rtt2 = 0;
}
@@ -148,7 +148,7 @@ void InstanceImpl::StartClient(std::string_view identity) {
m_inst, identity, localStorage, connectionList, logger,
[this](int64_t serverTimeOffset, int64_t rtt2, bool valid) {
std::scoped_lock lock{m_mutex};
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIMESYNC, serverTimeOffset,
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIME_SYNC, serverTimeOffset,
rtt2, valid);
if (valid) {
m_serverTimeOffset = serverTimeOffset;
@@ -177,7 +177,7 @@ void InstanceImpl::StopClient() {
client.reset();
{
std::scoped_lock lock{m_mutex};
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIMESYNC, 0, 0, false);
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIME_SYNC, 0, 0, false);
m_serverTimeOffset.reset();
m_rtt2 = 0;
}
@@ -210,13 +210,13 @@ std::optional<int64_t> InstanceImpl::GetServerTimeOffset() {
void InstanceImpl::AddTimeSyncListener(NT_Listener listener,
unsigned int eventMask) {
std::scoped_lock lock{m_mutex};
eventMask &= (NT_EVENT_TIMESYNC | NT_EVENT_IMMEDIATE);
eventMask &= (NT_EVENT_TIME_SYNC | NT_EVENT_IMMEDIATE);
listenerStorage.Activate(listener, eventMask);
if ((eventMask & (NT_EVENT_TIMESYNC | NT_EVENT_IMMEDIATE)) ==
(NT_EVENT_TIMESYNC | NT_EVENT_IMMEDIATE) &&
if ((eventMask & (NT_EVENT_TIME_SYNC | NT_EVENT_IMMEDIATE)) ==
(NT_EVENT_TIME_SYNC | NT_EVENT_IMMEDIATE) &&
m_serverTimeOffset) {
listenerStorage.NotifyTimeSync({&listener, 1},
NT_EVENT_TIMESYNC | NT_EVENT_IMMEDIATE,
NT_EVENT_TIME_SYNC | NT_EVENT_IMMEDIATE,
*m_serverTimeOffset, m_rtt2, true);
}
}

View File

@@ -61,11 +61,11 @@ void ListenerStorage::Activate(NT_Listener listenerHandle, unsigned int mask,
m_valueListeners.Add(listener);
}
// detect the higher log bits too; see LoggerImpl
if ((deltaMask & NT_EVENT_LOGMESSAGE) != 0 ||
if ((deltaMask & NT_EVENT_LOG_MESSAGE) != 0 ||
(deltaMask & 0x1ff0000) != 0) {
m_logListeners.Add(listener);
}
if ((deltaMask & NT_EVENT_TIMESYNC) != 0) {
if ((deltaMask & NT_EVENT_TIME_SYNC) != 0) {
m_timeSyncListeners.Add(listener);
}
}
@@ -380,11 +380,11 @@ ListenerStorage::DoRemoveListeners(std::span<const NT_Listener> handles) {
if ((listener->eventMask & NT_EVENT_VALUE_ALL) != 0) {
m_valueListeners.Remove(listener.get());
}
if ((listener->eventMask & NT_EVENT_LOGMESSAGE) != 0 ||
if ((listener->eventMask & NT_EVENT_LOG_MESSAGE) != 0 ||
(listener->eventMask & 0x1ff0000) != 0) {
m_logListeners.Remove(listener.get());
}
if ((listener->eventMask & NT_EVENT_TIMESYNC) != 0) {
if ((listener->eventMask & NT_EVENT_TIME_SYNC) != 0) {
m_timeSyncListeners.Remove(listener.get());
}
}

View File

@@ -46,25 +46,25 @@ static constexpr unsigned int kFlagDebug4 = 1u << 24;
static unsigned int LevelToFlag(unsigned int level) {
if (level >= wpi::util::WPI_LOG_CRITICAL) {
return EventFlags::kLogMessage | kFlagCritical;
return EventFlags::LOG_MESSAGE | kFlagCritical;
} else if (level >= wpi::util::WPI_LOG_ERROR) {
return EventFlags::kLogMessage | kFlagError;
return EventFlags::LOG_MESSAGE | kFlagError;
} else if (level >= wpi::util::WPI_LOG_WARNING) {
return EventFlags::kLogMessage | kFlagWarning;
return EventFlags::LOG_MESSAGE | kFlagWarning;
} else if (level >= wpi::util::WPI_LOG_INFO) {
return EventFlags::kLogMessage | kFlagInfo;
return EventFlags::LOG_MESSAGE | kFlagInfo;
} else if (level >= wpi::util::WPI_LOG_DEBUG) {
return EventFlags::kLogMessage | kFlagDebug;
return EventFlags::LOG_MESSAGE | kFlagDebug;
} else if (level >= wpi::util::WPI_LOG_DEBUG1) {
return EventFlags::kLogMessage | kFlagDebug1;
return EventFlags::LOG_MESSAGE | kFlagDebug1;
} else if (level >= wpi::util::WPI_LOG_DEBUG2) {
return EventFlags::kLogMessage | kFlagDebug2;
return EventFlags::LOG_MESSAGE | kFlagDebug2;
} else if (level >= wpi::util::WPI_LOG_DEBUG3) {
return EventFlags::kLogMessage | kFlagDebug3;
return EventFlags::LOG_MESSAGE | kFlagDebug3;
} else if (level >= wpi::util::WPI_LOG_DEBUG4) {
return EventFlags::kLogMessage | kFlagDebug4;
return EventFlags::LOG_MESSAGE | kFlagDebug4;
} else {
return EventFlags::kLogMessage;
return EventFlags::LOG_MESSAGE;
}
}
@@ -108,7 +108,7 @@ static unsigned int LevelsToEventMask(unsigned int minLevel,
mask |= kFlagDebug4;
}
if (mask == 0) {
mask = EventFlags::kLogMessage;
mask = EventFlags::LOG_MESSAGE;
}
return mask;
}
@@ -125,7 +125,7 @@ void LoggerImpl::AddListener(NT_Listener listener, unsigned int minLevel,
m_listenerLevels.emplace_back(listener, minLevel, maxLevel);
m_listenerStorage.Activate(listener, LevelsToEventMask(minLevel, maxLevel),
[](unsigned int mask, Event* event) {
event->flags = NT_EVENT_LOGMESSAGE;
event->flags = NT_EVENT_LOG_MESSAGE;
return true;
});
}

View File

@@ -11,13 +11,13 @@ namespace wpi::nt {
// internal helper class for PubSubOptions
class PubSubOptionsImpl : public PubSubOptions {
public:
constexpr PubSubOptionsImpl() : PubSubOptionsImpl{kDefaultPubSubOptions} {}
constexpr PubSubOptionsImpl() : PubSubOptionsImpl{DEFAULT_PUB_SUB_OPTIONS} {}
/*implicit*/ constexpr PubSubOptionsImpl( // NOLINT
const PubSubOptions& options)
: PubSubOptions{options} {
if (periodic == 0) {
periodic = kDefaultPeriodic;
periodic = DEFAULT_PERIODIC;
}
periodicMs = static_cast<unsigned int>(periodic * 1000);
if (pollStorage == 0) {

View File

@@ -73,11 +73,11 @@ static void ConvertToC(const Event& in, NT_Event* out) {
if (auto v = in.GetConnectionInfo()) {
return ConvertToC(*v, &out->data.connInfo);
}
} else if ((in.flags & NT_EVENT_LOGMESSAGE) != 0) {
} else if ((in.flags & NT_EVENT_LOG_MESSAGE) != 0) {
if (auto v = in.GetLogMessage()) {
return ConvertToC(*v, &out->data.logMessage);
}
} else if ((in.flags & NT_EVENT_TIMESYNC) != 0) {
} else if ((in.flags & NT_EVENT_TIME_SYNC) != 0) {
if (auto v = in.GetTimeSyncEventData()) {
return ConvertToC(*v, &out->data.timeSyncData);
}
@@ -108,7 +108,7 @@ static void DisposeEvent(NT_Event* event) {
DisposeTopicInfo(&event->data.topicInfo);
} else if ((event->flags & NT_EVENT_CONNECTION) != 0) {
DisposeConnectionInfo(&event->data.connInfo);
} else if ((event->flags & NT_EVENT_LOGMESSAGE) != 0) {
} else if ((event->flags & NT_EVENT_LOG_MESSAGE) != 0) {
DisposeLogMessage(&event->data.logMessage);
}
}

View File

@@ -426,7 +426,7 @@ static void CleanupListeners(
if ((mask & (NT_EVENT_TOPIC | NT_EVENT_VALUE_ALL)) != 0) {
ii.localStorage.RemoveListener(listener, mask);
}
if ((mask & NT_EVENT_LOGMESSAGE) != 0) {
if ((mask & NT_EVENT_LOG_MESSAGE) != 0) {
ii.logger_impl.RemoveListener(listener);
updateMinLevel = true;
}
@@ -442,10 +442,10 @@ static void DoAddListener(InstanceImpl& ii, NT_Listener listener,
if ((mask & NT_EVENT_CONNECTION) != 0) {
ii.connectionList.AddListener(listener, mask);
}
if ((mask & NT_EVENT_LOGMESSAGE) != 0) {
if ((mask & NT_EVENT_LOG_MESSAGE) != 0) {
ii.logger_impl.AddListener(listener, NT_LOG_INFO, UINT_MAX);
}
if ((mask & NT_EVENT_TIMESYNC) != 0) {
if ((mask & NT_EVENT_TIME_SYNC) != 0) {
ii.AddTimeSyncListener(listener, mask);
}
} else if ((mask & (NT_EVENT_TOPIC | NT_EVENT_VALUE_ALL)) != 0) {

View File

@@ -30,7 +30,7 @@ class MultiSubscriber final {
*/
MultiSubscriber(NetworkTableInstance inst,
std::span<const std::string_view> prefixes,
const PubSubOptions& options = kDefaultPubSubOptions)
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS)
: m_handle{::wpi::nt::SubscribeMultiple(inst.GetHandle(), prefixes,
options)} {}

View File

@@ -70,32 +70,32 @@ class NetworkTableInstance final {
* Client/server mode flag values (as returned by GetNetworkMode()).
* This is a bitmask.
*/
enum NetworkMode {
kNetModeNone = NT_NET_MODE_NONE,
kNetModeServer = NT_NET_MODE_SERVER,
kNetModeClient = NT_NET_MODE_CLIENT,
kNetModeLocal = NT_NET_MODE_LOCAL
enum class NetworkMode {
NONE = NT_NET_MODE_NONE,
SERVER = NT_NET_MODE_SERVER,
CLIENT = NT_NET_MODE_CLIENT,
LOCAL = NT_NET_MODE_LOCAL
};
/**
* Logging levels (as used by SetLogger()).
*/
enum LogLevel {
kLogCritical = NT_LOG_CRITICAL,
kLogError = NT_LOG_ERROR,
kLogWarning = NT_LOG_WARNING,
kLogInfo = NT_LOG_INFO,
kLogDebug = NT_LOG_DEBUG,
kLogDebug1 = NT_LOG_DEBUG1,
kLogDebug2 = NT_LOG_DEBUG2,
kLogDebug3 = NT_LOG_DEBUG3,
kLogDebug4 = NT_LOG_DEBUG4
enum class LogLevel {
CRITICAL = NT_LOG_CRITICAL,
ERR = NT_LOG_ERROR,
WARNING = NT_LOG_WARNING,
INFO = NT_LOG_INFO,
DEBUG = NT_LOG_DEBUG,
DEBUG_1 = NT_LOG_DEBUG1,
DEBUG_2 = NT_LOG_DEBUG2,
DEBUG_3 = NT_LOG_DEBUG3,
DEBUG_4 = NT_LOG_DEBUG4
};
/**
* The default port that network tables operates on.
*/
static constexpr unsigned int kDefaultPort = NT_DEFAULT_PORT;
static constexpr unsigned int DEFAULT_PORT = NT_DEFAULT_PORT;
/**
* Construct invalid instance.
@@ -487,7 +487,7 @@ class NetworkTableInstance final {
ListenerCallback callback) const {
return ::wpi::nt::AddListener(
m_handle,
NT_EVENT_TIMESYNC | (immediate_notify ? NT_EVENT_IMMEDIATE : 0),
NT_EVENT_TIME_SYNC | (immediate_notify ? NT_EVENT_IMMEDIATE : 0),
std::move(callback));
}
@@ -615,7 +615,7 @@ class NetworkTableInstance final {
void StartServer(std::string_view persist_filename = "networktables.json",
std::string_view listen_address = "",
std::string_view mdns_service = "",
unsigned int port = kDefaultPort) {
unsigned int port = DEFAULT_PORT) {
::wpi::nt::StartServer(m_handle, persist_filename, listen_address,
mdns_service, port);
}

View File

@@ -144,7 +144,7 @@ class NetworkTableListener final {
ListenerCallback listener) {
return NetworkTableListener{::wpi::nt::AddListener(
inst.GetHandle(),
NT_EVENT_TIMESYNC | (immediate_notify ? NT_EVENT_IMMEDIATE : 0),
NT_EVENT_TIME_SYNC | (immediate_notify ? NT_EVENT_IMMEDIATE : 0),
std::move(listener))};
}
@@ -363,7 +363,7 @@ class NetworkTableListenerPoller final {
NT_Listener AddTimeSyncListener(bool immediate_notify) {
return ::wpi::nt::AddPolledListener(
m_handle, ::wpi::nt::GetInstanceFromHandle(m_handle),
NT_EVENT_TIMESYNC | (immediate_notify ? NT_EVENT_IMMEDIATE : 0));
NT_EVENT_TIME_SYNC | (immediate_notify ? NT_EVENT_IMMEDIATE : 0));
}
/**

View File

@@ -14,29 +14,29 @@ namespace wpi::nt {
*/
enum class NetworkTableType {
/// Unassigned data type.
kUnassigned = NT_UNASSIGNED,
UNASSIGNED = NT_UNASSIGNED,
/// Boolean data type.
kBoolean = NT_BOOLEAN,
BOOLEAN = NT_BOOLEAN,
/// Double precision floating-point data type.
kDouble = NT_DOUBLE,
DOUBLE = NT_DOUBLE,
/// String data type.
kString = NT_STRING,
STRING = NT_STRING,
/// Raw data type.
kRaw = NT_RAW,
RAW = NT_RAW,
/// Boolean array data type.
kBooleanArray = NT_BOOLEAN_ARRAY,
BOOLEAN_ARRAY = NT_BOOLEAN_ARRAY,
/// Double precision floating-point array data type.
kDoubleArray = NT_DOUBLE_ARRAY,
DOUBLE_ARRAY = NT_DOUBLE_ARRAY,
/// String array data type.
kStringArray = NT_STRING_ARRAY,
STRING_ARRAY = NT_STRING_ARRAY,
/// Integer data type.
kInteger = NT_INTEGER,
INTEGER = NT_INTEGER,
/// Single precision floating-point data type.
kFloat = NT_FLOAT,
FLOAT = NT_FLOAT,
/// Integer array data type.
kIntegerArray = NT_INTEGER_ARRAY,
INTEGER_ARRAY = NT_INTEGER_ARRAY,
/// Single precision floating-point array data type.
kFloatArray = NT_FLOAT_ARRAY
FLOAT_ARRAY = NT_FLOAT_ARRAY
};
} // namespace wpi::nt

View File

@@ -376,7 +376,7 @@ class ProtobufTopic final : public Topic {
*/
[[nodiscard]]
SubscriberType Subscribe(
T defaultValue, const PubSubOptions& options = kDefaultPubSubOptions) {
T defaultValue, const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
wpi::util::ProtobufMessage<T> msg;
auto typeString = msg.GetTypeString();
return ProtobufSubscriber<T>{
@@ -400,7 +400,8 @@ class ProtobufTopic final : public Topic {
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
PublisherType Publish(
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
wpi::util::ProtobufMessage<T> msg;
auto typeString = msg.GetTypeString();
return ProtobufPublisher<T>{
@@ -428,7 +429,7 @@ class ProtobufTopic final : public Topic {
[[nodiscard]]
PublisherType PublishEx(
const wpi::util::json& properties,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
wpi::util::ProtobufMessage<T> msg;
auto typeString = msg.GetTypeString();
return ProtobufPublisher<T>{
@@ -458,7 +459,7 @@ class ProtobufTopic final : public Topic {
*/
[[nodiscard]]
EntryType GetEntry(T defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
wpi::util::ProtobufMessage<T> msg;
auto typeString = msg.GetTypeString();
return ProtobufEntry<T>{

View File

@@ -514,8 +514,8 @@ class StructArrayTopic final : public Topic {
std::convertible_to<std::ranges::range_value_t<U>, T>
#endif
[[nodiscard]]
SubscriberType Subscribe(
U&& defaultValue, const PubSubOptions& options = kDefaultPubSubOptions) {
SubscriberType Subscribe(U&& defaultValue, const PubSubOptions& options =
DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructArraySubscriber<T, I...>{
@@ -547,7 +547,7 @@ class StructArrayTopic final : public Topic {
[[nodiscard]]
SubscriberType Subscribe(
std::span<const T> defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructArraySubscriber<T, I...>{
@@ -577,7 +577,8 @@ class StructArrayTopic final : public Topic {
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
PublisherType Publish(
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructArrayPublisher<T, I...>{
@@ -611,7 +612,7 @@ class StructArrayTopic final : public Topic {
[[nodiscard]]
PublisherType PublishEx(
const wpi::util::json& properties,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructArrayPublisher<T, I...>{
@@ -652,7 +653,7 @@ class StructArrayTopic final : public Topic {
#endif
[[nodiscard]]
EntryType GetEntry(U&& defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructArrayEntry<T, I...>{
@@ -688,7 +689,7 @@ class StructArrayTopic final : public Topic {
*/
[[nodiscard]]
EntryType GetEntry(std::span<const T> defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructArrayEntry<T, I...>{

View File

@@ -416,7 +416,7 @@ class StructTopic final : public Topic {
*/
[[nodiscard]]
SubscriberType Subscribe(
T defaultValue, const PubSubOptions& options = kDefaultPubSubOptions) {
T defaultValue, const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructSubscriber<T, I...>{
@@ -444,7 +444,8 @@ class StructTopic final : public Topic {
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
PublisherType Publish(
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructPublisher<T, I...>{
@@ -476,7 +477,7 @@ class StructTopic final : public Topic {
[[nodiscard]]
PublisherType PublishEx(
const wpi::util::json& properties,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructPublisher<T, I...>{
@@ -511,7 +512,7 @@ class StructTopic final : public Topic {
*/
[[nodiscard]]
EntryType GetEntry(T defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return std::apply(
[&](const I&... info) {
return StructEntry<T, I...>{

View File

@@ -195,7 +195,7 @@ class Topic {
*/
[[nodiscard]]
GenericSubscriber GenericSubscribe(
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Create a new subscriber to the topic.
@@ -214,7 +214,7 @@ class Topic {
[[nodiscard]]
GenericSubscriber GenericSubscribe(
std::string_view typeString,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Create a new publisher to the topic.
@@ -235,7 +235,7 @@ class Topic {
[[nodiscard]]
GenericPublisher GenericPublish(
std::string_view typeString,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Create a new publisher to the topic, with type string and initial
@@ -258,7 +258,7 @@ class Topic {
[[nodiscard]]
GenericPublisher GenericPublishEx(
std::string_view typeString, const wpi::util::json& properties,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Create a new generic entry for the topic.
@@ -280,7 +280,7 @@ class Topic {
*/
[[nodiscard]]
GenericEntry GetGenericEntry(
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Create a new generic entry for the topic.
@@ -304,7 +304,7 @@ class Topic {
[[nodiscard]]
GenericEntry GetGenericEntry(
std::string_view typeString,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Equality operator. Returns true if both instances refer to the same

View File

@@ -319,7 +319,7 @@ class UnitTopic final : public Topic {
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return UnitSubscriber<T>{
::wpi::nt::Subscribe(m_handle, NT_DOUBLE, "double", options),
defaultValue};
@@ -344,7 +344,7 @@ class UnitTopic final : public Topic {
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return UnitSubscriber<T>{
::wpi::nt::Subscribe(m_handle, NT_DOUBLE, typeString, options),
defaultValue};
@@ -366,7 +366,8 @@ class UnitTopic final : public Topic {
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
PublisherType Publish(
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return UnitPublisher<T>{::wpi::nt::PublishEx(
m_handle, NT_DOUBLE, "double", {{"unit", T{}.name()}}, options)};
}
@@ -392,7 +393,7 @@ class UnitTopic final : public Topic {
[[nodiscard]]
PublisherType PublishEx(
std::string_view typeString, const wpi::util::json& properties,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
wpi::util::json props = properties;
props["unit"] = T{}.name();
return UnitPublisher<T>{
@@ -421,7 +422,7 @@ class UnitTopic final : public Topic {
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return UnitEntry<T>{
::wpi::nt::GetEntry(m_handle, NT_DOUBLE, "double", options),
defaultValue};
@@ -450,7 +451,7 @@ class UnitTopic final : public Topic {
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions) {
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS) {
return UnitEntry<T>{
::wpi::nt::GetEntry(m_handle, NT_DOUBLE, typeString, options),
defaultValue};

View File

@@ -119,9 +119,9 @@ enum NT_EventFlags {
/** Topic value updated (network or local). */
NT_EVENT_VALUE_ALL = NT_EVENT_VALUE_REMOTE | NT_EVENT_VALUE_LOCAL,
/** Log message. */
NT_EVENT_LOGMESSAGE = 0x100,
NT_EVENT_LOG_MESSAGE = 0x100,
/** Time synchronized with server. */
NT_EVENT_TIMESYNC = 0x200,
NT_EVENT_TIME_SYNC = 0x200,
};
/*
@@ -266,8 +266,8 @@ struct NT_Event {
* - NT_EVENT_CONNECTED or NT_EVENT_DISCONNECTED: connInfo
* - NT_EVENT_PUBLISH, NT_EVENT_UNPUBLISH, or NT_EVENT_PROPERTIES: topicInfo
* - NT_EVENT_VALUE_REMOTE, NT_NOTIFY_VALUE_LOCAL: valueData
* - NT_EVENT_LOGMESSAGE: logMessage
* - NT_EVENT_TIMESYNC: timeSyncData
* - NT_EVENT_LOG_MESSAGE: logMessage
* - NT_EVENT_TIME_SYNC: timeSyncData
*/
unsigned int flags;

View File

@@ -51,37 +51,37 @@ namespace wpi::nt {
struct EventFlags {
EventFlags() = delete;
static constexpr unsigned int kNone = NT_EVENT_NONE;
static constexpr unsigned int NONE = NT_EVENT_NONE;
/**
* Initial listener addition.
* Set this flag to receive immediate notification of matches to the
* flag criteria.
*/
static constexpr unsigned int kImmediate = NT_EVENT_IMMEDIATE;
static constexpr unsigned int IMMEDIATE = NT_EVENT_IMMEDIATE;
/** Client connected (on server, any client connected). */
static constexpr unsigned int kConnected = NT_EVENT_CONNECTED;
static constexpr unsigned int CONNECTED = NT_EVENT_CONNECTED;
/** Client disconnected (on server, any client disconnected). */
static constexpr unsigned int kDisconnected = NT_EVENT_DISCONNECTED;
static constexpr unsigned int DISCONNECTED = NT_EVENT_DISCONNECTED;
/** Any connection event (connect or disconnect). */
static constexpr unsigned int kConnection = kConnected | kDisconnected;
static constexpr unsigned int CONNECTION = CONNECTED | DISCONNECTED;
/** New topic published. */
static constexpr unsigned int kPublish = NT_EVENT_PUBLISH;
static constexpr unsigned int PUBLISH = NT_EVENT_PUBLISH;
/** Topic unpublished. */
static constexpr unsigned int kUnpublish = NT_EVENT_UNPUBLISH;
static constexpr unsigned int UNPUBLISH = NT_EVENT_UNPUBLISH;
/** Topic properties changed. */
static constexpr unsigned int kProperties = NT_EVENT_PROPERTIES;
static constexpr unsigned int PROPERTIES = NT_EVENT_PROPERTIES;
/** Any topic event (publish, unpublish, or properties changed). */
static constexpr unsigned int kTopic = kPublish | kUnpublish | kProperties;
static constexpr unsigned int TOPIC = PUBLISH | UNPUBLISH | PROPERTIES;
/** Topic value updated (via network). */
static constexpr unsigned int kValueRemote = NT_EVENT_VALUE_REMOTE;
static constexpr unsigned int VALUE_REMOTE = NT_EVENT_VALUE_REMOTE;
/** Topic value updated (local). */
static constexpr unsigned int kValueLocal = NT_EVENT_VALUE_LOCAL;
static constexpr unsigned int VALUE_LOCAL = NT_EVENT_VALUE_LOCAL;
/** Topic value updated (network or local). */
static constexpr unsigned int kValueAll = kValueRemote | kValueLocal;
static constexpr unsigned int VALUE_ALL = VALUE_REMOTE | VALUE_LOCAL;
/** Log message. */
static constexpr unsigned int kLogMessage = NT_EVENT_LOGMESSAGE;
static constexpr unsigned int LOG_MESSAGE = NT_EVENT_LOG_MESSAGE;
/** Time synchronized with server. */
static constexpr unsigned int kTimeSync = NT_EVENT_TIMESYNC;
static constexpr unsigned int TIME_SYNC = NT_EVENT_TIME_SYNC;
};
/** NetworkTables Topic Information */
@@ -249,8 +249,8 @@ class Event {
* - NT_EVENT_PUBLISH, NT_EVENT_UNPUBLISH, or NT_EVENT_PROPERTIES:
* GetTopicInfo()
* - NT_EVENT_VALUE, NT_EVENT_VALUE_LOCAL: GetValueData()
* - NT_EVENT_LOGMESSAGE: GetLogMessage()
* - NT_EVENT_TIMESYNC: GetTimeSyncEventData()
* - NT_EVENT_LOG_MESSAGE: GetLogMessage()
* - NT_EVENT_TIME_SYNC: GetTimeSyncEventData()
*/
unsigned int flags{0};
@@ -304,7 +304,7 @@ struct PubSubOptions {
/**
* Default value of periodic.
*/
static constexpr double kDefaultPeriodic = 0.1;
static constexpr double DEFAULT_PERIODIC = 0.1;
/**
* Structure size. Must be set to sizeof(PubSubOptions).
@@ -325,7 +325,7 @@ struct PubSubOptions {
* minimum period for all values) or apply a restricted range to this value.
* The default is 100 ms.
*/
double periodic = kDefaultPeriodic;
double periodic = DEFAULT_PERIODIC;
/**
* For subscriptions, if non-zero, value updates for ReadQueue() are not
@@ -385,7 +385,7 @@ struct PubSubOptions {
/**
* Default publish/subscribe options.
*/
constexpr PubSubOptions kDefaultPubSubOptions;
constexpr PubSubOptions DEFAULT_PUB_SUB_OPTIONS;
/**
* @defgroup ntcore_instance_func Instance Functions
@@ -783,7 +783,7 @@ bool SetTopicProperties(NT_Topic topic, const wpi::util::json& update);
* @return Subscriber handle
*/
NT_Subscriber Subscribe(NT_Topic topic, NT_Type type, std::string_view typeStr,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Stops subscriber.
@@ -802,7 +802,7 @@ void Unsubscribe(NT_Subscriber sub);
* @return Publisher handle
*/
NT_Publisher Publish(NT_Topic topic, NT_Type type, std::string_view typeStr,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Creates a new publisher to a topic.
@@ -816,7 +816,7 @@ NT_Publisher Publish(NT_Topic topic, NT_Type type, std::string_view typeStr,
*/
NT_Publisher PublishEx(NT_Topic topic, NT_Type type, std::string_view typeStr,
const wpi::util::json& properties,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Stops publisher.
@@ -835,7 +835,7 @@ void Unpublish(NT_Handle pubentry);
* @return Entry handle
*/
NT_Entry GetEntry(NT_Topic topic, NT_Type type, std::string_view typeStr,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Stops entry subscriber/publisher.
@@ -878,7 +878,7 @@ NT_Topic GetTopicFromHandle(NT_Handle pubsubentry);
*/
NT_MultiSubscriber SubscribeMultiple(
NT_Inst inst, std::span<const std::string_view> prefixes,
const PubSubOptions& options = kDefaultPubSubOptions);
const PubSubOptions& options = DEFAULT_PUB_SUB_OPTIONS);
/**
* Unsubscribes a multi-subscriber.

View File

@@ -45,8 +45,8 @@ class NtLogForwarder:
return
default_cfg = (
_ntcore.NetworkTableInstance.LogLevel.kLogInfo,
_ntcore.NetworkTableInstance.LogLevel.kLogCritical,
_ntcore.NetworkTableInstance.LogLevel.INFO,
_ntcore.NetworkTableInstance.LogLevel.CRITICAL,
"nt",
)
minLevel, maxLevel, logName = cls._instcfg.get(handle, default_cfg)

View File

@@ -73,7 +73,7 @@ py::object ntvalue2py(const wpi::nt::Value &ntvalue) {
}
return std::move(l);
}
case NT_STRING_ARRAY: {
return py::cast(ntvalue.GetStringArray());
}
@@ -150,27 +150,27 @@ wpi::nt::Value py2ntvalue(py::handle h) {
py::function valueFactoryByType(wpi::nt::NetworkTableType type) {
py::object PyNtValue = py::module::import("ntcore").attr("Value");
switch (type) {
case wpi::nt::NetworkTableType::kBoolean:
case wpi::nt::NetworkTableType::BOOLEAN:
return PyNtValue.attr("makeBoolean");
case wpi::nt::NetworkTableType::kDouble:
case wpi::nt::NetworkTableType::DOUBLE:
return PyNtValue.attr("makeDouble");
case wpi::nt::NetworkTableType::kString:
case wpi::nt::NetworkTableType::STRING:
return PyNtValue.attr("makeString");
case wpi::nt::NetworkTableType::kRaw:
case wpi::nt::NetworkTableType::RAW:
return PyNtValue.attr("makeRaw");
case wpi::nt::NetworkTableType::kBooleanArray:
case wpi::nt::NetworkTableType::BOOLEAN_ARRAY:
return PyNtValue.attr("makeBooleanArray");
case wpi::nt::NetworkTableType::kDoubleArray:
case wpi::nt::NetworkTableType::DOUBLE_ARRAY:
return PyNtValue.attr("makeDoubleArray");
case wpi::nt::NetworkTableType::kStringArray:
case wpi::nt::NetworkTableType::STRING_ARRAY:
return PyNtValue.attr("makeStringArray");
case wpi::nt::NetworkTableType::kInteger:
case wpi::nt::NetworkTableType::INTEGER:
return PyNtValue.attr("makeInteger");
case wpi::nt::NetworkTableType::kFloat:
case wpi::nt::NetworkTableType::FLOAT:
return PyNtValue.attr("makeFloat");
case wpi::nt::NetworkTableType::kIntegerArray:
case wpi::nt::NetworkTableType::INTEGER_ARRAY:
return PyNtValue.attr("makeIntegerArray");
case wpi::nt::NetworkTableType::kFloatArray:
case wpi::nt::NetworkTableType::FLOAT_ARRAY:
return PyNtValue.attr("makeFloatArray");
default:
throw py::type_error("empty nt value");

View File

@@ -86,7 +86,7 @@ classes:
})
wpi::nt::BooleanArrayTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
BooleanArrayTopic:
overloads:

View File

@@ -78,7 +78,7 @@ classes:
})
wpi::nt::BooleanTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
BooleanTopic:
overloads:

View File

@@ -86,7 +86,7 @@ classes:
})
wpi::nt::DoubleArrayTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
DoubleArrayTopic:
overloads:

View File

@@ -78,7 +78,7 @@ classes:
})
wpi::nt::DoubleTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
DoubleTopic:
overloads:

View File

@@ -86,7 +86,7 @@ classes:
})
wpi::nt::FloatArrayTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
FloatArrayTopic:
overloads:

View File

@@ -78,7 +78,7 @@ classes:
})
wpi::nt::FloatTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
FloatTopic:
overloads:

View File

@@ -86,7 +86,7 @@ classes:
})
wpi::nt::IntegerArrayTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
IntegerArrayTopic:
overloads:

View File

@@ -78,7 +78,7 @@ classes:
})
wpi::nt::IntegerTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
IntegerTopic:
overloads:

View File

@@ -24,7 +24,7 @@ classes:
force_type_casters:
- std::function
attributes:
kDefaultPort:
DEFAULT_PORT:
enums:
NetworkMode:
arithmetic: true
@@ -160,8 +160,8 @@ classes:
NetworkTableInstance::LogLevel minLevel, NetworkTableInstance::LogLevel maxLevel, py::str logName) {
py::module::import("ntcore._logutil").attr("_config_logging")(self, minLevel, maxLevel, logName);
}, py::kw_only(),
py::arg("min") = NetworkTableInstance::LogLevel::kLogInfo,
py::arg("max") = NetworkTableInstance::LogLevel::kLogCritical,
py::arg("min") = NetworkTableInstance::LogLevel::INFO,
py::arg("max") = NetworkTableInstance::LogLevel::CRITICAL,
py::arg("name") = "nt",
py::doc("Configure python logging for this instance.\n"
"\n"

View File

@@ -78,7 +78,7 @@ classes:
})
wpi::nt::StringArrayTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
StringArrayTopic:
overloads:

View File

@@ -86,7 +86,7 @@ classes:
})
wpi::nt::StringTopic:
attributes:
kTypeString:
TYPE_STRING:
methods:
StringTopic:
overloads:

View File

@@ -30,20 +30,20 @@ functions:
classes:
wpi::nt::EventFlags:
attributes:
kNone:
kImmediate:
kConnected:
kDisconnected:
kConnection:
kPublish:
kUnpublish:
kProperties:
kTopic:
kValueRemote:
kValueLocal:
kValueAll:
kLogMessage:
kTimeSync:
NONE:
IMMEDIATE:
CONNECTED:
DISCONNECTED:
CONNECTION:
PUBLISH:
UNPUBLISH:
PROPERTIES:
TOPIC:
VALUE_REMOTE:
VALUE_LOCAL:
VALUE_ALL:
LOG_MESSAGE:
TIME_SYNC:
wpi::nt::TopicInfo:
attributes:
name:
@@ -76,7 +76,7 @@ classes:
inline_code: |
.def("__repr__", [](const ConnectionInfo &self) -> py::str {
return py::str("<ConnectionInfo id={} addr={}:{} last_update={} protocol={}>")
.format(self.remote_id, self.remote_ip, self.remote_port,
.format(self.remote_id, self.remote_ip, self.remote_port,
self.last_update, self.protocol_version);
})
wpi::nt::ValueEventData:
@@ -194,7 +194,7 @@ classes:
wpi::nt::PubSubOptions:
force_no_default_constructor: true
attributes:
kDefaultPeriodic:
DEFAULT_PERIODIC:
structSize:
ignore: true
pollStorage:
@@ -239,7 +239,7 @@ classes:
}),
py::kw_only(),
py::arg("pollStorage") = 0,
py::arg("periodic") = wpi::nt::PubSubOptions::kDefaultPeriodic,
py::arg("periodic") = wpi::nt::PubSubOptions::DEFAULT_PERIODIC,
py::arg("excludePublisher") = std::nullopt,
py::arg("sendAll") = false,
py::arg("topicsOnly") = false,
@@ -250,8 +250,8 @@ classes:
py::arg("excludeSelf") = false,
py::arg("hidden") = false,
R"(
:param pollStorage: Polling storage size for a subscription. Specifies the maximum number of
updates NetworkTables should store between calls to the subscriber's
ReadQueue() function. If zero, defaults to 1 if sendAll is false, 20 if