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

4 次查看(过去 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