LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Usage of event structure

Hello everyone,
Is it possible to have an event structure that listens to two events in one case and if those two events for example change, then an action is taken, if only one event occurs then no action is taken? I have four clusters and i trying to setup an event structure that listens to changes. (e.g. cluster 1 & cluster2 change , do something, cluster 1 & 4 changes, do  something different). Is this possible?
0 Kudos
Message 1 of 13
(4,137 Views)
Events come in one at a time. You can register for multiple corresponding events in the same event structure, but the event case will execute if any one of the registered events fires, not all of them.

There are fundamental reasons behind this too. Event Structures are usually used for user interaction. There's only one mouse. You can only manipulate one control at a time.

Your best bet will be to use Shift Registers to keep track of when one event happens, and then not do anything until an event happens on the other corresponding control.
Jarrod S.
National Instruments
0 Kudos
Message 2 of 13
(4,128 Views)
Here's one example of what I mean. The implementation is very poor and quickly done, so I wouldn't recommend copying it. But it should give you some ideas for how you could do it better. It's saved in 8.0.
Jarrod S.
National Instruments
0 Kudos
Message 3 of 13
(4,126 Views)
You can also accomplish this using custom events. There's an example that ships with LabVIEW called "Programmatical Fire Events" that shows the basic idea. You would create an event that is your cluster1 and cluster2 change, and another that is your cluster1 and cluster4 change. Then you would set your event structure to have one case to handle when this event gets fired.

One thing that is not clear is if cluster1 is changed, and then cluster4 is changed, and then cluster2 is changed, is this two events (cluster1/cluster4 change and cluster1/cluster2 change), or one (cluster1/cluster2 change)? In other words, does an event cancel out a possible event that is "building"?
0 Kudos
Message 4 of 13
(4,105 Views)


@smercurio_fc wrote:
You can also accomplish this using custom events. There's an example that ships with LabVIEW called "Programmatical Fire Events" that shows the basic idea. You would create an event that is your cluster1 and cluster2 change, and another that is your cluster1 and cluster4 change. Then you would set your event structure to have one case to handle when this event gets fired.

One thing that is not clear is if cluster1 is changed, and then cluster4 is changed, and then cluster2 is changed, is this two events (cluster1/cluster4 change and cluster1/cluster2 change), or one (cluster1/cluster2 change)? In other words, does an event cancel out a possible event that is "building"?


Well thank you guys for your rapid response. What I am trying to do is have four clusters and essentially i need to determine which clusters where chosen. It could be all four, or three or two, or just one and determine which one it is . Once i know which one it is, i build an array accordingly to the number of clusters chosen and place zeros for the clusters not chosen in my array. I am playing around with the examples and trying to implement a custom event for these cases, but it doesn't seem like this is the best way to go at it.

0 Kudos
Message 5 of 13
(4,080 Views)
The basic issue is the one that Jarrod pointed out (in a very artistic way Smiley Wink ) - namely that events happen one at a time. No matter how you structure your code you will only see one event occuring at any point in time - though it is possible to create a history of the last N events that occurred and change what any particular event does based on what had happed just previously.

Perhaps it would help if we could see what your user interface looks like and what behavior, exactly, you are wanting to produce.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 6 of 13
(4,075 Views)
Hello,
I've attached a Jpg of what I am working on. Essentially I have four clusters, if one is selected, the cluster is modified and a couple items are appended to it. (right hand side), if more then one, in which case 2 or 3, each cluster is modified and displayed. The clusters on the right hand side won't show up unless some input is changed on the left hand side.. Now what i'd like to do is, once i know which cluster or clusters is chosen, i proceede to build a file with information on the gas we plan to flow.
Hopefully this makes sense..
thanks for all the input.
0 Kudos
Message 7 of 13
(4,055 Views)
Unless I'm missing something in your description I don't see where there is any interaction between the various clusters. All you need to do is an event to handle changes in the clusters as they occur. One thing that will make this easier is that all the clusters are the same, hence you can have one event that handles all four clusters. The thing that makes this possible is that a reference to the control that fired the event is included in the event data. From this event you can get the name of the cluster.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 13
(4,055 Views)


@mikeporter wrote:
Unless I'm missing something in your description I don't see where there is any interaction between the various clusters. All you need to do is an event to handle changes in the clusters as they occur. One thing that will make this easier is that all the clusters are the same, hence you can have one event that handles all four clusters. The thing that makes this possible is that a reference to the control that fired the event is included in the event data. From this event you can get the name of the cluster.

Mike...


Hey Mike,
Well I need to know how many clusters were selected, which ones and how many, i setup a data file that mixes these gases, in certain time intervals, but i need to know how many, to establish a pattern and which ones, because they are in a different column in my array.


0 Kudos
Message 9 of 13
(4,045 Views)
That's simple.  Create a cluster containing 4 boolean values (one for each cluster) and pass it through the event loop using a shift-register. When a cluster is selected, turn on the bit associated with that cluster. Counting the number of bits turned on gives you the number of clusters that were selected.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 13
(4,043 Views)