-
Notifications
You must be signed in to change notification settings - Fork 0
/
device-data-thread.cpp
61 lines (50 loc) · 1.68 KB
/
device-data-thread.cpp
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
#include <nan.h>
#include <device.hpp>
#include <device-data-thread.hpp>
bool DeviceData::update = false;
bool DeviceData::connecting = false;
std::string DeviceData::portName = "none";
unsigned char DeviceData::poorSignal = 0;
unsigned char DeviceData::attention = 0;
unsigned char DeviceData::meditation = 0;
int DeviceData::EEGData::delta = 0;
int DeviceData::EEGData::theta = 0;
int DeviceData::EEGData::lowAlpha = 0;
int DeviceData::EEGData::highAlpha = 0;
int DeviceData::EEGData::lowBeta = 0;
int DeviceData::EEGData::highBeta = 0;
int DeviceData::EEGData::lowGamma = 0;
int DeviceData::EEGData::midGamma = 0;
void DeviceData::reset(){
// Icky looking piece of duplication this.
DeviceData::update = false;
DeviceData::connecting = false;
DeviceData::portName = "none";
DeviceData::poorSignal = 0;
DeviceData::attention = 0;
DeviceData::meditation = 0;
DeviceData::EEGData::delta = 0;
DeviceData::EEGData::theta = 0;
DeviceData::EEGData::lowAlpha = 0;
DeviceData::EEGData::highAlpha = 0;
DeviceData::EEGData::lowBeta = 0;
DeviceData::EEGData::highBeta = 0;
DeviceData::EEGData::lowGamma = 0;
DeviceData::EEGData::midGamma = 0;
};
/*
Initialised inline. See header.
DeviceDataThread::DeviceDataThread(NanCallback* callback, Mindwave* mindwaveDevice){};
*/
DeviceDataThread::~DeviceDataThread(){};
void DeviceDataThread::Execute(){
readPorts?
localDeviceReference -> readPorts(localDeviceReference):
localDeviceReference -> readDevice(localDeviceReference);
}
void DeviceDataThread::HandleOKCallback(){
NanScope();
v8::Local<v8::Value> argv[] = { NanNew<v8::Boolean>(DeviceData::update) };
callback -> Call(1, argv);
}
// Will use the default NAN HandleErrorCallback for now.