Azzera filtri
Azzera filtri

Why can I not access some COM objects in Matlab that are available from a VB script?

4 visualizzazioni (ultimi 30 giorni)
I have a VB script which sucessfully accesses objects and methods in Vector CANalyzer - the gist of the code is:
Set App = CreateObject("CANalyzer.Application")
App.Open (PathConfig & "Easy.cfg")
Set Logging = App.Configuration.OnlineSetup.LoggingCollection(1)
Set Exporter = Logging.Exporter
With Exporter.Sources
.Clear
.Add (src_file)
End With
Exporter.Load
Exporter.Save True
But when I try the same operation in Matlab, I don't seem to be able to access the 'Exporter' object - I can only get as far as the
'LoggingCollection' object, which I can call methods from.
app = actxserver('CANalyzer.Application');
logging = app.Application.Configuration.OnlineSetup.LoggingCollection;
invoke(logging)
test = Add(logging);
Quit(app);
delete(app);
I've tried following the advice on this thread, trying to access objects and methods even though they're not visible, but this doesn't work either. i.e.
testValue = get(app.Application.Configuration.OnlineSetup.LoggingCollection.Logging, 'FullName');
Returns error: 'No appropriate method, property or field Logging for class Interface.413... etc...
Am I setting up the COM server incorrectly, or is this a peculiarity of the program I'm accessing? Is there any way to solve this problem?
Many thanks,
Tom

Risposta accettata

Tom Hillman
Tom Hillman il 27 Mar 2015
I've managed to sort this out - the problem was that the LoggingCollection object technically was a group of objects, even though there was only one of them. Using an invoke command to return the handle of item 1 in this group seems to work.
The code below uses Canalyzer to convert .asc files to .mat files...
% This script allows matlab to control the conversion of Canalyzer .asc files to matlab .mat files
%Opens COM server - best to already have Canalyzer running with the correct configuration open
app = actxserver('CANalyzer.Application');
Get handle of logging collection object
logging = app.Application.Configuration.OnlineSetup.LoggingCollection;
% Select first logging block
export1 = invoke(logging, 'Item', 1);
% clear sources and write new source
invoke(export1.exporter.sources, 'Clear');
invoke(export1.exporter.sources, 'Add', 'C:\test.ASC');
% clear destinations and write new destination
invoke(export1.exporter.destinations, 'Clear');
invoke(export1.exporter.destinations, 'Add', 'C:\test.mat');
invoke(export1.exporter,'Load')
invoke(export1.exporter,'Save','True')

Più risposte (0)

Categorie

Scopri di più su Use COM Objects in MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by