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.destinationIndex" Type="Int">0</Property>
<Property Name="Source.itemID" Type="Ref">Name.lvclass</Property>
<Property Name="Source.sourceInclusion" Type="Str">Include</Property>
<Property Name="Source.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?
(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)
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,
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.
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
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.
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!