LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

in labwindows,i like to stop the execution of the program.

the control should be in uir,so that i can enter other values and restart the program.i used stop command button to stop the execution of the program,but the program didnt stop becos it didnt come out of the execution.
0 Kudos
Message 1 of 12
(5,120 Views)
Create a callback function for control you want to use to quit the program and call QuitUserInterface() under EVENT_COMMIT.
To create a callback for a control:
1. Double-click on the control in the UIR editor.
2. Enter a function name (make one up) in the box labeled Callback Function, and click OK.
3. Right-click on the control and select Generate Control Callback.
4. Right-click on the control and select View Control Callback.
5. Call QuitUserInterface() under EVENT_COMMIT.
To allow the X on the Windows titlebar to close the program, you need to edit the panel and assign the control to be the Close Control for the panel: in the UIR editor, select Edit >> Panel. Look for the control labeled Close Control.
When you initially create your program, you can generate
the callback code (including QuitUserInterface) automatically using the UIR editor.
1. Assign a callback function to the control (steps 1 & 2 above).
2. In the UIR editor, select Panel... from the Edit menu.
3. Use the control labeled Close Control to select the command button, then click OK.
4. From the Code menu, select Generate >> All Code.
5. In the box at the bottom, place a checkmark to the left of the control you want to use to close the application.
Look at just about any of the userint sample programs that ship with CVI to see how they use a close control (or Quit button). The sample programs are typically installed in c:\Program Files\National Instruments\MeasruementStudio\CVI\samples. Open any project in userint and look for a Quit button on the user interface. Right-click on Quit and select View Control Callback.
0 Kudos
Message 2 of 12
(5,120 Views)
actually i need to stop the execution of the program and bring back the control to UIR window.i have a STOP button and callback function for it.but my problem is that in middle of the program,if i need to stop execution of the program, i press the stop button,but the control is not working immediately.after the complete execution of the program only,the stop callback function is called.can u please tell me how to overcome this problem?
0 Kudos
Message 3 of 12
(5,120 Views)
While in a callback function, CVI doesn't automatically look at other events (like clicking a button). If you want CVI to check events within a callback, you need to periodically call ProcessSystemEvents(). Look at the help for ProcessSystemEvents.
Do you want to stop your program or just to abort a function? If you stop the program, you don't return control to the UIR window: you exit the program. If you want to abort a function, within that function you need to periodically call ProcessSystemEvents() or check the value of a control (like an Abort Function button). If Abort Function is TRUE, clean up and abort the function (return early from it).
0 Kudos
Message 4 of 12
(5,120 Views)
My problem is that we need to acquire data for an unspecified amount of time. How can you configure the code so that the user has control of the UIR after the function has been called, because it seems that while the acquisition proceedure is running, A)it won't stop until it cycles through all of its code, B)an commit event cannont be triggered to stop the function because the user has no control of the interface.
0 Kudos
Message 5 of 12
(5,120 Views)
A) Do you want to abort the acquisition early? Then put a command button on your main panel labeled Abort Acquisition. In your acquisition function, periodically call ProcessSystemEvents() or GetCtrlVal() to check the Abort button. Cleanup and return early if Abort is requested.
B) If the user presses a button, EVENT_COMMIT will be triggered in your acquisition function if you call ProcessSystemEvents().
See the help for ProcessSystemEvents, which states, in part, "While inside of a callback function or in code that does not call RunUserInterface() or GetUserEvent(), user interface and system events are not processed. If a particular function is overly time-consuming, it will essentially "lock-out" user interface and system events.
To force these events to be processed, call ProcessSystemEvents() occasionally in the code that is locking out system events."
0 Kudos
Message 6 of 12
(5,120 Views)
I'll give it a try. Thanks.
0 Kudos
Message 7 of 12
(5,120 Views)
Just keep in mind that you have to call ProcessSystemEvents() every time you want to check for events. Don't just call it once and expect to get all future events. It's not an enable toggle, it checks for events prior to the time you call it. So if your callback runs a loop, put it in the loop. If your callback has many lines of code, you may want to call ProcessSystemEvents multiple times, even in the same loop, depending on which commands or chunks of code take a long time to execute.
0 Kudos
Message 8 of 12
(5,120 Views)
If I send you my code, do you think that you can make a recommendation. I just don't understand how to exit this loop once it starts.
0 Kudos
Message 9 of 12
(5,120 Views)
Actually, this better explains my needs. When the toggle control that I have place on the GUI is set to on, I want to initiate a sequence of scans to run until that same switch on the gui is toggled to off. Is that possible?
0 Kudos
Message 10 of 12
(5,120 Views)