LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flattening to string in class appends class name?

Hi!

I am trying to send cluster of different size integers over TCP, using flatten to string function. (LabView version 14)

tc1.PNG

 

It works just fine in regular VI.

 

Then I move my code to a class, by creating a dynamic dispatch method and run it. There is appended class name in front of data.

tc2.PNG

 

Is there a bug or am I misusing functionality of LabView?

 

Should I create accessor for all private data and flatten it outside the class?

 

Thanks!

 

 

 

0 Kudos
Message 1 of 2
(1,718 Views)

@peterklepec wrote:

 

Is there a bug


No. When you flatten an object the class name is part of the data.

 


@peterklepec wrote:

 

or am I misusing functionality of LabView?


Probably. Whether you are passing a cluster or an object, if you know what the data type is on the other side, you just need to feed the flattened string and the data type into the unflatten primitive and you will get back your original data. You don't need to create a separate accessor, and you don't even need a method in the class. You can just flatten the object directly.

 

There's also no point in having the size as part of the cluster, as that doesn't really seem to make sense. You don't need it as part of the cluster and you certainly don't need it to unflatten. If you want to know how many bytes to read on the other side, you can either prepend the size separately (using concat) and read the first four bytes on the other side (the shipping TCP examples should show this) or look at the size of the cluster on the other side (although that's less robust, because it won't work if your data can have variable size). There is also the prepend size input on the primitive, but that isn't relevant for a cluster.


___________________
Try to take over the world!
0 Kudos
Message 2 of 2
(1,708 Views)