From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Project Providers

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an easy way to write composite data structures to ProjectItems?

So, the Provider API is full-featured for writing primitive datatypes to Project Items using methods such as mxLvSetStringProperty.vi and mxLvGetStringProperty.vi, but I'm having a tough time trying to figure out a slick way to persist and read composite data structures (e.g., clusters, arrays, and more specifically arrays of clusters).

I have noticed that Project Providers (both from NI and third parties) who such data structures use a format that looks something like this example from the Application Build Spec:

                                        <Property Name="Source[0].destinationIndex" Type="Int">0</Property>

                                        <Property Name="Source[0].itemID" Type="Ref">Name.lvclass</Property>

                                        <Property Name="Source[0].sourceInclusion" Type="Str">Include</Property>

                                        <Property Name="Source[0].type" Type="Str">Library</Property>

   ....

                                        <Property Name="SourceCount" Type="Int">20</Property>

yet I can't find a good API for generating/reading these composite structures. Does one exist?

Thanks!

(By the way, also played around with VIServer Get/Set Tags for ProjectItem refs, and these methods appear to serialize structures as binary values rather than converting to XML)

0 Kudos
Message 1 of 6
(3,149 Views)

I don't know of a way offhand to read/write clusters with an existing API.  Which providers are you looking at that does this, perhaps I can find the developer who owns them and get some ideas. 

I can think of a few workarounds, but don't know if they'll be as useful.  Of course you could flatten the data to string or binary and store them as that type, but the XML wouldn't be readable in the project file.  Alternately you could probably create a VI that takes a cluster as a variant, and then uses the cluster functions to pick it apart element by element, but you would have to create the VIs to do this manually and it'll probably require some overhead. 

Anyway, I'm glad to dig into it more after the new year if you let me know which providers you saw this behavior in. 

Let me know if I can help and have a great holiday,

David out...

0 Kudos
Message 2 of 6
(3,119 Views)

David_L wrote:

I don't know of a way offhand to read/write clusters with an existing API.... you could probably create a VI that takes a cluster as a variant, and then uses the cluster functions to pick it apart element by element, but you would have to create the VIs to do this manually and it'll probably require some overhead.

Yeah, was just hoping to leverage existing capability.

David_L wrote:

Which providers are you looking at that does this, perhaps I can find the developer who owns them and get some ideas. 

The XML in the original post is from the "Sources" array written to a Build Spec Project Item by App Builder. When examining how that data is written to the project (by deduction using "Browse Relationships >> This VI's SubVIs"), one concludes App Builder is manually decomposing it's particular data structure, then reading/writing components using the primitive datatype accessors. If there's an existing, accessible generic solution, by all means I'd be grateful to hear from the dev! But if it's procedural logic tied to the data structure, this is basically the path I'll be taking in the meantime, and no need to bug the dev.

I have noticed Wireflow writing arrays of clusters to project items -- maybe Jonas will swoop in and save the day with some cool trick 🙂

In the spirit of Christmas, maybe we can add composite datatype accessor support to our Santa Claus list :yes: :thumbup1:

0 Kudos
Message 3 of 6
(3,119 Views)

On a positive note, while attempting to characterize the performance ramifications of decomposing composite data structures into individual ProjectItem Properties, a quick test shows that the ProjectItem SetTag method is capable of writing 100 tags per 20msec -- this is an impressive throughput of ~200usec/tag which is plenty performant for lotsa tags! Kudos to whoever wrote the engine.

0 Kudos
Message 4 of 6
(3,119 Views)

Sorry Jack...

No trick on our part, just brute force.

Make a wish from Santa 😉

/J

0 Kudos
Message 5 of 6
(3,119 Views)

Thanks for weighing in, Jonas. All this information in hand, it's time to move forward in a similar fashion -- just wanted to check if I was totally overlooking some better method!

0 Kudos
Message 6 of 6
(3,119 Views)