LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree Map

Highlighted

Author: Piotr Kruczkowski
Copyright: Copyright (c) 2019, National Instruments
License: Sample Code License
Compatible LabVIEW Versions: >= 2019.
Compatible OS Versions: ALL.

Description:
This package is intended to use the inbuilt LV19 Set and Map data types to provide a Tree Map data type. It includes basic functions and helpers to interact with the new Tree Map type.

In computer science, a tree is a widely used abstract data type (ADT)—or data structure implementing this ADT—that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.

https://en.wikipedia.org/wiki/Tree_(data_structure)

 

This package is a little more open, simpler and more native than the previously available Tree API. It should be considered for all new designs.

Please comment for feature requests and bug reports. Collaboration -> https://github.com/Primary-Key/Tree-Map-API

 

PrimaryKey_0-1575481349024.png

 

 

Examples Sub-paletteExamples Sub-palette

 2.png

 

3.png

 

4.png

 

1.png

 

KNOWN ISSUES:

Visualizing Tree Map in Tree Control - The order of elements is defined in alphabetical order, due to the implementation of Sets and Maps in LabVIEW.

The unique ID generation integer appending to have 6 digits of precision filling with zeroes e.g. NodeName_000001 will be the uniquified node name.

This effect will change the order of nodes only with 1M+ nodes with the same name under one parent, something which should almost never happen 🙂

 

Thank you and enjoy,

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Message 1 of 14
(2,932 Views)
Highlighted

There is one limitation I am finding difficult to solve which is the requirement of LV map to have unique node names. This means that if the XML consists of node names which are duplicated under one parent node, this XML will not load correctly.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
0 Kudos
Message 2 of 14
(2,623 Views)
Highlighted

This can be remedied by validating the XML against a schema that defines each node to have a unique name.  The uniqueness can be enforced by the schema.  Then, only use the XML if valid, otherwise error out.

0 Kudos
Message 3 of 14
(2,605 Views)
Highlighted

I am already fixing it another way. I don't want to touch schemas, I am deathly afraid of regular expressions 😄

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
0 Kudos
Message 4 of 14
(2,588 Views)
Highlighted

Hey Piotr, 

 

This looks really interesting. I've been working on something similar here:

https://github.com/tannerblair/advanced-labview-variant-tools

 

It currently does json instead of xml, but I'm interested in comparing notes if you are interested. 

Tanner B.
Systems R&D Engineer - Aerospace, Defense, and Government
National Instruments
0 Kudos
Message 5 of 14
(1,989 Views)
Highlighted

Hi Piotr,

 

Thanks for maintaining the Tree library through LabVIEW 2019! We have upgraded from 2018 recently and I've replaced the old instances with this new API. The changes were easy to make and my code has simplified, not having to have a reference to the tree manager.

 

Will this package be published on a repository for download via VIPM? 

Nathan Murphy
Certified LabVIEW Architect
0 Kudos
Message 6 of 14
(1,960 Views)
Highlighted

Hello Sir, I would love to collaborate. I was already thinking about adding JSON support to my API. Did you have a chance to try it out? Btw. you should use Tree Map or my older Tree API instead of creating a new one 🙂

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
0 Kudos
Message 7 of 14
(1,946 Views)
Highlighted

I am working on publishing it as we speak 🙂

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Message 8 of 14
(1,945 Views)
Highlighted

Glad to hear it, thank you!

Nathan Murphy
Certified LabVIEW Architect
0 Kudos
Message 9 of 14
(1,911 Views)
Highlighted

I'm trying to use the Tree Map in another VI. 

 

I have a Tree of available equipment that a user might use. Previously I manually managed this tree control interactively by adding and organizing equipment. I was trying to use the Tree Map to capture the data of this tree control and print to XML so that it can be managed separate from the VI. I ran into a couple issues using the Tree Map that maybe you have thoughts on how to handle.

 

  1. There's a very nice API for going from a Tree Map to a Tree Control, but not the other way around. I don't do a lot of work with Trees so I may not know the intricacies here, but would it be difficult to have a function that created a new Tree Map from a Tree control?
  2. My Tree Node names contain spaces. When I pretty print these to Pretty XML, the spaces get converted to an underscore, but they don't get converted back to a space when creating a Tree Map from the Pretty XML. Do you have a suggestion on how to handle Tree Roots/Nodes with spaces in their name when you want to persist the Tree contents?
    Tree Map Pretty XML.PNG
Nathan Murphy
Certified LabVIEW Architect
0 Kudos
Message 10 of 14
(1,905 Views)