LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger event in multiple subVIs

Solved!
Go to solution

Hi

 

I have an application that launches several subVIs each containing X-Y Graphs. All subVIs use a event driven Prod/Consumer framework. I would like to be able to syncronize the cursors in all Graphs, so if I change cursor position in one subVI it will change in all subVIs. Because of P/C framework I need to trigger an event in each subVI to make it work. Is there a simpler way of doing this than setting up an User Event in each subVI? I've been hoping that a Global variable could trigger events, but it doesn't look like this is possible.

 

Regards

Bård  

0 Kudos
Message 1 of 5
(2,564 Views)
Solution
Accepted by BBend

Trust me, the User Event will be the best solution.  Since you are Event Driven P/C, you already have the structure there.  Just create an Action Engine to contain the event and let everybody make their own registrations to the event.  You can also use the Action Engine to send the event.

 

If you want to take it a step farther, you can create a library with the Action Engine a private function and then you just make wrappers for creating a registration, sending the event, and closing out the event.


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
Message 2 of 5
(2,557 Views)

In stead of an action engine, you can do more or less the same thing in a class. Create a user even in an init method, and register for the event in a register event method...

 

Upside is you have wires going into VI's that use the events. And you can duplicate the code (statically or dynamically) so you get the same functionality twice without the two copies interfering.

 

Downside is you have wires going into VI's that use the events. That is, it's an acquired taste. I think it's better in the long run, since you don't get these globals (smart globals are still globals).

 

Anyway, the only alternative that *might* be easier is a channel wire.

Message 3 of 5
(2,534 Views)

Ok, User event it is then! I was hoping for a simpler solution as I only need to trigger on one parameter, so a Global Variable event trigger would be a nice feature, for some quick&dirty programming Smiley Very Happy 

 

Wiebe: OO classes etc I haven't learned yet so I'll leave that for later. I'll look into the Channel Wire method which I haven't used before. Thanks for suggestions

0 Kudos
Message 4 of 5
(2,479 Views)

You might want to look into channel wires first. They are quite new, so there's not a lot of experience around, but if they fit (and there are several flavours) they will save a lot of work.

 

Not sure how channel wires turn out in a project in the wild, but if you're looking for a quick hack, I think a channel wire will do just fine (or better). Not that channel wires are a hack (I just don't know jet), but they are quick that's for sure. You do need LV16 or higher...

0 Kudos
Message 5 of 5
(2,453 Views)