08-29-2016 09:51 AM
In an event structure, we can relate controls to the timeout event. But if we do it this way, we don't get event data node related to the controls. I don't know whether this is a good practice and whether there are potention issues. Please comment. Thanks.
Solved! Go to Solution.
08-29-2016 09:58 AM
I don't understand the statement or the question. The Timeout Event "fires" when the indicated Time elapses with no other Event firing. You can do anything you want in that Event (or, if you don't need it, you can leave it out of the Event Structure altogether).
I would have a much easier time understanding your question if you posted some code (please, attach a VI, not just a picture, so we can see the entire Event Structure, i.e. all of the Events, and can even "try it out").
Bob Schor
08-29-2016 10:00 AM
I never needed to use a control together with a Timeout case of an Event Structure. I cannot imagine why it is needed for you. Could you explain why you need this?
08-29-2016 10:32 AM
@Blokk wrote:I never needed to use a control together with a Timeout case of an Event Structure. I cannot imagine why it is needed for you.
That was my immediate thought. Still haven't thought of a good reason to do this.
08-29-2016 10:41 AM
My guess is let's say instead of -1 keep maybe some timeout value 100ms and manipulate the control values regularly after 100ms?
-If that is the case, the timeout event is not connected any specific control instead to entire Application. So you might do extra processing to get the values of controls indirectly in case of timeout(Like getting the values of controls programatically).
-Well as others asked it might be the question why matters to give better explanation of what you are thinking or trying to achieve.
08-29-2016 10:59 AM
I have an "auto test" button, when then button is false, we have -1 to the timeout terminal; when the button is pressed, I want the program to go through timeout case. Of course I can create another case for the "auto test" button value change, but this case will not do much, just send the 100 to the timeout terminal.
08-29-2016 11:20 AM
@guangdew1 wrote:In an event structure, we can relate controls to the timeout event. But if we do it this way, we don't get event data node related to the controls. I don't know whether this is a good practice and whether there are potention issues. Please comment. Thanks.
A "practice" is what you do. You are talking about a limitation (or feature). Event data nodes only show items that are common to all events of that particular event case, so e.g. "old/new val" is not available if there is also a timeout assigned. If you don't need them, it does not matter if they are there or not.
This is often not a problem because you typically only need the new value and you can get that by placing the control terminal inside that event.
If you need the specific event data node, create an otherwise empty dedicated event case for the control and fire the timeout event by temporarily setting the timeout to zero via a shift register. Set the timeout back to zero in the timeout event case. If the new value is also needed in the timeout event, leave the terminal inside the timeout event use the newval from the event data node in the specific case.
08-29-2016 11:21 AM
I have the feeling you could do much easier with a proper State Machine. I guess you try to program all required functionality with a simple Event Structure in a While loop? If so, I advise you to have a look how a proper State Machine works (either using a single While loop with cases where the Event structure is in one "Check GUI" case, or the Producer/Consumer (Events) design is also very useful).
08-29-2016 11:27 AM - edited 08-29-2016 01:57 PM
@guangdew1 wrote:I have an "auto test" button, when then button is false, we have -1 to the timeout terminal; when the button is pressed, I want the program to go through timeout case. Of course I can create another case for the "auto test" button value change, but this case will not do much, just send the 100 to the timeout terminal.
Sorry, I did not see your post here. Yes, there is no problem adding specific control events to the timeout event. You don't need to add specific events just to trigger the timeout unless you need the specific event data node.
A few versions ago, having specific events was more important to add code to prevent accumulation of stale events in the event queue, but now we can set the queue size.
08-29-2016 02:01 PM
altenbach, thanks for the explanation which made feel assured that this is an okay way, even though it's not a very common practice. As you mentioned, I don't get the new value from the data node, but if I have the control or local variable inside of the case, I get the new value.