LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree API

When using LabVIEW 2019 or later consider using the native MAP and SET data structures, available in LabVIEW 2019. I recommend using the new TREE MAP functions available HERE.

 

Tree v1.10 by NI
Author: Piotr Kruczkowski
Copyright: Copyright (c) 2017, NI
License: Sample Code License
Compatible LabVIEW Versions: >= 2015.
Compatible OS Versions: ALL.

Description:

This is a tree data structure. Essentially dictionary on steroids. Has a bunch of cool features:

- automatically assigns unique ID to trees,
- can store and retrieve tree attributes,
- is based on variants,
- can work with plugin classes for new data types,

- handles classes namespaces,
- flattens and unflattens to XML,
- visualizes in a LV Tree Control,
- allows for easy interaction with Tree Control,
- is optimized for speed,
- provides a search by path functionality,
- is reference based and can be easily shared between threads,
- is handled through manager to remove race conditions,
- works on RT targets.

If you need a dynamic, hierarchical data storage and retrieval mechanism, check out this package and profit!

 

Decisions behind the design:

Q: Why is the Tree API using a manager and Tree IDs instead of bundle-style, by value construction of Trees or references?

Even though it would be more familiar to users and might sometimes feel more natural, the bundle-style by-value construction would easily introduce problems with copying and updating the values in Trees. These problems could be solved using references like DVRs that would point to Trees, but this instead introduces race condition and dead lock in multithreading issues and limits the possibilities for optimization. The current design minimizes these problems while introducing options for improving performance. Additionally it is designed to play nicely with other Tree like APIs already used in LV i.e. Tree Control or XML Doc Parser API. The only drawback of this approach is treating clusters like special, complex data types, that require different method for conversion to and from Trees than other types.

 

1.10v Release Notes:
Updated small issues. Fixed a minor bug on Tree release. Provided snippets on glyph handling. Removed the reference type def. It was not used. Updated the API. Run all examples as unit tests.

 

1.9.2v Release Notes: 

- COMPILED FOR LV 2015

- Bug Fix: The Get Meta Data method was returning a Name instead of Meta Data.

 

1.9v Release Notes: 

- Removed the Attr tag in XML. Now the name of the attribute is the name of the node created in the flat representation. This makes the XML even cleaner and leaner.
- Slightly changed the way how Tree is flattened to XML to make it more pretty (Pretty Print). Does not impact unflattening.
- Added two new methods to help with conversion of clusters. These are placeholders for now. Will fill them with code soon.

 

1.8.3v Release Notes: 

- Removed the Attr tag in XML. Now the name of the attribute is the name of the node created in the flat representation. This makes the XML even cleaner and leaner.

 

1.8.2v Release Notes: 

- Fixed a bug that would generate an error for 1D and 2D arrays unflattening when the string that was unflattened was just a white space.
- Fixed a bug creating a "" instead of empty value field for empty 1d array of strings.

 

1.8v Release Notes: 

- Included character escaping in the String and Path types.
- Improved formatting of values in XML and TreeControl representation.
- Rewrote the storage mechanism for Attrs to keep their order (not have the order random). This will help make XML and TreeControl visualization always look the same and keep order.

 

1.7.1v Release Notes: 

- Added 2D arrays for all basic types.
- Added MetaData to tree elements.
- Integrated the variant casing into the polymorphic Tree Data casting VIs.
- Rewrote some examples to be more readable.

 

1.6.1v Release Notes:

- Fixed a bug that loaded old DOM library for XML parsing even though it was not used anymore.
- Removed trailing zeros from Flt representation.
- Rewrote the TreeControl visualizing mechanism to keep the XML order of elements and optimize view speed.

1.6v Release Notes:

- Rewrote XML parsing using pure LV to make XML Flatten and Unflatten work on any target
- Added Merge method to the API
- Added Update DD method for Tree Data
- Added Tree API method Update to invoke Tree Data Update method
- Added a Format for Tree Control DD method for Tree Data

- Added 1D Array Tree Data types.
- Added some more options to polymorphic VIs.
- Added Variant to and from converters. Now any custom type can be handled.
- Abbreviated attribute tag name in XML to Attr to remove noise.
- Added Optimize Search method that will speed up all searching in the API.
- Filtering out empty MetaData while flattening to XML, to remove junk from XML.

 

Images below are for example purposes. Newest version might look a little different.
 

Visualizing multiple root elements.Visualizing multiple root elements.

 

Interacting with LV Tree Control.Interacting with LV Tree Control.

 

Working with OO Types, Flattening and Unflattening XML.Working with OO Types, Flattening and Unflattening XML.

 

Shallow and Deep copying.Shallow and Deep copying.

 

Non object oriented custom types support.Non object oriented custom types support.

 

Tree API palette.Tree API palette.

 

Examples palette.Examples palette.

 

Tree Data helpers palette.Tree Data helpers palette.

 

Advanced palette.Advanced palette.

 

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Download All
Message 1 of 40
(19,514 Views)

Please let me know what features you would like to see to make it as useful as possible for you.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
0 Kudos
Message 2 of 40
(19,434 Views)

Where is the source code so contributions can be made?

Cheers,

Matt Pollock
National Instruments
0 Kudos
Message 3 of 40
(19,406 Views)

Source code is on my machine 🙂 I will think about how to share source code and post info about it.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
0 Kudos
Message 4 of 40
(19,390 Views)

Hello,

 

Looks fantastic API that we can use various way. But unfortunatelly, I'm using LabVIEW 2015. Is it possible to release version 2015?

 

Look forward to reply.

 

Best regrads,

Dooyoung

Best Regards,
-----------------------------------------------------------------------------------------------------------


0 Kudos
Message 5 of 40
(19,205 Views)

Hi Piotr,

 

great tool - as always 🙂 Thanks for sharing!

 

We're in the middle of building a configuration tool that should work on Windows and on Linux RT with embedded UI. Your Tree API would be a perfect match for what we have in mind, but as there is no native XML support in LabVIEW Real-Time, we're stuck. 

 

Is this something that you might have an idea how to work around?

 

Thanks in advance,

Joerg




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (The Future of Team-Based LabVIEW Development)


0 Kudos
Message 6 of 40
(19,069 Views)

Yeah, I can do that. The features I'm working on is optimization of search, making XML available on RT i.e. not using .net for XML and providing TO and FROM cluster converters.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Message 7 of 40
(19,058 Views)

Great! Thanks in advance, Piotr!




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (The Future of Team-Based LabVIEW Development)


0 Kudos
Message 8 of 40
(19,052 Views)

Yes, I will save the package here for previous version of LV. It will not be packaged normally though but just a ZIP with the source for LV 2015. Will that help?

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
0 Kudos
Message 9 of 40
(19,052 Views)

Hello,

 

Sure, zip file is of course good to me. 🙂 Thanks in advance!!

Best Regards,
-----------------------------------------------------------------------------------------------------------


0 Kudos
Message 10 of 40
(19,046 Views)