diff --git a/contrib/plugins/server-drivers/eemagine-eego/src/ovasCDriverEEGO.cpp b/contrib/plugins/server-drivers/eemagine-eego/src/ovasCDriverEEGO.cpp index 6a6e597c87ab3991b8cf22c78e71d83688b84013..15b5176e1936711be10df5a01cf6bf549e9de848 100644 --- a/contrib/plugins/server-drivers/eemagine-eego/src/ovasCDriverEEGO.cpp +++ b/contrib/plugins/server-drivers/eemagine-eego/src/ovasCDriverEEGO.cpp @@ -5,6 +5,7 @@ #include <bitset> #include <exception> #include <memory> +#include <regex> #if defined TARGET_OS_Linux || defined TARGET_OS_MacOS #include <cstddef> @@ -239,6 +240,36 @@ bool CDriverEEGO::start() // Check configuration if (!check_configuration()) { return false; } + m_driverCtx.getLogManager() << Kernel::LogLevel_Info << "CDriverEEGO::start - Check amplifier" << "\n"; + /* + * Check device type and set BIP range accordingly + * This step is necessary for the 511 series amplifiers + */ + try { + // stop old streams, if existing + m_pStream.reset(); + m_pAmplifier->OpenEegStream(m_header.getSamplingFrequency()); + + const std::string amplifierType = m_pAmplifier->getType(); + + std::regex amplifierType511("EE511"); + if (std::regex_search(amplifierType, amplifierType511) && m_iBIPRange != 2.5 * m_iEEGRange) { + m_iBIPRange = 2.5 * m_iEEGRange; + m_driverCtx.getLogManager() << Kernel::LogLevel_Info << "Amplifier type EE-511: BIP Signal Range is constrained to 2.5 times the EEG Signal range. Forcing BIP Signal Range to " << m_iBIPRange << "\n"; + } + + /* + * Needed in order to successfully call OpenEEGStream again. + * Needs to be done in two steps, otherwised the amplifier is not released + */ + m_pAmplifier.reset(); + m_pAmplifier.reset(factory().getAmplifier()); + + } catch(const std::exception& ex) { + m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Did not manage to verify amplifier type: " << ex.what() << "\n"; + return false; + } + // ... // request hardware to start // sending data