Enabled starting z-Tree instances again

remotes/origin/HEAD
markuspg 8 years ago
parent 18b42ef0af
commit 6c0c5d012b

@ -51,5 +51,4 @@ OTHER_FILES += \
data/Labcontrol.conf \
data/scripts/kill_zLeaf_labcontrol2.sh \
data/scripts/start_zLeaf_labcontrol2.sh \
data/scripts/start_zTree_labcontrol2.sh \
doc/manual.tex

@ -17,7 +17,7 @@ client_quantity=24
client_xpos=1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24
client_ypos=1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1
# If multiple receipts are availabe, this indicates, which one will be shown by default (the index counting from 0 following an alphabetical ordering)
default_receipt_index=1
default_receipt_index=0
dvips_command=/usr/bin/dvips
file_manager=/usr/bin/nautilus
# The port which shall be used by zTree by default
@ -43,6 +43,7 @@ scp_command=/usr/bin/scp
# The IP of the server running zTree
server_ip=192.168.1.200
ssh_command=/usr/bin/ssh
taskset_command=/usr/bin/taskset
terminal_emulator_command=/usr/bin/gnome-terminal
# The name of the user of the clients which is used to conduct experiments
user_name_on_clients=user
@ -50,6 +51,7 @@ vnc_viewer=/usr/bin/vinagre
wakeonlan_command=/usr/bin/wakeonlan
# URLs to available webcams
webcams="webcam_left|webcam_right"
wine_command=/usr/bin/wine
wmctrl_command=/usr/bin/wmctrl
xset_command=/usr/bin/xset
# The folder were all zTree versions are installed (in subfolders matching the scheme zTree_X.Y.Z)

@ -1,3 +0,0 @@
#!/bin/bash
/usr/bin/wine32 $1/$2/ztree.exe /datadir Z:/$3 /privdir Z:/$3 /gsfdir Z:/$3 /tempdir Z:/$3 /leafdir Z:/$3 /channel $4 &

@ -329,37 +329,51 @@ void lc::Lablib::ShowPreprints() {
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] %1 %2" ).arg( program ).arg( arguments.join( " " ) ) );
}
void lc::Lablib::StartNewZTreeInstance() {
if ( !QDir( chosenZTreeDataTargetPath ).exists() ) {
void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort,
QString argzTreeVersion,
bool argReceiptsForLocalClients,
QString argAnonReceiptPlaceholder,
QString argChosenLatexHeader ) {
if ( !QDir( argDataTargetPath ).exists() ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target path does not exist" ),
tr( "Your chosen data target path does not exist. Do you want it to be created automatically?" ), QMessageBox::Yes | QMessageBox::No };
tr( "Your chosen data target path does not exist."
" Do you want it to be created automatically?" ),
QMessageBox::Yes | QMessageBox::No };
messageBox.exec();
if ( messageBox.clickedButton() == messageBox.button( QMessageBox::No ) ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory will not be created" ),
tr( "Your chosen data target directory does not exist and will not be created. Please chose another one." ), QMessageBox::Ok };
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory will not"
" be created" ),
tr( "Your chosen data target directory does not exist and"
" will not be created. Please choose another one." ),
QMessageBox::Ok };
messageBox.exec();
return;
}
else {
if ( !QDir().mkpath( chosenZTreeDataTargetPath ) ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory could not be created" ),
tr( "Your chosen data target directory does not exist and could not be created. Please chose another one." ), QMessageBox::Ok };
} else {
if ( !QDir().mkpath( argDataTargetPath ) ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory could"
" not be created" ),
tr( "Your chosen data target directory does not exist"
" and could not be created. Please choose another"
" one." ), QMessageBox::Ok };
messageBox.exec();
return;
}
}
}
try {
sessionsModel->push_back( new Session{ debugMessagesTextEdit, chosenZTreeDataTargetPath,
chosenZTreePort, chosenZTreeVersion,
PrintReceiptsForLocalClients,
anonymousReceiptsPlaceholder, chosenLaTeXHeader } );
sessionsModel->push_back( new Session{ debugMessagesTextEdit, argDataTargetPath,
argPort, argzTreeVersion,
argReceiptsForLocalClients,
argAnonReceiptPlaceholder,
argChosenLatexHeader } );
occupiedPorts->append( sessionsModel->back()->zTreePort );
}
catch ( Session::lcDataTargetPathCreationFailed ) {
QMessageBox::information( nullptr, tr( "Chosen data target path could not be created" ),
tr( "The path specified by your chosen data target path '%1' could not be created. Please check if it is a valid location and you have all needed permissions." )
.arg( chosenZTreeDataTargetPath ) );
tr( "The path specified by your chosen data target path '%1'"
" could not be created. Please check if it is a valid"
" location and you have all needed permissions." )
.arg( argDataTargetPath ) );
}
}

@ -145,7 +145,11 @@ public:
void SetUserNameOnServer( const QString &argUserName );
void ShowOrsee();
void ShowPreprints();
void StartNewZTreeInstance();
public slots:
void StartNewZTreeInstance( QString argDataTargetPath, int argPort, QString argzTreeVersion,
bool argReceiptsForLocalClients, QString argAnonReceiptPlaceholder,
QString argChosenLatexHeader );
signals:
void ZLEAF_RUNNING( QString argClientIP );

