LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding DVRs

Solved!
Go to solution

The key thing seems to be in the name NEW DATA VALUE REFERENCE.

 

I have thought of wires as variables before, because it's sometimes a useful way of explaining things to folks coming from another language.

I've heard it declared that variables are not wires but it didn't matter before.

But here's a case where it does matter.

 

NEW:  you're creating something that did not exist before.

REFERENCE:  it's not a thing, but a reference ('pointer', sort of) to a thing.

DATA VALUE:  The thing is a VALUE.  It is NOT a control (I knew that), it is NOT a wire, or even the contents of that wire. It is a DATA VALUE.  It has a DATA TYPE and it has a DATA VALUE. Period.

Wires come and go - the data flows down them, and off the ends and gets deallocated. 

But this is a separate chunk of memory, which you allocate and initialize at CREATE DVR time, and it stays allocated forever (well, until LV decides your program is over, anyway).

Once created from a wire, the DVR has no association with that wire.  The wire can change as it will, and the DVR refers to the old value.  If I change via the DVR, the wire does not notice.

If I were to CREATE DVR in a loop, then every iteration allocates a new chunk of memory.

 

That means that if I want to share an instance of a class, I have to create a DVR and then use NOTHING BUT the DVR.

 

I have to use the in-place elements to dereference it, call the method, and re-reference it.

Yuck.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 31 of 32
(959 Views)

@CoastalMaineBird wrote:

 

If I were to CREATE DVR in a loop, then every iteration allocates a new chunk of memory. 


Apparently you can only do that 2^20 times.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 32 of 32
(949 Views)