[英]How can I read data from COM object (an activex server) in MATLAB?
I am trying to connect a simulator to the MATLAB. 我正在尝试将模拟器连接到MATLAB。 The simulator program exposes a COM object interface.
模拟器程序公开一个COM对象接口。
I have connected to the COM object by the following command and can perform most of it methods: 我已经通过以下命令连接到COM对象,并且可以执行大多数方法:
h=actxserver(ProgID)
But some of its methods need passing of a Variant*
type as output. 但是其某些方法需要传递
Variant*
类型作为输出。
Here is the signature of one of the methods indicated by "invoke" method: 这是“调用”方法指示的方法之一的签名:
ReadOutputImage=Variant(Pointer) ReadOutputImage(handle, int32, int32, `ImageDataTypeConstants, Variant(Pointer))`
I have called this method with several syntax's, but none of them work: 我用几种语法调用了此方法,但是它们都不起作用:
a=uint8([0]) %means unsigned integer array with 1 member
h.ReadOutputImage(0,1,2,a) % 0 ,1 ,2 are contants pointing to the position, number of elements to read and size of elemnts while 2 shows Byte element (VT_UI2 COM type).
Other syntax's that I have tried and has no result are: using uint16
, uint32
, int8
, int16
, int32
for all of the followings: 我尝试过但没有结果的其他语法是:将
uint16
, uint32
, int8
, int16
, int32
用于以下所有方面:
logical types (like a=[false]),
cell arrays (like a={uint8([0])} )
empty cell array {}
empty array []
empty sring ''
I have used libpointer as well: 我也使用过libpointer:
a=libpointer;
also a=libpointer('uint8Ptr',0)
also a=libpointer('bool',false)
also a=libpointer('bool',[0])
The problem is that I am not sure about the following items: 问题是我不确定以下各项:
To find how the data appears in other clients, I have imported the same dll file into Delphi and the signature of the type library for the above method is like this: 为了找到数据在其他客户端中的显示方式,我将相同的dll文件导入了Delphi,并且上述方法的类型库的签名如下:
procedure ReadOutputImage(StartIndex: Integer; ElementsToRead: Integer;
DataType: ImageDataTypeConstants; var pData: OleVariant);
Yes Siemens has provided a guide for this com server (prosim) and based on such documentation I have connected and performed most of its methods. 是的,西门子提供了此com服务器(prosim)的指南,并且基于此类文档,我已连接并执行了大多数方法。 But the methods which read I/o data are not working.
但是读取I / O数据的方法不起作用。 In documentation the method signature is specified as follows: (in VB)
在文档中,方法签名指定如下:(在VB中)
STDMETHOD(CS7Prosim::ReadOutputImage)(long startindex,long elementstoread, imagedatatypeconstants DtaType, VARIANT* pData)
What about your application, was it working? 您的应用程序如何运作? Did it contains variant pointers as the returning argument?
它是否包含变体指针作为返回参数? Did you have simillar methods in that application?
您在该应用程序中是否有类似方法?
Thank you 谢谢
I can help with #2 in your question. 在您的问题中我可以为您提供帮助。 I just worked through this myself.
我只是自己完成此工作。 Basically, any pass by reference to COM object you to access after it is modified, Matlab just spits back as an output.
基本上,在修改COM对象后通过引用访问您要访问的COM对象,Matlab只会将其作为输出返回。
[var1 a]=thisObject.DB.Execute(queryString,a)
See here "The syntax shown here shows a server function being called by the MATLAB client. The function's return value is shown as retval. The function's output arguments (out1, out2, ...)
follow this: 见这里 “这里展示的语法,显示了MATLAB客户端被称为服务器功能的函数的返回值显示为retval的函数的输出参数。
(out1, out2, ...)
遵循此:
[retval out1 out2 ...] = handle.functionname(in1, in2, ...);
MATLAB makes use of the pass by reference capabilities in COM to implement this feature. MATLAB利用COM中的“按引用传递”功能来实现此功能。 Note that pass by reference is a COM feature.
请注意,按引用传递是COM功能。 It is not available in MATLAB at this time."
目前在MATLAB中不可用。”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.