From 8606b284585ca92db196089c9305a159e7064265 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Thu, 20 Aug 2020 19:24:35 +0300
Subject: [PATCH] Change pylon temp monitor

---
 .../src/sources/stereovideo/pylon.cpp           | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
index 89bc33812..3e3945a72 100644
--- a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
+++ b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
@@ -124,15 +124,14 @@ PylonDevice::PylonDevice(nlohmann::json &config)
 	});
 
 	monitor_ = true;
-	temperature_monitor_ = ftl::timer::add(ftl::timer::timerlevel_t::kTimerIdle1, 3.0, [this](int64_t ts) {
-		for (auto* cam : {lcam_, rcam_}) {
-			// is this thread safe?
-			float temperature = cam->DeviceTemperature();
-			LOG_IF(WARNING, temperature > 53.0)
-				<< "Camera temperature over 50C (value: " << temperature << ")";
-
-			// TODO: stop if camera temperature exceeds threshold
-		}
+	temperature_monitor_ = ftl::timer::add(ftl::timer::timerlevel_t::kTimerIdle1, 10.0, [this](int64_t ts) {
+
+		float temperature = (rcam_) ? std::max(lcam_->DeviceTemperature(), rcam_->DeviceTemperature()) : lcam_->DeviceTemperature();
+
+		LOG_IF(WARNING, temperature > 53.0)
+			<< "Camera temperature over 50C (value: " << temperature << ")";
+
+		// TODO: stop if camera temperature exceeds threshold
 
 		return true;
 	});
-- 
GitLab