Enabled starting z-Tree instances again

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

@ -51,5 +51,4 @@ OTHER_FILES += \
data/Labcontrol.conf \ data/Labcontrol.conf \
data/scripts/kill_zLeaf_labcontrol2.sh \ data/scripts/kill_zLeaf_labcontrol2.sh \
data/scripts/start_zLeaf_labcontrol2.sh \ data/scripts/start_zLeaf_labcontrol2.sh \
data/scripts/start_zTree_labcontrol2.sh \
doc/manual.tex 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_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 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) # 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 dvips_command=/usr/bin/dvips
file_manager=/usr/bin/nautilus file_manager=/usr/bin/nautilus
# The port which shall be used by zTree by default # 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 # The IP of the server running zTree
server_ip=192.168.1.200 server_ip=192.168.1.200
ssh_command=/usr/bin/ssh ssh_command=/usr/bin/ssh
taskset_command=/usr/bin/taskset
terminal_emulator_command=/usr/bin/gnome-terminal terminal_emulator_command=/usr/bin/gnome-terminal
# The name of the user of the clients which is used to conduct experiments # The name of the user of the clients which is used to conduct experiments
user_name_on_clients=user user_name_on_clients=user
@ -50,6 +51,7 @@ vnc_viewer=/usr/bin/vinagre
wakeonlan_command=/usr/bin/wakeonlan wakeonlan_command=/usr/bin/wakeonlan
# URLs to available webcams # URLs to available webcams
webcams="webcam_left|webcam_right" webcams="webcam_left|webcam_right"
wine_command=/usr/bin/wine
wmctrl_command=/usr/bin/wmctrl wmctrl_command=/usr/bin/wmctrl
xset_command=/usr/bin/xset xset_command=/usr/bin/xset
# The folder were all zTree versions are installed (in subfolders matching the scheme zTree_X.Y.Z) # 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( " " ) ) ); debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] %1 %2" ).arg( program ).arg( arguments.join( " " ) ) );
} }
void lc::Lablib::StartNewZTreeInstance() { void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort,
if ( !QDir( chosenZTreeDataTargetPath ).exists() ) { QString argzTreeVersion,
bool argReceiptsForLocalClients,
QString argAnonReceiptPlaceholder,
QString argChosenLatexHeader ) {
if ( !QDir( argDataTargetPath ).exists() ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target path does not exist" ), 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(); messageBox.exec();
if ( messageBox.clickedButton() == messageBox.button( QMessageBox::No ) ) { if ( messageBox.clickedButton() == messageBox.button( QMessageBox::No ) ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory will not be created" ), QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory will not"
tr( "Your chosen data target directory does not exist and will not be created. Please chose another one." ), QMessageBox::Ok }; " be created" ),
tr( "Your chosen data target directory does not exist and"
" will not be created. Please choose another one." ),
QMessageBox::Ok };
messageBox.exec(); messageBox.exec();
return; return;
} } else {
else { if ( !QDir().mkpath( argDataTargetPath ) ) {
if ( !QDir().mkpath( chosenZTreeDataTargetPath ) ) { QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory could"
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory could not be created" ), " not be created" ),
tr( "Your chosen data target directory does not exist and could not be created. Please chose another one." ), QMessageBox::Ok }; tr( "Your chosen data target directory does not exist"
" and could not be created. Please choose another"
" one." ), QMessageBox::Ok };
messageBox.exec(); messageBox.exec();
return; return;
} }
} }
} }
try { try {
sessionsModel->push_back( new Session{ debugMessagesTextEdit, chosenZTreeDataTargetPath, sessionsModel->push_back( new Session{ debugMessagesTextEdit, argDataTargetPath,
chosenZTreePort, chosenZTreeVersion, argPort, argzTreeVersion,
PrintReceiptsForLocalClients, argReceiptsForLocalClients,
anonymousReceiptsPlaceholder, chosenLaTeXHeader } ); argAnonReceiptPlaceholder,
argChosenLatexHeader } );
occupiedPorts->append( sessionsModel->back()->zTreePort ); occupiedPorts->append( sessionsModel->back()->zTreePort );
} }
catch ( Session::lcDataTargetPathCreationFailed ) { catch ( Session::lcDataTargetPathCreationFailed ) {
QMessageBox::information( nullptr, tr( "Chosen data target path could not be created" ), 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." ) tr( "The path specified by your chosen data target path '%1'"
.arg( chosenZTreeDataTargetPath ) ); " 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 SetUserNameOnServer( const QString &argUserName );
void ShowOrsee(); void ShowOrsee();
void ShowPreprints(); void ShowPreprints();
void StartNewZTreeInstance();
public slots:
void StartNewZTreeInstance( QString argDataTargetPath, int argPort, QString argzTreeVersion,
bool argReceiptsForLocalClients, QString argAnonReceiptPlaceholder,
QString argChosenLatexHeader );
signals: signals:
void ZLEAF_RUNNING( QString argClientIP ); void ZLEAF_RUNNING( QString argClientIP );

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

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

@ -27,15 +27,22 @@ extern std::unique_ptr< lc::Settings > settings;
lc::ZTree::ZTree( QPlainTextEdit *argDebugMessagesTextEdit, lc::ZTree::ZTree( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const int &argZTreePort, const QString &argZTreeDataTargetPath, const int &argZTreePort,
const QString &argZTreeVersionPath ) { const QString &argZTreeVersionPath ) {
QString program{ settings->lcInstDir + "/scripts/start_zTree_labcontrol2.sh" }; QString program{ settings->tasksetCmd };
QStringList arguments; QStringList arguments{ QStringList{} << "0x00000001" << settings->wineCmd
arguments << settings->zTreeInstDir << argZTreeVersionPath << argZTreeDataTargetPath << QString{ settings->zTreeInstDir + "/zTree_"
<< QString::number( static_cast< int >( argZTreePort ) - 7000 ); + 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(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
zTreeInstance.setProcessEnvironment( env ); zTreeInstance.setProcessEnvironment( env );
zTreeInstance.startDetached( program, arguments, QDir::currentPath(), &pid ); 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 // Output message via the debug messages tab
argDebugMessagesTextEdit->appendPlainText( "[DEBUG] " + program + " " + arguments.join( " " ) ); 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 *sessionStarter = new SessionStarter{ lablib, ui->PTEDebugMessages, this };
sessionStarter->setWindowFlags( Qt::Window ); sessionStarter->setWindowFlags( Qt::Window );
sessionStarter->show(); sessionStarter->show();
connect( sessionStarter, &SessionStarter::SessionRequested,
lablib, &Lablib::StartNewZTreeInstance );
connect( sessionStarter, &SessionStarter::destroyed, connect( sessionStarter, &SessionStarter::destroyed,
sessionStarter, &SessionStarter::deleteLater ); sessionStarter, &SessionStarter::deleteLater );
// // Show an error message, if no zTree version was chosen yet // // 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 ); 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() { void lc::SessionStarter::on_SBPort_editingFinished() {
ui->SBPort->setStyleSheet( "" ); ui->SBPort->setStyleSheet( "" );
lablib->SetChosenZTreePort( ui->SBPort->value() ); lablib->SetChosenZTreePort( ui->SBPort->value() );

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

Loading…
Cancel
Save