06-07-2024 04:00 AM
Is the 'Data Value Reference Read/Write' function limited to 'In place element structures'? Couldn't find it in functions pallet.
06-07-2024 05:30 AM
@Jyo263 wrote:
Is the 'Data Value Reference Read/Write' function limited to 'In place element structures'? Couldn't find it in functions pallet.
Yes.
Those are not functions, they are options to a in place element structure.
The idea is you have to use an IPES to read\write a DRV.
The only other way to write a DVR's data is to create it.
The only other way to read a DVR's data is to destroy it.
06-07-2024 09:04 AM
@Jyo263 wrote:
Is the 'Data Value Reference Read/Write' function limited to 'In place element structures'? Couldn't find it in functions pallet.
This is how DVR working. In general InPlace Element Structure acts as critical section, guaranteed race condition free access when you will modify your variable at different places without data copies. Better to illustrate with following simple code snippet:
Here you will get always "2" as output data value.
Technically under the hood the LabVIEW will call DataValueReferenceLock() function when you enter InPlace Structure, then will call DataValueReferenceUnlock() when you leave, like mutex.
It is quite simple to proof, just put 1000 ms delay inside and check how long execution will take, and you will see that both structures executed sequentially:
But if you don't need to modify underlying data inside, then you can mark InPlace Structures as Allow Parallel Read-Only Access, leave write connector unwired, then the code will be executed fully parallel:
Hope this explanation helps.
06-07-2024 09:28 AM
And with the Allow read only parallel access, it's fairly easy to make a .vim that accepts and DVR and returns it's value...
You can of course make a .vim for the write too.
But when you actually start using these .vims (in combination: read, modify, write) you'll have higher risk on race conditions.
That is the reason the IPES should be used. Without it, the DVR is just another by reference wire, with all the downsides of a reference (that they share with global resources). Mostly: race conditions.