Restarting background data acquisition when going back - multiple mlapp files
Show older comments
App designer app with multiple files. Each screen is being opened by the previous screen, then hiding the previous screen.
Each screen is displaying different data, at different rates (and thus needs it's own ScansAvailableFcn).
No issues starting background data acquisition when entering the next screen - but when you click back to go to the previous screen (and delete current screen) I have not found any good way to re-start background data acquisition with the previous screens ScansAvailableFcn.
Currently using a flag variable and just watching to see the next screen closed inside my "Continue Button Pushed" callback - but that seems wasteful and silly. Feels like there has to be a better way other than just looping and pausing while waiting for the next screen to disappear.
Code Example -
Screen2.mlapp
function ContinueButtonPushed(app, event)
%First, stop the DAQ
stop(app.DAQ)
%Set Next screen open variable
app.SC3Open=1;
%Start new screen
screen3(app,app.UIFigure.Position);
%Monitor open screen fopr close
while (app.SC3Open>0)
% The next screen exists
pause(1);
end
%Screen gone - Start the DAQ with this screen settings
DAQStart(app);
end
Screen3.mlapp
function BackButtonPushed(app, event)
%First, stop the DAQ
stop(app.Screen2.DAQ)
%Set Screen Open variable to show closed
app.Screen2.SC3Open = 0;
%Make previous screen visible and delete current screen
app.Screen2.UIFigure.Visible = 'on';
drawnow;
delete(app);
end
4 Comments
dpb
less than a minute ago
If the DAQ is beinig stopped from one step to another, why is it necessary to compound issues by having several chained apps; why can't simply set a new figure for the specific data and then restart the DAQ with its new set of conditions? It seems overly complex scheme this way...
Aaron Borgman
about 10 hours ago
Edited: Walter Roberson
about 2 hours ago
Aaron Borgman
29 minutes ago
My bad...I wrote figure when was thinking about multiple panes/axes, sorry. If one needs a whole different UI and not just what data is acquired/displayed, then it's a problem, granted.
It would seem the idea would be that the various higher level apps need to pass their app struct from the parent to the child on creation. In that case, create the OnRestart function in each parent app as a Public function and pass its handle to the child app. The child can then execute that function in its BackButton callback before exiting.
Just thinking off the cuff, that routine might be a one-shot timer whose callback is to check a "WakeUp" variable also set by the exiting child process on exit. That would eliminate the need for a polling operation and provide a little delay time for the context switching to occur.
Accepted Answer
More Answers (0)
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!