From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

child-parent and access to an object of another vi

Hi,

1.-I have a vi that is a child of a vi parent and it works but now I want my vi child is parent of another vi child. How can I do it? Can a vi be a child of a vi parent and a parent of another vi child at the same time?

2.-How can I access to an object of a vi from another vi in order to read or modify the value of that object (without using call by reference and passing parameters)?

Thanks,

ToNi.
0 Kudos
Message 1 of 21
(4,648 Views)
What do you mean by child and parent? Are you refering to a subpanel? If so, I haven't tried it, but I think it should work. Just try it with any 3 VIs and see if it works.

To access a control or an indicator in another VI, wire the reference of that VI into an invoke node and select the Get or Set Control Value method. Be sure to watch out for race conditions and for typing errors (the name of the control has to be identical, including case).

___________________
Try to take over the world!
0 Kudos
Message 2 of 21
(4,637 Views)
It works but.. is there another method to do it without using a block open reference, using only a VI refnum wired to an invoke node (without an open reference block)? Because I have a vi that is configured as open when called and if I use a open reference block the user can see this vi is opened by the application and I would like it was transparent for user (He cannot see the vi open while I am reading/modifying the values of indicators/controls of that vi). I want to access the controls and indicators of that vi without open it so the user cannot see it opened. It is necessary that the vi I am reading/modifying indicators/controls values is configured as open when called.

By parent and child I refer to a MDI child application where the child vi is inside the parent vi. Then, I want to have a vi that is child of a parent vi and at the same time it is parent of another child. for example:

vi(3) - vi(1) - vi(2)

vi(3) is parent of vi(1)
vi(1) is child of vi(3)
vi(1) is parent of vi(2)
vi(2) is child of vi(1)

I attach you an example in LV 7 Express but it doesn't work. Notes_ vi(3) is MainParent.vi, vi(1) is child-parent.vi and vi(2) is child.vi

Can I do it?

Thanks,

ToNi.
0 Kudos
Message 3 of 21
(4,631 Views)
You did not include the subVI Create Child N2. LabVIEW does not support MDI and true child windows. Your child windows will not be inside any other VI unless you do a lot of work passing the window position of the main VI to the subVI and contricting the window position of the subVI. In your example, you also are setting all subVIs to be maximized. If you don't want a user to see a window while you modify it, can't you first set it to hidden and then show it?
0 Kudos
Message 4 of 21
(4,622 Views)
Yes, I can set it to hidden before reading/modifying values of indicators/controls, this is a good idea but there is another problem... if the vi I am accessing to its indicators/controls in order to read/modifying values is already opened....it generates an error, because I am attempting to open an vi that is already opened by the user and it is possible in my application that the user opened this vi at the same time I am accesing to it. How can I solve it then?

I attach you Create Child N2.vi. Sorry.

Thanks very much for helping me,

ToNi.
0 Kudos
Message 5 of 21
(4,617 Views)
What you could do first is use the property Front Panel Window:State. If the VI has not been opened by the user, it will return the value "closed".
0 Kudos
Message 6 of 21
(4,612 Views)
Yeahhhh it is a very good idea Dennis 😉

but before I can use the property front panel window:state to view if it is opened... I must to obtain the reference to that vi with the open reference node (I can not directly use the property node you tell me if I don't obtain reference to that vi before) and... if it is already opened.... it returns me an error if I try to open it with an open reference node... what I can do if it returns me an error is a case structure. If it returns error it means that it is already opened by the user and if it not returns error it means that it is closed. Is it a good idea?

but if I want to read the value of that indicador of that vi at the same time it is opened by the user.... What can I do? One solution would be to wait for user closes it and then I try again to read the value but... If I don't want to wait the user closes it and I want to read it at the same time the vi is opened by the user... how can I do it?

Thanks,

ToNi.
0 Kudos
Message 7 of 21
(4,606 Views)
I'm not sure I understand. If I just use the Open VI Reference on a VI that's already open, I don't get an error. What is the error code that you get? I'm also able to use the Get Control method on any VI, whether it was opened by another VI or manually.
0 Kudos
Message 8 of 21
(4,598 Views)
Ok, sorry. It is a mistake mine. Now I am trying to do it. If I have problems again I will tell you something. Your idea is very good and it has been very helpful for me.

With regard to the vi I have attached here about parent-child, is it not possible that a vi that is child of one vi could be parent of another vi at the same time?

And, what is the most efficient way to make threads in LV 7? I would like to communicate two or several VIs, that is, several VIs do an individual task and in a point of time they interchange information. Sorry If I don't explain it to you very well. If I don't understand me, please, tell me and I try to explain it to you better.

And If I want to do a task every x seconds in a vi... what is the best efficient method? with Elapsed time or wait until next ms multiple inside a while loop? I want it was not blocking, I want it was asynchronous so I can do other things at the same time it executes.

Thanks again for helping me 😉

ToNi.
0 Kudos
Message 9 of 21
(4,593 Views)
Since LabVIEW doesn't support MDI, it's not really accurate to speak of parent-child relationships. The fact that VI_1 opens and runs VI-2 doesn't make VI_2 a child of VI_1. Using VI Server, VI_1 opens and runs VI_2 but VI_2 could just as easily open and control VI_1, and VI_2 can open V1_3 which could open and control VI_1. After being opened by VI_2, VI_3 could be controlled by VI_1. It's like opening an running a VI from the File>Open menu. Once opened, they are independent and there isn't a way, asfaik, for a VI to know who or what opened it.

In a single VI, you can separate while loops operating independently. They can share data via queues or even local variables. When you have separate VIs, they can share data with Get/Set Control Value methods, queues, global variables, datasocket, TCP/IP. Depends on the type of data and whether you'll be using the app builder and have separate exe files.

Wait or Wait Until Next are synchronous. They will block all other operations in the same while loop. Elapsed time does a Get Time in Seconds with every loop iteration. It might not block but if you wire it to a case statement that you want to run when time has elapsed, what's inside the case statement might block other tasks inside the same while loop. Things that you want to run continuously is best put in a separate while loop.
0 Kudos
Message 10 of 21
(4,589 Views)