Jump to content

Best way to mimic fixed-size array use in clusters?


Recommended Posts

When using a fixed-size array inside a cluster, I am unable to use the cluster with functions that demand a fixed-size data type.  This even though the cluster is actually a fixed size.

 

 post-38039-0-99059900-1371673456.png

 

The alternative is to add an individual element for each entry in the array, but that quickly gets unwieldy and results in messy, overcomplicated code.

 

post-38039-0-43834600-1371673457.png

 

I've run into this issue several times and haven't found an elegant alternative to manually wiring up every single entry.  Hoping y'all have some good ideas in lieu of NI fixing the issue.

 

Thanks

Link to comment

Hmm, I can't really help with your specific question, but is it possible to break out the fixed size array (unbundle) and just use that with the RT FIFO and update whatever the integer is (channel number?) in the same command (perhaps via control), right before you load the array in?


Alternatively, but slightly messier, you could have FIFOs that dequeue at the same time, one for the array, one for the int.

Link to comment

On thing you can do (although I haven't tested this with RT FIFOs) is create a type definition for the cluster that is the fixed-size array. Then, put that cluster inside the cluster that contains the integer. It is then easy to convert the nested cluster into an array (using cluster to array). Going the other direction is only slightly more complicated. If you know that the array size won't change, you can use array to cluster. Otherwise you can typecast the array to the cluster type definition; this may be less efficient (my understanding is that typecast will always flatten to a string, then unflatten to the new representation, instead of a more direct conversion) but is more flexible.

  • Like 1
Link to comment

I don't think you can do exactly what you want. Easiest way is to probably break out the array data from the cluster and send it down it's own FIFO. Reassemble the cluster on the receiving end from the data received from each FIFO if need be. The RT FIFO create primitive has an input that allows you to specify array size.

Link to comment
On thing you can do (although I haven't tested this with RT FIFOs) is create a type definition for the cluster that is the fixed-size array. Then, put that cluster inside the cluster that contains the integer. It is then easy to convert the nested cluster into an array (using cluster to array). Going the other direction is only slightly more complicated. If you know that the array size won't change, you can use array to cluster. Otherwise you can typecast the array to the cluster type definition; this may be less efficient (my understanding is that typecast will always flatten to a string, then unflatten to the new representation, instead of a more direct conversion) but is more flexible.

 

Cool. That's what I ended up doing.  Submitted a feature request for what I was asking:  http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Implement-full-support-for-fixed-size-arrays-in-Labview/idi-p/2467734

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.