LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

User Interface Only when required

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

0 Kudos
Message 1 of 6
(4,204 Views)

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.

0 Kudos
Message 2 of 6
(4,197 Views)

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

0 Kudos
Message 3 of 6
(4,186 Views)

@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 ?

0 Kudos
Message 4 of 6
(4,180 Views)

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....

0 Kudos
Message 5 of 6
(4,177 Views)

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;

}

 

 

0 Kudos
Message 6 of 6
(4,164 Views)