10-26-2013 06:33 AM - edited 10-26-2013 06:45 AM
The Problem is ... I have function which needs to to run continously... unless there is button pressed on the panel... it should break off ....
go do the other function and come back to the orginal function...
i noticed that callback would be called even if you move on top of the button.... i don't want this to happen i want function to be called only when button is pressed ...
is it possible
thanks in advance
10-26-2013 09:45 AM
Yes, it is possible.
In your callback you need to check for a suitable event - because the callback is called for any event (such as mouse move etc.) and you want to react to a specific one only.
So your callback would look like
int CVICALLBACK MyButton ( int panel, int control, int event, void *callbackData, int eventData1, int eventData2 )
{
if ( event == EVENT_COMMIT )
{
...
}
return ( 0 );
}
In the UI editor, make sure that the control mode of your button is hot.
10-28-2013 12:03 AM
Let me explain it in detail
1. I'm a begineer
2. The thing is i recevie data througn my com port, i want this data to be received continously and using this data I manipulate into required results and then display it to a graph.
3. The problem is if i dont run user interface i dont get the graph if i run it i cant get the values and manipulate it is there a better way to handle it
10-28-2013 12:26 AM
@karthik9 wrote:
3. ... if i run it i cant get the values and manipulate it is there a better way to handle it
I don't understand what you mean by 'you can't get the values'? Secondly, what is the connection to the button ?
10-28-2013 12:31 AM
Ok from the com port i get my data .... i require it to be continuous .... i.e the data should be displayed like a daq.... now if i press exit button it should break....
10-28-2013 07:08 AM
As usual, there are several possible solutions.
My suggestion is to have a look at the sample program userint\timer.
In the timer callback, place your code for acquisition and display. In the StopButtonCallback, stop the timer. Alternatively, you can leave the timer running and use a logical variable such as:
int main ( )
{
int acquisition = 1;
if (InitCVIRTE (0, argv, 0) == 0)
return -1;
if ((hmainPanel = LoadPanel (0, "mypanelr.uir", PANEL)) < 0)
return -1;
DisplayPanel (hmainPanel);
// configure port
RunUserInterface ();
DiscardPanel (hmainPanel);
CloseCVIRTE ();
return 0;
}
int CVICALLBACK TimerCallback ( )
{
if ( event == EVENT_TIMER_TICK && acquisition )
{
// read port
// display data
)
}
int CVICALLBACK StopButton ( )
{
if ( event == EVENT_COMMIT )
{
acquisition = 0;
}
return 0;
}