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

Commit

Permalink
Automated filename is now set when run experiment is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-kretschmerf committed Feb 10, 2017
1 parent 7a6af0b commit 2ef5d3e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
43 changes: 27 additions & 16 deletions Mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ void MainWindow::on_pushButton_Run_clicked()
settings.fileNameNegative = ui->lineEdit_fileNegative->text();
settings.fileNamePositive = ui->lineEdit_filePositive->text();
settings.licksToReward = ui->lineEdit_licksToReward->text().toInt();

if(ui->checkBox_autoFilename->isChecked()){
generateAutoFileName();
}
settings.logFileName = ui->lineEdit_outputFolder->text() + "/" + ui->lineEdit_outputFilename->text() + ".csv";


Expand Down Expand Up @@ -144,22 +148,7 @@ void MainWindow::on_checkBox_autoFilename_clicked(bool checked)
{
// auto option checked
if(checked) {
time_t rawtime;
struct tm * timeinfo;
// ensure buffer is big enought
char buffer[42];

// current date/time based on current system
time(&rawtime);
// convert now to string form
timeinfo = localtime(&rawtime);

// write date/time info into formatted string
strftime(buffer,42,"%Y%m%d%H%M%S_AudioGame_events",timeinfo);
QString autoFilename(buffer);

// write to input field and disable it
ui->lineEdit_outputFilename->setText(autoFilename);
ui->lineEdit_outputFilename->setText("YYYYMMDDhhmmss_AudioGame_events");
ui->lineEdit_outputFilename->setDisabled(true);
} else {
// clear input field and enable it
Expand Down Expand Up @@ -222,6 +211,9 @@ void MainWindow::onStateMachineTerminated()
{
ui->pushButton_Run->setText("Run");
ui->pushButton_Run->setDisabled(false);
if(ui->checkBox_autoFilename->isChecked()){
ui->lineEdit_outputFilename->setText("YYYYMMDDhhmmss_AudioGame_events");
}
}

void MainWindow::onStatusMessage(QString statusMessage)
Expand Down Expand Up @@ -249,6 +241,25 @@ void MainWindow::updateIti()
}
}

void MainWindow::generateAutoFileName()
{
time_t rawtime;
struct tm * timeinfo;
// ensure buffer is big enought
char buffer[42];

// current date/time based on current system
time(&rawtime);
// convert now to string form
timeinfo = localtime(&rawtime);

// write date/time info into formatted string
strftime(buffer,42,"%Y%m%d%H%M%S_AudioGame_events",timeinfo);

// write to input field and disable it
ui->lineEdit_outputFilename->setText(QString(buffer));
}

void MainWindow::on_pushButton_about_clicked()
{
AboutDialog* aboutDialog = new AboutDialog(this);
Expand Down
1 change: 1 addition & 0 deletions Mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private slots:
StateMachineController smc;

void updateIti();
void generateAutoFileName();
const double userReaction = 30; //sec

const QString DEFAULT_DIR_KEY = "/home";
Expand Down

0 comments on commit 2ef5d3e

Please sign in to comment.