LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you control a state machine from another .vi?

Solved!
Go to solution

I have written a VI that is an event driven state machine.  The events are operator actions taking place on latched buttons on the Front Panel.  Each event puts one or more state names on the state queue.  A state machine then takes the state names off the state queue and uses them to open the appropriate cases which contain the functions to be performed....Now comes the desire to interact with this vi programatically from another vi.  Since the the events can't be caused remotely because the buttons are latch type and can't be manipulated by property node (value(signal))...Is there some way to remotely add a state name to the state que...?  That would be neat.

 

I would rather not add any "hidden" buttons to the original vi, or have to modify the event structure.

 

Is there a better way...?

 

Hummer1

0 Kudos
Message 1 of 7
(3,453 Views)
Solution
Accepted by topic author Hummer1

Either you use "Obtain Queue" with the same name in the other VI or you use a Functional Global Variable to pass the Queues Reference to the other VI.

Then you write the state names via "Enqueue Element" as you would do it in the VI containing the State Machine.

 

 

Message 2 of 7
(3,447 Views)

I like Christian's suggestion but as far as the latch action preventing the use of value-signaling...

 

Change the latch action and just write a false to a LOCAL of the boolean in the event case assigned for the boolean.

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 7
(3,442 Views)

So, In the controlling vi, I could obtain Queue (with the same name as the Queue) in the controlled vi, and any items placed on the queue in the controlling vi would pass to the controlled vi...no further connections required?

 

Hummer1

0 Kudos
Message 4 of 7
(3,437 Views)

@Hummer1 Exactly, do you see this connector called "create if not found?" at the Obtain Queue.vi, it says if you try to create a Q with the same name it refers to the allready existing one.

 

@Ben Thanks!

Message 5 of 7
(3,431 Views)

Yes!

 

Disclaimer:

 

The two VIs must be running in the same process context

 

Translation:They both must be started from the same project or both opened without a project.

 

If the two VI are opened from different projects LV will create a sepearte execution environment for both and they will not be able to to interact with the saem queue.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 7
(3,429 Views)

Thanks,

 

this is very powerful...and the context warning from Ben is very important too.

 

Hummer1

0 Kudos
Message 7 of 7
(3,421 Views)