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

Commit

Permalink
Added error message when TDT device fails to initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-kretschmerf committed Jan 3, 2017
1 parent 1449430 commit fa1d47b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
27 changes: 15 additions & 12 deletions StateMachineController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,21 @@ StateMachineController::StateMachineController(QObject *parent)
// nidaq->DAQmxInitializeInterface();

tdt = new TDTInterface();
tdt->initializeInterface();

logFileThread = new QThread(this);
logFileWriter = new LogFileWriter();

/*Thread-safe event communication*/
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)));
logFileWriter->moveToThread(logFileThread);
logFileThread->start();
if(!tdt->initializeInterface()){
logFileThread = new QThread(this);
logFileWriter = new LogFileWriter();

/*Thread-safe event communication*/
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)));
logFileWriter->moveToThread(logFileThread);
logFileThread->start();
}else{
QMessageBox messageBox;
messageBox.critical(0,"Error","Unable to initialize TDT audio interface!");
}


}
Expand Down
1 change: 1 addition & 0 deletions StateMachineController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QHistoryState>
#include <QDebug>
#include <QTime>
#include <QMessageBox>

#include <ctime>
#include <algorithm> //std::random_shuffle
Expand Down
6 changes: 3 additions & 3 deletions TDTInterface.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "TDTInterface.h"

/* initialize TDT Sound System */
void TDTInterface::initializeInterface()
int TDTInterface::initializeInterface()
{

/* connect to RP2 system */
if (!rp.ConnectRP2("USB", 1))
{
fprintf(stderr, "TDTError:TDTInterface/TDTInitializeInterface:\n\tfailed to connect to RP2!\n");
exit(EXIT_FAILURE);
return(EXIT_FAILURE);
}

/* check status */
Expand All @@ -28,7 +28,7 @@ void TDTInterface::initializeInterface()
rp.ClearCOF();
}

return;
return 0;
}

/* destroy TDT Engine */
Expand Down
2 changes: 1 addition & 1 deletion TDTInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TDTInterface
static const int TDT_STATUS_CIRCUIT_RUNNING = 0x04;

/* funciton prototypes */
void initializeInterface();
int initializeInterface();
void loadRCXCircuit(QString fileName);
void destroyInterface();

Expand Down

0 comments on commit fa1d47b

Please sign in to comment.