09-20-2024 05:44 AM - edited 09-20-2024 05:45 AM
Why is there no Data Type Map in Shared Variable?
I would love to share a map containing clusters of timestamp and variant.
Solved! Go to Solution.
09-20-2024 06:39 AM - edited 09-20-2024 06:42 AM
The Shared Variable predates LabVIEW Maps by many many years. And NI hasn't made significant updates to the Shared Variable engine in a long time. Besides, it is arguable if such complex data types such as Maps are very useful to transfer like that. The overhead of a Map in terms of memory to be able to reconstruct it exactly on the remote side is also considerable.
Maybe you can put it in a Variant and transfer it as such? It's a guess but may work. On the other hand I'm not exactly sure of the exact underlaying nature of a Map. If it is more analogues to a refnum rather than a value variable (there could be good performance arguments for that) the Variant may not capture the content of the Map but just its reference. And that would mean nothing on the remote side.
09-20-2024 09:06 AM
@Quiztus2 wrote:
Why is there no Data Type Map in Shared Variable?
I would love to share a map containing clusters of timestamp and variant.
Are you talking about a network shared variable or something local? If you don't require the network part, you can contain your map fully into an action engine.
09-20-2024 04:09 PM - edited 09-20-2024 04:09 PM
It's the network case. A map would be great to share variables dynamically. Putting the map into a variant is a interesting idea.
09-22-2024 01:02 PM
I am still trying to wrap my head around the use case here. A typical map is a large data structure and having it in a shared variable would require every operation (lookup, add, delete, etc.) to copy that data structure to the caller and back. This seems like a gigantic overhead!
If you embed the map into an action engine as suggested, the map data stays isolated and only the item is transported. You could even implement it as a simple map server if operations are required across networked devices.
09-22-2024 09:18 PM
Good point with the size. I came to this use case, since the creation of ordinary shared variables during runtime seemed not easy or impossible. I thought a map could have been a workaround for this. But I didn't consider the overhead here. I moved on to DataSocket dstp protocol, which allows creation on runtime.