LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Type conversion for Invoke Method

I am trying to invoke a simple method that processes and returns data in arrays (C# ArrayList collection to be specific). I am able to successfully set up the Constructor Node and Invoke Method within LabVIEW 7.1 but when I go to wire up data from within LabVIEW to Invoke Method I get all sorts of type clashes. Are the LabVIEW data types available within .Net so that I can just write my code using them? If not, any guidance on the conversion process?

-Matthew
0 Kudos
Message 1 of 6
(2,037 Views)
source (LabVIEW) data is 1-d arrays of int, double and point clusters
0 Kudos
Message 2 of 6
(2,030 Views)
LabVIEW does support automatic conversion of key primative types (such as ints, doubles, strings and arrays of such things). However, an ArrayList actually is not an Array type - it is a Collections type. It just happens to use an array internally for implementation. But it provides features that Arrays do not, such as dynamic resizing.

If the method you are trying to call uses ArrayList objects, then you'll need to create a subVI that converts to and from LV arrays of types into the array list. For example, check out the screen shot attached. Note that the ToObject vi can be found in vi.lib\Platform\dotnet.llb

One thing I just thought of - the constructor for the ArrayList can take an initial size. You can always get the size of the incoming array to initialize the ArrayList to the right size. This will save a lot of internal reallocations in the ArrayList if your LV array is large.
0 Kudos
Message 3 of 6
(2,020 Views)
I am writing the functionality in C# so if Array conversion is supported then I can convert my methods to pass Array and if I need the extended functionality I'll map inside my method. I'll give this approach a try for the 1d array and post my results.

Any guidance on how to get the array of point clusters over? Is it essentially a 2d array?
0 Kudos
Message 4 of 6
(2,011 Views)
Once you move into clusters, the auto conversion breaks down. A 1-d array of clusters might seem like a 2-d array, but it isn't really.

Recommendations depend a lot on how the data flows around. If you need to pass small arrays of clusters around, it is best to do something like I showed earlier where you convert to and from .NET types (or even your own C# structs).

If you are dealing with very large arrays of complex types, then it gets much harder (things like CIN + C++.NET). In general, its best to do as much as you can in LV and then convert complex LV types into simplier LV types before calling .NET. Our conversion routines are optimized in the next release for large arrays of primatives so if you can hit that path you'll get better performance.
0 Kudos
Message 5 of 6
(1,999 Views)
OK, I found the To Object.vi and To Variant.vi for converting between dot net and LV types and I see what you mean with arrays of clusters - the array of ints converts fine but the arrays of point clusters blow up. So, I'll take a cut at the conversions for now.
0 Kudos
Message 6 of 6
(1,978 Views)