From 0d9a91618b94353020ae2b3106740360c84d8958 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Thu, 20 Aug 2020 19:41:06 +0300
Subject: [PATCH] Fatal error on camera overheat

---
 components/rgbd-sources/src/sources/stereovideo/pylon.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
index 3e3945a72..b9690e2d8 100644
--- a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
+++ b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
@@ -125,13 +125,15 @@ PylonDevice::PylonDevice(nlohmann::json &config)
 
 	monitor_ = true;
 	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
+		// TODO: check actual temperature status.
+		if (temperature > 65.0) {
+			LOG(FATAL) << "Cameras are overheating";
+		}
 
 		return true;
 	});
@@ -140,6 +142,7 @@ PylonDevice::PylonDevice(nlohmann::json &config)
 PylonDevice::~PylonDevice() {
 	monitor_ = false;
 	temperature_monitor_.cancel();
+
 	lcam_->Close();
 	rcam_->Close();
 }
-- 
GitLab