08-23-2012 07:16 AM
Thank you, that worked. I finally got round to having a look at it, and now have a few questions ranging from generalities to specifics.
08-23-2012 10:04 AM
@J.Mamakos wrote:
Thank you, that worked. I finally got round to having a look at it, and now have a few questions ranging from generalities to specifics.
- Is it generally good practice to have an 'error' case statement after dequeueing elements in a slave loop (in a similar way to what one does in a sub-vi)? Or is this usually not necessary?
- I have never used dynamic events before. When are they best used, for what, and why? The LabVIEW help files are useful, but only say so much.
- Do (or can) the registered dynamic events override the 'normal' events, or do they just add to the list of events handled by the structure?
- I read that you can register and unregister for events so that different parts of your code can enable/disable certain events being handled. Under what circumstances would this be useful, and has anyone used this themselves (or has examples)?
- Am I right in drawing similarities between the User Event wire and a queue? Or is there a difference in how the wires are handled?
- When releasing queues or destroying references (etc) in the termination sequence of a vi, should I not connect those primitives with an error input (despite there being a terminal to do so)? This, I assume, would be a way of ensuring that the handles are properly released no matter what.
- A couple of questions regarding your use of variants in the queues. I've split them into this thread.
1. I generally do not use a separate error case for the queue but it is not a bad practice. To date, the only errors I have ever gotten from a queue are a timeout and after it has been destroyed. Since I almost exclusively use explicite stop and exit messages on my queue and release the queue only after everything has been shutdown I don't look for the error. However, as I said it certainly doesn't hurt.
2. User events add to the list of events you can handle. They do not override existing events. There are certainly cases where you want to unregister for events. In a dynamic system you may want to ignore certain events at times. For instance, you have a background task that is acquiring data and it fires an event to allow the UI to update. However, at some point you do not want to update the UI. Simply unregister the event and no updates occur. The acquisition can still fire the events and there is not need to message that task to stop sending events. The receiver simply ignores them. THis helps in decoupling your code so different portions do not need to know or care about the state of other tasks in the system. User events and queues are very similar in nature. The two main differences are the dynamic registration (you would have to write your own code to have queues filter or throw away elements). User events can be deregistered and the events will get dropped. With a queue the elements are placed in the queue and would need to be read. The other major difference is that with queues you can only have one reader. You would get nondeterministic behavior if you had two tasks dequeueing elements. You would have no way of knowing which task gets which message. With user events you can have multiple tasks registered to receive the event. In this case it is like a broadcast.
3. You can safely wire the error cluster to the release. The release/close VIs ignore the error in and simply use it to enforce data flow. Even with an error present the resource will get released or closed.
08-24-2012 07:33 AM
Can you use User Events (or something else) to manually trigger the 'normal' events?
This question arises because I am adding the ability to save/load FP control/indicator values to/from a data file. In my event structure, I have cases that toggle visibility of other controls depending on the state of the one that triggered the event. I was wondering how to execute all of these events (where necessary) when loading in the values from the data file, so that I'm not left with controls/indicators that are in the wrong visible state. There are also a couple of arrays that need populating/changing when some numerical indicators are updated.
If my initial question is not possible, how would you suggest me accomplishing my main aim?
08-24-2012 09:47 AM
What "normal" events are you referring to? You can use a property node to set a value on a control using value(with signaling) which will trigger a value change event for that control. I am not sure you can trigger such things as mouse down/mouse up type of events programmically. An option you have would be to create some corresponding user events that you want to fire. An event case can be triggered by multiple events such as a mouse down and your user event.
08-24-2012 10:00 AM
Ah, okay. The Value (Signalling) property node works as I wanted, thank you.