BioSignalPi  v2
devicemanager.cpp
Go to the documentation of this file.
1 
2 #include <samplingthread.h>
3 #include "devicemanager.h"
4 #include "settingssingleton.h"
5 
6 #include <QDebug>
7 
8 
9 
11 
12 
13 
14 }
15 
17  delete device;
18 }
19 void DeviceManager::close(){
20  delete device;
21  device=NULL;
22 
23 }
24 
25  void DeviceManager::receiveSampleVector(QVector<QVector<QPointF> > input){
26 
27  emit sendSampleVector(input);
28  }
29  void DeviceManager::receiveStatus(QString input){
30  emit updateStatus(input);
31  }
32 
34 // while(device->connected()) {
35  device->init(stream);
36  device->getData(stream);
37 
38 // }
39  return;
40 }
41 
43 
44 
45  device->start();
46  emit updateStatus("Device Started");
47 }
48 
50  device->stop();
51 }
52 
53 void DeviceManager::init(int deviceNumber, DataStream& inputStream){
55  if (device!=NULL)
56  close();
57  if (deviceNumber==4) {
58  device=new EcgMock(inputStream);
59 
60  }else {
61  device=new SamplingThread(inputStream);
62 
63  }
64  QThread *sampleT = new QThread;
65  device->moveToThread(sampleT);
66  //device->init(inputStream);
67  connect(device, SIGNAL(updateStatus(QString)), this, SLOT(receiveStatus(QString)),Qt::QueuedConnection);
68  connect(device, SIGNAL(sendSampleVector(QVector<QVector<QPointF> >)), this, SLOT(receiveSampleVector(QVector<QVector<QPointF> >)),Qt::QueuedConnection);
69 
70 
71 }
72 
73 bool DeviceManager::connected(){
74  bool state;
75  return state;
76 }
void receiveStatus(QString)
Slot used to transfer updateStatus from initiated device to the local signal.
virtual void stop()=0
DeviceInterface Class responsible for sampling ECG.
DeviceInterface * device
The connected device.
Definition: devicemanager.h:33
void stop()
Stops the running device.
void collectData(DataStream &)
Collects data from the connected device.
static SettingsSingleton & instance()
Retrives a reference to the ONE and ONLY SettingsSingleton created for the application.
void sendSampleVector(QVector< QVector< QPointF > >)
Sends a QVector that can be used for a GUI to plot in "Real-time".
Abstract Interface that should be used for storing data in the memory.
Definition: datastream.h:16
void init(int, DataStream &)
Prepares a new data-collection,.
virtual void init(DataStream &)
Mock version of an device The EcgMock device will return sine and cosine functions as data...
Definition: ecgmock.h:21
int getSourceId()
Returns a int containing the value from private int sourceId.
virtual void getData(DataStream &)=0
void updateStatus(QString)
Information signal for updating status about progress.
void receiveSampleVector(QVector< QVector< QPointF > >)
Slot used to transfer sendSampleVector from initiated device to the local signal. ...
void startCapture()
Starts the initiated device through a call to start()