LabVIEW Data Tools
290 likes | 524 Vues
LabVIEW Data Tools. As presented by Jean-Pierre Drolet May 6, 2003. What is a variant?. It is a polymorphic type that bundles data value and data type. Coercion. Dynamic building of datatypes. Header with type code. Data name. Subtype(s) if any (with fully qualified type descriptors).
LabVIEW Data Tools
E N D
Presentation Transcript
LabVIEW Data Tools As presented by Jean-Pierre Drolet May 6, 2003
What is a variant? • It is a polymorphic type that bundles data value and data type. Coercion Dynamic building of datatypes
Header with type code Data name Subtype(s) if any (with fully qualified type descriptors) What is a type descriptor? • Exactly what its name says... • Overview of its structure:
LabVIEW Data Tools • Set of tools to manipulate: • Variant data (polymorphism) • Flattened data • Type descriptors
Manipulating Variant • For a close set of datatypes • Trials and errors: no knowledge of low level type/data formats is required
Manipulating Variant • For an open set of datatypes • Analyze the data type
Manipulating Variant • Basic Tool to Analyze types: • Type Descriptor Header Typecast the header into an easily workable structure
Manipulating Variant • Example • Get the size of an array
Clusters as Array of Variants • A Cluster is a list of mixed data • It can be converted to an array of variant elements • elements keep their name • elements can be replaced, added or removed allowing dynamic building of clusters
Clusters as Array of Variants • Cluster to Array of Vdata
Clusters as Array of Variants • Setting Elements by name The name of the data is included in the datatype (wire). It is used to locate the element.
Converting LabVIEW Data • Variant Data contains: • Data name • Data type • Data value • All that is needed to convert LabVIEW data into other formats
Variant Config File • Convert a Variant to an ini line • Name = Value • The data name avoids redundancy
Variant Config File • Convert a simple element Convert to type and write to ini file
Variant Config File • How to convert clusters, or array, or array of clusters, cluster of arrays and so on...? • Convert the variant to an array of variants and use recursion.
Variant Config File • For Clusters Clustername.elementname1 = value1 Clustername.elementname2 = value2
Variant Config File • For Clusters as Section [Clustername] elementname1 = value1 elementname2 = value2
Variant Config File • For Clusters as INI File [TopCluster] elementname1 = value1 elementname2 = value2 [SubCluster1] ... [SubCluster2] ...
Other data Formats • Conversion to other data formats • Variant Config file Vis can be used as templates to quickly design VIs to convert LabVIEW data to/from other formats such as: • Python • XML (Flatten to XML, Unflatten from XML) • SQL command
Format Conversion - Python Data • Python represents ordered sequences (of mixed types) as Lists. • We will represent LabVIEW Clusters and Arrays as Python Lists • We will map other scalar types appropriately
Format Conversion - Python Data • An example – Convert a cluster to Python Data and back again
Format Conversion - Python Data We can convert well formed Python data strings to Python data programmatically
Flatten to XML – pure G version • Why? Error I/O, modifiable (# of float digits), custom schemas
Flatten to XML – pure G version • Most Data Type Are easily handled • Clusters are handled recursively Simple Types:I8..I32, U8..U32, String, Paths Cluster (Arrays of Clusters)
Unflatten XML – pure G version • It’s a lot harder to unflatten XML (or any format). • Is error handling for not well-formed XML strings required? • Why not just use an XML parser?
Recap • Variant offers polymorphic inputs and outputs for generic VIs • Parsing of type descriptors allows to manage any type of data • LabVIEW Data Tools are a complete set of low level VIs to manipulate Type Descriptors and Variant Data • It is possible to recurse into structures • Conversion of LabVIEW data to other formats is made more easy