to receive feedback in loop with out providing command- Newton Anderson camera.

조회 수: 5 (최근 30일)
Dear friends,
I am trying to build newton anderson camera GUI. Here I am using sdk commands provided by newtoncamera.
From the code below, I want GetAcquisitionProgress() to be called automatically i.e it should always looks for change in
'GetAcquisitionProgress()' and update the value inside [ret, acc, series] and not only when I provide 'value = islogging(obj)' command.
Hence, I request to please help if this is achieveable. I read something about making it listener(link attached) but I am still not able to understand how to implement.
function value = islogging(obj)
[ret, acc, series] = GetAcquisitionProgress(); CheckWarning(ret);
value = series;
end

채택된 답변

Jaimin
Jaimin 2024년 9월 30일
To achieve continuous monitoring of the “GetAcquisitionProgress” function and automatically update the values without explicitly calling “islogging(obj)” I would reccomand using the MATLAB event listeners.
For a better understanding of creating event listeners and making calls, kindly refer to the following code snippet.
classdef CameraGUI < handle
properties
AcquisitionProgress
TimerObj
end
events
ProgressChanged
end
methods
function obj = CameraGUI()
% Initialize properties
obj.AcquisitionProgress = 0;
% Set up a listener for the ProgressChanged event
addlistener(obj, 'ProgressChanged', @(src, event) obj.updateProgress());
% Set up a timer to periodically check acquisition progress
obj.TimerObj = timer('ExecutionMode', 'fixedRate', ...
'Period', 1, ... % Check every second
'TimerFcn', @(~,~) obj.checkProgress());
start(obj.TimerObj);
end
function checkProgress(obj)
[ret, acc, series] = GetAcquisitionProgress();
CheckWarning(ret);
if series ~= obj.AcquisitionProgress
obj.AcquisitionProgress = series;
notify(obj, 'ProgressChanged'); % Trigger the event
end
end
function updateProgress(obj)
% Update the GUI or perform any action needed when progress changes
disp(['Acquisition Progress Updated: ', num2str(obj.AcquisitionProgress)]);
end
end
end
function [ret, acc, series] = GetAcquisitionProgress()
% Mock implementation of GetAcquisitionProgress
ret = 0;
acc = 0;
series = 0; % Random value to simulate progress
end
function CheckWarning(ret)
% Mock implementation of CheckWarning
if ret ~= 0
warning('An error occurred.');
end
end
For additional information on Event and Listener Concepts and Overview Events and Listeners please refer to the MathWorks Documentation.
I hope this will be helpful.

추가 답변 (0개)

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by