07-28-2010 03:02 PM
Hi All,
I am communicating between a producer/consumer loop using a queue. The queue'd element is a cluster made up of a type-def enum and a variant. Data-type in the variant will depend on the state of the enum.
I would like to use a subVI to convert the variant back to the original data-type. The first option that occurs is a simple subVI with an output for each data-type and wire only the relevent output. The second option that occurs would be a polymorphic VI where the user selects the relevant state.
What I would like to do is wire the inside terminal of my case-structure to my SubVI and have it dynamically change (before run-time) to the appropriate output-type. This would be similar to the existing 'auto' function on polymorphic VIs. Can anyone tell me if this is possible?
Regards and thanks,
Delta
Solved! Go to Solution.
07-28-2010 03:44 PM - edited 07-28-2010 03:45 PM
Yes it's possible with LVOOP, the first thing I thought when looking at one of the first examples of LVOOP was 'Runtime Polymoprhism'.
What you do is create a class 'DataTypes' , with a method 'Read'
Then a class 'DataType1' which inherits from 'DataTypes'.
You create a queue of type 'DataTypes', and you sent in an object of type 'DataType1', in your dequeu system you use the 'DataTypes.Read' method, LabVIEW will select the proper handler of a child class to deal with the data.
There should be an example (can't check right now) that shows that for 'bacteria' testing or something like that.
Ton
07-29-2010 03:32 AM
Hi Ton,
Looks like exactly what I need - many thanks. Its also going to be a good excuse to start working with OOP
If you get a chance could you post a link to the example or maybe a copy of the code.....I've searched but I can't find the bacteria example you mention anywhere.
Thanks,
Delta
07-29-2010 06:34 AM
I can't find it neither, but the LabVIEW examples have 'dynamic dispatch' example that shows the idea.
Ton
07-30-2010 02:58 AM
Thanks Ton - it looks likes something I can definately use!
Regards and thanks,
Delta