05-21-2024 02:07 PM
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.
05-21-2024 02:19 PM
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.
05-21-2024 02:32 PM
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)
05-21-2024 02:45 PM - edited 05-21-2024 02:51 PM
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")?
05-21-2024 02:48 PM
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.
05-21-2024 03:00 PM - edited 05-21-2024 03:02 PM
Probably all you really need:
(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!)
05-21-2024 04:07 PM
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.
05-21-2024 06:11 PM - edited 05-21-2024 06:14 PM
@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.
Can you give more detail on what you are trying to do? Sometimes there are better ways to improve performance by orders of magnitude.
05-21-2024 07:19 PM
@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.