Can Functional Globals be used to share data between VIs running on different targets?

StackOverflow https://stackoverflow.com/questions/18521870

  •  26-06-2022
  •  | 
  •  

سؤال

The LabVIEW wiki page on Functional Global Variables (FGV) states that

The primary use of Functional Globals is to provide data sharing across an entire project, both horizontally and vertically.

In the past, I have successfully used FGVs to share data among VIs running on the same target.

In my current project, which involves multiple targets (namely, a host PC and a cRIO), I now want to pass configuration data between a Host VI and an RT VI, and I thought an FGV would come in handy for that.

However, it doesn't seem to work: I write to the FGV on the Host VI alright; but when I read data from the FGV in the RT VI, I only get default values, as if nothing had ever been written to the shift registers.

Before you suggest it: yes, I have checked the VI properties of my FGV; its execution is set, as it should be, to non-reentrant.

Can Functional Global Variables be used to share data between VIs running on different targets? Or is an FGV's scope limited to the target it runs on?

Unfortunately, I couldn't find any answers to those questions in the LabVIEW online help, or on any LabVIEW discussion board...

هل كانت مفيدة؟

المحلول

Functional Global Variables only work within a single context. Contexts only exist on one target (e.g. My Computer, a Compact RIO, RT device, etc).

FGVs are really just a neat way to create a shared value in a program using a feature of shift registers -- if you don't initialize the shift register on the diagram then it will be initialized with whatever value it hat last. A VI that is running on two targets is not the same VI -- it's two copies of it. So you have two copies of your FGV, which is why the data you want to share isn't being shared.

To communicate between two targets, I suggest you check out shared variables, TCP, or network streams. There are a lot of other options, but those are my favorite and easiest to set up in difference scenarios.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top