[wpilib] Rename private constants to all caps

This commit is contained in:
Peter Johnson
2026-03-17 16:35:16 -07:00
parent b7122f0fda
commit 8a802fd670
9 changed files with 24 additions and 24 deletions

View File

@@ -219,7 +219,7 @@ struct Instance {
// if less than this much free space, delete log files until there is this much
// free space OR there are this many files remaining.
static constexpr uintmax_t kFreeSpaceThreshold = 50000000;
static constexpr int kFileCountThreshold = 10;
static constexpr int FILE_COUNT_THRESHOLD = 10;
static std::string MakeLogDir(std::string_view dir) {
if (!dir.empty()) {
@@ -303,7 +303,7 @@ void Thread::Main() {
int count = entries.size();
for (auto&& entry : entries) {
--count;
if (count < kFileCountThreshold) {
if (count < FILE_COUNT_THRESHOLD) {
break;
}
auto size = entry.file_size();

View File

@@ -63,8 +63,8 @@ struct Instance {
// if less than this much free space, delete log files until there is this much
// free space OR there are this many files remaining.
static constexpr uintmax_t kFreeSpaceThreshold = 50000000;
static constexpr int kFileCountThreshold = 10;
static constexpr uintmax_t FREE_SPACE_THRESHOLD = 50000000;
static constexpr int FILE_COUNT_THRESHOLD = 10;
static std::string MakeLogDir(std::string_view dir) {
if (!dir.empty()) {
@@ -132,7 +132,7 @@ void Thread::Main() {
} else {
freeSpace = UINTMAX_MAX;
}
if (freeSpace < kFreeSpaceThreshold) {
if (freeSpace < FREE_SPACE_THRESHOLD) {
// Delete oldest WPILIB_*.wpilog files (ignore WPILIB_TBD_*.wpilog as we
// just created one)
std::vector<fs::directory_entry> entries;
@@ -152,7 +152,7 @@ void Thread::Main() {
int count = entries.size();
for (auto&& entry : entries) {
--count;
if (count < kFileCountThreshold) {
if (count < FILE_COUNT_THRESHOLD) {
break;
}
auto size = entry.file_size();
@@ -160,7 +160,7 @@ void Thread::Main() {
WPILIB_ReportWarning("DataLogManager: Deleted {}",
entry.path().string());
freeSpace += size;
if (freeSpace >= kFreeSpaceThreshold) {
if (freeSpace >= FREE_SPACE_THRESHOLD) {
break;
}
} else {
@@ -168,13 +168,13 @@ void Thread::Main() {
entry.path().string());
}
}
} else if (freeSpace < 2 * kFreeSpaceThreshold) {
} else if (freeSpace < 2 * FREE_SPACE_THRESHOLD) {
WPILIB_ReportError(
warn::Warning,
"DataLogManager: Log storage device has {} MB of free space "
"remaining! Logs will get deleted below {} MB of free space. "
"Consider deleting logs off the storage device.",
freeSpace / 1000000, kFreeSpaceThreshold / 1000000);
freeSpace / 1000000, FREE_SPACE_THRESHOLD / 1000000);
}
}

View File

@@ -45,7 +45,7 @@ void Tracer::PrintEpochs(wpi::util::raw_ostream& os) {
using std::chrono::microseconds;
auto now = wpi::hal::monotonic_clock::now();
if (now - m_lastEpochsPrintTime > kMinPrintPeriod) {
if (now - m_lastEpochsPrintTime > MIN_PRINT_PERIOD) {
m_lastEpochsPrintTime = now;
for (const auto& epoch : m_epochs) {
os << fmt::format(

View File

@@ -107,7 +107,7 @@ void Watchdog::Impl::Main() {
auto watchdog = m_watchdogs.pop();
wpi::units::second_t now{curTime * 1e-6};
if (now - watchdog->m_lastTimeoutPrintTime > kMinPrintPeriod) {
if (now - watchdog->m_lastTimeoutPrintTime > MIN_PRINT_PERIOD) {
watchdog->m_lastTimeoutPrintTime = now;
if (!watchdog->m_suppressTimeoutMessage) {
WPILIB_ReportWarning("Watchdog not fed within {:.6f}s",

View File

@@ -63,7 +63,7 @@ class Tracer {
void PrintEpochs(wpi::util::raw_ostream& os);
private:
static constexpr std::chrono::milliseconds kMinPrintPeriod{1000};
static constexpr std::chrono::milliseconds MIN_PRINT_PERIOD{1000};
wpi::hal::monotonic_clock::time_point m_startTime;
wpi::hal::monotonic_clock::time_point m_lastEpochsPrintTime;

View File

@@ -112,7 +112,7 @@ class Watchdog {
private:
// Used for timeout print rate-limiting
static constexpr auto kMinPrintPeriod = 1_s;
static constexpr auto MIN_PRINT_PERIOD = 1_s;
wpi::units::second_t m_startTime = 0_s;
wpi::units::second_t m_timeout;

View File

@@ -62,8 +62,8 @@ public final class DataLogManager {
// if less than this much free space, delete log files until there is this much free space
// OR there are this many files remaining.
private static final long kFreeSpaceThreshold = 50000000L;
private static final int kFileCountThreshold = 10;
private static final long FREE_SPACE_THRESHOLD = 50000000L;
private static final int FILE_COUNT_THRESHOLD = 10;
private DataLogManager() {}
@@ -308,7 +308,7 @@ public final class DataLogManager {
{
File logDir = new File(m_logDir);
long freeSpace = logDir.getUsableSpace();
if (freeSpace < kFreeSpaceThreshold) {
if (freeSpace < FREE_SPACE_THRESHOLD) {
// Delete oldest WPILIB_*.wpilog files (ignore WPILIB_TBD_*.wpilog as we just created one)
File[] files =
logDir.listFiles(
@@ -321,14 +321,14 @@ public final class DataLogManager {
int count = files.length;
for (File file : files) {
--count;
if (count < kFileCountThreshold) {
if (count < FILE_COUNT_THRESHOLD) {
break;
}
long length = file.length();
if (file.delete()) {
DriverStation.reportWarning("DataLogManager: Deleted " + file.getName(), false);
freeSpace += length;
if (freeSpace >= kFreeSpaceThreshold) {
if (freeSpace >= FREE_SPACE_THRESHOLD) {
break;
}
} else {
@@ -336,12 +336,12 @@ public final class DataLogManager {
}
}
}
} else if (freeSpace < 2 * kFreeSpaceThreshold) {
} else if (freeSpace < 2 * FREE_SPACE_THRESHOLD) {
DriverStation.reportWarning(
"DataLogManager: Log storage device has "
+ freeSpace / 1000000
+ " MB of free space remaining! Logs will get deleted below "
+ kFreeSpaceThreshold / 1000000
+ FREE_SPACE_THRESHOLD / 1000000
+ " MB of free space. "
+ "Consider deleting logs off the storage device.",
false);

View File

@@ -18,7 +18,7 @@ import org.wpilib.driverstation.DriverStation;
* which parts of an operation consumed the most time.
*/
public class Tracer {
private static final long kMinPrintPeriod = 1000000; // microseconds
private static final long MIN_PRINT_PERIOD = 1000000; // microseconds
private long m_lastEpochsPrintTime; // microseconds
private long m_startTime; // microseconds
@@ -72,7 +72,7 @@ public class Tracer {
*/
public void printEpochs(Consumer<String> output) {
long now = RobotController.getMonotonicTime();
if (now - m_lastEpochsPrintTime > kMinPrintPeriod) {
if (now - m_lastEpochsPrintTime > MIN_PRINT_PERIOD) {
StringBuilder sb = new StringBuilder();
m_lastEpochsPrintTime = now;
m_epochs.forEach(

View File

@@ -25,7 +25,7 @@ import org.wpilib.util.WPIUtilJNI;
*/
public class Watchdog implements Closeable, Comparable<Watchdog> {
// Used for timeout print rate-limiting
private static final long kMinPrintPeriod = (long) 1e6; // μs
private static final long MIN_PRINT_PERIOD = (long) 1e6; // μs
private double m_startTime;
private double m_timeout;
@@ -260,7 +260,7 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
Watchdog watchdog = m_watchdogs.poll();
double now = curTime * 1e-6;
if (now - watchdog.m_lastTimeoutPrint > kMinPrintPeriod) {
if (now - watchdog.m_lastTimeoutPrint > MIN_PRINT_PERIOD) {
watchdog.m_lastTimeoutPrint = now;
if (!watchdog.m_suppressTimeoutMessage) {
DriverStation.reportWarning(