Commit 6fd9e6b0 authored by Jussi Lindgren's avatar Jussi Lindgren

Drivers: Added gtec gNautilus driver

Driver contributed by g.tec medical engineering GmbH
parent e2fbd6e5
# ---------------------------------
# Finds GNEEDaccessAPI
# Adds library to target
# Adds include path
# ---------------------------------
#IF(OV_ThirdPartyGMobilab)
# MESSAGE(STATUS " NOTE gtec Mobilab has already been found, cannot have gUSBAmp driver in the same executable")
# MESSAGE(STATUS " [ SKIP ] gUSBampCAPI...")
# RETURN()
#ENDIF(OV_ThirdPartyGMobilab)
IF(WIN32)
FIND_PATH(PATH_GNEEDaccessAPI GDSClientAPI.h PATHS
"C:/Program Files/gtec/gNEEDaccess Client API/C"
"C:/Program Files (x86)/gtec/gNEEDaccess Client API/C"
"C:/Program Files/gtec/gNEEDaccess Client API/C/win32"
"C:/Program Files (x86)/gtec/gNEEDaccess Client API/C/win32"
${OV_CUSTOM_DEPENDENCIES_PATH})
IF(PATH_GNEEDaccessAPI)
MESSAGE(STATUS " Found gNEEDaccessAPI...")
INCLUDE_DIRECTORIES(${PATH_GNEEDaccessAPI})
FIND_PATH(PATH_ClientAPI GDSClientAPI.lib PATHS
"C:/Program Files (x86)/gtec/gNEEDaccess Client API/C/win32"
"C:/Program Files/gtec/gNEEDaccess Client API/C/win32"
)
IF(PATH_ClientAPI)
FIND_LIBRARY(LIB_GDSClientAPI GDSClientAPI PATHS ${PATH_ClientAPI})
MESSAGE(STATUS "${LIB_GDSClientAPI}")
IF(LIB_GDSClientAPI)
MESSAGE(STATUS " [ OK ] lib ${LIB_GDSClientAPI}")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_GDSClientAPI} )
ELSE(LIB_GDSClientAPI)
MESSAGE(STATUS " [FAILED] lib GDSClientAPI")
ENDIF(LIB_GDSClientAPI)
ENDIF(PATH_ClientAPI)
FIND_PATH(PATH_ServerLIB GDSServer.lib PATHS
"C:/Program Files (x86)/gtec/gNEEDaccess Client API/C/win32"
"C:/Program Files/gtec/gNEEDaccess Client API/C/win32"
)
IF(PATH_ServerLIB)
# Find GDSServer lib and dll
FIND_LIBRARY(LIB_GDSServer GDSServer PATHS ${PATH_ServerLIB})
IF(LIB_GDSServer)
MESSAGE(STATUS " [ OK ] lib ${LIB_GDSServer}")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_GDSServer} )
ELSE(LIB_GDSServer)
MESSAGE(STATUS " [FAILED] lib GDSServer")
ENDIF(LIB_GDSServer)
ENDIF(PATH_ServerLIB)
# Copy the DLL file at install
INSTALL(PROGRAMS "${PATH_ClientAPI}/GDSClientAPI.dll" DESTINATION "bin")
INSTALL(PROGRAMS "${PATH_ClientAPI}/gAPI.dll" DESTINATION "bin")
INSTALL(PROGRAMS "${PATH_ClientAPI}/Networking.dll" DESTINATION "bin")
INSTALL(PROGRAMS "${PATH_ServerLIB}/GDSServer.dll" DESTINATION "bin")
ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyGNEEDaccessAPI)
SET(OV_ThirdPartyGNEEDaccess "YES")
ELSE(PATH_GNEEDaccessAPI)
MESSAGE(STATUS " FAILED to find gNEEDaccessAPI (optional)")
ENDIF(PATH_GNEEDaccessAPI)
ENDIF(WIN32)
......@@ -45,6 +45,7 @@ OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/gtec-g
OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/gtec-bcilab")
OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/gtec-gmobilabplus")
OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/gtec-gusbamp")
OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/gtec-gnautilus")
OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/mbt-smarting")
OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/mitsarEEG202A")
OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/openal-mono16bit-audiocapture")
......
......@@ -15,6 +15,7 @@
#include "ovasCDriverGTecGUSBampLegacy.h"
#include "ovasCDriverGTecGUSBampLinux.h"
#include "ovasCDriverGTecGMobiLabPlus.h"
#include "ovasCDrivergNautilusInterface.h"
#include "ovasCDriverFieldtrip.h"
#include "ovasCDriverMBTSmarting.h"
#include "ovasCDriverMitsarEEG202A.h"
......@@ -44,6 +45,9 @@ namespace OpenViBEContributions {
#endif
#if defined TARGET_HAS_ThirdPartyGMobiLabPlusAPI
vDriver->push_back(new OpenViBEAcquisitionServer::CDriverGTecGMobiLabPlus(pAcquisitionServer->getDriverContext()));
#endif
#if defined TARGET_HAS_ThirdPartyGNEEDaccessAPI
vDriver->push_back(new OpenViBEAcquisitionServer::CDrivergNautilusInterface(pAcquisitionServer->getDriverContext()));
#endif
vDriver->push_back(new OpenViBEAcquisitionServer::CDriverFieldtrip(pAcquisitionServer->getDriverContext()));
......
# This script is usually run relative to applications/platform/acquisition-server/
INCLUDE("FindThirdPartyBrainmasterCodeMakerAPI")
INCLUDE("FindThirdPartyEemagineEEGO")
INCLUDE("FindThirdPartyGMobiLabPlusAPI")
INCLUDE("FindThirdPartyGUSBampCAPI")
INCLUDE("../../../contrib/cmake-modules/FindThirdPartyGNEEDaccessAPI.cmake")
INCLUDE("FindThirdPartyMitsar")
This source diff could not be displayed because it is too large. You can view the blob instead.
#include "ovasCConfigurationgNautilusInterface.h"
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBEAcquisitionServer;
using namespace std;
/*_________________________________________________
Insert callback to specific widget here
Example with a button that launch a calibration of the device:
*/
//Callback connected to a dedicated gtk button (button_select_channels_bipolar_car_noise):
static void button_channel_settings_cb(::GtkButton* pButton, void* pUserData)
{
CConfigurationgNautilusInterface* l_pConfig=static_cast<CConfigurationgNautilusInterface*>(pUserData);
l_pConfig->buttonChannelSettingsPressedCB();
}
//Callback actually called:
void CConfigurationgNautilusInterface::buttonChannelSettingsPressedCB(void)
{
// Connect to the hardware, ask for calibration, verify the return code, etc.
GtkWidget *l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderConfigureInterface,"dialog_select_channels_bipolar_car_noise"));
gint l_i32Resp = gtk_dialog_run(GTK_DIALOG(l_pDialog));
gtk_widget_hide(l_pDialog);
}
//Callback connected to a dedicated gtk button (button_select_sensitivity_filters):
static void button_sensitivity_filters_cb(::GtkButton* pButton, void* pUserData)
{
CConfigurationgNautilusInterface* l_pConfig=static_cast<CConfigurationgNautilusInterface*>(pUserData);
l_pConfig->buttonSensitivityFiltersPressedCB();
}
//Callback actually called:
void CConfigurationgNautilusInterface::buttonSensitivityFiltersPressedCB(void)
{
// get bandpass and notch filters for currenty selected sampling rate and set to filter list in corresponding dialog
GtkWidget *l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderConfigureInterface,"dialog_sensitivity_filters"));
gint l_i32Resp = gtk_dialog_run(GTK_DIALOG(l_pDialog));
gtk_widget_hide(l_pDialog);
}
//Callback connected to a dedicated gtk button (button_sensitivity_filters_apply):
static void button_sensitivity_filters_apply_cb(::GtkButton* pButton, void* pUserData)
{
CConfigurationgNautilusInterface* l_pConfig=static_cast<CConfigurationgNautilusInterface*>(pUserData);
l_pConfig->buttonSensitivityFiltersApplyPressedCB();
}
//Callback actually called:
void CConfigurationgNautilusInterface::buttonSensitivityFiltersApplyPressedCB(void)
{
// get handle to sensitivity and filters dialog and close it
GtkWidget *l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderConfigureInterface,"dialog_sensitivity_filters"));
gtk_widget_hide(l_pDialog);
}
//Callback connected to a dedicated gtk button (button_channel_apply):
static void button_channel_settings_apply_cb(::GtkButton* pButton, void* pUserData)
{
CConfigurationgNautilusInterface* l_pConfig=static_cast<CConfigurationgNautilusInterface*>(pUserData);
l_pConfig->buttonChannelSettingsApplyPressedCB();
}
//Callback actually called:
void CConfigurationgNautilusInterface::buttonChannelSettingsApplyPressedCB(void)
{
// get handle to channel settings dialog and close it
GtkWidget *l_pDialog = GTK_WIDGET(gtk_builder_get_object(m_pBuilderConfigureInterface,"dialog_select_channels_bipolar_car_noise"));
gtk_widget_hide(l_pDialog);
// get number of channels selected and set range as number of channels starting at number of channels
unsigned __int16 l_ui16NumberOfChannels = 0;
unsigned __int16 i;
char l_sTemporary[30];
for (i = 0; i < GDS_GNAUTILUS_CHANNELS_MAX; i++)
{
// set electrode names as channel names in channel selection dialog
sprintf_s(&l_sTemporary[0],30,"checkbutton_channel_%d",(i + 1));
GtkButton *l_pCheckButton = GTK_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,l_sTemporary));
if (l_pCheckButton)
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCheckButton)))
l_ui16NumberOfChannels += 1;
}
GtkSpinButton *l_pSpinButton = GTK_SPIN_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,"spinbutton_number_of_channels"));
gtk_spin_button_set_range(l_pSpinButton,l_ui16NumberOfChannels,l_ui16NumberOfChannels);
gtk_spin_button_set_value(l_pSpinButton,l_ui16NumberOfChannels);
}
// catch combobox sampling rate changed signal and call function which handles event
static void sample_rate_changed_cb(::GtkComboBox* pComboBox, void *pUserData)
{
CConfigurationgNautilusInterface* l_pConfig=static_cast<CConfigurationgNautilusInterface*>(pUserData);
l_pConfig->comboboxSampleRateChangedCB();
}
// Callback actually called
void CConfigurationgNautilusInterface::comboboxSampleRateChangedCB()
{
// get hardware filters according to sampling frequency currently selected
OpenViBE::boolean l_bFunctionReturn = getFiltersForNewSamplingRate();
if (!l_bFunctionReturn)
{
// TODO: add error handling
}
}
// catch noise reduction checkbox toggled signal and call function which handles event
static void noise_reduction_changed_cb(::GtkCheckButton* pCheckbutton, void* pUserData)
{
CConfigurationgNautilusInterface* l_pConfig = static_cast<CConfigurationgNautilusInterface*>(pUserData);
l_pConfig->checkbuttonNoiseReductionChangedCB();
}
// Callback actually called
void CConfigurationgNautilusInterface::checkbuttonNoiseReductionChangedCB()
{
// activate/deactivate noise reduction checkboxes in dialog_select_channels_bipolar_car_noise
GtkCheckButton *l_pCheckButtonNoiseReduction = GTK_CHECK_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,"checkbutton_noise_reduction"));
gboolean l_bCheckButtonValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCheckButtonNoiseReduction));
char l_sTemporary[45];
for (unsigned __int16 i = 0; i < GDS_GNAUTILUS_CHANNELS_MAX; i++)
{
sprintf_s(&l_sTemporary[0],45,"checkbutton_noise_channel_%d",(i + 1));
l_pCheckButtonNoiseReduction = GTK_CHECK_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,l_sTemporary));
if (l_pCheckButtonNoiseReduction)
{
gtk_widget_set_sensitive(GTK_WIDGET(l_pCheckButtonNoiseReduction),l_bCheckButtonValue);
}
}
}
// catch car checkbox toggled signal and call function which handles event
static void car_changed_cb(::GtkCheckButton* pCheckbutton, void* pUserData)
{
CConfigurationgNautilusInterface* l_pConfig = static_cast<CConfigurationgNautilusInterface*>(pUserData);
l_pConfig->checkbuttonCARChangedCB();
}
// Callback actually called
void CConfigurationgNautilusInterface::checkbuttonCARChangedCB()
{
// activate/deactivate car checkboxes in dialog_select_channels_bipolar_car_noise
GtkCheckButton *l_pCheckButtonCAR = GTK_CHECK_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,"checkbutton_car"));
gboolean l_bCheckButtonValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_pCheckButtonCAR));
char l_sTemporary[45];
for (unsigned __int16 i = 0; i < GDS_GNAUTILUS_CHANNELS_MAX; i++)
{
sprintf_s(&l_sTemporary[0],45,"checkbutton_car_channel_%d",(i + 1));
l_pCheckButtonCAR = GTK_CHECK_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,l_sTemporary));
if (l_pCheckButtonCAR)
{
gtk_widget_set_sensitive(GTK_WIDGET(l_pCheckButtonCAR),l_bCheckButtonValue);
}
}
}
// get hardware related settings from GDS
OpenViBE::boolean CConfigurationgNautilusInterface::getHardwareSettings(void)
{
GtkTreeIter l_iter;
unsigned __int32 i;
// get network channel and set in dialog and set one as active in dialog
unsigned __int32 l_ui32SupportedNWChannelsCount;
unsigned __int32* l_pSupportedNWChannels;
// get number of supported network channels to allocate memory to hold supported network channels
m_oGdsResult = GDS_GNAUTILUS_GetSupportedNetworkChannels(m_ui64DeviceHandle, m_sDeviceNames, NULL, &l_ui32SupportedNWChannelsCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
return false;
}
l_pSupportedNWChannels = new unsigned __int32[l_ui32SupportedNWChannelsCount];
m_oGdsResult = GDS_GNAUTILUS_GetSupportedNetworkChannels(m_ui64DeviceHandle, m_sDeviceNames, l_pSupportedNWChannels, &l_ui32SupportedNWChannelsCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
return false;
}
// get network channel currently used between base station and headstage
unsigned __int32 l_ui32NetworkChannel;
m_oGdsResult = GDS_GNAUTILUS_GetNetworkChannel(m_ui64DeviceHandle, m_sDeviceNames, &l_ui32NetworkChannel);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
return false;
}
// put network channels to combobox
GtkComboBox *l_pComboBoxNetworkChannel = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilderConfigureInterface, "combobox_network_channel"));
GtkTreeModel *l_pListStoreNetworkChannel = gtk_combo_box_get_model(l_pComboBoxNetworkChannel);
gtk_list_store_clear(GTK_LIST_STORE(l_pListStoreNetworkChannel));
stringstream l_sNetworkChannel;
if (m_vComboBoxNetworkChannels.size() > 0)
m_vComboBoxNetworkChannels.clear();
// fill network channel combobox with available network channels
for (i = 0; i < l_ui32SupportedNWChannelsCount; i++)
{
l_sNetworkChannel << l_pSupportedNWChannels[i];
gtk_list_store_append(GTK_LIST_STORE(l_pListStoreNetworkChannel), &l_iter);
gtk_list_store_set(GTK_LIST_STORE(l_pListStoreNetworkChannel),&l_iter,0,l_sNetworkChannel.str().c_str(),-1);
l_sNetworkChannel.clear();
l_sNetworkChannel.str("");
m_vComboBoxNetworkChannels.push_back(l_pSupportedNWChannels[i]);
}
vector<OpenViBE::uint32>::iterator l_NetworkChannelIterator;
l_NetworkChannelIterator = find(m_vComboBoxNetworkChannels.begin(),m_vComboBoxNetworkChannels.end(),l_ui32NetworkChannel);
__int32 nw_ch_index = distance(m_vComboBoxNetworkChannels.begin(),l_NetworkChannelIterator);
gtk_combo_box_set_active(l_pComboBoxNetworkChannel,nw_ch_index);
delete [] l_pSupportedNWChannels;
// get supported sample rates
unsigned __int32 *l_pSupportedSamplingRates;
unsigned __int32 l_ui32SupportedSamplingRatesCount;
stringstream l_sSupportedSamplingRates;
// get number of supported sample rates
m_oGdsResult = GDS_GNAUTILUS_GetSupportedSamplingRates(m_ui64DeviceHandle, m_sDeviceNames, NULL, &l_ui32SupportedSamplingRatesCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
return false;
}
l_pSupportedSamplingRates = new unsigned __int32[l_ui32SupportedSamplingRatesCount];
// get supported sample rates
m_oGdsResult = GDS_GNAUTILUS_GetSupportedSamplingRates(m_ui64DeviceHandle, m_sDeviceNames, l_pSupportedSamplingRates, &l_ui32SupportedSamplingRatesCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
return false;
}
// set sample rates as content of combo box in corresponding dialog
GtkComboBox *l_pComboBoxSamplingRates = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilderConfigureInterface, "combobox_sampling_frequency"));
GtkTreeModel *l_pListStoreSamplingRates = gtk_combo_box_get_model(l_pComboBoxSamplingRates);
gtk_list_store_clear(GTK_LIST_STORE(l_pListStoreSamplingRates));
for (i = 0; i < l_ui32SupportedSamplingRatesCount; i++)
{
l_sSupportedSamplingRates << l_pSupportedSamplingRates[i];
gtk_list_store_append(GTK_LIST_STORE(l_pListStoreSamplingRates), &l_iter);
gtk_list_store_set(GTK_LIST_STORE(l_pListStoreSamplingRates), &l_iter, 0, l_sSupportedSamplingRates.str().c_str(),-1);
l_sSupportedSamplingRates.clear();
l_sSupportedSamplingRates.str("");
}
gtk_combo_box_set_active(l_pComboBoxSamplingRates,0);
boolean l_bFunctionReturn = getFiltersForNewSamplingRate();
if (!l_bFunctionReturn)
{
return false;
}
// set list of sensitivities according to sensitivities returned by gds function
double *l_pSupportedSensitivities;
unsigned __int32 l_ui32SupportedSensitivitiesCount;
std::stringstream l_sSensitivities;
// get number of sensitivities
m_oGdsResult = GDS_GNAUTILUS_GetSupportedSensitivities(m_ui64DeviceHandle, m_sDeviceNames, NULL, &l_ui32SupportedSensitivitiesCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
// TODO: add error handling
return false;
}
// get sensitivities
l_pSupportedSensitivities = new double[l_ui32SupportedSensitivitiesCount];
m_oGdsResult = GDS_GNAUTILUS_GetSupportedSensitivities(m_ui64DeviceHandle, m_sDeviceNames, l_pSupportedSensitivities, &l_ui32SupportedSensitivitiesCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
// TODO: add error handling
return false;
}
// set items in dialog item combobox_select_sensitivity
GtkComboBox *l_pComboBoxSensitivities = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilderConfigureInterface, "combobox_select_sensitivity"));
GtkTreeModel *l_pListStoreSensitivities = gtk_combo_box_get_model(l_pComboBoxSensitivities);
gtk_list_store_clear(GTK_LIST_STORE(l_pListStoreSensitivities));
for (i = 0; i < l_ui32SupportedSensitivitiesCount; i++)
{
l_sSensitivities << (l_pSupportedSensitivities[i] / 1000);
gtk_list_store_append(GTK_LIST_STORE(l_pListStoreSensitivities), &l_iter);
gtk_list_store_set(GTK_LIST_STORE(l_pListStoreSensitivities), &l_iter, 0, l_sSensitivities.str().c_str(),-1);
m_vComboBoxSensitivityValues.push_back(l_pSupportedSensitivities[i]);
l_sSensitivities.clear();
l_sSensitivities.str("");
}
gtk_combo_box_set_active(l_pComboBoxSensitivities,0);
delete [] l_pSupportedSensitivities;
// set input signals in input sources combobox in main configuration dialog
GDS_GNAUTILUS_INPUT_SIGNAL *l_pSupportedInputSources;
unsigned __int32 l_ui32SupportedInputSourcesCount;
// first get number of supported input sources (call with third parameter set to NULL)
m_oGdsResult = GDS_GNAUTILUS_GetSupportedInputSources(m_ui64DeviceHandle, m_sDeviceNames, NULL, &l_ui32SupportedInputSourcesCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
// TODO: add error handling
return false;
}
// allocate memory to hold input sources
l_pSupportedInputSources = new GDS_GNAUTILUS_INPUT_SIGNAL[l_ui32SupportedInputSourcesCount];
// now get input sources
m_oGdsResult = GDS_GNAUTILUS_GetSupportedInputSources(m_ui64DeviceHandle, m_sDeviceNames, l_pSupportedInputSources, &l_ui32SupportedInputSourcesCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
// TODO: add error handling
return false;
}
// set values to combobox_input_source (there are only three allowed at the moment, see code below)
GtkComboBox *l_pComboBoxInputSources = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilderConfigureInterface, "combobox_input_source"));
GtkTreeModel *l_pListStoreInputSources = gtk_combo_box_get_model(l_pComboBoxInputSources);
gtk_list_store_clear(GTK_LIST_STORE(l_pListStoreInputSources));
stringstream l_sInputSource;
for (i = 0; i < l_ui32SupportedInputSourcesCount; i++)
{
if (l_pSupportedInputSources[i] == 0)
{
// electrode input
m_vComboBoxInputSources.push_back(l_pSupportedInputSources[i]);
l_sInputSource << "Electrode";
gtk_list_store_append(GTK_LIST_STORE(l_pListStoreInputSources), &l_iter);
gtk_list_store_set(GTK_LIST_STORE(l_pListStoreInputSources), &l_iter, 0, l_sInputSource.str().c_str(),-1);
}
else if (l_pSupportedInputSources[i] == 1)
{
// shortcut
m_vComboBoxInputSources.push_back(l_pSupportedInputSources[i]);
l_sInputSource << "Shortcut";
gtk_list_store_append(GTK_LIST_STORE(l_pListStoreInputSources), &l_iter);
gtk_list_store_set(GTK_LIST_STORE(l_pListStoreInputSources), &l_iter, 0, l_sInputSource.str().c_str(),-1);
}
else if (l_pSupportedInputSources[i] == 5)
{
// test signal
m_vComboBoxInputSources.push_back(l_pSupportedInputSources[i]);
l_sInputSource << "Test Signal";
gtk_list_store_append(GTK_LIST_STORE(l_pListStoreInputSources), &l_iter);
gtk_list_store_set(GTK_LIST_STORE(l_pListStoreInputSources), &l_iter, 0, l_sInputSource.str().c_str(),-1);
}
l_sInputSource.clear();
l_sInputSource.str("");
}
gtk_combo_box_set_active(l_pComboBoxInputSources,0);
return true;
}
// get channel names for hardware currently connected (cannot be changed as electrode grid is fixed)
OpenViBE::boolean CConfigurationgNautilusInterface::getChannelNames(void)
{
unsigned __int32 l_ui32MountedModulesCount, l_ui32ElectrodeNamesCount;
char l_sTemporary[30];
stringstream l_sBipolarEntry;
// get number of mounted modules and electrode names currently available
l_ui32MountedModulesCount = 0;
l_ui32ElectrodeNamesCount = 0;
m_oGdsResult = GDS_GNAUTILUS_GetChannelNames(m_ui64DeviceHandle,m_sDeviceNames,&l_ui32MountedModulesCount,NULL,&l_ui32ElectrodeNamesCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
return false;
}
// set array of electrode names according to names currently available
char (*l_pElectrodeNames)[GDS_GNAUTILUS_ELECTRODE_NAME_LENGTH_MAX] = new char[l_ui32ElectrodeNamesCount][GDS_GNAUTILUS_ELECTRODE_NAME_LENGTH_MAX];
// get electrode names
m_oGdsResult = GDS_GNAUTILUS_GetChannelNames(m_ui64DeviceHandle,m_sDeviceNames,&l_ui32MountedModulesCount,l_pElectrodeNames,&l_ui32ElectrodeNamesCount);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
return false;
}
unsigned __int16 i;
GtkComboBox *l_pComboBoxBipolarChannels = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilderConfigureInterface,"combobox_channel_1"));
GtkTreeModel *l_pListStoreBipolarChannels = gtk_combo_box_get_model(l_pComboBoxBipolarChannels);
gtk_list_store_clear(GTK_LIST_STORE(l_pListStoreBipolarChannels));
l_sBipolarEntry << "none";
GtkTreeIter l_iter;
gtk_list_store_append(GTK_LIST_STORE(l_pListStoreBipolarChannels), &l_iter);
gtk_list_store_set(GTK_LIST_STORE(l_pListStoreBipolarChannels), &l_iter, 0, l_sBipolarEntry.str().c_str(),-1);
for (i = 0; i < GDS_GNAUTILUS_CHANNELS_MAX; i++)
{
// set electrode names as channel names in channel selection dialog
sprintf_s(&l_sTemporary[0],30,"checkbutton_channel_%d",(i + 1));
GtkButton *l_pCheckButtonChannel = GTK_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,l_sTemporary));
if ((l_pCheckButtonChannel) && (i < l_ui32ElectrodeNamesCount))
{
gtk_button_set_label(l_pCheckButtonChannel,&l_pElectrodeNames[i][0]);
gtk_list_store_append(GTK_LIST_STORE(l_pListStoreBipolarChannels), &l_iter);
gtk_list_store_set(GTK_LIST_STORE(l_pListStoreBipolarChannels), &l_iter, 0, &l_pElectrodeNames[i][0],-1);
}
else if ((l_pCheckButtonChannel) && (i > l_ui32ElectrodeNamesCount))
{
gtk_widget_set_sensitive(GTK_WIDGET(l_pCheckButtonChannel),false);
}
}
for (i = 0; i < GDS_GNAUTILUS_CHANNELS_MAX; i++)
{
sprintf_s(&l_sTemporary[0],30,"combobox_channel_%d",(i + 1));
l_pComboBoxBipolarChannels = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilderConfigureInterface,l_sTemporary));
if (l_pComboBoxBipolarChannels)
{
gtk_combo_box_set_model(l_pComboBoxBipolarChannels,l_pListStoreBipolarChannels);
gtk_combo_box_set_active(l_pComboBoxBipolarChannels,0);
}
}
// adapt number of recorded channels in main configuration dialog according to number of actual selected channels
GtkSpinButton *l_pSpinButtonNumberOfChannels = GTK_SPIN_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,"spinbutton_number_of_channels"));
gtk_spin_button_set_range(l_pSpinButtonNumberOfChannels,l_ui32ElectrodeNamesCount,l_ui32ElectrodeNamesCount);
gtk_spin_button_set_value(l_pSpinButtonNumberOfChannels,l_ui32ElectrodeNamesCount);
// set electrode names as channel names
m_vChannelName.clear();
for (i = 0; i < l_ui32ElectrodeNamesCount; i++)
{
m_vChannelName[i] = l_pElectrodeNames[i];
}
delete [] l_pElectrodeNames;
return true;
}
// get channels currenly available for g.Nautilus used
OpenViBE::boolean CConfigurationgNautilusInterface::getAvailableChannels(void)
{
char l_sTemporary[30];
// get channels currently available on connected device
BOOL l_bAvailableChannels[GDS_GNAUTILUS_CHANNELS_MAX];
m_oGdsResult = GDS_GNAUTILUS_GetAvailableChannels(m_ui64DeviceHandle,m_sDeviceNames,&l_bAvailableChannels);
if (m_oGdsResult.ErrorCode != GDS_ERROR_SUCCESS)
{
return false;
}
m_vAvailableChannels.resize(GDS_GNAUTILUS_CHANNELS_MAX);
for (unsigned __int16 i = 0; i < GDS_GNAUTILUS_CHANNELS_MAX; i++)
{
sprintf_s(&l_sTemporary[0],30,"checkbutton_channel_%d",(i + 1));
GtkCheckButton *l_pCheckButtonChannel = GTK_CHECK_BUTTON(gtk_builder_get_object(m_pBuilderConfigureInterface,l_sTemporary));
if (l_bAvailableChannels[i] == 1)
{
if (l_pCheckButtonChannel)
{
gtk_widget_set_sensitive(GTK_WIDGET(l_pCheckButtonChannel),true);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pCheckButtonChannel),true);
}
m_vAvailableChannels[i] = true;
}
else
{
if (l_pCheckButtonChannel)
{
gtk_widget_set_sensitive(GTK_WIDGET(l_pCheckButtonChannel),false);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(l_pCheckButtonChannel),false);
}
m_vAvailableChannels[i] = false;
}
}
return true;
}
// if sampling rate changed filters in filter settings dialog have to be updated according to new sampling rate
boolean CConfigurationgNautilusInterface::getFiltersForNewSamplingRate(void)
{
GtkTreeIter l_iter;
unsigned __int32 i;
// get current sample rate
GtkComboBox *l_pComboBoxSamplingRate = GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilderConfigureInterface, "combobox_sampling_frequency"));
co