How can I use an event triggered by a COM object to call a method of one of my classes, without having a callback function in the COM object?
Afficher commentaires plus anciens
I use a com server to connect with a measurement device:
ophirApp = actxserver('OphirLMMeasurement.CoLMMeasurement')
Whenever the device is ready for a readout it triggers the event DataReady:
events(ophirApp)
DataReady = void DataReady(int32 hDevice, int32 channel)
When the event is triggered I would like to have a listener which calls a method of a different object since the ophirApp has not built in callback function: Something like:
el = addlistener(ophirApp,'DataReady',@handleEvent);
where @handleEvent is NOT a method of ophirApp
Is there a way to doe so?
1 commentaire
Yuxiao Zhai
le 15 Mar 2023
Perhaps you could define a new class that has a property to store your phirApp.
The new class also has a method that triggers the DataReady in ophirApp.
You could then create a handle of the method of an instantiation of the new class and pass the handle to addlistener
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Use COM Objects in MATLAB dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!