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
0 个评论
采纳的回答
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.
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 National Instruments Frame Grabbers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!