08-12-2015 08:01 AM
Hi,
I was wondering: Is there a way to programmatically access Single Process Shared Variables using the API similar to Network Shared SV? That would be a very handy feature and this post suggests there is:
https://forums.ni.com/t5/LabVIEW/programmatically-select-global-variable-object/m-p/1855565#M631304
But I couldn't find any example or what to use as "Link to Variable"
Thanks!
Solved! Go to Solution.
08-12-2015 11:59 AM
I'm pretty sure that the Open Variable Connection is designed for Network Shared Variables, not Single Process Variables. The Link to Variable is just the URL to the deployed variable. I created a tiny project with a Boolean Shared Variable called Test -- if I made it a Network Shared Variable and deployed it to my PC, I could access it just fine as the Snippet illustrates. But if I made it a Single Process Variable (and got rid of the Network Shared Variable), I got Error -1950679035 on Open Variable Connection, Unable to located the SV on the Shared Variable Engine (which makes sense, it is not deployed there). Incidentally, when I run this code, Start is False and End is True, as it should be.
Bob Schor
08-12-2015 02:01 PM
@Bob_Schor wrote:
I'm pretty sure that the Open Variable Connection is designed for Network Shared Variables, not Single Process Variables. The Link to Variable is just the URL to the deployed variable. I created a tiny project with a Boolean Shared Variable called Test -- if I made it a Network Shared Variable and deployed it to my PC, I could access it just fine as the Snippet illustrates. But if I made it a Single Process Variable (and got rid of the Network Shared Variable), I got Error -1950679035 on Open Variable Connection, Unable to located the SV on the Shared Variable Engine (which makes sense, it is not deployed there). Incidentally, when I run this code, Start is False and End is True, as it should be.
Bob Schor
I found basically the same thing. What I was not sure of was whether you should be able to read Single-Process Shared Variables.
Looking at our help documentation for the Open Variable Connection, it opens connection to a shared variable. The documentation for the Read Variable function is more specific and says that it reads from a, "network-published shared variable, I/O variable, or I/O variable container" which a SPSV is not.
http://zone.ni.com/reference/en-XX/help/371361L-01/lvcomm/sv_dynamic_open/
http://zone.ni.com/reference/en-XX/help/371361L-01/lvcomm/sv_dynamic_read/
Based on the Read Variable's help documentation I would say that it is probably not possible. The problem I had was what the URL of the variable would be. In the multivariable editor the URL is just ./<Library>/<Variable> and it would not be ni.var.psp or ni.var.io becuase the SPSV do not communicate using PSP and are not IO.
08-13-2015 02:45 AM
Thanks for the tests! It's a pity that this feature only works for network shared variables (which in my case are too slow to be used), would be really useful also for the single-process ones.
08-13-2015 06:35 AM
@ehrlich wrote:
Thanks for the tests! It's a pity that this feature only works for network shared variables (which in my case are too slow to be used), would be really useful also for the single-process ones.
If you are not looking for network published, then you really should take a look at the Current Value Table (CVT). It is a way of defining and excessing variables by name. Developed by NI Systems Engineers and available for FREE on the LabVIEW Tools Network.
08-13-2015 11:56 AM
This looks very intersting. Thank you for the hint!