LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

access controls in another project

I have two projects. I want a VI in project A to be able to modify a control in a different VI in project B. From the VI in project A I can obtain an array of references to all controls in the VI in project B. I can isolate which control I'm interested by cycling through the Label.Text property of all controls within the VI in project B.

 

Is modification (such as writing to the Val(Sgnl) property) of these controls in project B only allowed in project B? I can get my test code to execute in project B but not when it is run from a VI in project A. 

 

Does anyone have a solution or idea on how I can do this?

 

I want to avoid passing commands using Datasockets, clipboard/command line calls & text files.

0 Kudos
Message 1 of 7
(2,832 Views)

There's no real reason why this shouldn't work. What exactly happens? How are you creating the reference? Are you passing in a string or the full path? You'll need to do the latter. Do you have VI B open by means of double-clicking on the VI in the project? If so, don't expect to see a change there since when you create the reference from VI A it's within the namespace of project A. You can see this if you look at the title bar of the VIs. If you were to open VI B from project B, and then open VI B directly from disk, you would see two "VI B" VIs if project A was the active project at the time.

0 Kudos
Message 2 of 7
(2,824 Views)

I pass in a full vi location path to the open vi reference function (does that create the reference?). I take the vi reference and pass it to the panel property. I use the panel property to access the controls[]. I the search through the Label.Text property till I locate the label I want. I then use that labels reference to change the value of the control.

 

 

 

I opened VI A and VI B outside of their projects and the code works!! What should I modify to get it to work while the VI's are in their respective projects?

0 Kudos
Message 3 of 7
(2,814 Views)

There's nothing you need to do. The code will be updating the control value. It's just that when you open the VI from the project window, you're essentially opening a different view of the VI. VI A is still opening a reference to VI B and talking to it. See the attached example.

 

Tip: You can use the Control Value.Set method to set a control by name directly without hunting through the list of controls.

0 Kudos
Message 4 of 7
(2,807 Views)

Why not pass the data via queues? If you are running these VIs from the IDE and not as individual applications (built exe), they should be able to reference the same queue. You could also consider using network streams (available in LV 2010) or a simple network based protocol.

 

Reaching directly into an application such as getting the references to it's controls/indicators just seems like it is asking for problems. If something from the outside has to update an application there should be a defined interface to do that.

 

I agree that using the file or the clipboard is not the best approach but in my opinion neither is reaching directly into an application.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 7
(2,804 Views)

They will be separate executables so a queue would not work. Project/executable A will launch executable B through the command line. I just need a way to gracefully close executable B so the use of the tskill command is not an option. The idea was to access a close button in executable B to access the value change event which shuts down the program.

 

I happened to come across this enlightening article and it seems what I want to do is a security risk so it is no longer allowed. I'll probably define a simple tcp/ip interface and go that route. Thanks guys!

 

 

0 Kudos
Message 6 of 7
(2,791 Views)

Since you are using two separate executables using references wouldn't work either. I suggest that you check out network streams or network queues. If you are using LV 2010 I think the network streams would be your best bet.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 7
(2,786 Views)