ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

取消
显示结果 
搜索替代 
您的意思是: 

Quick question about latching boolean and event structures

已解决!
转到解答

Hey, for some reason my latched boolean controls are not resetting when using an event structure. 

I have put the booleans controls in their respective events, and even tried using flat sequence structures to ensure the VI reads them. 

What is a reason this could be happening? Can't post the code just at the moment. 

0 项奖励
1 条消息(共 23 条)
7,364 次查看

Are you sure the event case is being called?  Are you sure the control is set to Latch?

 

Those are the only reasons it would not unlatch when the terminal is in the Value Change event case.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 项奖励
2 条消息(共 23 条)
7,349 次查看

If you have a Latch Until Released button tied to a while loop condition terminal that exits the program, the button likely won't unlatch before the program exits.

Capture.PNG

aputman
3 条消息(共 23 条)
7,314 次查看

@aputman wrote:

If you have a Latch Until Released button tied to a while loop condition terminal that exits the program, the button likely won't unlatch before the program exits.

Capture.PNG


Why do you say that?  My experience, the button unlatches as soon as it is read, which is going to occur before the event structure exits and then the while loop.

4 条消息(共 23 条)
7,310 次查看

@RavensFan wrote:

@aputman wrote:

If you have a Latch Until Released button tied to a while loop condition terminal that exits the program, the button likely won't unlatch before the program exits.

Capture.PNG


Why do you say that?  My experience, the button unlatches as soon as it is read, which is going to occur before the event structure exits and then the while loop.


Because it doesn't unlatch.  Try it.  I guess if you can click and release the mouse fast enough before the program exits, it would unlatch.  But I can't run the above code and get the button to unlatch before exiting.  

aputman
0 项奖励
5 条消息(共 23 条)
7,306 次查看

It works just fine for me.

 

Here is a version saved in LV2014.  (I originally created it in LV16 and it worked fine there also.)

 

I also tried making it Latch When Pressed to see if that changed anything.  It still unlatched.

0 项奖励
6 条消息(共 23 条)
7,301 次查看

I'm still on 2012 so I can't open your file.  Latch When Pressed and Latch When Released work fine.  If you look at the visual explanation of Latch Until Released, the mouse goes down, the button value is changed, the control is read and at this point the event structure is complete and the program can exit but the mouse button hasn't be released and so the control can't reset. Has something changed since 2012 in this regard?

Untitled.png

aputman
0 项奖励
7 条消息(共 23 条)
7,296 次查看

This is what happens when no code is posted to explain the problem.  LOL 极度高兴的表情

aputman
0 项奖励
8 条消息(共 23 条)
7,291 次查看

I'm sorry.  You're right.  Having code sure would've helped.  The original poster never really did say which version of Latched he was using.

 

Your posts did say "Latch Until Released" and I kept thinking "Latch When Released".  Why, I have never found a valid reason to ever use Latch Until Released and don't know why anyone would.

 

If I would rank the order of how often I used the different actions.

 

1 or 2  Latch When Released  (bottom center)

1 or 2  Switch When Released (top center)  both of these behave with normal Windows button action of allowing you to drag off before releasing in case you made a mistake.

 

3  Switch Until Relased (top right)  used this a few times for "jog" buttons,  act on when pushed in, stop immediately upon release.  Usually use in conjection with an event structure.

 

4 or 5  Latch When Pressed  (bottom left)

4 or 5  Switch When Pressed (top left)  only use if I need an instantaneous action upon the press

 

6  Latch Until Released (bottom right)  Never, ever, ever used it.  No idea why I would.

 

But you're right, Latch Until Released does not pop up because the VI probably stops running before you let go.  And a non-running VI has no latching and unlatching actions with it.

 

To the original poster, if you are using Latch Until Release, just don't.  If you think you do, please tell us why.  I would bet you are using the wrong action and really want Latch When Released.

 

0 项奖励
9 条消息(共 23 条)
7,279 次查看

@nishalc wrote:

Hey, for some reason my latched boolean controls are not resetting when using an event structure. 

I have put the booleans controls in their respective events, and even tried using flat sequence structures to ensure the VI reads them. 


We cannot debug vague sentences.

 

As mentioned, we don't even know if the event executes. You also did not say what kind of event is assigned to the latched boolean (value changed, mouse down, etc.).

 

I don't understand your "use flat sequences" logic. Sequences don't ensure anything except execution order.

0 项奖励
10 条消息(共 23 条)
7,262 次查看