This commit is contained in:
2021-10-14 13:47:35 +02:00
commit 6625a8dfaa
4026 changed files with 844291 additions and 0 deletions
@@ -0,0 +1,395 @@
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="openvibe-acquisition-server-settings">
<property name="border_width">5</property>
<property name="title" translatable="yes">Device configuration</property>
<property name="window_position">center</property>
<property name="type_hint">dialog</property>
<property name="gravity">center</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox">
<property name="visible">True</property>
<property name="spacing">8</property>
<child>
<object class="GtkLabel" id="label_title">
<property name="visible">True</property>
<property name="label" translatable="yes">Mitsar EEG202</property>
<property name="justify">center</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox">
<property name="visible">True</property>
<property name="border_width">8</property>
<property name="spacing">8</property>
<child>
<object class="GtkHBox" id="hbox">
<property name="visible">True</property>
<property name="spacing">8</property>
<child>
<object class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="n_rows">6</property>
<property name="n_columns">2</property>
<child>
<object class="GtkComboBox" id="combobox_gender">
<property name="visible">True</property>
<property name="model">modelGender</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_age">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment2</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_identifier">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_age">
<property name="visible">True</property>
<property name="label" translatable="yes">Age :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_identifier">
<property name="visible">True</property>
<property name="label" translatable="yes">Identifier :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Gender :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">Reference :</property>
<property name="justify">right</property>
</object>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox_ref">
<property name="visible">True</property>
<property name="model">modelRef</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_number_of_channels">
<property name="visible">True</property>
<property name="label" translatable="yes">Number of channels :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_sampling_frequency">
<property name="visible">True</property>
<property name="label" translatable="yes">Sampling frequency :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_number_of_channels">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">adjustment3</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox_sampling_frequency">
<property name="visible">True</property>
<property name="model">modelSamplingFreq</property>
<property name="button_sensitivity">off</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_change_channel_names">
<property name="label" translatable="yes">Change channel names</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton_EventAndBioChannels">
<property name="label" translatable="yes">Event and Bio channels</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label-info">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;span size="smaller" foreground="#602020"&gt;All channels are acquired
The signal is sampled at 500 Hz&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button_apply">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-10">button_apply</action-widget>
<action-widget response="-6">button_cancel</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="modelGender">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">unspecified</col>
</row>
<row>
<col id="0" translatable="yes">female</col>
</row>
<row>
<col id="0" translatable="yes">male</col>
</row>
<row>
<col id="0" translatable="yes">unknown</col>
</row>
</data>
</object>
<object class="GtkListStore" id="modelChan">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">31 EEG + 1 Event + 1 Bio</col>
</row>
<row>
<col id="0" translatable="yes">31 EEG + 1 Event + 1 Bio + 3 Synchro</col>
</row>
</data>
</object>
<object class="GtkListStore" id="modelRef">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Common (A1 et A2)</col>
</row>
<row>
<col id="0" translatable="yes">Left A1 - Right A2</col>
</row>
</data>
</object>
<object class="GtkAdjustment" id="adjustment1">
<property name="value">1025</property>
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkListStore" id="modelSamplingFreq">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">500</col>
</row>
</data>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="lower">33</property>
<property name="upper">33</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
</interface>
@@ -0,0 +1,50 @@
#if defined(TARGET_HAS_ThirdPartyMitsar)
#if defined TARGET_OS_Windows
#include "ovasCConfigurationMitsarEEG202A.h"
#include <windows.h>
namespace OpenViBE {
namespace AcquisitionServer {
CConfigurationMitsarEEG202A::CConfigurationMitsarEEG202A(const char* gtKbuilderXMLFileName, uint32_t& refIndex, bool& eventAndBioChannelsState)
: CConfigurationBuilder(gtKbuilderXMLFileName), m_rEventAndBioChannelsState(eventAndBioChannelsState), m_rRefIdx(refIndex) {}
bool CConfigurationMitsarEEG202A::preConfigure()
{
if (!CConfigurationBuilder::preConfigure()) { return false; }
GtkComboBox* ref = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox_ref"));
//::GtkComboBox* comboBox_Chan = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox_channels"));
GtkToggleButton* buttonDrift = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton_driftCorrection"));
GtkToggleButton* buttonHardwareTagging = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton_EventAndBioChannels"));
gtk_combo_box_set_active(ref, 0);
//::gtk_combo_box_set_active(comboBox_Chan, 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(buttonHardwareTagging), m_rEventAndBioChannelsState);
return true;
}
bool CConfigurationMitsarEEG202A::postConfigure()
{
GtkComboBox* ref = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox_ref"));
//::GtkComboBox* comboBox_Chan=GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox_channels"));
GtkToggleButton* buttonDrift = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton_driftCorrection"));
GtkToggleButton* buttonHardwareTagging = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton_EventAndBioChannels"));
m_rRefIdx = uint32_t(gtk_combo_box_get_active(ref));
m_rEventAndBioChannelsState = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(buttonHardwareTagging)) > 0);
if (!CConfigurationBuilder::postConfigure()) { return false; }
return true;
}
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif
#endif
@@ -0,0 +1,36 @@
#pragma once
#if defined(TARGET_HAS_ThirdPartyMitsar)
#if defined TARGET_OS_Windows
#include "../ovasCConfigurationBuilder.h"
#include <gtk/gtk.h>
namespace OpenViBE {
namespace AcquisitionServer {
/**
* \class CConfigurationMitsarEEG202A
* \author Gelu Ionescu (GIPSA-lab)
* \date 26 April 2012
* \brief The CConfigurationMitsarEEG202A class handles configuration specific to the Mitsar EEG 202A amplifier.
*
* submitted by Anton Andreev (GIPSA-lab)
*/
class CConfigurationMitsarEEG202A final : public CConfigurationBuilder
{
public:
CConfigurationMitsarEEG202A(const char* gtKbuilderXMLFileName, uint32_t& refIndex, bool& rHardwareTaggingState);
bool preConfigure() override;
bool postConfigure() override;
bool& m_rEventAndBioChannelsState;
protected:
uint32_t& m_rRefIdx;
};
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif
#endif
@@ -0,0 +1,383 @@
#if defined(TARGET_HAS_ThirdPartyMitsar)
#if defined TARGET_OS_Windows
#include "ovasCDriverMitsarEEG202A.h"
#include "ovasCConfigurationMitsarEEG202A.h"
#include <toolkit/ovtk_all.h>
#include <system/ovCTime.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <windows.h>
#define msleep(ms) Sleep(ms) // Sleep windows
namespace OpenViBE {
namespace AcquisitionServer {
//___________________________________________________________________//
// //
CDriverMitsarEEG202A::CDriverMitsarEEG202A(IDriverContext& ctx)
: IDriver(ctx), m_settings("AcquisitionServer_Driver_MitsarEEG202A", m_driverCtx.getConfigurationManager())
{
m_header.setChannelCount(CHANNEL_NB);
m_header.setSamplingFrequency(SAMPLING_RATE);
m_settings.add("Header", &m_header);
m_settings.add("RefIndex", &m_refIdx);
m_settings.add("EventAndBioChannelsState", &m_eventAndBioChannelsState);
m_settings.load();
}
void CDriverMitsarEEG202A::release()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "CDriverMitsarEEG202A::release\n";
delete this;
}
const char* CDriverMitsarEEG202A::getName()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "CDriverMitsarEEG202A::getName\n";
return "Mitsar EEG 202 - A";
}
//___________________________________________________________________//
// //
#define _Mitsar_EEG202A_DLLFileName_ "MitsarDll.dll"
typedef int ( __stdcall *MitsarDLL_initialize)();
typedef int ( __stdcall *MitsarDLL_start)(int refType);
typedef int ( __stdcall *MitsarDLL_stop)();
typedef int ( __stdcall *MitsarDLL_uninitialize)();
typedef int ( __stdcall *MitsarDLL_loop)(float* sample);
static HINSTANCE mitsarDLLInstance = nullptr;
static MitsarDLL_initialize mitsarDLLInitialize = nullptr;
static MitsarDLL_start mitsarDLLStart = nullptr;
static MitsarDLL_stop mitsarDLLStop = nullptr;
static MitsarDLL_uninitialize mitsarDLLUninitialize = nullptr;
static MitsarDLL_loop mitsarDLLLoop = nullptr;
//___________________________________________________________________//
// //
bool CDriverMitsarEEG202A::initialize(const uint32_t nSamplePerSentBlock, IDriverCallback& callback)
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "CDriverMitsarEEG202A::initialize\n";
if (m_driverCtx.isConnected()) { return false; }
mitsarDLLInstance = ::LoadLibrary(_Mitsar_EEG202A_DLLFileName_);
if (!mitsarDLLInstance)
{
std::cout << "INIT ERROR : Load Library" << std::endl;
return false;
}
mitsarDLLInitialize = (MitsarDLL_initialize)GetProcAddress(mitsarDLLInstance, "MITSAR_EEG202_initialize");
mitsarDLLStart = (MitsarDLL_start)GetProcAddress(mitsarDLLInstance, "MITSAR_EEG202_start");
mitsarDLLStop = (MitsarDLL_stop)GetProcAddress(mitsarDLLInstance, "MITSAR_EEG202_stop");
mitsarDLLUninitialize = (MitsarDLL_uninitialize)GetProcAddress(mitsarDLLInstance, "MITSAR_EEG202_uninitialize");
mitsarDLLLoop = (MitsarDLL_loop)GetProcAddress(mitsarDLLInstance, "MITSAR_EEG202_loop");
if (!mitsarDLLInitialize || !mitsarDLLStart || !mitsarDLLStop || !mitsarDLLUninitialize || !mitsarDLLLoop)
{
std::cout << "INIT ERROR : DLL functions list" << std::endl;
std::cout << "mitsarDLLInitialize : " << mitsarDLLInitialize << std::endl;
std::cout << "mitsarDLLStart : " << mitsarDLLStart << std::endl;
std::cout << "mitsarDLLStop : " << mitsarDLLStart << std::endl;
std::cout << "mitsarDLLUninitialize : " << mitsarDLLUninitialize << std::endl;
std::cout << "mitsarDLLLoop : " << mitsarDLLLoop << std::endl;
FreeLibrary(mitsarDLLInstance);
mitsarDLLInstance = nullptr;
mitsarDLLInitialize = nullptr;
mitsarDLLStart = nullptr;
mitsarDLLStop = nullptr;
mitsarDLLUninitialize = nullptr;
mitsarDLLLoop = nullptr;
return false;
}
const int error = mitsarDLLInitialize();
if (error)
{
FreeLibrary(mitsarDLLInstance);
mitsarDLLInstance = nullptr;
mitsarDLLInitialize = nullptr;
mitsarDLLStart = nullptr;
mitsarDLLStop = nullptr;
mitsarDLLUninitialize = nullptr;
mitsarDLLLoop = nullptr;
std::cout << "INIT ERROR : Init DLL function" << std::endl;
return false;
}
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "CDriverMitsarEEG202A::CDriverMitsarEEG202A\n";
if (this->m_eventAndBioChannelsState) m_header.setChannelCount(CHANNEL_NB);
else m_header.setChannelCount(CHANNEL_NB - 2);
m_header.setSamplingFrequency(SAMPLING_RATE);
//uint32_t idx = 0;
m_header.setChannelName(0, "FP1");
m_header.setChannelName(1, "FPz");
m_header.setChannelName(2, "FP2");
m_header.setChannelName(3, "F7");
m_header.setChannelName(4, "F3");
m_header.setChannelName(5, "Fz");
m_header.setChannelName(6, "F4");
m_header.setChannelName(7, "F8");
m_header.setChannelName(8, "FT7");
m_header.setChannelName(9, "FC3");
m_header.setChannelName(10, "FCz");
m_header.setChannelName(11, "FC4");
m_header.setChannelName(12, "FT8");
m_header.setChannelName(13, "T3");
m_header.setChannelName(14, "C3");
m_header.setChannelName(15, "Cz");
m_header.setChannelName(16, "C4");
m_header.setChannelName(17, "T4");
m_header.setChannelName(18, "TP7");
m_header.setChannelName(19, "CP3");
m_header.setChannelName(20, "CPz");
m_header.setChannelName(21, "CP4");
m_header.setChannelName(22, "TP8");
m_header.setChannelName(23, "T5");
m_header.setChannelName(24, "P3");
m_header.setChannelName(25, "Pz");
m_header.setChannelName(26, "P4");
m_header.setChannelName(27, "T6");
m_header.setChannelName(28, "O1");
m_header.setChannelName(29, "Oz");
m_header.setChannelName(30, "O2");
if (this->m_eventAndBioChannelsState)
{
m_header.setChannelName(31, "CH_Event"); // Event signals (0/+3v)
m_header.setChannelName(32, "Bio1"); // Biological signals (ECG, EMG, EOG...)
}
const uint32_t stimulationChannel = 31;
m_iSamples.resize(SAMPLES_NB * CHANNEL_NB);
m_oSamples.resize(SAMPLES_NB * CHANNEL_NB);
m_lastStimulation = STIMULATION_0;
// memorize the stimulation channel position
m_stimulationChannel = &m_oSamples[SAMPLES_NB * stimulationChannel];
m_stimulationIDs.resize(SAMPLES_NB);
m_stimulationDates.resize(SAMPLES_NB);
m_callback = &callback;
return true;
}
bool CDriverMitsarEEG202A::start()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Info << "CDriverMitsarEEG202A::start\n";
if (!m_driverCtx.isConnected())
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "CDriverMitsarEEG202A::start - not connected.\n";
return false;
}
if (m_driverCtx.isStarted())
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "CDriverMitsarEEG202A::start - already started.\n";
return false;
}
//) Check reference type : 1->Ref=A1-Left A2-Righ else Ref=Common(A1&A2)
int Ref_type = 1;
if (m_refIdx == 1)
{
std::cout << "Ref= A1-Left A2-Right\n";
Ref_type = 1;
}
else
{
std::cout << "Ref=Common(A1&A2) \n";
Ref_type = 0;
}
const int error = mitsarDLLStart(Ref_type);
printf("Dll start %s\n", error ? "WRONG" : "OK");
return (error ? false : true);
}
bool CDriverMitsarEEG202A::loop()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "CDriverMitsarEEG202A::loop\n";
if (!m_driverCtx.isConnected()) { return false; }
if (!m_driverCtx.isStarted()) { return true; }
if (mitsarDLLLoop(&m_iSamples[0])) { return false; }
// INPUT s1 c1 c2 c3 ....cN
// s2 c1 c2 c3 ....cN
// s3 c1 c2 c3 ....cN
// sM c1 c2 c3 ....cN
// OUTPUT c1 s1 s2 s3 ....sM
// c2 s1 s2 s3 ....sM
// c3 s1 s2 s3 ....sM
// cN s1 s2 s3 ....sM
// transpose data from sample lines to channel lines
for (uint32_t j = 0; j < CHANNEL_NB; ++j) // channel
{
for (uint32_t i = 0; i < SAMPLES_NB; ++i) // sample
{
m_oSamples[j * SAMPLES_NB + i] = m_iSamples[CHANNEL_NB * i + j];//CHANNEL_NB
}
}
if (m_eventAndBioChannelsState)
{
// look for stimulations
uint32_t nStimulations = 0;
float* stimChannel = m_stimulationChannel;
for (uint32_t iSample = 0; iSample < SAMPLES_NB; iSample++, stimChannel++)
{
uint32_t stim = STIMULATION_0;
//std::cout << *stimChannel << " " << stim << std::endl;
// Stim192 < 0.03 <= Stim128 < 0.1 <= Stim64 < 0.16 <= Stim0
float stimulationF = *stimChannel;
if (stimulationF < 0.03)
{
stim = STIMULATION_192;
*stimChannel = 3.0f;
}
else if (stimulationF < 0.1)
{
stim = STIMULATION_128;
*stimChannel = 2.0f;
}
else if (stimulationF < 0.16)
{
stim = STIMULATION_64;
*stimChannel = 1.0f;
}
else { *stimChannel = 0.0f; }
if ((stim != STIMULATION_0) && (stim != m_lastStimulation))
{
m_stimulationIDs[nStimulations] = stim;
m_stimulationDates[nStimulations] = iSample;
nStimulations++;
}
m_lastStimulation = stim;
//std::cout << *stimChannel << " " << stim << std::endl;
}
// prepare stimulations
CStimulationSet stimSet;
stimSet.setStimulationCount(nStimulations);
for (uint32_t iStimulation = 0; iStimulation < nStimulations; ++iStimulation)
{
uint64_t identifier;
switch (m_stimulationIDs[iStimulation])
{
default:
case STIMULATION_64: identifier = OVTK_StimulationId_Label_01; break;
case STIMULATION_128: identifier = OVTK_StimulationId_Label_02; break;
case STIMULATION_192: identifier = OVTK_StimulationId_Label_03; break;
}
const uint64_t date = CTime(m_header.getSamplingFrequency(), uint64_t(m_stimulationDates[iStimulation])).time();
stimSet.setStimulationIdentifier(iStimulation, identifier);
stimSet.setStimulationDate(iStimulation, date);
stimSet.setStimulationDuration(iStimulation, 1);
//std::cout << "Trigger " << std::hex << m_stimulationIDs[iStimulation] << " ";
}
//m_callback->setStimulationSet(stimSet);
}
// Drift correction from GUI
m_driverCtx.correctDriftSampleCount(m_driverCtx.getSuggestedDriftCorrectionSampleCount());
// SEND SAMPLES & STIMULATIONS
m_callback->setSamples(&m_oSamples[0], uint32_t(SAMPLES_NB));
msleep(1); // free CPU ressources
return true;
}
bool CDriverMitsarEEG202A::stop()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "CDriverMitsarEEG202A::stop\n";
if (!m_driverCtx.isConnected() || !m_driverCtx.isStarted()) { return false; }
return (mitsarDLLStop() ? false : true);
}
bool CDriverMitsarEEG202A::uninitialize()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "CDriverMitsarEEG202A::uninitialize\n";
if (!m_driverCtx.isConnected() || m_driverCtx.isStarted()) { return false; }
FreeLibrary(mitsarDLLInstance);
m_callback = nullptr;
mitsarDLLInstance = nullptr;
mitsarDLLInitialize = nullptr;
mitsarDLLStart = nullptr;
mitsarDLLStop = nullptr;
mitsarDLLUninitialize = nullptr;
mitsarDLLLoop = nullptr;
return true;
}
//___________________________________________________________________//
// //
bool CDriverMitsarEEG202A::isConfigurable()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "CDriverMitsarEEG202A::isConfigurable\n";
return true;
}
bool CDriverMitsarEEG202A::configure()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "CDriverMitsarEEG202A::configure\n";
CConfigurationMitsarEEG202A config(Directories::getDataDir() + "/applications/acquisition-server/interface-Mitsar-EEG202.ui", m_refIdx, m_eventAndBioChannelsState);
if (!config.configure(m_header)) { return false; }
m_settings.save();
return true;
}
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif
#endif
@@ -0,0 +1,76 @@
#pragma once
#if defined(TARGET_HAS_ThirdPartyMitsar)
#if defined TARGET_OS_Windows
#include "ovasIDriver.h"
#include "../ovasCHeader.h"
#include "../ovasCSettingsHelper.h"
#include "../ovasCSettingsHelperOperators.h"
namespace OpenViBE {
namespace AcquisitionServer {
/**
* \class CDriverMitsarEEG202A
* \author Gelu Ionescu (GIPSA-lab)
* \date 26 April 2012
* \brief The CDriverMitsarEEG202A allows the acquisition server to acquire data from a Mitsar EEG 202A amplifier.
*
* submitted by Anton Andreev (GIPSA-lab)
*/
class CDriverMitsarEEG202A final : public IDriver
{
typedef enum
{
CHANNEL_NB = 33,
SAMPLING_RATE = 500,
SAMPLES_NB = 33,
STIMULATION_0 = 0,
STIMULATION_128 = 128,
STIMULATION_64 = 64,
STIMULATION_192 = (STIMULATION_128 + STIMULATION_64), //both buttons pressed
} misc_t;
public:
explicit CDriverMitsarEEG202A(IDriverContext& ctx);//modif new Idriver
void release();
const char* getName() override;
bool initialize(const uint32_t nSamplePerSentBlock, IDriverCallback& callback) override;
bool uninitialize() override;
bool start() override;
bool stop() override;
bool loop() override;
bool isConfigurable() override;
bool configure() override;
const IHeader* getHeader() override { return &m_header; }
//??? virtual void processData (cf neXus)
protected:
SettingsHelper m_settings;
IDriverCallback* m_callback = nullptr;
CHeader m_header;
uint32_t m_refIdx = 0;
bool m_eventAndBioChannelsState = false;
uint32_t m_lastStimulation = 0;
float* m_stimulationChannel = nullptr;
std::vector<size_t> m_stimulationIDs;
std::vector<size_t> m_stimulationDates;
std::vector<float> m_iSamples;
std::vector<float> m_oSamples;
};
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif
#endif