53 #include <QtCore/QtPlugin>
54 #include <QtCore/qmath.h>
66 #define BUFFERX1 // X1 determination
87 : m_pTriggerOutput(NULL)
90 , m_pDataSingleChannel(new dBuffer(1024))
103 int size = (int) qFloor(m_fs/m_refFreq);
104 m_refSin = VectorXd(size);
105 m_vecCorr = VectorXd(size);
106 for(
int i = 0; i < size; ++i)
107 m_refSin(i) = qSin(2*M_PI*m_refFreq*i*m_dt);
118 if(this->isRunning())
127 QSharedPointer<TriggerControl> pTriggerControlClone(
new TriggerControl);
128 return pTriggerControlClone;
142 connect(m_pRTMSAInput.data(), &PluginInputConnector::notify,
this, &
TriggerControl::update, Qt::DirectConnection);
156 m_pTriggerOutput->data()->setName(
"Dummy Output");
157 m_pTriggerOutput->data()->setUnit(
"");
158 m_pTriggerOutput->data()->setMinValue(-200);
159 m_pTriggerOutput->data()->setMaxValue(360);
160 m_pTriggerOutput->data()->setSamplingRate(256.0/1.0);
191 if(!m_pSerialPort->open())
192 std::cout <<
"Not able to open port - test" << std::endl;
207 if(m_pSerialPort->open())
211 m_pSerialPort->m_digchannel.replace(9,1);
213 m_pSerialPort->encodedig();
215 m_pSerialPort->sendData(m_pSerialPort->m_data);
219 std::cout <<
"data sent" << std::endl;
223 std::cout <<
"Sending not possible, please check settings" << std::endl;
236 m_pSerialPort->close();
238 m_bIsRunning =
false;
241 QThread::terminate();
244 m_pDataSingleChannel->clear();
249 if(m_pDataMatrixBuffer)
252 m_pDataMatrixBuffer->
clear();
258 for(
int i=0; i<m_vTimes.size(); i++)
261 QFile file(qApp->applicationDirPath()+
"/mne_x_plugins/resources/triggercontrol/t_meas.txt");
262 for(
int i=0; i<m_vTimes.size(); i++)
265 std::cout <<
"Average time: " << sum/m_vTimes.size() << std::endl;
266 std::cout <<
"Size m_vTimes: " << m_vTimes.size() << std::endl;
268 file.open(QIODevice::WriteOnly | QIODevice::Text);
269 QTextStream out(&file);
271 for(
int i=0; i<m_vTimes.size() ;i++)
272 out << m_vTimes[i] << endl;
298 return "Trigger Control";
338 if(!m_pDataMatrixBuffer)
372 int periodTime = (int)qFloor(1.0/m_alphaFreq * 1000);
433 msleep(periodTime-basisDelay-shift-10);
455 m_isReceived =
false;
463 m_vTimes.push_back(m_qTime.elapsed());
464 m_isReceived =
false;
479 bool t_bFound =
false;
490 if(t_bFound && m_pData.size() > 0)
510 if(m_pData.size() > 0)
512 if((!t_bFound) && (m_pData.first()[m_iNumChs-2] > x_u) && (m_pData.first()[m_iNumChs-2] < x_o))
536 emit sendByte(1, m_pSerialPort->m_wiredChannel);
538 emit sendByte(0, m_pSerialPort->m_wiredChannel);
688 m_pSerialPort->m_digchannel.replace(channel,0);
689 m_pSerialPort->encodedig();
690 m_pSerialPort->sendData(m_pSerialPort->m_data);
694 m_pSerialPort->m_digchannel.replace(channel,1);
695 m_pSerialPort->encodedig();
696 m_pSerialPort->sendData(m_pSerialPort->m_data);
712 double TriggerControl::corr(VectorXd a, VectorXd b)
714 VectorXd c = a.transpose()*b;
716 return c(0)/a.size();
OutputConnectorList m_outputConnectors
The SerialPort is a class which holds all properties and methods necesarry to open, communicate and close a serial port. In most cases you want to open the port, encode your output information (digital, analog or retrieve) and decode input information (digital or analog). When you are done, close the serial port.
The TriggerControl is a MNE-X plugin which contains an intuitive terminal for manual configurations o...
QSharedPointer< CircularMatrixBuffer > SPtr
Contains the declaration of the SerialPort class.
void sendByteTo(int value, int channel)
virtual QString getName() const
void updateSingleChannel(XMEASLIB::NewMeasurement::SPtr pMeasurement)
virtual QWidget * setupWidget()
virtual IPlugin::PluginType getType() const
QSharedPointer< NewMeasurement > SPtr
static QSharedPointer< PluginOutputData< T > > create(IPlugin *parent, const QString &name, const QString &descr)
InputConnectorList m_inputConnectors
The NewRealTimeSampleArray class is the base class of every NewRealTimeSampleArray Measurement...
Contains the declaration of the TriggerControl class.
virtual QSharedPointer< IPlugin > clone() const
void update(XMEASLIB::NewMeasurement::SPtr pMeasurement)
The RealTimeMultiSampleArrayNew class is the base class of every RealTimeMultiSampleArrayNew Measurem...