02-25-2010 06:40 PM
Consider some of the following improvements:
1. Terminals outside the case structures allow "inplace-ness" for dataflow from the parent diagram into the SubVI.
2. The Variant array is using a Build Array inside the loop. Typically, try not to do this, since you're making a call to the Memory Manager each time. It's better to preallocate arrays, or in your case, autoindexing the output should be used since the output dimension matches the auto-indexed input dimensions.
3. All of the code in every case was identical except for the polymorphic VI and consequently the datatype of the wire going into the To Variant. I have created a sequence structure around what should become one SubVI. That VI takes "Type" as an argument, and inside that one VI is a single case structure with multiple cases to handle your type conversions. Note that the sequence structure represents a functional block with identical inputs (Type, and data) and outputs (Variant Array). This is good news, meaning you can get rid of the polymorphic VI and replace it with just one VI.
4. Note that on Loops and Structures you can click "Visible Items > Label" to type descriptive comments of what's going on inside.
02-25-2010 11:31 PM
Hi Jack,
A lot of good comments.
2. good catch.
3. The subvi that would get types and handle all the cases is the subvi that I have attached. So after all, I have to make a subvi that has many cases, right?
4. I love the visible label for structure. I forgot about that somehow, thanks for reminding me.
Yik
02-26-2010 01:41 AM
Jack's basically done what i suggested (+1 clever detail in autobuilding the array), he's sending out a Variant from the sub-vi, thus it can be polymorphic and have identical outputs. Since you're building a variant array to allow for a mix of datatypes (as i understand it), it's logical to use variant as output from the sub-vi. 🙂
/Y
02-26-2010 08:01 AM
Yamaeda wrote:"thus it can be polymorphic"
The SubVI doesn't need to be polymorphic, but it will have several cases, yes, because this is one of the caveats of having several datatypes. If you upload an image and the code of a couple of those subVI's, we may even be able to get rid of the cases.
My biggest curiosity is the purpose of this VI altogether. It starts off with an encoded array of data, and you end up with an encoded array of data. I wonder if this whole operation could be simplified, looking at the processes that use this VI?