Hook MATLAB event listeners to TestLab events through Microsoft Automation (COM)

16 views (last 30 days)
Hey all,
I understand that this may be a bit specialised towards TestLab inner workings, but I believe it is worth asking.
I’ve been trying to implement some kind of acquisition with TestLab controlled through MATLAB. I would like to automate the whole process (MATLAB will handle the automated movement of some system components), and I decided to go with Microsoft’s Automation framework.
I’m still at the first steps of the process development, and I’ve been experimenting with some very simple examples. I’ve been trying to hook a MATLAB function to some TestLab DataWatches. Specifically, I’ve tried the “ValueChanged” event of the “Active Section” and "Active Sheet” watches, but apparently, I am doing something wrong and the events are not triggered in MATLAB.
Below is a very simple code snippet I’ve been using.
tl = actxserver("LMSTestLabAutomation.Application"); % Get a TestLab application object
asw = tl.ActiveBook.ActiveSectionWatch; % Get the active section watch -- NOT SURE THIS IS CORRECT, I MAY HAVE TO USE THE FindDataWatch OF THE ActiveBook
asw.registerevent({"ValueChanged", @letmeknow}); % Hook the event handler to call letmeknow(varargin) defined in a different .m file -- as "instructed" by MATLAB's documentation --- This works with Excel!
Unfortunately, the function letmeknow() is never called when I change the active section (I have created some and change through them). To check whether MATLAB “knows about” the changes, I have used
inspect(asw);
which opens a GUI with the properties of the ActiveSectionWatch, and the Data and AsyncData are updated correctly (at the specified update interval - given at the “UpdateFrequency” property value). That means that MATLAB can get notified of the changes happening in TestLab, but obviously, I am doing something wrong.
I assume that I do not register the events correctly in MATLAB. I am somewhat sceptical as to whether I should use the ActiveSectionWatch object or I should acquire a Watch object through the FindDataWatch function of (in this example) ActiveBook. I haven’t tested that because I haven’t managed to open the .tlb file of the documentation to look for the appropriate Port names to pass to the FindDataWatch, due to restrictions in the available software running on the computer with TestLab and the move of data (the .tlb file that is) out of the computer.
I would appreciate your help or any ideas I could test.
Best to all.

Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!