[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

@@ -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;