Jump to content

Exposing only parts of a cluster


codcoder

Recommended Posts

Hi, 

So I have this situation where I want to flatten a cluster to a byte array for data transfer. But as things are there are empty spaces between some of the parameters, call it reserved according to the format specification the cluster mirrors.

So to make the flatten process as simple as possible I want to be able to traverse the cluster in a loop so the cluster must self-contain all information.

I am currently solving this by including dummy parameters between the real ones to reflect these reserved areas.

But of course, as you all probably agree upon, I do not want to expose the dummy parameters to the user (the vi will be accessed by Teststand btw).

Som my question is: can some controls in a cluster be private somehow? And if not is there any other smart way to solve it? 

My current solution to this is to create a "public cluster" without these dummy controls and move data between. So a secondary question is there any smart way to do that? I want to keep my code as flat as possible so my idea is simply to use bundle/unbundle but create it using vi scripting.

Edited by codcoder
Spelling error
Link to comment

you can use the following

1: Flatten to string will give you a binary representation.  Much more smaller, faster, dare I say accurate where numbers are conserned.   But not human readable, you may have to convert it to base64 if you're doing url encoding etc.

2: flatten to xml.   slower, larger, human readable.  take care that numbers with decimal places

3: Flatten to json.  similar to xml, lesser is size, easier to read for some people

4: do your own, but I'd not recommend it..   

 

Link to comment
14 hours ago, Stagg54 said:

It feels like you are trying to be too clever. Brute force seems like the easier way. Yes it's less elegant. Unless your cluster is enormous, I would probably just brute force it.

So yes I went for "brute force".

But I managed to solve it using VI scripting, i.e. automatically creating undbundle-by-name from the public cluster to bundle-by-name to the private cluster. So even if the creation process is obscure the result is easy to read by someone who knows only little LabVIEW. Which was what I was aiming for.

Link to comment

There is no way to change the scope for elements inside a cluster. You can only hide them on the front panel.

Your solution to unbundle the private cluster and bundle the public cluster is the best way to hide internal complexity.

If you just want to omit certain parameters without explicitly unbundling/bundling, you could also serialize to and from JSON. Of course, this comes at a performance cost.

Note, however, that this only works if the element names are exactly the same.

Here is an example using JSONtext

1624014264_ConvertClustersusingJSONtext.png.e3574a9746ccc6d8d08c9a22750f26bd.png

image.png.6c0046d60943340026cdeea6a5a05730.png

Convert Clusters using JSONtext.vi

Edited by LogMAN
  • Like 1
Link to comment
11 hours ago, codcoder said:

So yes I went for "brute force".

But I managed to solve it using VI scripting, i.e. automatically creating undbundle-by-name from the public cluster to bundle-by-name to the private cluster. So even if the creation process is obscure the result is easy to read by someone who knows only little LabVIEW. Which was what I was aiming for.

Sounds like an OOP solution is what you really want.

Link to comment
17 hours ago, crossrulz said:

Sounds like an OOP solution is what you really want.

Well yes from a data structure point of view it is.

It would make sense to store the private cluster as the private data of the class and use a public cluster as an exposed API. But solving the same issue with a library isn't that different.

It doesn't however solve the issue of connecting the public and private data in some smart way. But @LogMAN provided an interesting solutionf or that! I'll look into it!

Edited by codcoder
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.