LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create Data Value Reference for Individual elements and as Array

In my project, need to write and read a huge set of element of same type (ex:DBL). Need a control (read/write) on each element and also as a group(Array). To achive this objective, created a sample VI, where i create a Reference to an individual element and Reference to an Array. Not getting the expected result when changed the data using the Array (Updated Arrray) and read it in Individual element (Array of Reference). My understanding on DVR is minimal. Please let me know what i am doing wrong. Also suggest if there is any other way of achiving it.

 

Refer the attached example.

0 Kudos
Message 1 of 9
(591 Views)

Hi addhts,

 


@ADDHTS wrote:

To achive this objective, created a sample VI, where i create a Reference to an individual element and Reference to an Array.


  • How do you create a DVR reference to an element of an array?
  • Why do you even think using DVRs would be a good idea here?
  • Why don't you use the array as it is and only change one element inside it (maybe using an Inplace structure)?
  • Where's your VI? (When attaching VIs please consider to downconvert for older LabVIEW versions using File->Save for previous. I prefer LV2019.)
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(587 Views)

Need to use DVR,as the element will be accessed in multiple sub VI and different functions for various data manipulation.  Attached the LabVIEW sample code (2019) 

0 Kudos
Message 3 of 9
(576 Views)

Hi addhts,

 


@ADDHTS wrote:

Not getting the expected result when changed the data using the Array (Updated Arrray) and read it in Individual element (Array of Reference). My understanding on DVR is minimal.


Why do you expect to magically change values for your array of DVRs (on scalar elements) when you change the value behind the DVR to the whole array?

 

Whenever you have problems to understand LabVIEW code you should first speak out loud "THINK DATAFLOW!". Seriously!

One consequence of "THINK DATAFLOW" is that each wire branch (like you do when wiring the array constant to the FOR loop and the ObtainDVR node) will/can create a DATA COPY in memory. In the end you create a DVR to ONE COPY of the array data and an array of DVRs to scalar values taken from ANOTHER COPY of the array data…

 

Why don't you use a functional global (aka ActionEngine aka LV2-style global) to hold your array data? This way it's easy to handle one array and access its values in multiple places inside your program!

Or do one more step and start to use OOP with LabVIEW classes. This way it's easy to encapsulate the array data inside an object and use several methods to access/manipulate the object data…

 

Again: why do you think you need to use DVRs (considered your understanding of them is "minimal")?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 9
(562 Views)

Why are you expecting 5, 6, 7, 8?

 

You have two different DVRs and you only update one of those DVRs. Everything you want can be done in-place with a single DVR for your array.

0 Kudos
Message 5 of 9
(558 Views)

Probably all you really need:

 

altenbach_0-1716321575465.png

 

(It is obvious that you don't understand DVRs, so let's not even go there! You are creating five different DVRs and only ever modify one of them!)

 

0 Kudos
Message 6 of 9
(545 Views)

Thanks for the reply. 

As mentioned, this is just sample vi to test the concept. In my real application, the data will be used by multiple threads. Need a way to have reference to individual element to an Array and Reference to same elements of Array. Need a Array Reference for quick copy of data.  Will be handling like 10,000 data in 10 msec in timed loop. Currently, it is getting timed out when i do a FOR loop to copy individual data.

0 Kudos
Message 7 of 9
(533 Views)

@ADDHTS wrote:

As mentioned, this is just sample vi to test the concept. In my real application, the data will be used by multiple threads. Need a way to have reference to individual element to an Array and Reference to same elements of Array. Need a Array Reference for quick copy of data.  Will be handling like 10,000 data in 10 msec in timed loop. Currently, it is getting timed out when i do a FOR loop to copy individual data.


Most of what you say is gibberish to me. Creating 10K DVRs for scalars does not seem reasonable.

 

The DVR IPE frame protects the array from concurrent access (unless you allow parallel read-only access). And whenever The entire array leaves the IPE structure, a copy will be made.

 

Obviously, you are trying to solve a "performance" problem. I have no idea what "handling" and "quick copy" means. I thought the point was to avoid copies of large datasets. Basically, all you need is a single reference to the entire array and then identify the desired element by index.

 

Quick sketch. On the left we replace certain elements. On the right two parallel process access different elements concurrently.

 

altenbach_0-1716332688469.png

 

 

Can you give more detail on what you are trying to do? Sometimes there are better ways to improve performance by orders of magnitude.

0 Kudos
Message 8 of 9
(516 Views)

@ADDHTS wrote:

Thanks for the reply. 

As mentioned, this is just sample vi to test the concept. In my real application, the data will be used by multiple threads. Need a way to have reference to individual element to an Array and Reference to same elements of Array. Need a Array Reference for quick copy of data.  Will be handling like 10,000 data in 10 msec in timed loop. Currently, it is getting timed out when i do a FOR loop to copy individual data.


I can't really tell what you are trying to do, but it sounds like you might be working toward creating a large set of race conditions.

Message 9 of 9
(494 Views)