Destructor calls in Preflight

Forum for software developers to discuss BCI2000 software development
Locked
timo.veldt
Posts: 23
Joined: 12 Feb 2010, 04:08

Destructor calls in Preflight

Post by timo.veldt » 11 Mar 2010, 06:08

I'm using a Datatranslation board to control custom hardware. To control the hardware I've written a class that I've tested and it works.

However, when I use this class in my BCI2000 Application, I get one of my own exception thrown at me. The problem is that when I press Set Config, both Preflight and Initialization are called on the application, which causes the initialization of the hardware (once for Preflight, once for initialization), but the hardware only gets closed for the preflight. When pressing the Set Config button again, the hardware is still in use by the last initialization. What is a good place to stop the hardware to prevent an error with re-configuring?

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 11 Mar 2010, 08:22

There is a GenericFilter::Halt() function provided for this purpose. It is called each time prior to the Preflight()-Initialize() sequence.

In your filter's header file, declare

Code: Select all

virtual void Halt();
and close the hardware from the definition of this method.

Also, add a Halt() call to the filter's destructor to make sure the hardware is closed when the filter is destructed.

Locked

Who is online

Users browsing this forum: No registered users and 0 guests