LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OPC UA toolkit user event datatype is variant of variant

In case anyone has strange issues with data coming out of the NI OPC UA toolkit user event subscriptions, the datatype is variant<variant<T>>, not variant<T>.

 

This seems to unpack the inner variant so it is variant<T>:

avogadro5_0-1727987337775.png

This isn't a question as much as a PSA to save future Googlers potentially several days of debugging.

 

Message 1 of 2
(257 Views)

If the structure of the variant data is not too complicated, you can see it at a glance by looking at the variant control (provided that "Show Data" option is checked). Example for a Variant containing a Variant<Variant<I32>>:

 

raphschru_2-1727993455750.png

 

 

As for the "Variant to Data" function, it unwraps as many levels of variant as needed to find underlying data with a compatible type.

You can make fun experiments like this:

raphschru_0-1727992712704.png

 

 

The solution you found uses the same logic: it goes down in the variant until it finds... another variant, which is exactly one level lower:

 

raphschru_0-1727995001302.png

 

 

Regards,

Raphaël.

Message 2 of 2
(230 Views)