04-15-2011 05:38 AM
I am trying to use an event structure to trigger a 1 off event. I thought that I could check for the condition that I want to trigger the event and wire this the Val(signaling) property of a Boolean. I then created a Value Change event on this control expecting the event to trigger when the value changed from false to true. what I find is that writing to the Val Signaling property triggers the event every time not just when the value changes.
The attachment is a simple vi to try and illustrate this point using the iteration counter to try and trigger a 1 off event on the 10th iteration. The Boolean 'Once' changes from False to True on the 10th iteration but the event is triggered for every iteration. Need to run in debug
Any Help much appreciated
Ken
Solved! Go to Solution.
04-15-2011 08:08 AM
I can't open your vi because I am on a laptop without LabVIEW right now. You might want to explore user events. You have one event that fires every time and in that event you determine if your trigger condition has been met and fire the user event. You can also programatically register for and unregister for events which could also be an option. If I could look at your vi I might have a better answer. But since you said you are writing to the value signaling property, user events are the first thing that came to mind.
04-15-2011 08:15 AM
I hope the remarks in the screenshot are sufficient to show what i want you to think about:
hope this helps,
Norbert
04-15-2011 08:25 AM
04-15-2011 09:12 AM
An example how to trigger user event.
04-15-2011 09:47 AM
One thing that I should have pointed out. I don't know what you are going to do in your "one off" event. If it is a time consuming operation you should not use an event but send a message to another loop and have that loop execute the code. Otherwise your event loop will be blocked.
You can send messages to other loops in a number of ways. Variables, Queues, Notifiers, Action Engines, etc..
Attached is your vi modified to use a notifier. I also modified your conditional logic. You said you wanted to have something happen only once but you were using a less than comparison. I changed that to an equals comparison so that when i = 9 a notification is sent to a slave loop.
A message box will be displayed on the tenth iteration of the master loop. Notice how your numeric indicator continues to increment even with the dialog box displayed. That would not happen if the dialog box were to be displayed in the master loop.
04-15-2011 09:51 AM - edited 04-15-2011 09:56 AM
@PaulieQ wrote:
An example how to trigger user event.
Kudos for the example but you forgot to unregister for and destroy the user event after the loop exits.
04-17-2011 07:03 AM
Thank you for all your comments. I have a lot to work with. I still do not understand why my vi failed to work as expected. The Boolean 'Once' starts off FALSE and stays FALSE until iteration 10 when it changes to TRUE and I want the code in the 'once' Value change frame of the event structure. Having run this code the Boolean remains TRUE so should not run again because it does not change again until the execution is stopped with the EXIT button. My vi is a simplified version of what is required for illustration only. I have a complicated test which changes from false to true at one point in the execution and want code to execute exclusively at this point. The solutions suggested seem to be over complicated for what is on the face of it a simple task.
04-17-2011 08:59 AM
I have seen this confusion over the value signaling property before. You would expect that it would only fire an event if you write a different value than what the control or indicator was set to. That is not the case. It will fire every time you write to it.
Your simplified example was writing to the value signaling property in the while loop on every iteration. That will fire the value changed event every time you write to it. Notice the property is "value signaling" and not "value changed signaling".
Some of the examples were complex with notifiers and user events. But the simplest one is just to put the property node inside a case structure so that it is only written when you want the one off event to fire. It does not matter what you write to the node if you are not sending any data to the event case.
If there is a reason you have to write to the boolean value signaling property on every iteration of the loop you can use the value written to conditionally execute code in the event case. But notifiers, queues and user events only look complicated.
04-18-2011 09:56 AM
Thanks for the clarification re Value Signaling. I will bear that in mind in future. I ended up doing what you suggested, putting the Val(Sgnl) in a case structure fron the result of an 'AND' on the two conditions I wanted to test and if the event had previously been activated.
Thanks for your help
Kudos given and accepted solution.