LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to only read the value from a data value reference

I know I can use the in-place structure to read and write to a data value reference, but what if I only need to read the data. I'm not changing the data and writing it back.

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

0 Kudos
Message 1 of 10
(5,096 Views)

No, you can't just read from a DVR, if just want the data that's in the DVR, then wire the value out of the in-place structure and wire the original value across back to the write.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 10
(5,088 Views)

Hi settlesj,

 

If you want to comunicate a data value through your code, there is several ways

If it's in the same diagram you can use a wires, loacl variables or a references.

If it's beetween different VI you can use global or FGV. (FGV is more efficient)

between two network you can use network variables.

 

the point of using In place stucture is when you whant to "operate" on data  (array, cluster ...) without requiring the LabVIEW  to duplicate data  in memory.

So if you only want to only read the data, i sugest you to choose one of the above options.

 

Best regards.

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 3 of 10
(5,079 Views)

@sabri.jatlaoui wrote:

If it's beetween different VI you can use global or FGV. (FGV is more efficient)


LIES!!!  LIES!!!  A global variable is extremely efficient.  It just does not protect from race conditions.  A simple read/write FGV does not protect from race conditions either, but is A LOT slower than the simple global.  I expect so much more from an NI employee.  Go look at this article: A Look at Race Conditions


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 4 of 10
(5,054 Views)

@settlesj wrote:

I know I can use the in-place structure to read and write to a data value reference, but what if I only need to read the data. I'm not changing the data and writing it back.


I'm curious what you are trying to do with the DVR.  I have rarely found a legitamate use for them.  It sounds like you should probably be using a queue or global variable instead.


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 10
(5,052 Views)

I am experimenting with a class for a device that continuously broadcasts serial packets. In the class I have a method that launches a background task to receive these continuous broadcasts. Because its a background task, I can't just place the data on the class wire as the rest of the test program won't see it. So I needed a reference as part of the class data that I could use to point to the data being received. I am not logging the data and I only really care about the latest value. I suppose I could use a single element queue and only ever preview the queue when I want to get data. I suppose a global would work, but I wasn't sure if you can include a global as part of the class data. A pointer would be great and the data value reference seemed like the next best thing. 

 

Using the data value reference works, but it just seemed silly that I was writing the same data back to the reference when i was reading it. 

 

The same goes for my background task. I dereference the value with the in place structure, but I only wire to the write value.

Write.JPG

Similar structure for the read, just in reverse and I wire the dereferenced value, which is a variant, straight to the write.

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

0 Kudos
Message 6 of 10
(5,040 Views)

Hi Crossrulz, Maybe it's my french! when i wrote efficiency, I was spoking about global code efficiency. FGV  can protect critical sections of code , but they do not inherently eliminate race conditions. By this point , my code is more efficient using it. In fact almost all my code variables are FGV.

 

By the way, I'm not an NI employee :).

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 7 of 10
(5,015 Views)

Yeah I don't think efficient is the right word then.

 


@sabri.jatlaoui wrote:

 

By the way, I'm not an NI employee :).


The thing above your avatar says otherwise.

 

I too find it difficult to have good examples of when to use a DVR.  The only time I feel like I was using it correctly, was in my Circular Buffer code, but even then I wonder if replacing them with some other LabVIEW technology would have any noticable performance difference.  That compiler gets smarter all the time.

0 Kudos
Message 8 of 10
(5,005 Views)

@sabri.jatlaoui wrote:

By the way, I'm not an NI employee :).



How do you get the blue bar next to your name?

0 Kudos
Message 9 of 10
(5,002 Views)

@Hooovahh wrote:

 

...

The thing above your avatar says otherwise.

 

I too find it difficult to have good examples of when to use a DVR.  ...

 

 


DVRs are useful if you do not know at development time, how many protected sections you will need.

Look at DAQmx tasks for example (or if you are old enough the old DAQ tasks).

 

Say I want to write an interface to an FPGA I have coded to do something fancy. I could put all of the functionality in a polymorphic VI that uses wrappers to an AE that interacts with the FPGA.

 

But the next day I find out that I will have three of the FPGA running. I would have clone the polymorphic three times over or use DVR so that I can choose which protected section I want to act on. By passing a DVR ref around, I can use the same sub-VIs to operatate on different FPGAs. Using a DVR will let me use teh reference to POINT at the data instead of what I would alternatively been storing in a SR. 

 

Forgive me if I am singing an old tune.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 10
(4,955 Views)