LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

programatically databind shared variables

Hello there,

I using Shared Variables to retrieve data from a PC on my network.

the problem is that I would like to let the user choose where to databind the control simply by inputing the IP address of the remote PC and the program would do the rest.

I tried using the Data Binding:Bind To Network Path method (to set the address)  but I kept getting this error:

LabVIEW:  This property is writable only when the VI is in edit mode, or this method is available only when the VI is in edit mode.
Method Name: Data Binding:Bind To Network Path

In the current situation the user has to Right Click>>Properties>>Data Binding>>browse>> select the variable from the network. I feel that for some users it won´t be too straighforward.

Is there a way to programatically set the path simply by inputing the IP address??

Thanks,

Adam
0 Kudos
Message 1 of 6
(3,723 Views)
Hi,
 
I ended up using the Datasocket Open, Read (or Write), and Close commands while using a "psp:\\IPaddress\libraryname\sharedvariablename" as the URL of the DataSocket Open, then fed down to the Read or Write as a reference.  "PSP" = Publish Subscribe Protocol if you wanted to do some more searches in the forums on what that does.  You could open and close the datasocket outside of a while loop, then perform the Read inside the loop at whatever time you want, or just perform the Read on its own if you wanted.
 
You can look in the Example Finder and search for "Shared", then look at the "Shared Variable Client - Server.lvproj" for some ideas.
 
Good luck
0 Kudos
Message 2 of 6
(3,719 Views)
Thanks for the answer,

I tried what you suggested and it worked fine! I'm going to use it.

I'm just wondering if it's possible to do this the "right way", programatically databind the url of the shared to a control?

I leave this question for the NI engineers... ( I think I saw somewhere on the forum that this was a bug).

Thanks,

Adam
0 Kudos
Message 3 of 6
(3,702 Views)

Hi,

Could you give us a small example of code (and project file) reproducing the problem, so that if it's a bug we could escalate the issue to R&D.

Regards,

ClémentG
0 Kudos
Message 4 of 6
(3,658 Views)
Hello there,

I made a simple example. I'm basically trying to read a shared variable by inputting the IP Address of the server PC.

Thanks
0 Kudos
Message 5 of 6
(3,652 Views)

Hi,

Thanks for the  attached example. Sorry but the error message you get is not a bug, when it says that the property can be set only in edit mode, that means that the vi shouldn't be running.

This invoke node can typically be used when you use your vi as an activeX server controlled by another application.

regards,

ClémentG
0 Kudos
Message 6 of 6
(3,634 Views)