Check if the programm is running already

23 visualizzazioni (ultimi 30 giorni)
Vitali Walter
Vitali Walter il 8 Ott 2017
Risposto: Manish Annappa il 11 Ott 2017
Hello.
I wrote a programm for the app designer which is running after pressing the start button. The program starts a session with the aquisition toolbox.The problem is, when I press the button afterwards again it gives me back an arror because of the session that has already started before. So I need a peace of code, wich will check if the session is already running.
Unfortanly I have no clu how I can do it. I was thinking abaout if-else: If true, dont start again, else run the program. Could anyone give me some hints how to do it?
Thx

Risposte (1)

Manish Annappa
Manish Annappa il 11 Ott 2017
There is a property called 'IsRunning' on the session object that can be used to check if the current session is active.
Note: However, this will work only if you are not clearing the work space or deleting the previous session object before 'Start' button click.
Here are a couple of other ways to achieve it.
1) Have a Stop button that will call a callback function which releases the current session by calling 'release' on the session object. Refer to the below link for more information on the 'release' function.
So, everytime click the 'Start' button after clicking 'Stop' button.
2) Calling 'daqreset' before creating the session in 'Start' button handler will make sure that all the current sessions are released.

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by