From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to initialize a shared variable?

I would like to know if there is a way to:

    1. initialize the values of a shared variable, and
    2. back up (automatically) the values of shared variables in case the system restarts

Perhaps there is a way to do this with DSC, but I would like to know if there is a non-DSC approach.

When a VI that uses shared variables starts up, what value does it take?

What would really be convenient are controls/indicators that are automatically written to disk.  Maybe in LV 23...



Thanks,

Jeremy
0 Kudos
Message 1 of 5
(3,772 Views)


@jeremy_levy wrote:
I would like to know if there is a way to:

    1. initialize the values of a shared variable, and
    2. back up (automatically) the values of shared variables in case the system restarts

Perhaps there is a way to do this with DSC, but I would like to know if there is a non-DSC approach.

When a VI that uses shared variables starts up, what value does it take?

What would really be convenient are controls/indicators that are automatically written to disk.  Maybe in LV 23...



Thanks,

Jeremy



The ability to have a shared variable with an initial value is, indeed, a LabVIEW DSC feature.  If you do not have DSC, the startup value of a variable is undefined and you should get a warning back on the error cluster indicating that the variable has no known value.
 
The last known good value of all your variables should be automatically saved when the system is shutdown.  When you next start, the value should be initialized to this last known good value.  This feature is available w/o LabVIEW DSC.
 
James
Senior Software Engineer
Web Technologies
LabVIEW R&D
0 Kudos
Message 2 of 5
(3,763 Views)
Thanks for the response.  However, I could not replicate your claim, nor could Jeff at NI.  If you could post an example VI showing how it works I would greaetly appreciate it. 

Here is what Jeff wrote:


Jeremy,

I created a LabVIEW 8 project that wrote the number "42" to a shared
      variable on my machine.  The variable was not bound to anything so
      that data was localized to my shared variable engine.  I could read
      that shared variable's data but when I restarted my computer and
      tried to read the variable I got the number 0 (which was the
      indicator's default value).  Furthermore when I open the shared
      variable manager, it says that the variable has "no value" so I think
      it is safe to say that when you shut down your computer (or just the
      shared variable engine for that matter) your data in the variable
      will be lost.

Now if the variable is bound to another variable on a different machine
      then perhaps there would be a different story.  I am at home now so I
      cannot test it at this time.

Regards,

Jeff
.


0 Kudos
Message 3 of 5
(3,757 Views)
Did you shut the machine down gracefully, or was it a hardware reset or power failure or some such?
 
If the machine (and more importantly, our variable engine service) was shut down properly, then the last written value should have been saved and this would be a bug.
 
We will investigate.
James
Senior Software Engineer
Web Technologies
LabVIEW R&D
0 Kudos
Message 4 of 5
(3,735 Views)
I thought I had shut down gracefully.  I just restarted the computer after quitting labview, but maybe there is another way to do it?
0 Kudos
Message 5 of 5
(3,725 Views)