LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

obtaining an activex COM interface from another COM interface

I have Animatics SmartMotors and am using their SMIEngine.dll, which is a COM dll. I'm having trouble with a particular interface called ISMICMotion. The help information for obtaining an instance of it is as follows:
The client application can obtain an instance of this interface, using the available ISMIComm interface.  The following examples show how to obtain this interface in Visual Basic and Visual C++.  In these examples CommInterface is assumed to be the available ISMIComm interface.


Visual Basic:


Dim CMotionInterface As ISMICMotion


      Set CMotionInterface = CommInterface


Visual C++:


    ISMICMotionPtr    CMotionInterface;


    HRESULT hr=CommInterface.QueryInterface(__uuidof(ISMICMotion),&CMotionInterface);


    if (FAILED(hr))


    {


          AfxMessageBox("The interface \"ISMICMotion\" not found!");


          return;


    }


I can open a reference to the ISMICMotion interface using Automation Open but the operation of the methods from the ISMICMotion interface is dependent on the ISMIComm interface. So opening an independent reference doesn't work and the ISMIComm interface does not have anything like a GetISMICMotion reference method.

Is there any way to achieve in LabVIEW what the above code does?

It seems to me that I should be able to acquire proper dependencies using only the exposed methods. Is it because the makers of the SMIEngine.dll have not followed some COM rules?

thanks for you help,
Louis

0 Kudos
Message 1 of 7
(3,991 Views)
Hi Louis,
From the example code that you provided, I do not see the portion as to how to acquire the ISMIComm interface or if it's accessible.  You would need ISMIComm to access ISMICMotion interface. LabVIEW can only access references and call methods that are exposed. From what I can gather based on the code, you need to get the reference for ISMIComm interface, find the method that gives you a reference to ISMICMotion interface, then get the reference for CommInterface, access QueryInterface method, then pass the reference to ISMICMotion as a parameter to QueryInterface. I cannot tell you how SMIEngine.dll is implimented, and it would be difficult for me to say exactly how the operation is done without familiarity with the implementation of your driver.
Hope this information helps.  Feel free to post here if you need any clarifications.

Yi Yan
Applications Engineer
www.ni.com/support

Message Edited by Yi Y on 06-21-2007 06:02 PM

0 Kudos
Message 2 of 7
(3,967 Views)

Hi Louis,

I just started to work with the Smart Motors and using the dll to drive them.

Did you solve this problem?

If so, please give a hint how you did it

 

regards,

Martin

0 Kudos
Message 3 of 7
(3,770 Views)

Hi MartinE,

Have you been able to find the references that Yi Y talked about?  I agree that this seems to be the key to the problem.  Hopefully Louis or someone else who has done this will chime in and be able to give some insight.

Adam H
National Instruments
Applications Engineer
0 Kudos
Message 4 of 7
(3,735 Views)

Hi Adam H,

 

As far as I found in the documentation there is no reference from the  Com interface to the Motion interface.

I posted this problem also to my distributor of the SmartMotors, he passed the question through to Animatics.

I sent them my test vi to show the problem.

 

regards,

Martin. 

0 Kudos
Message 5 of 7
(3,714 Views)

Hi Adam,

 

The issue I had was with initializing the  ISMICMotion interface which is used for Contouring Mode, also called Coordinated Motion. I've attached a VI with two initialization examples. The first in green is the typical init I use to control motors with individual Motor RefNums. If you are not trying to do Coordinated Motion with the CMotion interface then you would use this init. The second in orange is the init routine I used to start Coordinated Motion. The key there is the Variant to Data VI. I don't remember exactly how it works in this case because it was a while back when I figured this out, but I remember finding relevant information in the Developer Zone on using the Variant to Data VI with Automation or ActiveX.

 

I hope this helps.

 

best regards,

Louis

 

0 Kudos
Message 6 of 7
(3,695 Views)

 Hi Louis,

 

Great that you responded after this time and even better, found a solution for the problem as far as I can see just doing initialization.

I modified your example a little to get it working, but the essential thing was the use of the variant to data vi.

 

many thanks,

 

Martin.

 

0 Kudos
Message 7 of 7
(3,675 Views)