LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write classes with connectivity toolkit

Messing around with the connectivity toolkit.  Is there a way of writing a class object to a database?

0 Kudos
Message 1 of 5
(2,662 Views)

Hi reformedView,

 

Please have a look at this Database Connectivity Toolkit manual: http://www.ni.com/pdf/manuals/371525a.pdf. In chapter 4, it goes over data types. It looks like there isn't anything specfic to a class object, but you might be able to try and save it as binary. However, this could cause errors when decoding the objects on the other end, especially if the object contains any variably-sized data, e.g. dynamic arrays.

 

Another approach you could take is to have a DB table for each object, and then just save the object's parameters into their own table fields.

Andrew T.
"His job is to shed light, and not to master" - Robert Hunter
0 Kudos
Message 2 of 5
(2,619 Views)

Help me.  OO noob. What does "saving a class object" mean?  If it's saving the cluster, could you flatten to XML and save that as text?

0 Kudos
Message 3 of 5
(2,606 Views)

The cluster is private data. You can iterate through it and save the elements individually by casting it to a variant and then runnning it through "Get Variant Data" with Type set to an array of variants.  However, I am interested in what you would do if, say, one of the elements was itself a LabVIEW class.  I think I am going to do something as was suggested above, store the internal class in its own table and provide the owning class a reference to it -- its table and id, perhaps.  This seems to conform more to standard DB "foreign key" practice anyway.

0 Kudos
Message 4 of 5
(2,603 Views)

I would use the "Flatten to String" and "Unflatten from string" from the Numeric->Data Manipulation palette, if you don't need any program other than LabVIEW to ever read it.  With LabVIEW classes it's smart enough to not write any non-default values, and it's version controlled so even if you update your class to add or remove an element in the private cluster it will still load it OK.  

"Flatten to XML" and "Unflatten from XML" in the File I/O->XML->LabVIEW Schema palette work also, but the cost of the overhead from XML makes the data 3 to 100 times bigger in my experience, depending on how many default values you use.  You could also read those from other non-LV programs with some fairly standard parsing...

0 Kudos
Message 5 of 5
(2,587 Views)