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

cancel
Showing results for 
Search instead for 
Did you mean: 

motivation behind variant and error code 91.

Solved!
Go to solution

I have not used a variant before, normally I use a cluster containing a string(with state info) and enum (with states) to pass data between a producer and a consumer.loop. But I fail to understand the use of variant (usually instead of strings) in such cases. Can anyone please explain to me  the motivation behind using variants (specially in a producer consumer design pattern)? I knw that primarily they are used to convert from one data type to another,but how does that help ? can you pass the data using a variant? 

 

I tried to experiment with the variant but to no avail,I keep getting this error "The data type of variant is not compatible with the data type wired to the type input" - 

 

I know these are too many questions, but if anyone have a VI i could use to understand the concept behind variant, it would be great.

 

Thanks

 

variant_problem.JPG

 

 

0 Kudos
Message 1 of 5
(2,884 Views)

We cannot really troubleshoot this from a picture, please attach the actual VI instead.

 

You enqueue a cluster containing an empty variant, but then try to read is as a variant containing I32. Try to convert a I32 numeric value to a variant before enqueueing or simply ignore the variant in the start case.

 

0 Kudos
Message 2 of 5
(2,877 Views)

sorry for that.

 

Yes I can see that, can you please elaborate? 

0 Kudos
Message 3 of 5
(2,874 Views)
Solution
Accepted by topic author nizamani

Here's a quick illustration.

 

You can see that the various commands have different data type (I32, string, boolean, resp.) and the consumer loop handles them accordingly.

 

Whan you convert from variant you need to match the type of the data.

 

(Also note that latch action booleans belong inside their event case, else they don't properly reset.)

Message 4 of 5
(2,856 Views)

Thank you so much. This helped a lot. 

0 Kudos
Message 5 of 5
(2,842 Views)