How can I create an input dilaog window which is not block the running of the main window process?

16 visualizzazioni (ultimi 30 giorni)
I created a data acquisition and processing program. It works fine. I would like to be able to change parameters simultaniously, which would effects the data process. I can do it but all solution I found interrupt/block the running processes what I would really like to avoid. Is there any solution?

Risposte (1)

Walter Roberson
Walter Roberson il 27 Ott 2012
If you need to change the data acquisition parameters, then probably you will need an interruption in the data acquisition in order to have a chance for the new parameters to go into effect. This isn't what you asked about, but it has to be taken into account.
If the parameters are used to change what you calculate with the data you acquire (and no change to how the data is acquired) then if you might be able to do what you want.
An input dialog can exist that does not block the running program. You create a figure for the dialog, and populate controls on the dialog, and set callback routines -- and then leave it sitting there and return to what you were doing.
When the user interacts with the dialog in ways that do not require callback routines to be fired, such as by typing into an edit box without pressing enter, then those interactions are taken care of automatically, possibly by a different java thread. On a single processor system, that java thread would inherently need to interrupt the running program very briefly -- but the operating system is interrupting the running program constantly to maintain the various other bits of the system, so this is nothing special. It just happens and MATLAB continues exactly where it was.
When the user interacts with the dialog in ways that do require graphics callback routines to be fired, such as by selecting an element in a listbox or pressing enter in an edit box, then that MATLAB-level interrupt routine will not be serviced until the program gives it permission to serve the routine, which can happen by the program selecting or creating a figure, or by pause() or by drawnow() or by a small number of other means. If you are running a compute-intensive routine, especially one that uses internal libraries such as LAPACK, then it could be some time before there is any opportunity to service the interrupt routine, and if you write your code at the MATLAB level such that it does not invoke any of the small list of key routines, MATLAB will not allow the interrupt routine to run.
When there is eventually an opportunity for the interrupt routine to execute at the MATLAB level, the interrupt routine can change variables or state that the other routine is paying attention to. There is, though, no way for the interrupt routine to "notify" the executing routine that something has changed: the executing routine would need to know to periodically look at the variables or state and change its operations accordingly. For example,
for K = 1 : 1e7
keep_going = get(handles.ContinueRunning_radiobutton, 'Value');
if ~keep_going; break; end
.... continue with the calculation ...
end
  1 Commento
Zoltan
Zoltan il 5 Nov 2012
Your answer was a little too high for me at this time (I have just started to programming Matlab and I do not have any IT background only the common sense). I tried to digest what I did not understand but I need more help. I could not catch: "..then that MATLAB-level interrupt routine will not be serviced until the program gives it permission to serve the routine, which can happen by the program selecting or creating a figure, or by pause() or by drawnow() or by a small number of other means." I understand well that "the executing routine would need to know to periodically look at the variables or state and change its operations accordingly".
"get(handles.ContinueRunning_radiobutton, 'Value');"
But how can I get the handles of another parameter figure from the executing figure? At first I clarify my question: My problem is: I have a running figure collecting data from the COM port and plotting it. I would like to be able to change the parameters of the plotting using an other figure (preferable created by GUIDE to be as I want) I want to get back parameters whcih were typed into edit box by the user. I am using the following technique to get the data back:
function Properties_OpeningFcn(hObject, eventdata, handles, varargin)
uiwait(handles.figure1);
function figure1_CloseRequestFcn(hObject, eventdata, handles)
if isequal(get(hObject, 'waitstatus'), 'waiting')
uiresume(hObject);
else
delete(hObject);
end
function varargout = Properties_OutputFcn(hObject, eventdata, handles)
disp('AutOutput');
varargout{1} = handles.m;
delete(handles.figure1);
My stylized executing program is:
while somebodyStopsIt
read(COM)
parameter=Properiteswindowfunction
plot(COMdata,parameter)
end
It works perfectly but it stops the data acquisition figure till I close it what I do not want. Could you please help further?

Accedi per commentare.

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by