LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview ActiveX automation:I need to call to an activeX with array ref as argument?

Hi,
I'm trying to call a method from an ActiveX-Controll (COM-Automation) which returns the result ("Data" a DBL-Array) in a reference to an array.
This reference is (in VB) included in as the last argument of the call. The Visula Basic example in the Manual reads like:

...
Dim Data() as Double ; The reference for the return
...
DeviceApp.GetData Channel, StartTime, EndTime, Data
...

As far as I understand VB, this means I need to initialize the return-value "Data" of this method for it in order to work properly.
However the invoke node in Labview only supplies a return value with no option to deliver an pre-initialized reference/pointer to the method ???
The result is a c
omplete crash of Labview (V.7).
Calling other methods of the same object which don't handle arrays works just fine.
Can anyone help me to translate the VB-Call to Labview???

TIA. Thomas
0 Kudos
Message 1 of 7
(3,160 Views)
would you mind to post an image of that code section?

Joe
0 Kudos
Message 2 of 7
(3,160 Views)
The VB-Code is like the following (I cut out all trivila declarations and error checks).
The Method in Question ist
ChGrp.GetScaledMuxData ChInfo, HNrm.Index, 1, HNrm.Length, 1, Data
in the 4th line from the end:
-------- VB-Code -------
Dim MyOdyssey As RecorderApplication
Dim MyRec As Recording
Dim ChGrp As ChannelGroup
Dim HNrm As HNorm
Dim ChInfo() As ChannelInfo

Dim Data() As Double
Set MyOdyssey = New RecorderApplication
MyOdyssey.OpenRecording MyOdyssey.Recordings.Item(RecordingNum), MyRec

For Each ChGrp In MyRec.ChannelGroups

For Each HNrm In ChGrp.HNorms
ReDim ChInfo(1 To ChGrp.ChannelInfos.Count)
ChGrp.GetScaledMuxData ChInfo, HNrm.
Index, 1, HNrm.Length, 1, Data

Next HNrm 'Die verschiedenen Abschnitte auf der Zeitachse
Next ChGrp

-------- /VB-Code -----

I also attach a jpeg of the block diagram of my VI, the crucial/lethal invoke-node is encircled. The method is slightly different, but the whole group of methods which is supposed to fetch data is crashing no matter which I use:
.GetMuxData
.GetScaledMuxData
.GetResampledMuxData
.GetDisplayData
I think the reason is somehow connected to the fact, that the ActixeX Object is the one allocating the memory for the data.
0 Kudos
Message 3 of 7
(3,160 Views)
My first guess would be the result is a 2D-array and not a 1D-Array. I made the expirience using wrong datatypes with ActiveX crashes LV sometimes.
Connecting the Error in and out of your "Variant to Data" VI and Probing it, might give you some further clues to what is wrong.
0 Kudos
Message 4 of 7
(3,160 Views)
The LV-Errorhandling is unfortunately of no use since LV is no longer present in memory when the function/method returns.
LV crashes as soon as one of the "Get...Data" methods is called.
0 Kudos
Message 5 of 7
(3,160 Views)
My guess is the dynamic re-sized ChInfo array. where is it in the G code? It also seems like you are one more loop in the G code than the VB:
For each chgrp
for each chinfo
for each HNrm
...
This makes me think the ChInfo goes into the method might be invalid.

Joe
0 Kudos
Message 6 of 7
(3,160 Views)
Sorry, maybe my explanation was not precise. The VB Code is not the exakt counter part to the Block-diagramm (G-Code?).
Anyway, the ChInfo() array in VB is not really neccessary, the point is to check wether the actual Channel is an ".EventChannel" or not, because Eventchannels are treated differently.
In VB this is sorted out first and only "not Eventchannels" are treated afterwards. In G every channel is checked and (possibly) treated in one loop.

On the other hand I checked the IChannelInfo in G by calling one of it's method and it worked as expected. Also, I called an other method of IChannelGroup (".GetBestReductionFactor") this has a simple integer as return value and it also worked.
So to me everything seems valid ??
May
be it's best to write a wrapper DLL IN VB for this function. Then the LV-VBA-interface is in my hands!

Thomas
0 Kudos
Message 7 of 7
(3,160 Views)