timer in a class question

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

 Accepted Answer

Melissa
Melissa on 22 Jan 2015
oops, nevermind. looked at it again today with fresh eyes and saw the problem. there was a problem with variable naming.
mln

More Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Asked:

on 20 Jan 2015

Answered:

on 22 Jan 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!