GUI Timer to Control LabChart 'Realtime' Data collection
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello,
I'm looking to create a GUI that will allow me to gate when I pull data from an external device called Powerlab. There is currenly some interfacing code HERE which allows for the me to ge data but it is quite clunky. I'm wanting to use a timer function within a GUI to fetch new data on a regular interval, do some math on it and use this data to control another device for a closed-loop application.
When I run my code I get this error particular error (shown directly below) and I'm not really sure what to do about it.
<Error while evaluating TimerFcn for timer 'Reminder'
Undefined function 'updater' for input arguments of type 'timer'.>
I'd appreciate any helpful hints to help solve this issue.
Thanks,
Ryne
classdef SingleChannelGUI < matlab.apps.AppBase
%% Properties that correspond to app components
properties (Access = public)
%% Empty to limit size of post
end
%% Variables
properties (Access = public)
%% Empty to limit size of post
end
%% event functions
methods (Access = private)
%% Removed other functions to limit size of post
function updater(app,varargin)
gLCDoc.StartSampling(app.wndw)
plot(gChansData{gChans})
end
end
%% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
%% Empty to limit size of post
end
end
methods (Access = public)
% Construct app
function app = SingleChannelGUI
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
%% Setup Labchart
global gLCApp; % defines global gLCApp
global gChans; % Array of channel numbers specifying channels to retrieve
global tmr; % Global timer for windowing
global wndw; % to set the sample window
wndw = 1;
GetLCApp;
gChans = 1; % collect sampling data from channel 1, call multiple channels like this [1 2]
doc1 = gLCApp.ActiveDocument;
RegisterLCEvents(doc1); % hook up the OnSelectionChange event and the sampling events such as OnNewSamples and OnBlockStart.
tmr = timer('Name','Reminder',...
'Period',wndw,... % Update the time every 1 second for now
'StartDelay',0,... % In seconds.
'TasksToExecute',inf,... % number of times to update
'ExecutionMode','fixedSpacing',...
'TimerFcn',{@updater});
doc1 = gLCApp.ActiveDocument;
RegisterLCEvents(doc1); % hook up the OnSelectionChange event and the sampling events such as OnNewSamples and OnBlockStart.
start(tmr); % Start the timer object.
end
%% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
%% Close out Lab Chart connection
stop(tmr)
ReleaseLCDoc(doc1); %uncomment this if finished with doc1.
ReleaseLC(); %uncomment this if finished with gLCApp.
end
end
end
댓글 수: 2
Misha Zahid
2020년 2월 6일
Sir were you able to find a solution to this? I am working on a similar problem and stuck on the same thing as yours.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!