LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Single-Process Shared Variable programmatic access

Solved!
Go to solution

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!

0 Kudos
Message 1 of 6
(4,224 Views)

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.

SVE.png

Bob Schor

0 Kudos
Message 2 of 6
(4,184 Views)

@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.

SVE.png

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.

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 6
(4,164 Views)

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.

0 Kudos
Message 4 of 6
(4,128 Views)
Solution
Accepted by topic author ehrlich

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(4,112 Views)

This looks very intersting. Thank you for the hint!

0 Kudos
Message 6 of 6
(4,093 Views)