BioSignalPi  v2
ecgcapturemenu.cpp
Go to the documentation of this file.
1 #include "ecgcapturemenu.h"
2 #include "settingsmenu.h"
3 #include "../settingssingleton.h"
4 #include <chrono>
5 #include <thread>
6 #include "pifacecad.h"
7 
9 {
10  options={"Settings", "Start"};
12  device=new DeviceManager();
13  stream=new DataStream();
15  device->init(0, *stream);
16 
17  QThread *sampleT = new QThread;
18  device->moveToThread(sampleT);
19 
20 }
23  switch (currentOption){
24  case 0:
25  setUpperText();
26  newMenu=new SettingsMenu;
27  break;
28 
29  case 1:
30  setUpperText("Stop");
31  device->start();
32  while(true) {
33  std::this_thread::sleep_for(std::chrono::milliseconds(300)); // IMPORTANT if not using this time-out the read_switch fucntion would read a push more then once.
34  if(!pifacecad_read_switch(5)) {
35  device->stop();
36  logger->save(*stream);
37  break;
38  }
39  }
40 
41  }
42  return newMenu;
43 
44 
45 }
46 
47 
48 
void setSourceId(int sourceId)
Used to set private int name.
void stop()
Stops the running device.
Abstract menu object for PiFace CAD.
Definition: abstractmenu.h:17
static SettingsSingleton & instance()
Retrives a reference to the ONE and ONLY SettingsSingleton created for the application.
int numberOfOptions
number of elements stored in the options vector. To be set by the derived AbstractMenu object ...
Definition: abstractmenu.h:76
void save(DataStream &input)
Saves the input to a txt-file, header-file and edf-file(if bool saveAsEdf in SettingsSingleton) ...
Definition: datalogger.cpp:21
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,.
std::vector< std::string > options
std::vector containing the different options to display on the PiFace CAD To be set by the derived Ab...
Definition: abstractmenu.h:70
virtual AbstractMenu * newMenu()
Enter SettingsMenu for case 0 and starts DeviceManager and EcgCapture for case 1. ...
The SettingsMenu class for the PiFace GUI.
Definition: settingsmenu.h:10
virtual void setUpperText()
Sets the first row of the PiFace CAD to the current option choosen Uses the C library pifacecad...
Definition: abstractmenu.cpp:9
Handles which device to connect through the DeviceInterface.
Definition: devicemanager.h:23
int currentOption
Counter that keeps track of the option visible on the PiFace CAD.
Definition: abstractmenu.h:82