Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
passing constructor to parent
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-kretschmerf committed Jan 31, 2017
1 parent 8870fd4 commit 2919a39
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 227 deletions.
226 changes: 0 additions & 226 deletions AudioGameGUI.pro.user

This file was deleted.

24 changes: 23 additions & 1 deletion StateMachineController.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "StateMachineController.h"

StateMachineController::StateMachineController(QObject *parent)
StateMachineController::StateMachineController(QObject *parent):
QObject(parent)
{
// seed randomizer
srand(time(0));
Expand Down Expand Up @@ -68,11 +69,21 @@ StateMachineController::StateMachineController(QObject *parent)
logFileThread = new QThread(this);
logFileWriter = new LogFileWriter();

socketThread = new QThread(this);
socketClient = new SocketClient();

/*Thread-safe event communication*/

/*Main -> Logfile*/
connect(this, SIGNAL(openLogFile(QString)), logFileWriter, SLOT(onOpen(QString)));
connect(this, SIGNAL(closeLogFile()), logFileWriter, SLOT(onClose()));
connect(this, SIGNAL(writeToLogFile(QString, uint, uint, QString)), logFileWriter, SLOT(onWrite(QString, uint, uint, QString)));
connect(nidaq, SIGNAL(writeToLogFile(QString, uint, uint, QString)), logFileWriter, SLOT(onWrite(QString, uint, uint, QString)));

/*Socket -> Logfile*/
connect(socketClient, SIGNAL(socketTrackingResult(QVector<double>)), logFileWriter, SLOT(onWriteTrackingResult(QVector<double>)));

socketClient->moveToThread(socketThread);
logFileWriter->moveToThread(logFileThread);
logFileThread->start();
}else{
Expand All @@ -85,8 +96,19 @@ StateMachineController::StateMachineController(QObject *parent)

StateMachineController::~StateMachineController()
{

if(logFileThread){
logFileThread->quit();
logFileThread->wait();
}
if(socketThread){
socketThread->quit();
socketThread->wait();
}

delete nidaq;
delete tdt;
delete logFileWriter;
}

void StateMachineController::startStateMachine(audioGameSettings settings)
Expand Down
3 changes: 3 additions & 0 deletions StateMachineController.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "TimerDialog.h"
#include "NIDAQmxInterface.h"
#include "TDTInterface.h"
#include "SocketClient.h"
#include "rpcoxlib.h"
#include "LogFileWriter.h"

Expand Down Expand Up @@ -45,6 +46,8 @@ class StateMachineController : public QObject
TimerDialog *timerDialog;
NIDAQmxInterface* nidaq;
TDTInterface* tdt;
SocketClient* socketClient;
QThread* socketThread;
QThread* logFileThread;
LogFileWriter* logFileWriter;

Expand Down

0 comments on commit 2919a39

Please sign in to comment.