Skip to content

Commit

Permalink
Merge pull request #35 from IMSY-DKFZ/34-ui-responsiveness-hindered-b…
Browse files Browse the repository at this point in the history
…y-exposure

Fixes UI responsiveness hindered by temperature thread
  • Loading branch information
leoyala authored Sep 2, 2024
2 parents 2509f4d + a45c7a9 commit 09bfac6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

-
- Fixes UI responsiveness hindered by temperature thread

## [0.2.1]

Expand Down
5 changes: 5 additions & 0 deletions src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* License: see LICENSE.md file
*******************************************************/

#include <boost/thread.hpp>

#include "camera.h"

#include "logger.h"
Expand Down Expand Up @@ -129,6 +131,7 @@ int RGBCamera::InitializeCamera()

void XiSpecFamily::UpdateCameraTemperature()
{
boost::lock_guard<boost::mutex> guard(this->mtx_);
float chipTemp, houseTemp, houseBackSideTemp, sensorBoardTemp;

this->m_apiWrapper->xiGetParamFloat(*m_cameraHandle, XI_PRM_CHIP_TEMP, &chipTemp);
Expand All @@ -143,13 +146,15 @@ void XiSpecFamily::UpdateCameraTemperature()

void XiCFamily::UpdateCameraTemperature()
{
boost::lock_guard<boost::mutex> guard(this->mtx_);
float sensorBoardTemp;
this->m_apiWrapper->xiGetParamFloat(*m_cameraHandle, XI_PRM_SENSOR_BOARD_TEMP, &sensorBoardTemp);
this->m_cameraTemperature[SENSOR_BOARD_TEMP] = sensorBoardTemp;
}

void XiQFamily::UpdateCameraTemperature()
{
boost::lock_guard<boost::mutex> guard(this->mtx_);
float chipTemp, houseTemp, houseBackSideTemp, sensorBoardTemp;
if (*m_cameraHandle != INVALID_HANDLE_VALUE)
{
Expand Down
10 changes: 8 additions & 2 deletions src/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#ifndef XILENS_CAMERA_H
#define XILENS_CAMERA_H

#include <xiApi.h>

#include <QMap>
#include <QString>
#include <boost/thread.hpp>
#include <xiApi.h>

#include "constants.h"
#include "xiAPIWrapper.h"
Expand All @@ -22,6 +22,12 @@ class CameraFamily
*/
HANDLE *m_cameraHandle;

/**
* Mutex used to lock access to variables like the camera temperature, this allows updating temperature from
* multiple threads.
*/
boost::mutex mtx_;

public:
explicit CameraFamily(HANDLE *handle) : m_cameraHandle(handle)
{
Expand Down
5 changes: 3 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ void MainWindow::HandleTemperatureTimer(const boost::system::error_code &error)
return;
}

m_cameraInterface.m_camera->family->get()->UpdateCameraTemperature();
this->DisplayCameraTemperature();

// Reset timer
Expand All @@ -328,6 +329,8 @@ void MainWindow::HandleTemperatureTimer(const boost::system::error_code &error)

void MainWindow::StartTemperatureThread()
{
// Initial temperature update to ensure that it is populated before recordings start.
m_cameraInterface.m_camera->family->get()->UpdateCameraTemperature();
if (m_temperatureThread.joinable())
{
StopTemperatureThread();
Expand Down Expand Up @@ -459,7 +462,6 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::handleBaseFolderButtonClicked()
{
bool isValid = false;
this->StopTemperatureThread();
while (!isValid)
{
QString baseFolderPath = QFileDialog::getExistingDirectory(
Expand All @@ -477,7 +479,6 @@ void MainWindow::handleBaseFolderButtonClicked()
}
}
}
this->StartTemperatureThread();
}

void MainWindow::WriteLogHeader()
Expand Down

0 comments on commit 09bfac6

Please sign in to comment.