MNE-CPP  beta 1.0
eegosportsproducer.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //*************************************************************************************************************
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
42 #include "eegosportsproducer.h"
43 #include "eegosports.h"
44 #include "eegosportsdriver.h"
45 
46 #include <QDebug>
47 
48 
49 //*************************************************************************************************************
50 //=============================================================================================================
51 // USED NAMESPACES
52 //=============================================================================================================
53 
54 using namespace EEGoSportsPlugin;
55 
56 
57 //*************************************************************************************************************
58 //=============================================================================================================
59 // DEFINE MEMBER METHODS
60 //=============================================================================================================
61 
63 : m_pEEGoSports(pEEGoSports)
64 , m_pEEGoSportsDriver(new EEGoSportsDriver(this))
65 , m_bIsRunning(true)
66 {
67 }
68 
69 
70 //*************************************************************************************************************
71 
73 {
74  //cout << "EEGoSportsProducer::~EEGoSportsProducer()" << endl;
75 }
76 
77 
78 //*************************************************************************************************************
79 
80 void EEGoSportsProducer::start(int iNumberOfChannels,
81  int iSamplingFrequency,
82  bool bUseChExponent,
83  bool bWriteDriverDebugToFile,
84  QString sOutputFilePath,
85  bool bMeasureImpedance)
86 {
87  //Initialise device
88  if(m_pEEGoSportsDriver->initDevice(iNumberOfChannels,
89  iSamplingFrequency,
90  bUseChExponent,
91  bWriteDriverDebugToFile,
92  sOutputFilePath,
93  bMeasureImpedance))
94  {
95  m_bIsRunning = true;
96  QThread::start();
97  }
98  else
99  m_bIsRunning = false;
100 }
101 
102 
103 //*************************************************************************************************************
104 
106 {
107  //Wait until this thread (EEGoSportsProducer) is stopped
108  m_bIsRunning = false;
109 
110  //In case the semaphore blocks the thread -> Release the QSemaphore and let it exit from the push function (acquire statement)
111  m_pEEGoSports->m_pRawMatrixBuffer_In->releaseFromPush();
112 
113  while(this->isRunning())
114  m_bIsRunning = false;
115 
116  //Unitialise device only after the thread stopped
117  m_pEEGoSportsDriver->uninitDevice();
118 }
119 
120 
121 //*************************************************************************************************************
122 
124 {
125  while(m_bIsRunning)
126  {
127  //std::cout<<"EEGoSportsProducer::run()"<<std::endl;
128  //Get the TMSi EEG data out of the device buffer and write received data to a QList
129  MatrixXf matRawBuffer;
130 
131  if(m_pEEGoSportsDriver->getSampleMatrixValue(matRawBuffer))
132  m_pEEGoSports->setSampleData(matRawBuffer);
133  }
134 
135  //std::cout<<"EXITING - EEGoSportsProducer::run()"<<std::endl;
136 }
137 
138 
Contains the declaration of the EEGoSports class.
The EEGoSportsDriver class provides real time data acquisition of EEG data with a TMSi Refa device...
void setSampleData(MatrixXf &matRawBuffer)
Definition: eegosports.cpp:502
Contains the declaration of the EEGoSportsDriver class. This class implements the basic communication...
virtual void start(int iNumberOfChannels, int iSamplingFrequency, bool bUseChExponent, bool bWriteDriverDebugToFile, QString sOutputFilePath, bool bMeasureImpedance)
EEGoSportsProducer(EEGoSports *pEEGoSports)
Contains the declaration of the EEGoSportsProducer class.
The EEGoSports class provides a EEG connector. In order for this plugin to work properly the driver d...
Definition: eegosports.h:120