to receive feedback in loop with out providing command- Newton Anderson camera.
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Jaimin
on 30 Sep 2024
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.
Event and Listener Concepts: https://www.mathworks.com/help/matlab/matlab_oop/events-and-listeners-concepts.html
Overview Events and Listeners: https://www.mathworks.com/help/matlab/matlab_oop/learning-to-use-events-and-listeners.html
I hope this will be helpful.
0 Comments
More Answers (0)
See Also
Categories
Find more on National Instruments Frame Grabbers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!