LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Alternativly running vi from 2 separate callers

Solved!
Go to solution

The goal:  Run a sub-vi from either one of two parent Vi's

 

Problem: Determining the execution state of the Sub VI.  If the Subvi is not running then run it from which ever vi is started first.  The Sub vi is a consumer of producer loops that are running in the parent Vi's.  Either of the parent vi's may be run, or they may be run at the same time.  The Exec. State does not differentiate between running, and reserved to be run.  This means that if the Sub VI is on the block diagram of either of the two Parent VI's then there isn't a way to know if it should be run.  

 

An example of the Vi's is included below.  The Coordinator vi is the subvi.  I need a way to execute the subvi from which ever This, or THat is called first.

 

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
Download All
0 Kudos
Message 1 of 11
(3,115 Views)

eximo,

 

I am not sure I understand what you want.  I suspect that there is a simpler way to do what you are trying to do.

 

A semaphore can be used to protect a resource from being accessed at multiple points.  You may need to use timeouts appropriately to keep the semaphore from completely blocking the other caller.

 

Lynn

Message 2 of 11
(3,109 Views)
Solution
Accepted by topic author eximo

Hey eximo,
       From your description and the VI's you provided I think I have a basic understanding of what you're trying to do. With that said, let me know if I'm heading down the wrong road. Basically, you have 2 main VI's each calling a SubVI, but you only want the main VI that executes first to access and run the subVI. I think the route you may need to take would be to place the subVI in a case structure that checks the value of a global variable shared by the two Main VI's. The 2 Main VI's will then change the value of the global variable if it finishes and is calling the subVI. However, the downside to this is that you may encounter race conditions. The other way to do this might be to reverse your program hierarchy where you would now monitor the Exec State of the two Main VI's and tell the SubVI to run the data from whichever Main VI goes to Idle first. This way, you can be sure you're only executing the SubVI once and eliminate the race conditions. Hope this helps!

 

--Ryan S.

 

Message 3 of 11
(3,084 Views)

@johnsold wrote:

eximo,

 

I am not sure I understand what you want.  I suspect that there is a simpler way to do what you are trying to do.

 

A semaphore can be used to protect a resource from being accessed at multiple points.  You may need to use timeouts appropriately to keep the semaphore from completely blocking the other caller.

 

Lynn


Ouch,

 

It hurts to see a nice example treated so inhumanely.  I has understood your original request to be similar to a dual seat flight control- Pilot and copilot control the same airplane.  Requiring instant feedback of aircraft state and assuming both pilots will arrive before operations begin (and needing error handleing in the event one dies in route or the aircraft blows up)

 

We need a clearer idea of the process flow.  Tell us what you are up to? Who are the operators? What do they need to know about each other if anything? 

 

Lynn is almost assuredly correct that there is a simpler approach


"Should be" isn't "Is" -Jay
Message 4 of 11
(3,079 Views)

@eximo wrote:

The Coordinator vi is the subvi.  I need a way to execute the subvi from which ever This, or THat is called first.

 



I am missing something. Your Coordinator.vi is not reentrant. It will be called by whoever called it first, and the other will be blocked until it is done.

 

[Edit: After re-reading I think I know what you are getting at. You could check if That.vi is running from This.vi, and check if This.vi is running from That.vi. Do the check at the beginnnig of the VIs. Use this to select a case in a case structure that contains your Coordinator.vi. But I agree with the others, there must be an easier way.]

=====================
LabVIEW 2012


0 Kudos
Message 5 of 11
(3,072 Views)

I decided to utilize the global variable.  When one of the two "pilots" exits "die" they terminate the "airplane" or slave program.  However both pilots are continously checking the global variable.  If it ever is off then it re-engages the slave.  The slave is only terminated when both pilots have exited.  

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 6 of 11
(3,068 Views)

it's true, it will be blocked, so maybe I don't even need to worry about it?

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 7 of 11
(3,064 Views)

@Steve Chandler wrote:

I am missing something. Your Coordinator.vi is not reentrant. It will be called by whoever called it first, and the other will be blocked until it is done.

Its a continuation of this thread.  I had assumed they would be called in parallel from a "process start" vi and hence none would exist on any other's block diagram.  Apparently, I missed something.

 

Eximo- You can use the "Created New" outputs of the obtain queue functions to determine of the queues already existed (and by simple logic decide which vi started first)


"Should be" isn't "Is" -Jay
Message 8 of 11
(3,063 Views)

@Jeff Bohrer wrote:

Eximo- You can use the "Created New" outputs of the obtain queue functions to determine of the queues already existed (and by simple logic decide which vi started first)


I would have never thought of that. Cat LOL  (Hey, new emoticons!)

=====================
LabVIEW 2012


0 Kudos
Message 9 of 11
(3,061 Views)

You need a bit more logic. to halt the queue filling up with backchannel data to the "dead pilot" (whos not dequeueing it)  Set the max length of the backchannel to 1 creating a lossy queue.  if the "dead Pilot" wakes up he will have 1 copy of the latest and greatest status of the aircraft.


"Should be" isn't "Is" -Jay
Message 10 of 11
(3,057 Views)