LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Run a VI when it is active?

Hi,

I want to make a VI (which allways runs) that can call multiple vi's and
when i click on one VI, that VI has to be active and running an de other
VI's has to hold? A little bit like it is in photoshop.

Does anybody has an example?

Best regards,
Thijs Boeree
0 Kudos
Message 1 of 12
(3,860 Views)
I think you are asking for a VI that is the main VI that does nothing more than launch subVIs. This easily done by using an event structure and having the subVIs show front panel when called. It would then hold until the subVI's run ended. The control would then return to the main VI.

Or you could be asking for a main VI that did not hold that would launch other VIs and they would block each other (the hold being of the other subVIs). This could be done by dynamically launching the subVIs and having then share a semaphore of some sort (semaphore, notifier, queue). The SubVIs would be set for floating. I have not done anything like this but I think it may not be that difficult. Please write back with a few more details.
0 Kudos
Message 2 of 12
(3,860 Views)
Thanx,

But what i mean is One VI a big front panel (a), and when you push a button
another front panel (b) opens but the main vi (a) still runs, then when you
push another button from the main VI (a), another front panel opens (c) and
then when you click somewhere on panel (b) panel (c) holds but is still
visable in the back (panel a is allways visable in the back), then when you
click somewhere on (c), panel (b) holds but is still visable in the back.
Something like that.

I hope you understand what I mean, anyway thank you!

Best regards,
Thijs


"LabVIEWer" schreef in bericht
news:5065000000050000008F870100-1079395200000@exchange.ni.com...
> I think you are asking for a VI that is the main VI that does nothing
> more than launch subVI
s. This easily done by using an event structure
> and having the subVIs show front panel when called. It would then
> hold until the subVI's run ended. The control would then return to
> the main VI.
>
> Or you could be asking for a main VI that did not hold that would
> launch other VIs and they would block each other (the hold being of
> the other subVIs). This could be done by dynamically launching the
> subVIs and having then share a semaphore of some sort (semaphore,
> notifier, queue). The SubVIs would be set for floating. I have not
> done anything like this but I think it may not be that difficult.
> Please write back with a few more details.
0 Kudos
Message 3 of 12
(3,860 Views)
Hi Thijs,
I have attached a VI written in LabVIEW 7 that will guide you on how to do this. It uses VI server functions.

I hope this helps.

Sincerely,
Feroz
National Instruments
0 Kudos
Message 4 of 12
(3,860 Views)
> But what i mean is One VI a big front panel (a), and when you push a button
> another front panel (b) opens but the main vi (a) still runs, then when you
> push another button from the main VI (a), another front panel opens (c) and
> then when you click somewhere on panel (b) panel (c) holds but is still
> visable in the back (panel a is allways visable in the back), then when you
> click somewhere on (c), panel (b) holds but is still visable in the back.
> Something like that.
>

Perhaps the first place to start is with all three running freely. The
thing to recognize is that if you call a subVI, the calling diagram is
blocked until it returns. So if you have a fixed number of panels and
make that many loops, each of them can open
a panel and wait until it
finishes. The only issue will be if you want to close the top panel.

If you have a dynamic number of panels, or would like another way of
doing this, you can also use the Run method instead of a Call or Call by
Reference. The run method doesn't pass parameters to the subVI, but has
the option to wait or not wait for the subVI to complete. If you choose
not to wait, then the top VI can go ahead and do whatever it needs to
and each subVI is also independent.

As for the subVIs running only when active, assuming they need input,
all you have to do is make them wait on events or have time delays that
limit the amount of CPU they take. If they are acquiring I/O or
something similar, you can probably use the VI property Is Frontmost to
control the execution.

Greg McKaskle
0 Kudos
Message 5 of 12
(3,860 Views)
Thnx for your explanation but i'm not certain if i understand what you mean,
can you send me an example just simple Vi's but with this feature?

Thank you in advance,
Best regards,
Thijs Boeree

