02-20-2017 05:01 AM
Hi, sorry for my lack of details.
I am using latch when pressed.
The event structures are definitely executing because the thigns they are meant to do are happening. The code is a horrendous mess (not my mess) and I've just been trying to make it use event structures to execute all of the code (a huge event structure around all of the code).
02-20-2017 07:03 AM
Then there is something else to this story besides what you've already told us. There is no way we are going to be able to figure it out unless you attach the VI so we can poke around in it.
If it is such a horrendeous mess, you might be better off rebuilding it so it gives the same functionality (actually much better functionality since obviously it is functioning correctly right now), but using a cleaner, more maintainable architecture.
02-20-2017 01:22 PM - edited 02-20-2017 01:27 PM
@nishalc wrote:
The event structures are definitely executing because the thigns they are meant to do are happening.
You still have not said what kind of event is associated with the button. Is it "value changed" or something else? Read my previous post once more.
(For example if you use a mouse-down event on a "latch/switch when released" boolean, the boolean will still be in the old state when its value is read by the code. it only switches when the mouse is released while the event fires when it is pressed)
02-21-2017 04:14 AM
Sorry, I'm using the simplest cases. Event action is a value change, and the variables are on 'latch when pressed'.
The event structures execute when I press the buttons but the buttons don't return back to default state. The program has a while loop around this event structure and the buttons still work again (i.e they are in TRUE state after using once but will execute the event again and then be in the FALSE state).
02-21-2017 08:11 AM
More words won't help us help you.
Please attach a VI!
02-21-2017 09:07 AM
Well for lack of actual VIs. Here is the example that works perfectly as expected. Of course I use a Latch-when-released type boolean. LV 12. Now it is up to the original poster to show why her/his situation doesn't work.
1. Quick summary, use latch-when-released type booleans to allow resetting to work.
2. They do work.
To quote Trillian: “We have normality, I repeat, we have normality. Anything you still can’t cope with is therefore your own problem. Please relax.”
02-21-2017 09:24 AM - edited 02-21-2017 09:27 AM
To be honest I thought it would be something I missed and thus a quick fix but its probably something off with the program
I'll try out latch-when-released instead of latch-when-pressed to see if that makes any difference.
Thanks for the overwhelming support!
EDIT: So, switching to latch-when-released has fixed the issue. Not quite sure why (as they function the same in the example someone gave/other programs I made).
02-21-2017 09:32 AM
Yes it will make a difference. Consider the scenario:
Push boolean
it latches
Event fires
Boolean attempts to clear, but still pressed
Exit without boolean clearing.
Release boolean
Now if latches when released:
Push boolean
Release boolean
it latches
Event filres
Boolean clears since it is NOT pressed
Exit with cleared boolean
Release boolean
02-21-2017 09:45 AM
@sth wrote:
Yes it will make a difference. Consider the scenario:
Push boolean
it latches
Event fires
Boolean attempts to clear, but still pressed
Exit without boolean clearing.
Release boolean
Your explanation doesn't make sense to me. Latching, when talking about boolean controls, is the clearing of the boolean. So when you say "Press boolean....it latches", the boolean should be cleared. There is something else going on in the OP's code because latched when pressed should work. Maybe there is a local variable being used to NOT the boolean after it has already been cleared. Unfortunately, no code has yet been shown to find out what the real problem is.
02-21-2017 10:11 AM - edited 02-21-2017 10:14 AM
I do want to come back and follow up with this thread about the "Until Released" options. To be specific about when a Latch until released is preferable to a switch until released.
All three latched types And Switched When Released may use 1, 2 or 4 elements of the Colors[4] and Strings[4] properties. Switch Until released and Switch When pressed may only use 1 or 2 elements of them. The other difference is, of course, the ability to Read / Write the Value property from a P-Node.
So a Latch Until Released can changed "True" colors to "True to False" colors until it is read after it is released and from "True to False" to "False" colors after it unlatches. A Switch Until Released will immediately Change from "True" to "False" colors. Reading the Text property could be used to indicate "Final Iteration" or a "First Iteration" of a "Dead man's Switch" and place "Go to Idle State" or "Begin State" message out to some asynchronous process.