timer in a class question
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
I have been searching for the problem with this for quite a while and I am just not seeing what the problem is. I have a class that runs a timer that reads values from some hardware and displays them on a GUI. I am having trouble with the timer. here is the relevant code:
classdef Controller < handle
properties (Access = private)
gui_h;
ControllerObj;
positionTimer;
end
methods
function this = Controller()
this.gui_h = guihandles(Controller_fig);
this.ControllerObj = PI_GCS_Controller();
this.positionTimer = timer('BusyMode','drop','ExecutionMode','fixedRate','Period',1,'TimerFcn',@this.positionTimerFcn);
start(this.positionTimer);
end
methods (Access = private)
function this = UpdatePositionAndVoltage(this)
% reads from the hardware and displays to the GUI
end
function this = positionTimerFcn(this,src,event)
this.UpdatePositionAndVoltage(this);
end
end % end of methods
end
If I run this with the call to UpdatePositionAndVoltage commented out, and just disp a string to the command line, it works fine. the timer triggers at once per second. if I try to call this.UpdatePositionAndVoltage(this) I get the error message "Error while evaluating TimerFcn for timer 'timer-1' Too many input arguments." If I change the definition of Update... to UpdatePositionAndVoltage(this,~) I then get the error message "Error while evaluating TimerFcn for timer 'timer-1' No appropriate method, property, or field Controller for class Controller."
which seems like it is at least making it into the Update function, but the "Controller" is not defined in there? I am just not seeing what the problem is. I also tried passing in "this" as a parameter in the timer definition, but that didn't work either.
any insight would be greatly appreciated!
thanks, mln
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Software Development Tools dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!