LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event in case structure

Solved!
Go to solution

Dear all,

I am using Event Structure in a Tab Control.

On page 1, there is a Table Control and when the mouse is clicked on it, it returns the Cell Value. The event is working ablsolutely fine, but the problem is i have no idea how to Stop the Event.

 

I am attaching my Vi here. Pls have a look at it and let me know of a possible solution.

 

Thanks,

Ritesh

0 Kudos
Message 1 of 10
(4,192 Views)

Hi there

 

The Event structure returns only if an event defined in the structure has been fired. The only event in your structure is the TableControl::MouseUp event. The TIMO event never occurs, because the TIMO is set to default = infinity.

 

One way to solve this would be to add the StopButton::ValueChanged event and to stop the loop when this event occurs (see attachment). Another way would be to set the TIMO to a value != -1 (default)

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 10
(4,182 Views)

Hi Ritesh,

you don´t need the case structure. If you create another table on the other page and you also need an event for it, then it is a new one and the event structure already differ between them. Add a stop button to it and connect it with the loop condition.

 

Mike

0 Kudos
Message 3 of 10
(4,178 Views)

Hi,

I got the solution and its working fine.

 

But, it means that the Events in Page 1 are getting triggered even when the Control is on Page 2.

That would take the unnecessary memory and time as there is no need for the events on Page 1 to run when the Control is on a different page.

Is there any way to handle such a thing.

 

Thanks,

Ritesh

0 Kudos
Message 4 of 10
(4,174 Views)

Ritesh,

 

I don't know the context in which you want to use this event structure, but I can think of 3 things to improve your code:

 

1.

There is no need for the case  structure (page1/page2) around the event structure.

In fact the case structure will prevent the events from working properly if page 1 of the TAB-control is not selected.

 

2.

If you want any code in the WHILE loop to execute, that is outside the event structure,  connect a timeout value >0 to the EVENT TIMEOUT connector. If you leave the EVENT TIMEOUT unconnected, a timeout of -1 (never time out) is assumed and LabVIEW will just stop executeing the loop until the next event occurs.

This happens in your example, so the STOP button is only processed after the next event.

 

3.

To prevent polling, create a second event case to handle a value change in the STOP button.

In this case you may leave the event timeout at -1 and the loop will execute once if STOP is pressed.

 

 

I hope this helps.

 

Regards

Anke 

 

 

 

 

Message 5 of 10
(4,165 Views)

Hi MikeS81 and AnkeS,

I couldn't exactly followed what you said in your posts.

It would be really great if you could demonstrate your ideas with a sample Vi.

 

Thanks,

Ritesh

0 Kudos
Message 6 of 10
(4,163 Views)

Ritesh,

 

Events "in page 1" can only be triggered if  page 1 is visible and the user is using the mouse on the controls there.  

There is no overhead at all in an event structure waiting for an event that does not occur.

 

 I iclude a new version of your example.

 

 

 

Regards

Anke 

Message 7 of 10
(4,144 Views)

Hi Ritesh,

see the attached example.

 

Mike

Message 8 of 10
(4,135 Views)
Solution
Accepted by LVCoder

ritesh024 wrote:

But, it means that the Events in Page 1 are getting triggered even when the Control is on Page 2.

That would take the unnecessary memory and time as there is no need for the events on Page 1 to run when the Control is on a different page.


No, the event will not get "triggered", because if you are on the other tab it is impossible to fire the table event and a mouse up cannot occur. The event structure is in memory no matter what and placing it inside a case structure only complicates the code and can will lead to problems.

 

The event structure should always be in the dataflow, the tab position is irrelevant. Never hide an event structures inside a case structure!

 

Here's a quick example (LV 8.5). Tab 1 has your table and senses the cell position. Tab 2 has a light switch. As you can see there is no case structure needed.

 

 

Message 9 of 10
(4,118 Views)

Hi All,

Thanks alot for your examples.

Your explanations to the problem were really simple and above par.

 

Thanks,

Ritesh

0 Kudos
Message 10 of 10
(4,105 Views)