Page 1 of 1

Error Handling

Posted: 08 Mar 2010, 06:20
by timo.veldt
Another question... :oops:

As said, I'm working on my own application to present stimuli.

I've noticed that when I run the "gUSBampSource.exe" module with my amplifier turned off, the preflight gives me an error about this, resulting in a disabled start button.
However, when looking at the code that is responsible, I cannot find the section that is responsible for this. Since I'm using custom hardware, it would be nice to be able offer the same kind of functionality.

So when an error occurs during preflight, how do I make sure the user cannot start the experiment?

Posted: 08 Mar 2010, 07:41
by mellinger
So when an error occurs during preflight, how do I make sure the user cannot start the experiment?
Just write an error message into the bcierr stream, and flush the stream using an endl manipulator, e.g.

Code: Select all

bcierr << "An error occurred." << std::endl;
O return from Preflight(), the bcierr stream is checked for messages, and the start button is disabled if there are any.

The respective code is located at
http://www.bci2000.org/tracproj/browser ... e.cpp#L434
The operator module does not enable the Start button unless it received "initialized" messages from all modules.

For more information about BCI2000 error handling, see
http://www.bci2000.org/wiki/index.php/P ... r_Handling.

Posted: 08 Mar 2010, 09:04
by timo.veldt
Writing an std::endl character to the buffer does not necessarily flush it, however by calling the following code at the end of the preflight method, you can make sure the buffer gets flushed:

Code: Select all

void Application::Preflight(const SignalProperties& Input, SignalProperties& Output) const{
//Check parameters here

bcierr.flush();
}
So just before the function returns, call the flush method on the bcierr-channel.

Posted: 08 Mar 2010, 12:24
by mellinger
std::endl is not a newline character but a so-called manipulator that inserts a newline operator and then calls flush() on the buffer:
http://www.dinkumware.com/manuals/?manu ... .html#endl

So there is no need to call flush() at the end of Preflight().