Azzera filtri
Azzera filtri

What is the right event or or property to poll for ImportFileLog listener?

1 visualizzazione (ultimi 30 giorni)
Hello,
in my matlab app I would like to add a listener that tells me when FileLogImport is done after hitting the import FileLog button.
There are already some listeners in my app e.g.:
listeners = addlistener(tg, 'Connected', @(src,evnt)app.targetConnectedCB(src,evnt));
whereas tg is a slrealtime object.
I was hoping that there was also a kind of event/property to listen to which tells me that the import of the data is finnished.
Unforunately I have no idea how to find out which events are available (like in the example 'Connected').

Risposte (1)

Namnendra
Namnendra il 25 Feb 2024
Hi Brian,
In MATLAB, listeners are typically added to handle events that are triggered by various objects. The events that an object can trigger are defined by the class of that object. To find out which events are available for a given class, you can use the `events` function in MATLAB.
For example, to find out what events are available for the `slrealtime` object `tg`, you can do the following:
eventList = events(tg);
disp(eventList);
This will display a list of all the events that `tg` can trigger.
However, for your specific requirement of detecting when a file log import is done, you would need to know if the function or object that performs the import triggers an event upon completion. If this is a custom import function or a part of a larger framework or application, you would need to check the documentation or the source code to determine if and how it signals completion.
If the file import is done through a custom MATLAB function or a callback, there might not be an event mechanism in place by default. In this case, you would need to implement your own notification mechanism. You could do this by executing a callback function at the end of the import process.
For example, if you have a button callback that initiates the file import, you could do something like this:
function importFileLogButtonPushed(app, event)
% Code to import file log
...
% After import is done, call the completion function
fileLogImportCompleted(app);
end
function fileLogImportCompleted(app)
% Code to handle completion of file log import
...
end
If the file import is a part of a built-in MATLAB function or a third-party toolbox, you would need to refer to the documentation for that function or toolbox to see if there is a way to add a listener for the completion of the import process.
If the import process is asynchronous and provides no built-in event or callback mechanism, you might need to implement a polling mechanism or another form of asynchronous notification to check whether the import has completed. This could involve setting up a timer object that periodically checks the status of the import.
I hope the above steps resolve the issue.
Thank you.
  1 Commento
IronLikeABrian
IronLikeABrian il 26 Feb 2024
Hello Namnendra,
thank you, that 'events' function was exactly what I was looking for. It seems quite obvious, that I'm not to deep into object based programming...
Unfortunately there is no event indicating import status.
The ImportFileLogButton actually is part of the Simulink Real-Time toolbox. Another way to trigger File Log import from the target (Speedgoat) would be slrealtime.FileLogImport. It is getting the logged data from the speedgoat into simulink data inspecotor.
My goal is to do some renaming in the data inspector, but of course this can first be done when the import is finnished.

Accedi per commentare.

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by