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,812 @@
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkAdjustment" id="adjustment1">
<property name="value">4</property>
<property name="lower">1</property>
<property name="upper">16</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="GtkAdjustment" id="adjustment3">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkListStore" id="model1">
<columns>
<!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">32</col>
</row>
<row>
<col id="0" translatable="yes">64</col>
</row>
<row>
<col id="0" translatable="yes">128</col>
</row>
<row>
<col id="0" translatable="yes">256</col>
</row>
<row>
<col id="0" translatable="yes">512</col>
</row>
<row>
<col id="0" translatable="yes">600</col>
</row>
<row>
<col id="0" translatable="yes">1200</col>
</row>
<row>
<col id="0" translatable="yes">2400</col>
</row>
<row>
<col id="0" translatable="yes">4800</col>
</row>
<row>
<col id="0" translatable="yes">9600</col>
</row>
<row>
<col id="0" translatable="yes">19200</col>
</row>
<row>
<col id="0" translatable="yes">38400</col>
</row>
</data>
</object>
<object class="GtkListStore" id="model2">
<columns>
<!-- column-name gchararray -->
<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="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="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name="spacing">8</property>
<child>
<object class="GtkLabel" id="label_title">
<property name="visible">True</property>
<property name="label" translatable="yes">g.Tec gUSBamp</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">8</property>
<property name="n_columns">2</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkSpinButton" id="spinbutton_number_of_channels">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="adjustment">adjustment1</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">4</property>
<property name="bottom_attach">5</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">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_device">
<property name="visible">True</property>
<property name="label" translatable="yes">Device :</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="GtkComboBox" id="combobox_sampling_frequency">
<property name="visible">True</property>
<property name="model">model1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<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>
</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">5</property>
<property name="bottom_attach">6</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox_gender">
<property name="visible">True</property>
<property name="model">model2</property>
<child>
<object class="GtkCellRendererText" id="renderer2"/>
<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="GtkComboBox" id="combobox_device">
<property name="visible">True</property>
<property name="model">model3</property>
<child>
<object class="GtkCellRendererText" id="renderer3"/>
<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">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_identifier">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment2</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="GtkSpinButton" id="spinbutton_age">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment3</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="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="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_gender">
<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="GtkCheckButton" id="checkbutton_EventChannel">
<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="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_event_channel">
<property name="visible">True</property>
<property name="label" translatable="yes">Event channel :</property>
</object>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Check impedance :</property>
</object>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton_impedance">
<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="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</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_calibrate">
<property name="label" translatable="yes">Auto calibrate in 4 seconds...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator2">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-common-gnd-ref">
<property name="label" translatable="yes">Connect to Common Gnd and Ref</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-filters">
<property name="label" translatable="yes">Set Amplifier Filters</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator3">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">5</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="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">6</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="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</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="model3">
<columns>
<!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="dialog-common-gnd-ref">
<property name="border_width">5</property>
<property name="title" translatable="yes">Common Ground and Reference</property>
<property name="window_position">center</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;big&gt;Connect to Common Ground&lt;/big&gt;</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
</object>
<packing>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-gnd-blockA">
<property name="label" translatable="yes">Block A (yellow)</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="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-gnd-blockB">
<property name="label" translatable="yes">Block B (red)</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="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="GtkCheckButton" id="checkbutton-gnd-blockC">
<property name="label" translatable="yes">Block C (blue)</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="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-gnd-blockD">
<property name="label" translatable="yes">Block D (green)</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="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator4">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;big&gt;Connect to Common Reference&lt;/big&gt;</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
</object>
<packing>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-ref-blockA">
<property name="label" translatable="yes">Block A (yellow)</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="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-ref-blockB">
<property name="label" translatable="yes">Block B (red)</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="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="GtkCheckButton" id="checkbutton-ref-blockC">
<property name="label" translatable="yes">Block C (blue)</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="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton-ref-blockD">
<property name="label" translatable="yes">Block D (green)</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="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkDialog" id="dialog-filters">
<property name="border_width">7</property>
<property name="title" translatable="yes">Amplifier Filters</property>
<property name="window_position">center</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;big&gt;Notch filter&lt;/big&gt;
Type - Order - [Low Pass; High Pass] - Frequency</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox-notch">
<property name="visible">True</property>
<property name="model">liststore1</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator5">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;big&gt;Band Pass filter&lt;/big&gt;
Type - Order - [Low Cut; High Cut] - Frequency</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox-band-pass">
<property name="visible">True</property>
<property name="model">liststore2</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name filter -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="liststore2">
<columns>
<!-- column-name filter -->
<column type="gchararray"/>
</columns>
</object>
</interface>
@@ -0,0 +1,282 @@
#if defined TARGET_HAS_ThirdPartyGUSBampCAPI
#include "ovasCConfigurationGTecGUSBampLegacy.h"
#include <windows.h>
#include <gUSBamp.h>
#include <iostream>
#include <sstream>
namespace OpenViBE {
namespace AcquisitionServer {
static void CalibratePressedCB(GtkButton* /*button*/, void* data) { static_cast<CConfigurationGTecGUSBampLegacy*>(data)->buttonCalibratePressedCB(); }
static gboolean idle_calibrate_cb(void* data)
{
static_cast<CConfigurationGTecGUSBampLegacy*>(data)->idleCalibrateCB();
return FALSE;
}
static void button_common_gnd_ref_pressed_cb(GtkButton* /*button*/, void* data)
{
static_cast<CConfigurationGTecGUSBampLegacy*>(data)->buttonCommonGndRefPressedCB();
}
static void FiltersPressedCB(GtkButton* /*button*/, void* data) { static_cast<CConfigurationGTecGUSBampLegacy*>(data)->buttonFiltersPressedCB(); }
CConfigurationGTecGUSBampLegacy::CConfigurationGTecGUSBampLegacy(const char* gtkBuilderFilename, uint32_t& usbIdx, uint8_t& commonGndAndRefBitmap,
int& notchFilterIdx, int& bandPassFilterIdx, bool& triggerInput)
: CConfigurationBuilder(gtkBuilderFilename), m_usbIdx(usbIdx), m_commonGndAndRefBitmap(commonGndAndRefBitmap), m_notchFilterIdx(notchFilterIdx),
m_bandPassFilterIdx(bandPassFilterIdx), m_triggerInput(triggerInput) {}
bool CConfigurationGTecGUSBampLegacy::preConfigure()
{
if (!CConfigurationBuilder::preConfigure()) { return false; }
GtkCheckButton* hardwareTagging = GTK_CHECK_BUTTON(gtk_builder_get_object(m_builder, "checkbutton_EventChannel"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hardwareTagging), m_triggerInput);
GtkComboBox* comboBox = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox_device"));
char buffer[1024];
int count = 0;
bool selected = false;
// autodetection of the connected device
for (uint32_t i = 1; i < 11; ++i)
{
HANDLE handle = GT_OpenDevice(i);
if (handle)
{
GT_CloseDevice(&handle);
sprintf(buffer, "USB port %i", i);
gtk_combo_box_append_text(comboBox, buffer);
if (m_usbIdx == i)
{
gtk_combo_box_set_active(comboBox, count);
selected = true;
}
count++;
}
}
g_signal_connect(gtk_builder_get_object(m_builder, "button_calibrate"), "pressed", G_CALLBACK(CalibratePressedCB), this);
if (!selected && count != 0) { gtk_combo_box_set_active(comboBox, 0); }
g_signal_connect(gtk_builder_get_object(m_builder, "button-common-gnd-ref"), "pressed", G_CALLBACK(button_common_gnd_ref_pressed_cb), this);
g_signal_connect(gtk_builder_get_object(m_builder, "button-filters"), "pressed", G_CALLBACK(FiltersPressedCB), this);
GtkWidget* dialog = GTK_WIDGET(gtk_builder_get_object(m_builder, "dialog-common-gnd-ref"));
gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
dialog = GTK_WIDGET(gtk_builder_get_object(m_builder, "dialog-filters"));
gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
GtkToggleButton* checkBox = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-gnd-blockA"));
gtk_toggle_button_set_active(checkBox, (m_commonGndAndRefBitmap & 1));
checkBox = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-gnd-blockB"));
gtk_toggle_button_set_active(checkBox, (m_commonGndAndRefBitmap & (1 << 1)));
checkBox = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-gnd-blockC"));
gtk_toggle_button_set_active(checkBox, (m_commonGndAndRefBitmap & (1 << 2)));
checkBox = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-gnd-blockD"));
gtk_toggle_button_set_active(checkBox, (m_commonGndAndRefBitmap & (1 << 3)));
checkBox = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-ref-blockA"));
gtk_toggle_button_set_active(checkBox, (m_commonGndAndRefBitmap & (1 << 4)));
checkBox = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-ref-blockB"));
gtk_toggle_button_set_active(checkBox, (m_commonGndAndRefBitmap & (1 << 5)));
checkBox = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-ref-blockC"));
gtk_toggle_button_set_active(checkBox, (m_commonGndAndRefBitmap & (1 << 6)));
checkBox = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-ref-blockD"));
gtk_toggle_button_set_active(checkBox, (m_commonGndAndRefBitmap & (1 << 7)));
// To check for available filters in the amplifier, we must connect to it.
if (count != 0)
{
HANDLE handle = GT_OpenDevice(count);
int nBandPassFilters, nNotchFilters;
if (!GT_GetNumberOfFilter(&nBandPassFilters)) { std::cout << "err GT_GetNumberOfFilter\n"; }
if (!GT_GetNumberOfNotch(&nNotchFilters)) { std::cout << "err GT_GetNumberOfNotch\n"; }
FILT* bpFilterSpec = new FILT[nBandPassFilters];
FILT* notchFilterSpec = new FILT[nNotchFilters];
if (!GT_GetFilterSpec(bpFilterSpec)) { std::cout << "err GT_GetFilterSpec\n"; }
if (!GT_GetNotchSpec(notchFilterSpec)) { std::cout << "err GT_GetNotchSpec\n"; }
GtkComboBox* comboBoxBandPass = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox-band-pass"));
GtkTreeModel* bandPassListStore = gtk_combo_box_get_model(comboBoxBandPass);
std::stringstream desc;
desc << "no band pass filter.";
GtkTreeIter lIter;
gtk_list_store_append(GTK_LIST_STORE(bandPassListStore), &lIter);
gtk_list_store_set(GTK_LIST_STORE(bandPassListStore), &lIter, 0, desc.str().c_str(), -1);
desc.clear();
desc.str("");
for (int i = 0; i < nBandPassFilters; ++i)
{
if (bpFilterSpec[i].type == 1) { desc << "Butterworth - "; }
if (bpFilterSpec[i].type == 2) { desc << "Chebyshev - "; }
desc << bpFilterSpec[i].order << " - [" << bpFilterSpec[i].fu << "; " << bpFilterSpec[i].fo << "] - " << bpFilterSpec[i].fs;
GtkTreeIter iter;
gtk_list_store_append(GTK_LIST_STORE(bandPassListStore), &iter);
gtk_list_store_set(GTK_LIST_STORE(bandPassListStore), &iter, 0, desc.str().c_str(), -1);
desc.clear();
desc.str("");
}
gtk_combo_box_set_active(comboBoxBandPass, m_bandPassFilterIdx + 1); // +1 because -1 is for "no filter".
GtkComboBox* comboBoxNotch = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox-notch"));
GtkTreeModel* notchListStore = gtk_combo_box_get_model(comboBoxNotch);
desc << "no notch filter.";
gtk_list_store_append(GTK_LIST_STORE(notchListStore), &lIter);
gtk_list_store_set(GTK_LIST_STORE(notchListStore), &lIter, 0, desc.str().c_str(), -1);
desc.clear();
desc.str("");
for (int i = 0; i < nNotchFilters; ++i)
{
if (notchFilterSpec[i].type == 1) { desc << "Butterworth - "; }
if (notchFilterSpec[i].type == 2) { desc << "Chebyshev - "; }
desc << notchFilterSpec[i].order << " - [" << notchFilterSpec[i].fu << "; " << notchFilterSpec[i].fo << "] - " << notchFilterSpec[i].fs;
GtkTreeIter iter;
gtk_list_store_append(GTK_LIST_STORE(notchListStore), &iter);
gtk_list_store_set(GTK_LIST_STORE(notchListStore), &iter, 0, desc.str().c_str(), -1);
desc.clear();
desc.str("");
}
gtk_combo_box_set_active(comboBoxNotch, m_notchFilterIdx + 1);
delete bpFilterSpec;
delete notchFilterSpec;
GT_CloseDevice(&handle);
}
else
{
// deactivate the buttons
GtkWidget* button = GTK_WIDGET(gtk_builder_get_object(m_builder, "button-filters"));
gtk_widget_set_sensitive(button, false);
button = GTK_WIDGET(gtk_builder_get_object(m_builder, "button-common-gnd-ref"));
gtk_widget_set_sensitive(button, false);
}
return true;
}
bool CConfigurationGTecGUSBampLegacy::postConfigure()
{
GtkComboBox* comboBox = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox_device"));
if (m_applyConfig)
{
int iUsbIdx = 0;
const char* usbIdx = gtk_combo_box_get_active_text(comboBox);
if (usbIdx) { if (sscanf(usbIdx, "USB port %i", &iUsbIdx) == 1) { m_usbIdx = uint32_t(iUsbIdx); } }
GtkToggleButton* button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-gnd-blockA"));
m_commonGndAndRefBitmap = (gtk_toggle_button_get_active(button) ? 1 : 0);
button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-gnd-blockB"));
m_commonGndAndRefBitmap = m_commonGndAndRefBitmap + (gtk_toggle_button_get_active(button) ? (1 << 1) : 0);
button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-gnd-blockC"));
m_commonGndAndRefBitmap = m_commonGndAndRefBitmap + (gtk_toggle_button_get_active(button) ? (1 << 2) : 0);
button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-gnd-blockD"));
m_commonGndAndRefBitmap = m_commonGndAndRefBitmap + (gtk_toggle_button_get_active(button) ? (1 << 3) : 0);
button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-ref-blockA"));
m_commonGndAndRefBitmap = m_commonGndAndRefBitmap + (gtk_toggle_button_get_active(button) ? (1 << 4) : 0);
button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-ref-blockB"));
m_commonGndAndRefBitmap = m_commonGndAndRefBitmap + (gtk_toggle_button_get_active(button) ? (1 << 5) : 0);
button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-ref-blockC"));
m_commonGndAndRefBitmap = m_commonGndAndRefBitmap + (gtk_toggle_button_get_active(button) ? (1 << 6) : 0);
button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_builder, "checkbutton-ref-blockD"));
m_commonGndAndRefBitmap = m_commonGndAndRefBitmap + (gtk_toggle_button_get_active(button) ? (1 << 7) : 0);
GtkComboBox* notch = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox-notch"));
m_notchFilterIdx = gtk_combo_box_get_active(notch) - 1;
GtkComboBox* bandPass = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox-band-pass"));
m_bandPassFilterIdx = gtk_combo_box_get_active(bandPass) - 1;
GtkCheckButton* hardwareTagging = GTK_CHECK_BUTTON(gtk_builder_get_object(m_builder, "checkbutton_EventChannel"));
m_triggerInput = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hardwareTagging)) ? true : false);
}
if (!CConfigurationBuilder::postConfigure()) { return false; }
return true;
}
void CConfigurationGTecGUSBampLegacy::buttonCalibratePressedCB()
{
g_idle_add(idle_calibrate_cb, this);
m_calibrateDialog = gtk_message_dialog_new(nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, "Calibrating...");
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(m_calibrateDialog), "Please wait a few seconds...");
gtk_dialog_run(GTK_DIALOG(m_calibrateDialog));
gtk_widget_destroy(m_calibrateDialog);
if (m_calibrationDone)
{
GtkWidget* dialog = gtk_message_dialog_new(nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Calibration finished !");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
else
{
GtkWidget* dialog = gtk_message_dialog_new(nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Calibration failed !");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
}
void CConfigurationGTecGUSBampLegacy::idleCalibrateCB()
{
GtkComboBox* comboBox = GTK_COMBO_BOX(gtk_builder_get_object(m_builder, "combobox_device"));
m_calibrationDone = false;
int iUsbIdx = 0;
const char* usbIdx = gtk_combo_box_get_active_text(comboBox);
if (usbIdx)
{
if (sscanf(usbIdx, "USB port %i", &iUsbIdx) == 1)
{
HANDLE handle = GT_OpenDevice(iUsbIdx);
if (handle)
{
m_calibrationDone = true;
SCALE calibration;
if (!GT_Calibrate(handle, &calibration)) { std::cout << "err GT_Calibrate\n", m_calibrationDone = false; }
if (!GT_SetScale(handle, &calibration))
{
std::cout << "err GT_SetScale\n";
m_calibrationDone = false;
}
GT_CloseDevice(&handle);
}
}
}
gtk_dialog_response(GTK_DIALOG(m_calibrateDialog), 0);
}
void CConfigurationGTecGUSBampLegacy::buttonCommonGndRefPressedCB()
{
GtkWidget* dialog = GTK_WIDGET(gtk_builder_get_object(m_builder, "dialog-common-gnd-ref"));
gint resp = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_hide(dialog);
}
void CConfigurationGTecGUSBampLegacy::buttonFiltersPressedCB()
{
GtkWidget* dialog = GTK_WIDGET(gtk_builder_get_object(m_builder, "dialog-filters"));
gint resp = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_hide(dialog);
}
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyGUSBampCAPI
@@ -0,0 +1,41 @@
#pragma once
#if defined TARGET_HAS_ThirdPartyGUSBampCAPI
#include "../ovasCConfigurationBuilder.h"
#include <gtk/gtk.h>
namespace OpenViBE {
namespace AcquisitionServer {
class CConfigurationGTecGUSBampLegacy final : public CConfigurationBuilder
{
public:
CConfigurationGTecGUSBampLegacy(const char* gtkBuilderFilename, uint32_t& usbIdx, uint8_t& commonGndAndRefBitmap, int& notchFilterIdx,
int& bandPassFilterIdx, bool& triggerInput);
bool preConfigure() override;
bool postConfigure() override;
void buttonCalibratePressedCB();
void idleCalibrateCB();
void buttonCommonGndRefPressedCB();
void buttonFiltersPressedCB();
protected:
uint32_t& m_usbIdx;
uint8_t& m_commonGndAndRefBitmap;
int& m_notchFilterIdx;
int& m_bandPassFilterIdx;
bool& m_triggerInput;
private:
GtkWidget* m_calibrateDialog = nullptr;
bool m_calibrationDone = false;
};
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyGUSBampCAPI
@@ -0,0 +1,351 @@
#if defined TARGET_HAS_ThirdPartyGUSBampCAPI
#include "ovasCDriverGTecGUSBampLegacy.h"
#include "ovasCConfigurationGTecGUSBampLegacy.h"
#include <toolkit/ovtk_all.h>
#include <system/ovCTime.h>
#include <cmath>
#include <windows.h>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <gUSBamp.h>
#define GTEC_NUM_CHANNELS 16
namespace OpenViBE {
namespace AcquisitionServer {
/*
This driver always reads 17 channels: 16 + 1
16 are EEG channels
1 is the last channel that provides triggers from the parallel port of the GTEC
Although 17 channels are read only "m_nAcquiredChannel" + 1 (if m_pTriggerInputEnabled==true) are displayed.
If m_nAcquiredChannel=6 and m_pTriggerInputEnabled=true then the output in OpenVibe is 7 channels. If m_pTriggerInputEnabled=false then 6.
"m_nAcquiredChannel" is a user modifiable variable with default value 16
*/
CDriverGTecGUSBampLegacy::CDriverGTecGUSBampLegacy(IDriverContext& ctx)
: IDriver(ctx)
, m_settings("AcquisitionServer_Driver_GTecGUSBampLegacy", m_driverCtx.getConfigurationManager())
, m_deviceIdx(uint32_t(-1))
, m_notchFilterIdx(-1)
, m_bandPassFilterIdx(-1)
, m_nAcquiredChannel(GTEC_NUM_CHANNELS)
{
m_header.setSamplingFrequency(512);
m_header.setChannelCount(GTEC_NUM_CHANNELS);
m_settings.add("Header", &m_header);
m_settings.add("DeviceIndex", &m_deviceIdx);
m_settings.add("CommonGndAndRefBitmap", &m_commonGndAndRefBitmap);
m_settings.add("NotchFilterIndex", &m_notchFilterIdx);
m_settings.add("BandPassFilterIndex", &m_bandPassFilterIdx);
m_settings.add("TriggerInputEnabled", &m_bTriggerInputEnabled);
m_settings.load();
}
//___________________________________________________________________//
// //
bool CDriverGTecGUSBampLegacy::initialize(const uint32_t nSamplePerSentBlock, IDriverCallback& callback)
{
if (m_driverCtx.isConnected() || !m_header.isChannelCountSet() || !m_header.isSamplingFrequencySet()) { return false; }
if (m_bTriggerInputEnabled)
{
m_header.setChannelCount(m_nAcquiredChannel + 1);
m_header.setChannelName(m_nAcquiredChannel, "CH_Event");
}
else { m_header.setChannelCount(m_nAcquiredChannel); }
// If device has not been selected, try to find a device
uint32_t i = 0;
m_actualDeviceIdx = m_deviceIdx;
while (i < 11 && m_actualDeviceIdx == uint32_t(-1))
{
HANDLE handle = GT_OpenDevice(i);
if (handle)
{
GT_CloseDevice(&handle);
m_actualDeviceIdx = i;
}
i++;
}
if (m_actualDeviceIdx == uint32_t(-1)) { return false; }
m_pEvent = ::CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (!m_pEvent) { return false; }
//allocate buffers
m_bufferSize = (GTEC_NUM_CHANNELS + 1) * nSamplePerSentBlock * sizeof(float) + HEADER_SIZE;//+1 channel for trigger
m_Buffer = new uint8_t[m_bufferSize];
if (m_bTriggerInputEnabled) { m_sample = new float[(m_nAcquiredChannel + 1) * nSamplePerSentBlock]; }
else { m_sample = new float[m_nAcquiredChannel * nSamplePerSentBlock]; }
if (!m_Buffer || !m_sample)
{
delete [] m_Buffer;
delete [] m_sample;
CloseHandle(m_pEvent);
return false;
}
memset(m_Buffer, 0, m_bufferSize);
m_sampleTranspose = reinterpret_cast<float*>(m_Buffer + HEADER_SIZE);
m_pOverlapped = new OVERLAPPED;
if (!m_pOverlapped)
{
delete [] m_Buffer;
delete [] m_sample;
CloseHandle(m_pEvent);
return false;
}
#define m_pOverlapped ((OVERLAPPED*)m_pOverlapped)
memset(m_pOverlapped, 0, sizeof(OVERLAPPED));
m_pOverlapped->hEvent = m_pEvent;
m_Device = GT_OpenDevice(m_actualDeviceIdx);
if (!m_Device)
{
delete m_pOverlapped;
delete [] m_Buffer;
delete [] m_sample;
CloseHandle(m_pEvent);
return false;
}
m_actualImpedanceIdx = 0;
m_nSamplePerSentBlock = nSamplePerSentBlock;
m_callback = &callback;
return true;
}
bool CDriverGTecGUSBampLegacy::start()
{
if (!m_driverCtx.isConnected() || m_driverCtx.isStarted()) { return false; }
UCHAR channels[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
// The amplifier is divided in 4 blocks, A to D
// each one has its own Ref/gnd connections,
// user can specify whether or not to connect the block to the common ground and reference of the amplifier.
GND gnd;
gnd.GND1 = (m_commonGndAndRefBitmap & 1);
gnd.GND2 = (m_commonGndAndRefBitmap & (1 << 1));
gnd.GND3 = (m_commonGndAndRefBitmap & (1 << 2));
gnd.GND4 = (m_commonGndAndRefBitmap & (1 << 3));
REF ref;
ref.ref1 = (m_commonGndAndRefBitmap & (1 << 4));
ref.ref2 = (m_commonGndAndRefBitmap & (1 << 5));
ref.ref3 = (m_commonGndAndRefBitmap & (1 << 6));
ref.ref4 = (m_commonGndAndRefBitmap & (1 << 7));
if (!GT_SetMode(m_Device, M_NORMAL)) { m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetMode\n"; }
if (!GT_SetBufferSize(m_Device, m_nSamplePerSentBlock))
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetBufferSize\n";
}
if (!GT_SetChannels(m_Device, channels, sizeof(channels) / sizeof(UCHAR)))
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetChannels\n";
}
if (!GT_SetSlave(m_Device, FALSE)) { m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetSlave\n"; }
if (!GT_EnableTriggerLine(m_Device, TRUE))
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_EnableTriggerLine - the extra input trigger channel is disabled\n";
}
// GT_EnableSC
// GT_SetBipolar
for (uint32_t i = 0; i < m_nAcquiredChannel; ++i)
{
if (!GT_SetBandPass(m_Device, i + 1, m_bandPassFilterIdx))
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetBandPass for channel " << i << "\n";
}
if (!GT_SetNotch(m_Device, i + 1, m_notchFilterIdx))
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetNotch for channel " << i << "\n";
}
}
if (!GT_SetSampleRate(m_Device, m_header.getSamplingFrequency()))
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetSampleRate\n";
}
if (!GT_SetReference(m_Device, ref)) { m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetReference\n"; }
if (!GT_SetGround(m_Device, gnd)) { m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "Unexpected error while calling GT_SetGround\n"; }
m_lastStimulation = STIMULATION_0;
m_totalHardwareStimulations = 0;
m_totalDriverChunksLost = 0;
GT_Start(m_Device);
return true;
}
bool CDriverGTecGUSBampLegacy::loop()
{
CStimulationSet stimSet;
if (!m_driverCtx.isConnected()) { return false; }
if (m_driverCtx.isStarted())
{
if (GT_GetData(m_Device, m_Buffer, m_bufferSize, m_pOverlapped))
{
if (WaitForSingleObject(m_pOverlapped->hEvent, 1000) == WAIT_OBJECT_0)
{
DWORD nByte = 0;
GetOverlappedResult(m_Device, m_pOverlapped, &nByte, FALSE);
if (nByte == m_bufferSize)
{
for (uint32_t i = 0; i < m_nAcquiredChannel; ++i)
{
for (uint32_t j = 0; j < m_nSamplePerSentBlock; ++j)
{
m_sample[i * m_nSamplePerSentBlock + j] = m_sampleTranspose[j * (GTEC_NUM_CHANNELS + 1) + i];
}
}
if (m_bTriggerInputEnabled)
{
for (uint32_t iSample = 0; iSample < m_nSamplePerSentBlock; ++iSample)
{
const uint32_t stimCode = uint32_t(
m_sampleTranspose[iSample * (GTEC_NUM_CHANNELS + 1) + GTEC_NUM_CHANNELS]);
m_sample[m_nAcquiredChannel * m_nSamplePerSentBlock + iSample] = float(stimCode);
//this means that the user sends 0 after each stimulatuion and in the beginning
if ((stimCode != STIMULATION_0) && (stimCode != m_lastStimulation)
)
{
uint64_t identifier;
switch (stimCode)
{
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;
default: identifier = OVTK_StimulationId_Label_07;
}
const uint64_t time = CTime(m_header.getSamplingFrequency(), uint64_t(iSample)).time();
stimSet.appendStimulation(identifier, time, 0);
m_totalHardwareStimulations++;
}
m_lastStimulation = stimCode;
}
}
m_callback->setSamples(m_sample);
m_callback->setStimulationSet(stimSet);
m_driverCtx.correctDriftSampleCount(m_driverCtx.getSuggestedDriftCorrectionSampleCount());
}
else
{
m_totalDriverChunksLost++;
//m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "nByte and m_bufferSize differs : " << nByte << "/" << m_bufferSize << "(header size is " << HEADER_SIZE << ")\n";
/*m_driverCtx.getLogManager() << Kernel::LogLevel_Warning
<< "Returned data is different than expected. Total chunks lost: " << m_totalDriverChunksLost
<< ", Total samples lost: " << m_nSamplePerSentBlock * m_totalDriverChunksLost
<< "\n";*/
}
}
else
{
// TIMEOUT
//m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "timeout 1\n";
}
}
else
{
//m_driverCtx.getLogManager() << Kernel::LogLevel_Error << "tError on GT_GetData.\n";
}
}
else
{
if (m_driverCtx.isImpedanceCheckRequested())
{
double impedance = 0;
GT_GetImpedance(m_Device, m_actualImpedanceIdx + 1, &impedance);
if (impedance < 0) { impedance *= -1; }
m_driverCtx.updateImpedance(m_actualImpedanceIdx, impedance);
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "Channel " << m_actualImpedanceIdx << " - "
<< m_header.getChannelName(m_actualImpedanceIdx) << " : " << impedance << "\n";
m_actualImpedanceIdx++;
m_actualImpedanceIdx %= m_header.getChannelCount();
m_driverCtx.updateImpedance(m_actualImpedanceIdx, -1);
}
else { System::Time::sleep(20); }
}
return true;
}
bool CDriverGTecGUSBampLegacy::stop()
{
if (!m_driverCtx.isConnected() || !m_driverCtx.isStarted()) { return false; }
//stop device
GT_Stop(m_Device);
GT_ResetTransfer(m_Device);
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "Total number of hardware stimulations acquired: " << m_totalHardwareStimulations << "\n";
m_driverCtx.getLogManager() << Kernel::LogLevel_Trace << "Total chunks lost: " << m_totalDriverChunksLost << "\n";
return true;
}
bool CDriverGTecGUSBampLegacy::uninitialize()
{
if (!m_driverCtx.isConnected() || m_driverCtx.isStarted()) { return false; }
GT_CloseDevice(&m_Device);
CloseHandle(m_pEvent);
delete [] m_Buffer;
delete [] m_sample;
delete m_pOverlapped;
m_Device = nullptr;
m_pEvent = nullptr;
m_Buffer = nullptr;
m_sample = nullptr;
m_callback = nullptr;
return true;
}
bool CDriverGTecGUSBampLegacy::configure()
{
CConfigurationGTecGUSBampLegacy config(Directories::getDataDir() + "/applications/acquisition-server/interface-GTec-GUSBampLegacy.ui",
m_deviceIdx, m_commonGndAndRefBitmap, m_notchFilterIdx, m_bandPassFilterIdx,
m_bTriggerInputEnabled);
if (!config.configure(m_header)) { return false; }
this->m_nAcquiredChannel = m_header.getChannelCount();
m_settings.save();
return true;
}
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyGUSBampCAPI
@@ -0,0 +1,88 @@
#pragma once
#if defined TARGET_HAS_ThirdPartyGUSBampCAPI
#include "ovasIDriver.h"
#include "../ovasCHeader.h"
#include "../ovasCSettingsHelper.h"
#include "../ovasCSettingsHelperOperators.h"
#include <gtk/gtk.h>
#include <vector>
namespace OpenViBE {
namespace AcquisitionServer {
/**
* \class CDriverGTecGUSBampLegacy
* \author Yann Renard (Inria)
* \date unknown
* \brief GTEC driver
*
*/
class CDriverGTecGUSBampLegacy final : public IDriver
{
public:
explicit CDriverGTecGUSBampLegacy(IDriverContext& ctx);
void release() { delete this; }
const char* getName() override { return "g.tec gUSBamp Legacy"; }
bool initialize(const uint32_t nSamplePerSentBlock, IDriverCallback& callback) override;
bool uninitialize() override;
bool start() override;
bool stop() override;
bool loop() override;
bool isConfigurable() override { return true; }
bool configure() override;
const IHeader* getHeader() override { return &m_header; }
bool isFlagSet(const EDriverFlag flag) const override { return flag == EDriverFlag::IsDeprecated; }
protected:
SettingsHelper m_settings;
IDriverCallback* m_callback = nullptr;
CHeader m_header;
uint32_t m_nSamplePerSentBlock = 0;
uint32_t m_deviceIdx = 0;
uint32_t m_actualDeviceIdx = 0;
uint32_t m_bufferSize = 0;
uint8_t* m_Buffer = nullptr;
float* m_sampleTranspose = nullptr;
float* m_sample = nullptr;
void* m_Device = nullptr;
void* m_pEvent = nullptr;
void* m_pOverlapped = nullptr;
uint32_t m_actualImpedanceIdx = 0;
uint8_t m_commonGndAndRefBitmap = 0;
int m_notchFilterIdx = 0;
int m_bandPassFilterIdx = 0;
bool m_bTriggerInputEnabled = false;
uint32_t m_lastStimulation = 0;
// EVENT CHANNEL : contribution Anton Andreev (Gipsa-lab) - 0.14.0
typedef enum
{
STIMULATION_0 = 0,
STIMULATION_64 = 64,
STIMULATION_128 = 128,
STIMULATION_192 = 192
} gtec_triggers_t;
uint32_t m_totalHardwareStimulations = 0; //since start button clicked
uint32_t m_totalDriverChunksLost = 0; //since start button clicked
uint32_t m_nAcquiredChannel = 0; //number of channels 1..16 specified bu user
};
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyGUSBampCAPI