Jump to content

how to shared a FGV between 2 LVprojs ?


Recommended Posts

Hi all,

As mentioned in this thread, since LV 8.2 it is not possible to share a queue between 2 LV instance.

I have to LabVIEW projects (A.lvproj and B.lvproj) running on the same machine and I'de like to make them communicate by "sharing" a FGV.

Basically :

- the shared FGV VI is in project A

- at start, the FGV is set to be accessible using VIserver

- on certain event a value is put into the shared FGV

- project B opens an application reference using IP and port number (the same set by project A)

- project B opens a VI reference on the shared FGV to read a control value

I must be missing the point because it only works if the FGV's front panel is opened... see my code below

post-7452-1212131714.png?width=400

Can anybody help me on this ?

Link to comment

I'm guessing that the front panel needs to be at least loaded for the set control value method to work. You can test this by adding a property node for one of the controls to the code.

The better solution is to use the call by reference node. You're already opening the reference with the VI refnum type, so this should make it much cleaner and easier. A simple modification and testing of this example on two projects seems to work fine when the FP of the FGV is closed.

Link to comment

QUOTE (Yen @ May 30 2008, 11:27 AM)

Hi Yen,

Thanks for the link :).

I implemented the "call by reference" like in the example you pointed, but it just doesn't work and returns no error.. is the there any particular settings to set on the shared FGV to make it work ?

Side remark : When the 2 apps are on the same PC it seems to me more difficult than doing it with between a host PC and a RT target. I say this because I did it 2 years ago quite easily with LV 7.1 and I was expecting it to be straightforward..

Is there a significant change on this between LV 7.1 and LV 8 or is it just that I missed a detail of some kind ?

Link to comment

I made no modifications to the FGV. I just placed the VIs in different projects, enabled the VI server access on the "cFP" project (make sure your firewall allows that traffic and that you use a unique port for that project) and pointed the "PC" VI to that port.

QUOTE (Antoine @ May 30 2008, 01:08 PM)

Side remark : When the 2 apps are on the same PC it seems to me more difficult than doing it with between a host PC and a RT target. I say this because I did it 2 years ago quite easily with LV 7.1 and I was expecting it to be straightforward..

It shouldn't be any more difficult. As mentioned in the other thread, the key is using a unique port number for each application instance. When you work with another target it's simpler, because all instances default to port 3363, so you don't have to change it.

Link to comment

QUOTE (Antoine @ May 30 2008, 06:08 AM)

Hi Yen,

Thanks for the link :) .

I implemented the "call by reference" like in the example you pointed, but it just doesn't work and returns no error.. is the there any particular settings to set on the shared FGV to make it work ?

Side remark : When the 2 apps are on the same PC it seems to me more difficult than doing it with between a host PC and a RT target. I say this because I did it 2 years ago quite easily with LV 7.1 and I was expecting it to be straightforward..

Is there a significant change on this between LV 7.1 and LV 8 or is it just that I missed a detail of some kind ?

I have not done this LV 8.+ but I thought about it when the proj was introduced.

I believe Opening a ref to the proj that has the VI and then find a ref to the FGV running in that proj. Watch for name mangling if in a library.

And yes use call by reference.

Ben

Link to comment

QUOTE (Yen @ May 30 2008, 12:34 PM)

I have.. :o .

Using the the "get ctrl value" method works (*only* if the FGV's front panel is opened) but it make me think that the VIserver settings (port, VI access list, etc.) are correct, so the reference to the FGV is fine.

The "call by ref" method give no error at all, but I think that I am getting a reference to "another instance" of the FGV because if I add a "write" case using the "call by ref" method, project B write to the FGV and reads what it wrote, the same for project A.

How to do to have only one instance of the FGV and each project refering to it?

See attach code

corrections to do before running :

- in B project, in the VI B_reader_loop.vi change the "shared FGV's parent dir path")

- on both project adapt the port number to your setting (mine is 3385)

http://lavag.org/old_files/post-7452-1212145549.zip'>Download File:post-7452-1212145549.zip

EDIT :

Ok Neb,Yen,

I am just seing your posts now, I will try that.

In the end opening a reference to the project (which is a labview "context" if I understand well) sounds the correct way to do. Referring to LabVIEW turns out to open another instance of the pointed VI in the separate LabVIEW "context" that is the second project.

It's cool to learn, thank you guys !

Yen, I set 3385, because my labview 8.5 is set with 3385 ;)

* : I am not sure that "context" is the appropriate technical word for what I mean... I am not a proper software engineer (I use to be thermal engineer ;))

Link to comment

As far as I can tell, the issue here is with the programmatic setting of the VI server properties. It looks like the settings are only applied after the VIs in project A go idle. I'm not sure, but I think this is a bug.

In any case, if you run the VI from project A, stop it and then run it again, the FGV should work in project B. For me it worked earlier because I set the settings manually (by right clicking the My Computer icon).

As a minor point, if a VI is in memory, you can use its name to open a reference to it instead of its path. Makes you less dependent on its exact location.

Link to comment

I believe the terms "context" and "instance" are interchangable in this case. I personally prefer "application instance". An app instance determines all kinds of things.

Here are some examples of things that have to be unique within an instance:

  • Queues, notifiers, etc.
  • VI names (CTLs, standard VIs, global VIs...)

To open a reference to an instance, you use the Open App Ref primitive and give it the machine address and port number. The port number is what determines which application instance you connect to. Another key point is that if you want to connect to another instance in the local machine you HAVE to connect something (e.g. "localhost") to the machine name input, or it will open a reference to the current instance. This is most likely the source of your problem.

Once you have the application reference, you can operate on the VIs within that application (at least the ones you have permission for).

As for using the VI name - as I mentioned, the VI has to be already loaded in the application instance you're using. In this case, because you didn't actually connect to the other instance, you got the 1004 error because the VI was not loaded in your instance.

Link to comment

I still don't know if this is a bug or not (there may be a reason behind the design), but when you enable the TCP connection of the VI server it takes the default values rather than the ones you just set. If you enable the TCP connection first than the code should work fine.

In any case, I reported it to NI.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.