LabVIEW Channel Wires

cancel
Showing results for 
Search instead for 
Did you mean: 

Start a VI with a Message Channel Wire

Solved!
Go to solution

Is there a way to start a VI from a channel wire? I have a timer that needs to invoke a VI and then interact with it. The interactions are simple (start, stop, pause, resume), and the VI needs to close when stopped. I was planning to use a message-type channel wire with a simple enum as the message.

 

I originally had a producer/consumer pattern in a single VI with the timer and main loops communicating via a "stop" tag and the Val(Sgnl) property of a local variable (is that bad?). But I was seeing increased iteration times as the main loop ran for 5 or 10 minutes (it basically needs to run for 5 minutes, do nothing for a few minutes, run for 5 minutes, etc). So My idea was to start and stop the VI every time it needs to run instead of letting it accumulate iteration lag.

0 Kudos
Message 1 of 4
(4,708 Views)

Value(Signal) is not the best way to communicate between VIs.

 

I'm not sure what you mean by "Start a VI with a Channel Wire." - my initial reaction is to say no, it is not designed to start a VI or call one dynamically.

 

You could use a message Channel Wire type, or a User Event construct, where you register the consumer for the User Event and the Message you send can be anything, such as a Cluster of an Enum and a Variant - the Enum contains the command, the variant can contain any data needed for the consumer to process the command.  The nice thing about the User Event Structure is that is can sleep (set timeout = -1) if no messages are incoming. 

 

A queue message construct can do similar things, but is limited only to messaging.

 

Do you need data back from the VI that is running and pausing?

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 2 of 4
(4,684 Views)

Thanks for your response. I was going to use a User Event, but that seemed like a lot of coding for the same functionality of using Value(Signal) on a disabled control. I'm guessing this is against the style guide.

 

I may need data back from the consumer VI - I'm not sure yet.

 

Can you recommend an architecture that will allow me to do the following:

1) Start a parallel VI on command from a custom timer VI

2) Pass data to the VI at startup

3) Set a boolean in the target VI on user event within the timer VI

4) Stop the VI on command from the timer

5) Perhaps pass data back to the timer

 

So I need to start the target VI, communicate asynchronously, and then stop the VI all on-command from the timer VI.

 

I am currently using event-driven state machines in both the timer and target VI. Here is the timer loop. I believe I can eliminate the "Stop" feedback tag from the target VI with the new architecture.

0 Kudos
Message 3 of 4
(4,675 Views)
Solution
Accepted by topic author jfalesi
Message 4 of 4
(4,647 Views)