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: 

Function Globals do not work acrross multiple projects.

Hello I'm using a Function Global (uninitialized shift register on a 1 itteration loop) to share data in my aplication.
 
I have found that if I write to the Function Global from a VI inside a project that the data is not available to a caller that is not oppened from within the project.
 
Is there a way for the project to write to the main application instance? or vice versa?
 
Thanks,
Amaury
0 Kudos
Message 1 of 14
(3,588 Views)

I haven't used a Functional Global for vi's that were not part of a project..  so my comments are purely from a curiosity point of view.

I would have expected it to work, as long as the vi's that are not in the project were calling the Functional Global that was in the project (full path and same name).

I wonder if there are safeguards to prevent a Functional Global from sharing data with non-project members, in order to protect the integrity of the Functional Global data...  Although I doubt it, it would be an interesting feature if it did..  After all, a Functional Global is just another VI.  And then again, I haven't called any VI's by using another VI which is not part of the project..

I am curious. Did you make the Functional Global a re-entrant VI? (it shouldn't be).  Is it calling the exact same Fn Glbl (exact path & name)?  Did you at any time make a backup copy by selecting the project directory in Windows and then copy & paste to another location?

R

0 Kudos
Message 2 of 14
(3,570 Views)
I was curious about this as well so I setup a test to verify it.    When you call a functional global that is part of a project.  And that same vi is loaded into memory from a vi in the project.  The instance outside the project is a clone of the vi that is in the project.  The project protects data that is part of it's namespace from outside callers. 
 
I'm a little curious about your application and why you need to pass data as you describe? 
SteveA
CLD

-------------------------------------
FPGA/RT/PDA/TP/DSC
-------------------------------------
0 Kudos
Message 3 of 14
(3,554 Views)


StevenA wrote:
The instance outside the project is a clone of the vi that is in the project.  The project protects data that is part of it's namespace from outside callers. 

That's what I suspected..  It's a nice feature 🙂  But not if you try to call it from outside the project.
 
Workaround:  Create another project and include the Functional Global into the new project.

R
0 Kudos
Message 4 of 14
(3,534 Views)
This is intended, a project functions like a real executable, likewise it isn't possible to use queus between projects (or application instances like they are officially called), to do such a thing you can use shared variables, data socket or tcp-ip.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 14
(3,531 Views)
Yep that is as intended.
 
What you can do is (from memory so correct me if I am wrong);
 
Open a ref to LV and get a ref to the "other" project instance.
 
Get a list of all VI's open in the project context and locate the target VI by checking the names.
 
Use Invoke node > call by ref to use the Action Engine in the other project.
 
Note:
 
This same approach should work to access AE's on other computers if you open a ref to the LV instance on the other machine.
 
Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 14
(3,526 Views)
Nice solution Ben.
 
That should work well.. 🙂
Message 7 of 14
(3,513 Views)

Here are some more details about the method Ben mentioned (and an example).


___________________
Try to take over the world!
Message 8 of 14
(3,508 Views)

Thank Yair!

I was thinking of including a link to that thread but was just to lazy to go looking for it. Smiley Sad

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 14
(3,503 Views)
Thanks for the link to the example -- I'll take a look... For my application, though, I can just add some of the files NOT included in the project into the project so they use the same clone of the Fn Glbl... (That of the project's execution, not LV's Main Application Instance.)
 
Thanks again!
 
Amaury
0 Kudos
Message 10 of 14
(3,463 Views)