@ -59,6 +59,9 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) :
sshCmd{ ReadSettingsItem( "ssh_command",
"All actions concerning the clients will not be possible.",
argSettings, true ) },
tasksetCmd{ ReadSettingsItem( "taskset_command",
"Running z-Leaves or z-Tree will be possible.",
argSettings, true ) },
termEmulCmd{ ReadSettingsItem( "terminal_emulator_command",
"Conducting administrative tasks will not be possible.",
argSettings, true ) },
@ -71,6 +74,9 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) :
wakeonlanCmd{ ReadSettingsItem( "wakeonlan_command",
"Booting the clients will not work.",
argSettings, true ) },
wineCmd{ ReadSettingsItem( "wine_command",
"Running z-Leaves or z-Tree will be possible.",
argSettings, true ) },
wmctrlCmd{ ReadSettingsItem( "wmctrl_command",
"Setting zTree's window title to its port number will not work.",
argSettings, true ) },

@ -38,10 +38,12 @@ public:
const QString scpCmd;
const QString serverIP;
const QString sshCmd;
const QString tasksetCmd;
const QString termEmulCmd;
const QString userNameOnClients;
const QString vncViewer;
const QString wakeonlanCmd;
const QString wineCmd;
const QString wmctrlCmd;
const QString xsetCmd;
const QString zTreeInstDir;

@ -27,15 +27,22 @@ extern std::unique_ptr< lc::Settings > settings;
lc::ZTree::ZTree( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const int &argZTreePort,
const QString &argZTreeVersionPath ) {
QString program{ settings->lcInstDir + "/scripts/start_zTree_labcontrol2.sh" };
QStringList arguments;
arguments << settings->zTreeInstDir << argZTreeVersionPath << argZTreeDataTargetPath
<< QString::number( static_cast< int >( argZTreePort ) - 7000 );
QString program{ settings->tasksetCmd };
QStringList arguments{ QStringList{} << "0x00000001" << settings->wineCmd
<< QString{ settings->zTreeInstDir + "/zTree_"
+ argZTreeVersionPath + "/ztree.exe" }
<< "/datadir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/privdir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/gsfdir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/tempdir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/leafdir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/channel" << QString::number( argZTreePort - 7000 ) };
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
zTreeInstance.setProcessEnvironment( env );
zTreeInstance.startDetached( program, arguments, QDir::currentPath(), &pid );
connect( &zTreeInstance, SIGNAL( finished( int ) ), SLOT( ZTreeInstanceClosed() ) );
connect( &zTreeInstance, SIGNAL( finished( int ) ),
this, SLOT( ZTreeInstanceClosed() ) );
// Output message via the debug messages tab
argDebugMessagesTextEdit->appendPlainText( "[DEBUG] " + program + " " + arguments.join( " " ) );

@ -557,6 +557,8 @@ void lc::MainWindow::on_PBStartzTree_clicked() {
SessionStarter *sessionStarter = new SessionStarter{ lablib, ui->PTEDebugMessages, this };
sessionStarter->setWindowFlags( Qt::Window );
sessionStarter->show();
connect( sessionStarter, &SessionStarter::SessionRequested,
lablib, &Lablib::StartNewZTreeInstance );
connect( sessionStarter, &SessionStarter::destroyed,
sessionStarter, &SessionStarter::deleteLater );
// // Show an error message, if no zTree version was chosen yet

@ -95,6 +95,15 @@ void lc::SessionStarter::on_ChBReceiptsforLocalClients_clicked( bool checked ) {
lablib->SetPrintReceiptsForLocalClients( checked );
}
void lc::SessionStarter::on_PBStartzTree_clicked() {
emit SessionRequested( ui->CBDataTargetPath->currentText(), ui->SBPort->value(),
ui->CBzTreeVersion->currentText(),
ui->ChBReceiptsforLocalClients->isChecked(),
ui->CBReplaceParticipantName->currentText(),
ui->CBReceiptsHeader->currentText() );
close();
}
void lc::SessionStarter::on_SBPort_editingFinished() {
ui->SBPort->setStyleSheet( "" );
lablib->SetChosenZTreePort( ui->SBPort->value() );

@ -43,6 +43,11 @@ public:
//! (because no installed z-Tree instances could be detected).
class lcForbiddenCall {};
signals:
void SessionRequested( QString argDataTargetPath, int argPort, QString argzTreeVersion,
bool argReceiptsForLocalClients, QString argAnonReceiptPlaceholder,
QString argChosenLatexHeader );
private:
QPlainTextEdit * const debugMessagesTextEdit = nullptr;
Lablib * const lablib = nullptr;
@ -59,6 +64,7 @@ private slots:
void on_CBzTreeVersion_activated(const QString &arg1);
void on_ChBPrintanonymousreceipts_clicked( bool checked );
void on_ChBReceiptsforLocalClients_clicked(bool checked);
void on_PBStartzTree_clicked();
void on_SBPort_editingFinished();
signals:

Loading…
Cancel
Save