LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Variable - Run Node first?

Hello,
 
Two Shared Variable Questions:
 
First-
 
I'm trying to get a better understanding of what is meant by the following note from NI documents regarding Shared Variables:
 
"If you are using a network-published Shared Variable node that is configured to read data, you must run each Shared Variable node before the node subscribes and starts receiving buffered values. If a buffer for a network-published shared variable overflows, the data is lost, and LabVIEW does not return an error."

What is meant by "run each Shared Variable"?

 
Second-
 
Anyone know of a way to "clear out or empty" old, buffered values stores in a Shared Variable?
 

Thank you in advance.

- Con

 
Message 1 of 16
(5,576 Views)
*cues sound of crickets chirping*
Message 2 of 16
(5,546 Views)

I guess there are a few of ways to look at this...

1) The answer to my questions are so obvious to others that they must think I am trying to be funny just to ask? (I am sincere)

2) No one else knows?

3) No one else cares?

0 Kudos
Message 3 of 16
(5,516 Views)
My interpretation on "you need to run each variable node" is to deploy the library that contained the variables before running the VI.

I do not know how to reset the buffer, but i am curious on why you want to reset the buffer ? I think if you undeploy the variable that would  clear out the buffer




0 Kudos
Message 4 of 16
(5,513 Views)

@otoro wrote:
My interpretation on "you need to run each variable node" is to deploy the library that contained the variables before running the VI.

I do not know how to reset the buffer, but i am curious on why you want to reset the buffer ? I think if you undeploy the variable that would  clear out the buffer






Thank you for your post. 

As far as needing to deploy the variable to wherever is hosting the variable, I understand that.  However, it seems as if they (NI) could have easily used those words rather than saying "run each variable node".  So I am just looking for clarification from them.

Here's a reason for wanting to clear out that buffer:  I have a RT application ("RT-app") that populates a Buffered Shared Variable hosted on some other computer.  I have a second application ("2nd-app") that reads that Buffered Shared Variable while running.  When I run "2nd-app" the first data read it gets is the last value still in the Buffered Shared Variable (which is actually data from a previous RT-app run).  So I want to be able to clear out the Shared Variable at start up to get rid of any previous data still in it.

Any ideas?

As far as deploying/undeploying shared variables: Is this to be done only during development or can one deploy/undeploy shared variables programmatically during code execution?

Thanks again!


0 Kudos
Message 5 of 16
(5,512 Views)
I can only think of a workaround to check the timestamp of the data you read. On the variable node, you can right click on it and have the timestamp terminal added. Maybe you can compare the timestamp with the timestamp when your client application run the first time and discard the value if it is old.

To programmatically deploy/undeploy variables you need the DSC module. However I do not know if you can deploy/undeploy on remote RT targets. Maybe someone in DSC forum might know the answer.




0 Kudos
Message 6 of 16
(5,503 Views)

I just found some info on deploying/undeploying libraries:

Application Control | Library.Deploy Library Method

Shared Variables and Stand-Alone Applications or Shared Libraries

If you plan to distribute a stand-alone application that uses shared variables, do not include the .lvlib file in an LLB or in the executable. Use the Source Files Setting page of the Application Properties dialog box to change the Destination of the .lvlib file to a destination outside the executable or LLB. You can deploy the shared variables in two ways:

  • Write the application so that it programmatically deploys shared variables at start time. Call the Deploy Library Method in the top-level VI of the application. In the Library Path input of the method, use the relative path to the .lvlib file that contains the shared variable.
  • Manually deploy the shared variables to the computer or target Shared Variable Engine before running the built application.

If you plan to distribute a shared library (DLL) that uses shared variables, do not include the .lvlib file in the DLL. Use the Source Files Setting page of the Shared Library Properties dialog box to change the Destination of the .lvlib file to a destination outside the DLL.

Here's a link where the above was copied from:

http://zone.ni.com/reference/en-XX/help/371361A-01/lvconcepts/project_variables/

I'm still wondering if deploying/undeplying the library is the best way to go. Or is

On a side note: I'm still debating whether or not to use datasocket with a "psp://..." URL to publish and subscribe to the variables.  When I use the Shared Variables my applications seem to "get choppy" when the application first starts running.

 

0 Kudos
Message 7 of 16
(5,499 Views)
To answer your first question, "you need to run each variable node" means that for each variable node on your block diagrams that you want to receive buffered data through, you need to let that node execute at least once before it will start receiving that buffered data.  For instance, if you are reading buffered values in a while loop, you must let the while loop execute at least one iteration before values will start being buffered.  Does that make sense?

This process is completely separate from deploying variables.  If you try accessing a variable that hasn't been deployed yet, nothing will work and you'll get an error out of the shared variable nodes trying to access the variable.

greg
0 Kudos
Message 8 of 16
(5,479 Views)

Hi There,

You can programmatically deploy shared variables without the DSC module. This can be done by utilizing the Deploy Library method of the Invoke Node. To find the Deploy Library method:

  1. On the block diagram, right click to bring up the programming palette and go to Programming » Application Control and place the Invoke Node on the block diagram
  2. Using the hand tool, click on Method and select Library » Deploy Library
  3. Use the Path input to the Deploy Library invoke node to point to the library(s) containing your shared variables

You can also programmatically deploy shared variables on the shared variable engine on a RT target, but you would have to deploy it from the host vi running on a windows machine. To accomplish this all you have to do is give the IP address of the RT controller where you want to deploy it to in the Invoke Node. Hope this helps!

Regards,
Prashanth V
Applications Engineer
National Instruments

0 Kudos
Message 9 of 16
(5,477 Views)

Thanks everyone for your assistance and information.

- Con

0 Kudos
Message 10 of 16
(5,455 Views)