LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX Server Object. Automation Open.

Hello,
In our team we have developed an ActiveX server Object. This COM Object was developed with MS Visual C++. With LabVIEW, I like to share variant data (for example:1D Float Array values as variant). With Matlab and MS Excel, it´s no problem to use the functions of the COM Object and to share data with it.  With LabVIEW there are some problems.
Here is a short description of what I have done:
1.) Copy the COM object to windows\system32 directory
2.) Registration of theCOM Object (regsvr32.exe comobject.dll)
3.) Start LabVIEW
4.) Create New VI and place ActiveX refnum control on the frontpanel.
5.) Choose ActiveX class (rightclick on the ActiveX refnum control, and choose the new registrated comobject.dll)
6.) On the diagram, I connect the ActiveX server object with the "automation open" vi.
7.) Connect the ActiveX refnum of the automation open.vi with an invoke node.
8.) Choose a method of the ActiveX Object. LabIEW now shows automatically all input and  output functions of the choosed method.
To share strings with the COM objects is easy, but with variant data  we have some problems. Sometimes the Windows system crashes.
 
Did anybody has experiences with developed MS COMobjects (developed with MS Visual C++) and LabVIEW?
After we had developed the ActiveX server object, we used all methods and functions with Matlab and with MS-Excel without a problem. To use the same methods with LabVIEW causes a lot of problems. Why? In all three cases we used always variant data types. Are the variant data types different between Excel, Matlab and LabVIEW?
Any help?
0 Kudos
Message 1 of 9
(3,879 Views)

There shouldn't be anything too wierd about using variants with COM objects. The ADO functionality in Windows uses them all over the place and I've never had a problem. It sounds like perhaps something isn't quite right in the COM object your company created. Is there a particular reason that you are using variants?

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 9
(3,864 Views)

Hi Mike,

thank you for your reply.

The reason for using variants is, that we like to use the COM Object as an universal object, which is able to share data (vectors, enum, ...) with LabVIEW, Matlab and Excel.

My collegue, who has developed the COM object, told me that the COM object could not handle 2D arrays.

Did any guidelines exists? Guidelines for developing COM Objects which can be used with LabVIEW? What kind of datatypes can be shared with the COMobject and so forth ...?

Best regards

Peter

0 Kudos
Message 3 of 9
(3,861 Views)

I am not aware of any guidelines as I have never been involved in developing a COM object--just using them. Most variants that I recall interacting with right off hand are scalar values--though there is one place where I pass an ADO method a 1D array of variants. Which might be solution for you, have the input be an array of variants.

The place I would start is on MS's website, therir documentation of these sorts of things can be very complete. For example, the ADO documentation is excellent.

I also seem to remember reading somewhere that MS was going to be phasing-out variants in the future. Sorry, but I don't remember the details, or where I read it.

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 9
(3,847 Views)
You are correct that COM doesn't have a standard for a 2-d array. This is because C++ and VB don't agree on the memory layout for 2-D arrays. COM does have the SafeArray type, which can live in a variant, but that is about it. You can always create a COM class that provides a wrapper around your own 2-D array, although I recognize that this is a bit heavy.
0 Kudos
Message 5 of 9
(3,841 Views)

Hi Mike,

I want to share a 1 D DBL  Array  (instead of a variant) with a COM Object. But it don´t work. LabVIEW don´t understand that the COM objects uses 1D Array. MS Excel is able to share 1D Arrays with the COMobject, but LabVIEW not. Have you any idea, how to share 1D Arrays between a COM and LabVIEW?

Best regards

Peter

0 Kudos
Message 6 of 9
(3,831 Views)

Hi Mike,

I want to share a 1 D DBL  Array  (instead of a variant) with a COM Object. But it don´t work. LabVIEW don´t understand that the COM objects uses 1D Array. MS Excel is able to share 1D Arrays with the COMobject, but LabVIEW not. Have you any idea, how to share 1D Arrays between a COM and LabVIEW?

Best regards

Peter

0 Kudos
Message 7 of 9
(3,831 Views)

Hello Brian,

You know that COM suppoerts 1-d-arrays. Can i share 1d-arrays between COM and Labview, or must i use variants?

If yes, has NI any example C++  code available? There is an ActiveX Example in the LabView download area, but this example uses also only variants.

Thanks for your help

0 Kudos
Message 8 of 9
(3,830 Views)
Remember - Variants are just generic data holders - you still need to have a defined datatype internally. In this case (1-d arrays), the variant compatible datatype is the SafeArray. This is the default array type generated by VB and must be created via the COM APIs in C++, although I believe that ATL has template wrappers for it...don't remember the class. A SafeArray is one that knows the size of the array itself, unlike C++ arrays where the coder must keep track of that.
 
So, if you use SafeArrays instead of C++ arrays, you can easily put them into and take them out of Variants, and LV can automatically handle them and convert to and from LV arrays. Note - your COM API doesn't need to define the parameter as a Variant - you can define it as a SafeArray and it will work just fine.
 
I'm afraid I don't have any examples of this - I'd just search MSDN for SafeArray.
0 Kudos
Message 9 of 9
(3,823 Views)