Showing results for 
Search instead for 
Did you mean: 

Updating a cluster with IPE (In Place Element)

Go to solution

I want to update just one element of a cluster to the value of an indicator that is changed elsewhere in the VI in an event structure. The cluster is the type of the single-process shared variable "MotorTimes" (two floats and a string).


The first picture shows what I though should work: create DVR, and use an IPE structure to update that element. However it looks like the "Write DVR" terminal is not updating the cluster. I have to explicitly write to the single-process shared variable for it to update. That seems to defy the purpose of the IPE structure.


I have the feeling I'm missing something obvious, but can't figure out what. Thanks a lot for any suggestions.

Download All
0 Kudos
Message 1 of 6
Accepted by topic author gmand

The DVR doesn't do what you think it does. It creates a new variable that you can use of the type you specify. The reference coming out of the Create DVR *is* the DVR. It doesn't create a reference to the data space you wire in, it creates a new data object of the *type* you wire in.


I don't see a reason for you to use a DVR in this instance. You could use an IPE on the cluster directly, but a Bundle node will work just fine. What are you trying to do exactly?


I suppose you could make the shared variable a DVR reference, which you could edit across your program, but I don't know what that would accomplish. Your shared variable is a shared reference anyway which can be updated anywhere in your program.

0 Kudos
Message 2 of 6

Thank you, yes, it seemed to me that the IPE will replace the cluster element in place, without creating an additional copy. I have access to the cluster only through the shared variable (in this case it's needed because there are several separate VIs that use that cluster). So I chose IPE because I didn't want to risk concurrent access to the shared variable (even though it is only accessed in various event structures, no parallel loops, etc.).


I did try "Bundle by name", but it didn't work as expected -- if I try to update 1 element, it zeroes out everything else in the cluster, which seemed strange but I had my mind set on IPE so didn't pursue this further.

0 Kudos
Message 3 of 6

O-oh, thank you BertMcMahan! I just realized what you wanted to tell me -- instead of using DVR, I can use unbundle/bundle IPE -- it's simpler and works just as well.

0 Kudos
Message 4 of 6

You can still use Bundle By Name- you just have to wire in the old cluster to the top of the Bundle By Name node first. Bundle By Name replaces only what you specify to replace. IPE is more of a memory management technique than a tool to prevent concurrent access. It won't hurt to do it like you're doing it now, it just won't change performance much (if at all; the compiler will automatically do things in-place if possible, and IIRC the "read-bundle-write" operation is auto detected by the compiler to operate in place. Don't quote me on that, though.)


So, for example, you should wire "Old Cluster" into Bundle By Name, then select the element you want to swap, then wire the output of Bundle By Name into your Shared Variable node.


Glad you got it working.

0 Kudos
Message 5 of 6

Yes, that works too, thanks!

0 Kudos
Message 6 of 6