Error using StateButton ValueChanged callback in App designer

조회 수: 13 (최근 30일)
Dam-Be Douti
Dam-Be Douti 2018년 6월 27일
댓글: Dam-Be Douti 2018년 7월 13일
Hi, I'm developping an app for controlling instruments. One of my state button was working well until yesterday. I didn't change it's code, technically the changed I've made should not affect it's callback function. here is the error I get:
matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 352)
Error while evaluating StateButton PrivateValueChangedFcn.
Here is my callback function:
function XPSConnectButtonValueChanged(app, event)
value = app.XPSConnectButton.Value;
IP = app.XpsIPAdressEditField.Value;
Port = app.XpsPortEditField.Value;
timeout = app.XpsTimeOutEditField.Value;
if value==true
app.SocketID = TCP_ConnectToServer(IP,Port,timeout);
if app.SocketID==-1 % failed
message = ['Connection to XPS Server Failed: check if the drivers have been loaded,',...
'check the connection cables or increase the time out'];
uialert(app.UIFigure, message, 'Error', 'Icon', 'error');
app.XPSConnectButton.Value = false;
elseif app.SocketID==1e6 % ID didn't change ==> no response from driver
message = 'Connection to XPS Server Failed: check if the drivers have been loaded';
uialert(app.UIFigure, message, 'Error', 'Icon', 'error');
app.XPSConnectButton.Value = false;
else % Success
% Connection is ok, let's enable movements on the driver
% Long coding using instruments drivers
% Ready
message = 'XPS Server connected succesfully';
uialert(app.UIFigure, message, 'Success','Icon', 'success');
app.XPSConnectButton.BackgroundColor = 'g';
app.XPSConnectButton.Text = 'CONNECTED';
% Start the timer for reading the values
start(app.StageUpdateTimer);
end
else % changed from true to false ==> disconnect then
TCP_CloseSocket(app.SocketID);
uialert(app.UIFigure, ' Disconnected successfully', 'Success','Icon', 'success');
app.XPSConnectButton.BackgroundColor = 'r';
app.XPSConnectButton.Text = 'NOT CONNECTED';
% app.XPSConnectButton.Value = false;
stop(app.StageUpdateTimer); % Stop the timer which updates the position values
end
end
  댓글 수: 1
Dam-Be Douti
Dam-Be Douti 2018년 7월 13일
Solved ! Just that for some errors inside the callback function of button, matlab seems to not know how to report them and then report StateButton Evaluation error. The error has nothing to do with the StateButton actually, but with my instrument connections return.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by