05-13-2009 10:19 AM
hi,
i want to call a Vi from Matlab via ActiveX. i tried to keep it simple at first. The vi has only one numerical controll called "N".
LV = actxserver('Labview.Application','127.0.0.1');
vipath = 'C:\matlabtest.vi';
vi = LV.GetVIReference(vipath);
vi.Call('N',5);
i get the following error message:
No method 'Call' with matching signature found for class...
i can't use vi.Run(1); since the vi should be a subVi of a vi which is under execution when the script should be executed.
Using matlabtest.vi as a stand-alone-vi and utilizing vi.Run works fine...
Does anybody have an idea?
05-15-2009 01:35 PM
Hello hkracke,
please take a look at the following links:
http://forums.ni.com/ni/board/message?board.id=170&message.id=233780&requireLogin=False
http://forums.ni.com/ni/board/message?board.id=170&message.id=244029&requireLogin=False
http://forums.ni.com/ni/board/message?board.id=170&message.id=15913&requireLogin=False
I hope this will help you out.
If not please provide me with the versions of LabVIEW and Matlab. A small snippet of code (VI + .m-file) would be nice too.
With best regards
Ralf N.
Applications Engineering
Germany
05-19-2009 11:42 AM
hi ralfn,
first of all thanks for your reply. however, the links don't help (i already googled the problem and i knew these links...)
the vi i would like to call is a sub-vi of a Running VI. That's why i can't use the vi.run method!
The "call"-method works only with references. but i don't know how to create a reference in matlab...
I'm using Labview 8.2 and Matlab7.4
the .m file is the code above.
the vi has only one Numerical control called 'N'.
05-19-2009 03:22 PM
hkracke,
The first link that Ralf pointed to contained the solution that should work for you. The only difference is that you wouldn't need to invoke the Run method, since you already have a running VI. Something like the following should work:
vipath='C:\myVI.vi';
e=actxserver('LabVIEW.Application')
myvi=invoke(e, 'GetVIReference', vipath);
myvi.SetControlValue('N', 5);
Chris M
05-20-2009 06:46 AM
hi cmal,
myVI.vi should be a sub-Vi of a running vi (let's call it mother.vi).
mother.vi uses myVi.vi from time to time. So when mother.vi is running, myVi.vi is "waiting for execution".
i can set control values just like you pointed out but how can i tell labview to execute myVi.vi?
the running vi is not myVi.vi but mother.vi....
Perhaps i should give an example of such a situation:
it could be a control program which can query data of several instruments. for all these instruments exists a vi which handles the query process of this specific device.
I want to execute a certain vi of one instrument meanwhile the control program is running!
i hope that the problem is now clearly identified
05-21-2009 04:34 PM
hkracke,
You're right. In this case, the subVI ('myVI.vi') is waiting for execution as a subVI of 'mother.vi', so it cannot be called as a top-level VI from an external application. One solution would be to create a third VI, 'external_caller.vi', which would contain 'myVI.vi'. 'external_caller.vi' would be called from the ActiveX client, and it would allow 'myVI.vi' to be called from both 'mother.vi' and 'external_caller.vi'. Let me know if this works for you.
-Chris