LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I disable Callbacks in CVI

OK, funny questions I hear you say.
 
Well it is and it ins't. The scenario I have is as follows:-
 
I have a UIR that has a panel that has several callbacks, one of which is a Timer callback.
 
This UIR is used by several programs, some being debugged and some running live.
 
Now, when I am debugging a program the Timer callback keeps interrupting my debugging train of thought, i.e. it keeps interupting me whilst I'm looking at variables etc.
 
Is there a way I can disable the effect of the Timer callback for only the program I am debugging, i.e. by setting a variable call debug so that when it is true the Timer callback doesn't interrupt me, but when set to false the Timer acts as normal.
 
I could just set the timer to a different interval, but this would upset those programs running live.
 
I would like to stop the callback from being executed as even the interupt of doing nothing still upsets the debugging of a program.
 
Any suggestions greatfully received, before I lose too much hair.
0 Kudos
Message 1 of 7
(4,598 Views)
Hello,
 
the way I should do this is by using a definition. At the beginning of your main program you can write for example:
 
#define DBG_NO_TIMER
 
When you're not debugging, mark this out using the '//' signs.
 
Then later in your code just insert the lines:
 
#ifdef DBG_NO_TIMER
SetCtrlAttribute (your_panel, your_timer_control, ATTR_ENABLED, FALSE);
#endif
 
I hope this gets you on your way...
0 Kudos
Message 2 of 7
(4,593 Views)
If you're debugging a debug build while other people are using a release build you can use the predefined macro _CVI_DEBUG_. 

#ifdef _CVI_DEBUG_
SetCtrlAttribute (your_panel, your_timer_control, ATTR_ENABLED, FALSE);
#endif // _CVI_DEBUG_

From the help file:

_CVI_DEBUG_ is defined if you enable Build»Configuration»Debug in the Workspace window. The value of the macro is 1.


----
I am the founder of CnCSoftwareSolutions. When not cleaning up baby drool, I write about test data or work on Vision, a tool for understanding your test data. Visit me at www.cncsoftwaresolutions.com
Message 3 of 7
(4,581 Views)

Good option that macro! Smiley Wink

In case you do prefere some actual instruction instead of a macro, you can use BeingDebuggedByCVI () which returns 1 if the program is running in the IDE. So you can setup the timer with this instruction:

SetCtrlAttribute (your_panel, your_timer_control, ATTR_ENABLED, !BeingDebuggedByCVI());



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 7
(4,575 Views)

Thanks for the suggestions.

The one thought I have with the proposed suggestions is: -

As the UIR is not part of the executable and is available for all programs to see and use, if one program disables the Timer on the UIR will this not be disable the Timer for all programs that access this UIR, or is the Timer activation / de-activation only performed on a per program basis?

0 Kudos
Message 5 of 7
(4,538 Views)

Don't worry about that. A UIR file is only read by a program. It will not be modified.

The UIR file is read into a program with the LoadPanel function. If later in this program settings of timers, buttons or whatever are changed, this does not affect the UIR file. So when another program loads this UIR file, it is loaded with the original settings.

Message 6 of 7
(4,535 Views)

I don't really have much to add to this discussion except for a rather general recommendation.

I would suggest using an asynchronous timer instead of the timer control on a panel in a UIR file. Asynchronous timers run in their own threads and are much more reliable (and predictable). UIR timers can miss firing their callbacks if the system is busy processing other events. The asynchronous timer will not do this as it is running in its own thread with its own processor time.

 

 

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 7 of 7
(4,464 Views)