"Greg McKaskle" schreef in bericht
news:1Vzqc.127016$hR1.28658@fe2.texas.rr.com...
> > But what i mean is One VI a big front panel (a), and when you push a
button
> > another front panel (b) opens but the main vi (a) still runs, then when
you
> > push another button from the main VI (a), another front panel opens (c)
and
> > then when you click somewhere on panel (b) panel (c) holds but is still
> > visable in the back (panel a is allways visable in the back), then when
you
> > click somewhere on (c), panel (b) holds
but is still visable in the
back.
> > Something like that.
> >
>
> Perhaps the first place to start is with all three running freely. The
> thing to recognize is that if you call a subVI, the calling diagram is
> blocked until it returns. So if you have a fixed number of panels and
> make that many loops, each of them can open a panel and wait until it
> finishes. The only issue will be if you want to close the top panel.
>
> If you have a dynamic number of panels, or would like another way of
> doing this, you can also use the Run method instead of a Call or Call by
> Reference. The run method doesn't pass parameters to the subVI, but has
> the option to wait or not wait for the subVI to complete. If you choose
> not to wait, then the top VI can go ahead and do whatever it needs to
> and each subVI is also independent.
>
> As for the subVIs running only when active, assuming they need input,
> all you have to do is make them wait on events or have time delays that
> limit the am
ount of CPU they take. If they are acquiring I/O or
> something similar, you can probably use the VI property Is Frontmost to
> control the execution.
>
> Greg McKaskle
>
0 Kudos
Message 6 of 12
(3,860 Views)
> Thnx for your explanation but i'm not certain if i understand what you mean,
> can you send me an example just simple Vi's but with this feature?
>

Which feature, I described three. First is parallel loops, second is
using the run method and not waiting for completion, and third is the
IsFrontmost property of a VI.

You might start by looking up the help and looking for examples on these
individually. If you need additional help, please be more explicit.

Greg McKaskle
0 Kudos
Message 7 of 12
(3,860 Views)
OK

I've checked a lot event related examples, and now i know exactly what i
want, but i am not sure if you know what I mean so i'll try to explain it:

1. I want one Main VI that allways runs, and in this main VI there are (for
example) 2 buttons: Button A and Button B.

2. If i click on "button A" a pop up window appears (a new VI) this VI runs
on events (I allready know how to work with events).
Then; while pop up window "from Button A" still is running (on events) I
want to press (on the Main VI) on "Button B" and then another pop up windows
should appear (a new VI).

3. The Main VI keeps on running and the pop up windows are both there and i
can close them and restart them by pressing the A or B button again.


I hope you know what i mean, and do not hope to cause you a lot of work?

Again thanks in advance,
Best regards,
Thijs Boeree


"Greg McKaskle" schreef in bericht
news:AIIqc.618$KO2.391@fe2.texas.rr.com...
> > Thnx for your explanation but i'm not certain if i understand what you
mean,
> > can you send me an example just simple Vi's but with this feature?
> >
>
> Which feature, I described three. First is parallel loops, second is
> using the run method and not waiting for completion, and third is the
> IsFrontmost property of a VI.
>
> You might start by looking up the help and looking for examples on these
> individually. If you need additional help, please be more explicit.
>
> Greg McKaskle
>
0 Kudos
Message 8 of 12
(3,860 Views)
Hi Thijs,
I had attached a VI that allows you to do both (1) and (2) above.

As for step (3), I have reattached the VI with some changes that will allow you to open and close a VI using just one button. Please take a look at it and see if does what you want.

Sincerely,
Feroz
0 Kudos
Message 9 of 12
(3,860 Views)
> 1. I want one Main VI that allways runs, and in this main VI there are (for
> example) 2 buttons: Button A and Button B.
>
> 2. If i click on "button A" a pop up window appears (a new VI) this VI runs
> on events (I allready know how to work with events).
> Then; while pop up window "from Button A" still is running (on events) I
> want to press (on the Main VI) on "Button B" and then another pop up windows
> should appear (a new VI).
>
> 3. The Main VI keeps on running and the pop up windows are both there and i
> can close them and restart them by pressing the A or B button again.
>

I'll narrow your choices for you. In your event structure when
responding to a button, use the VI Server to Open a
VI reference using a
path to the VI and nothing else. Wire the output referece into an
Invoke node and select the Run VI method. Wire a FALSE to Wait until
done, and return from the event structure. Make another invoke node to
Open the Panel and chain it to the end. Your loop should then be able
to handle additional events, make measurements, etc.

Your subVIs can have their own loop to process messages, do I/O, etc.
If you want them to affect one other through similar buttons, add the VI
server code to them as well, or add a user event that passes the request
on to the Main VI.

To close a panel, get the reference and close the window. You can also
abort the VI if that is what you intend.

Greg McKaskle
0 Kudos
Message 10 of 12
(3,860 Views)