Monitoring Data without blocking the interface

2 views (last 30 days)
Hello everyone,
I am currently trying to create an interface that displays data about what happens in behavioural cages. To monitor the cages, I have a script that reads continuously reads outputs from a PCI card. It can also send signals if needed, according to a scenario. This part works fine on its own (with Mex files and stuff), and collects data that I would need to monitor.
In order to test a monitoring interface, I made simplifications : I want to read what happens in the cage through a script (which has its own .m file), and display the input values on the interface. This is done simply with these lines :
textLabel = sprintf('%d', value);
set(handles.edit1, 'String', textLabel);
Here is the interface. My monitoring script starts running when I use the intended button. (The script is called in the button's callback function).
You might notice the "copy value" button, and the text field. Using the button is supposed to copy the monitored value in the second text field. But I can't figure how to make it work.
First, in order for the interface to access the value, I tried putting it in the "handles" structure, so
handles.input = value;
Problem is, the "Copy Value" button won't work until my monitoring script is active. Do you have any idea on how to proceed ? Maybe I could call the script somewhere else, so that it doesn't block the rest of the interface ? But I don't know where and how...
  1 Comment
Geoff Hayes
Geoff Hayes on 19 Jun 2016
Guillaume - can you post some of the code in the callback to the Start Monitoring button? I suspect that you may have a tight while (or perhaps for) loop that does not allow itself to be interrupted. This could explain why pressing the Copy Value button does not do anything. If you are using one of these types of loops, you will need to add a pause call to temporarily halt execution of the loop which will allow the other button to execute. Try with
pause(0.01);

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!