From 74a051d721222ddd4d96513aa9f884c52ef53620 Mon Sep 17 00:00:00 2001 From: Drew Williams Date: Sun, 19 May 2024 20:36:44 -0400 Subject: [PATCH] [PhotonLib C++] Fix SetVersionCheckEnabled to actually disable version checking (#1323) * change verifyversion to use member variable * Revert "change verifyversion to use member variable" This reverts commit 4439839c8fc66bd69dbe30937918ffc22d0f2063. * Removed inline specifier for versioncheck variable --------- Co-authored-by: Drew Williams --- photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp | 9 ++++++++- photon-lib/src/main/native/include/photon/PhotonCamera.h | 6 ++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp index 47be45075..281351a31 100644 --- a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp +++ b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp @@ -60,6 +60,11 @@ namespace photon { constexpr const units::second_t VERSION_CHECK_INTERVAL = 5_s; static const std::vector PHOTON_PREFIX = {"/photonvision/"}; +bool PhotonCamera::VERSION_CHECK_ENABLED = true; + +void PhotonCamera::SetVersionCheckEnabled(bool enabled) { + VERSION_CHECK_ENABLED = enabled; +} PhotonCamera::PhotonCamera(nt::NetworkTableInstance instance, const std::string_view cameraName) @@ -189,7 +194,9 @@ std::optional PhotonCamera::GetDistCoeffs() { } void PhotonCamera::VerifyVersion() { - if (!PhotonCamera::VERSION_CHECK_ENABLED) return; + if (!PhotonCamera::VERSION_CHECK_ENABLED) { + return; + } if ((frc::Timer::GetFPGATimestamp() - lastVersionCheckTime) < VERSION_CHECK_INTERVAL) diff --git a/photon-lib/src/main/native/include/photon/PhotonCamera.h b/photon-lib/src/main/native/include/photon/PhotonCamera.h index 6d29754bf..f588c340d 100644 --- a/photon-lib/src/main/native/include/photon/PhotonCamera.h +++ b/photon-lib/src/main/native/include/photon/PhotonCamera.h @@ -152,9 +152,7 @@ class PhotonCamera { std::optional GetCameraMatrix(); std::optional GetDistCoeffs(); - inline static void SetVersionCheckEnabled(bool enabled) { - PhotonCamera::VERSION_CHECK_ENABLED = enabled; - } + static void SetVersionCheckEnabled(bool enabled); std::shared_ptr GetCameraTable() const { return rootTable; } @@ -192,7 +190,7 @@ class PhotonCamera { private: units::second_t lastVersionCheckTime = 0_s; - inline static bool VERSION_CHECK_ENABLED = true; + static bool VERSION_CHECK_ENABLED; inline static int InstanceCount = 0; void VerifyVersion();