-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepocutils_raw.hpp
177 lines (146 loc) · 7.42 KB
/
epocutils_raw.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/* epocutils.h - namespaced utility for the Emotiv Epoc SDK ( Dev Edition )
*
* This utility provides two easy ways to communicate with the Epoc headset
*
* Currently supports the EDK Dev & Research ( raw EEG data ) Edition
*
* supposed to be used: 1 -> as a utility class ( include header file in necessary .cpp file )
* 2 -> as a utility class, embedded in a library that is available system wide ( .so file )
*
* note: I own 2 Epoc headsets | a SDK Dev edition & I am able to get raw EEG data with it ( hint: all you need is the right 'dek.h' file to make your "Dev" edition a "Research" one ( ... ) )
*
*
* by StephaneAG - 2013
*/
/* includes the necessary standard stuff */
#include <iostream>
#include <cstdio> // necessary for 'printf()'
#include <cstdlib> // necessary for 'exit(1)'
#include <map> // necessary for the 'channelNames' map
/* include the Emotiv-proprietary stuff */
#include "edk.h"
#include "edkErrorCode.h"
#include "EmoStateDLL.h"
/* we define what this header file makes available to file that include it */
#ifndef epocutils_h
#define epocutils_h
namespace epocutils
{
/* RESEARCH EDITION - the target Data Channels List */
/*
EE_DataChannel_t targetChannelList[] = {
ED_COUNTER,
ED_AF3, ED_F7, ED_F3, ED_FC5, ED_T7,
ED_P7, ED_O1, ED_O2, ED_P8, ED_T8,
ED_FC6, ED_F4, ED_F8, ED_AF4,
ED_GYROX, ED_GYROY, ED_TIMESTAMP,
ED_FUNC_ID, ED_FUNC_VALUE, ED_MARKER, ED_SYNC_SIGNAL
};
*/
/* RESEARCH EDITION - the channels names */
/*
const char* channelNames[] = { "COUNTER","AF3","F7","F3","FC5","T7","P7","O1","O2","P8","T8","FC6","F4","F8","AF4","GYROX","GYROY","TIMESTAMP","FUNC_ID","FUNC_VALUE","MARKER","SYNC_SIGNAL" };
*/
/* RESEARCH EDITION - the 'EpocHeadsetRaw_t' structure to hold all the stuff we're interested in */
struct EpocHeadsetRaw_t
{
// bool to prevent unnecessary polling
bool newDataToRead;
// headset counter / Timestamp
int counter;
int timestamp;
// Gyroscope
int gyrox;
int gyroy;
// Fcn ID / value
int func_id;
int func_value;
// Marker / SyncSignal
int marker;
int sync_signal;
// the different channels available on the Epoc headset device
float af3;
float f7;
float f3;
float fc5;
float t7;
float p7;
float o1;
float o2;
float p8;
float t8;
float fc6;
float f4;
float f8;
float af4;
};
/* DEV EDITION - the 'EpocHeadset_t' structure to hold all the stuff we're interested in */
struct EpocHeadset_t
{
// bool to prevent unnecessary polling
bool newDataToRead;
// -- Epoc 'original' values -- // R: " #include <typeinfo> & then std::cout << typeid( <the-var-name> ).name() << std::endl; ", but still not that easy to use ( ...)
float time; // aka, returned a 'f' from the comment above in comments
unsigned int userID;
int wirelessSignalStatus; // R: do a 'static_cast<int>(ES_GetWIrelessSignalStatus(eState))' as else the type will be 'EE_SignalStrength_t' ( enum )
// Expressiv suite
int isBlinking;
int isWinkingLeft;
int isWinkingRight;
int isLookingLeft;
int isLookingRight;
// Digg the doc & ask Emotiv for the 'IsEyesOpen', 'IsLookingUp' & 'IsLookingDown' fcn ( ... )
float eyebrow; // R: " expressivStates[ EXP_EYEBROW ] "
float furrow;
float smile;
float clench;
float smirkLeft;
float smirkRight;
float laugh;
// Affectiv suite
float shortTermExcitement;
float longTermExcitement;
float engagementBoredom;
// Digg the doc & ask Emotiv for the 'Meditation' & 'Frustration'
// Cognitiv suite
int cogntivAction;
float cogntiviActionConfidence;
};
/* connect to the Epoc headset */
int connect(bool& connected);
/* disconnect from the Epoc headset ( WARNING: this function WILL NOT free the 'EmoStateHandle' neither the 'EmoEngineEventHandle' ! ) */
void disconnect(bool& connected);
/* disconnect from the Epoc headset AND clean up */
void disconnect(bool& connected, EmoStateHandle& eState, EmoEngineEventHandle& eEvent);
/* RESEARCH EDITION - disconnect from the Epoc headset AND clean up */
void disconnect(bool& connected,bool& dataAcquisitionEnabled, EmoStateHandle& eState, EmoEngineEventHandle& eEvent, DataHandle& hData);
/* RESEARCH EDITION - enable the data acquisition for the user */
int enableDataAcquisition(bool& connected, bool& dataAcquisitionEnabled, unsigned int& userID);
/* RESEARCH EDITION - set the buffer size in seconds */
void setBufferSizeInSeconds(bool& connected, bool& dataAcquisitionEnabled, float& bufferSizeInSeconds);
/* create an 'EmoEngineEventHandle' */
EmoEngineEventHandle createEventHandle();
/* create an 'EmoStateHandle' */
EmoStateHandle createStateHandle();
/* RESEARCH EDITION - create a 'DataHandle' */
DataHandle createDataHandle();
/* RESEARCH EDITION - create a 'EE_DataChannel_t' targetChannelList */
//EE_DataChannel_t createDataChannelsList();
/* RESEARCH EDITION - create a 'const char*' channelNames */
//const char* createDataChannelNames();
/* DEV EDITION - initialize the struct members ( I actually don't know if it's actually required, but it's always nice to init parameters before setting values to them anyway ( ... ) */
void initializeEpocHeadsetStruct(unsigned int& userID, EpocHeadset_t& epocheadset);
/* RESEARCH EDITION - initialize the struct members */
void initializeEpocHeadsetStruct(unsigned int& userID, EpocHeadsetRaw_t& epocheadset);
/* TO DO - 'createInitializedEpocHeadsetStruct' & 'createInitializedEpocHeadsetRawStruct' */
/* DEV EDITION - handle fresh data from the Epoc headset, if connected, & update the passed 'EpocHeadset_struct' structure with that data */
void handleEvents(bool& connected, int& epoc_state, EmoEngineEventHandle& eEvent, EmoStateHandle& eState, unsigned int& userID, EpocHeadset_t& epocheadset);
/* RESEARCH EDITION - handle fresh data from the Epoc headset, if connected & data acquisition enabled, & update the passed 'EpocHeadsetRaw_struct' structure with that data */
// the one used until wip the alt one:
void handleEvents(bool& connected, bool& dataAcquisitionEnabled, int& epoc_state, EmoEngineEventHandle& eEvent, EmoStateHandle& eState, DataHandle& hData, unsigned int& userID, EpocHeadsetRaw_t& epocheadset);
//void handleEvents(bool& connected, bool& dataAcquisitionEnabled, int& epoc_state, EmoEngineEventHandle& eEvent, EmoStateHandle& eState, DataHandle& hData, unsigned int& userID, EpocHeadsetRaw_t& epocheadset, EE_DataChannel_t& targetChannelList, const char*& channelNames );
//void handleEvents(bool& connected, bool& dataAcquisitionEnabled, bool& dataHandleIsSet, bool& bufferSizeIsSet, int& epoc_state, EmoEngineEventHandle& eEvent, EmoStateHandle& eState, DataHandle& hData, float& bufferSize, unsigned int& userID, EpocHeadsetRaw_t& epocheadset, EE_DataChannel_t& targetChannelList, const char*& channelNames);
void handleEvents(bool& connected, bool& dataAcquisitionEnabled, bool& dataHandleIsSet, bool& bufferSizeIsSet, int& epoc_state, EmoEngineEventHandle& eEvent, EmoStateHandle& eState, DataHandle& hData, float& bufferSize, unsigned int& userID, EpocHeadsetRaw_t& epocheadset, EE_DataChannel_t targetChannelList[], const char* channelNames[]);
/* TO DO - even just to know how to do it - ~same fcn as above but accept a 'fcn&' as last argument, to wich it 'd pass a struct/class when done processing new events ( if any ) */
}
#endif // epocutils_h