Check if the programm is running already

40 views (last 30 days)
Vitali Walter
Vitali Walter on 8 Oct 2017
Answered: Manish Annappa on 11 Oct 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

Answers (1)

Manish Annappa
Manish Annappa on 11 Oct 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.

Categories

Find more on App Building in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!