Skip to content

Commit

Permalink
fix windows thread problem
Browse files Browse the repository at this point in the history
  • Loading branch information
mjoppich committed Apr 6, 2017
1 parent 0411171 commit 8634ed7
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 40 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if (WIN32)
message(STATUS ">>> WIN32")
set(ENV{LUA_DIR} "D:/libraries/lua-5.3.3/;C:/lua53/")
message(STATUS "IN MINGW")
set(Qt5_DIR "C:/Qt/Qt5.7.0/5.7/mingw53_32;C:/Qt/5.7/mingw53_32")
set(Qt5_DIR "C:/Qt/5.8/mingw53_32;C:/Qt/5.8/mingw53_32")
set(ENV{OPENSSL_ROOT_DIR} "C:/OpenSSL-Win32/lib/")

endif()
Expand Down
6 changes: 3 additions & 3 deletions doc/biogui_idea.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
How does bioGUI work?
*********************

*bioGUI* heavily relies on the philosophy that everything is a network.
*bioGUI* relies on the philosophy that the visual appearance as well as the assembly of the command line arguments can be represented as a network.
Especially templates are seen as network, both in their visual description but most importantly also in the execution model.

.. _biogui_install_modules :
Expand Down Expand Up @@ -145,7 +145,7 @@ Finally we can send the template to *bioGUI*, if an IP address and port have bee
Make sure to use ``nc`` to send the content, as this will not work on Mac OS otherwise.
In order to customize the template inbetween the ``EOF``, bash variables to be replaced must be written as ``${var-name}``.
This conflicts with how *bioGUI* expects variables. Therefore make sure to escape the backslaash where you want to access variables in the *bioGUI* template!
This conflicts with how *bioGUI* expects variables. Therefore, make sure to escape the backslaash where you want to access variables in the *bioGUI* template!
bioGUI Templates
================
Expand Down Expand Up @@ -248,7 +248,7 @@ The idea is again based on a network of predefined nodes.
The nodes can either be visual components, accessed by their respective **id**, or :ref:`biogui_execution_nodes` .
Upon starting an application with *bioGUI*, the execution network is responsible to construct the command line arguments with which the target application is called.
Therefore all executable nodes in the ``<execution>`` part are searched and *evaluated* one after the other (if there exist several).
Therefore, all executable nodes in the ``<execution>`` part are searched and *evaluated* one after the other (if there exist several).
Since execution must be started via an ``action`` visual element, which can have a *program* attribute, this allows to specify which executable nodes are executed: if the ``program`` attribute is set, this must match with the ``program`` attribute of the executable node.
Finally an executable node is executed. Upon this the command line arguments are assembled. This is shown exemplarily in the below figure:
Expand Down
6 changes: 3 additions & 3 deletions doc/build_wsl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Step 2: Setup WSL

Despite the interest to hide any command line as much as possible from the user, the following initial setup can not be automised.
First a Command Prompt or better PowerShell must be started.
Therefore simply search for the *Windows PowerShell* in the start menu.
Search for the *Windows PowerShell* in the start menu.

.. image:: ./images/wsl/powershell.PNG
:scale: 30
Expand All @@ -41,8 +41,8 @@ However, before the download starts, first the user has to acknowledge that he w
:scale: 30

Finally, after *WSL* has been downloaded and extracted, *WSL* has to create a linux user account.
Therefore choose a username and password you can easily remember.
Remembering the password is essential here it will be needed for any installation one is performing on *WSL*.
It is recommended to choose a username and password you can easily remember.
Remembering the password is essential here, as it will be needed for any installation one is performing on *WSL*.

.. image:: ./images/wsl/powershell_setup_user.PNG
:scale: 30
Expand Down
Binary file modified doc/images/templates/existing_templates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/templates/template_submission.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions doc/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Mac OS

Download and open the provided dmg package. You can simply drag and drop the bioGUI.app into your Applications folder.
In order to productively use bioGUI, it may be required to install the OSX command line tools as well as brew.
Most (install) templates will require you to have wget and netcat install. Using brew installation is simple:
Most (install) templates will require you to have wget and netcat installed. Using brew installation is simple:

.. code:: bash
Expand All @@ -46,9 +46,10 @@ Downloading Templates


Part of *bioGUI* is a user-friendly accessibility of templates for various programs.
Therefore application developers and sophisticated users can upload their templates to our website in order to make their template available to other users.
Therefore, application developers and sophisticated users can upload their templates to our website in order to make their template available to other users.
The user has to submit his name, eMail address, a template name and the template itself.
He can select whether he wants to be an anonymous user (user name is always hidden) and whether this is an installation script (which downloads and creates the \ac{GUI} template specifically for this installed application) or a regular template.
Additionally, categories for the template can be supplied, e.g. whether this is a template for a sequencing tool, or proteomics.
A screenshot of the template submission is shown below.

.. image:: ./images/templates/template_submission.png
Expand All @@ -63,7 +64,7 @@ Available templates are only shown and can be downloaded via the *bioGUI* applic
Within *bioGUI*, clicking the *Download Templates* button, a new dialog window opens showing a list of available templates.
Columns can be sorted by double clicking the header, and using the search only templates which contain the searched words are shown.
Upon selecting one or multiple (keep ctrl-key down while clicking) rows and clicking the *Download* button, those templates are downloaded and available for the user.
Since it is possible to copy or alter templates, new templates are created at all times (no information is lost).
Since it is possible to copy or alter templates, *bioGUI* never overwrites existing templates, but will create a new copy.

.. image:: ./images/templates/biogui_selection.png
:scale: 50
Expand Down
2 changes: 1 addition & 1 deletion install_templates/install_wsl_first.igui
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo "Dependencies: build-essential dos2unix"
if [ ! "$2" = "" ]; then
echo "Installing dependencies"
echo $2 | sudo -S apt-get update
echo $2 | sudo -S apt-get -y install build-essential dos2unix
echo $2 | sudo -S apt-get -y install build-essential dos2unix unzip

echo "Enjoy bioGUI!"
else
Expand Down
13 changes: 10 additions & 3 deletions src/app/AdvancedStreamBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ Q_OBJECT
{

ExtendedProcessBuffer* pBuffer = oIt->second.at(i);
pBuffer->transferText("\n");

LOGERROR("Deleting PROC Buffer: " + std::to_string((uint64_t) pBuffer));

pBuffer->transferText("\n");
pBuffer->deleteLater();

}
Expand All @@ -272,7 +274,10 @@ Q_OBJECT
void finishThread( ExecuteThread* pThread )
{

std::cout << "finishing thread: " << pThread << std::endl;
LOGERROR("Finishing thread: " + std::to_string((uint64_t) pThread));

if (pThread == NULL)
return;


std::map<ExecuteThread*, std::vector<ExtendedThreadBuffer*> >::iterator oJt = m_mThreadToBuffer.find(pThread);
Expand Down Expand Up @@ -466,7 +471,9 @@ protected slots:
void receiveText(QString sString, QColor oColor, QString sStreamID)
{

std::cout << "received: " << sString.toStdString() << " for stream " << sStreamID.toStdString() << std::endl;
LOGERROR("AdvancedStreamBox received: " + std::to_string((uint64_t) this) + " for STREAM: " + sStreamID.toStdString());
LOGERROR( sString.toStdString() );
LOGERROR("RECEIVE END");

AdvancedListWidgetItem* pLastStream = this->getLastItemForStream(&sStreamID);

Expand Down
1 change: 1 addition & 0 deletions src/app/ExtendedThreadBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ExtendedThreadBuffer : public ExtendedStdBuffer {

if (this->m_pParentThread != NULL)
{
m_pParentThread->pThread->deleteLater();
delete m_pParentThread;
}

Expand Down
31 changes: 20 additions & 11 deletions src/app/ProcessLauncher.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define __BIOGUI__64
#endif

/*
class ProcessThread : public ExecuteThread
{
Expand Down Expand Up @@ -118,6 +119,8 @@ Q_OBJECT
};
*/

class ProcessLauncher : public QObject
{
Q_OBJECT
Expand All @@ -132,7 +135,7 @@ class ProcessLauncher : public QObject
{
m_pProcess = new QProcess();
} else {
m_pThread = NULL;//new ProcessThread(m_sProgram + " " + m_sParam);
//m_pThread = NULL;//new ProcessThread(m_sProgram + " " + m_sParam);
m_pProcess = new QProcess();
}
}
Expand Down Expand Up @@ -162,6 +165,8 @@ class ProcessLauncher : public QObject
return m_pProcess;
}

/*
ExecuteThread* getThread()
{
return NULL;
Expand All @@ -172,6 +177,8 @@ class ProcessLauncher : public QObject
return NULL;
}
*/

QString startBlocking(uint32_t iWaitMSec = 10000)
{
this->start();
Expand Down Expand Up @@ -259,23 +266,23 @@ class ProcessLauncher : public QObject
this->connect(m_pProcess, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
[pProcess, this](int exitCode, QProcess::ExitStatus exitStatus){

std::cerr << "Exit Code: " << exitCode << std::endl;
std::cerr << "Exit Status: " << exitStatus << std::endl;

std::string sError = pProcess->errorString().toStdString();
std::cerr << "Error: " << sError << std::endl;

std::string sProgram = pProcess->program().toStdString();
std::cerr << "Program: " << sProgram << std::endl;
LOGERROR( "Exit Code: " + std::to_string(exitCode) );
LOGERROR( "Exit Status: " + std::to_string(exitStatus) );
LOGERROR( "Error: " + pProcess->errorString().toStdString() );
LOGERROR( "Program: " + pProcess->program().toStdString() );

for (int i = 0; i < pProcess->arguments().size(); ++i)
{
std::string sArgument = pProcess->arguments().at(i).toStdString();

std::cerr << "Argument " << i << " : " << sArgument << std::endl;

LOGERROR( "Argument " + std::to_string(i) + ": " + pProcess->arguments().at(i).toStdString() );

}

std::cout << "finished: " << pProcess << std::endl;
LOGERROR( "Process ID: " + std::to_string(pProcess->processId()) );
LOGERROR( "Process: " + std::to_string((uint64_t) pProcess) );

emit this->finished();
});
Expand All @@ -294,8 +301,10 @@ public slots:

void executionFinished()
{
/*
if (m_pThread != NULL)
m_pThread->deleteLater();
*/

if (m_pProcess != NULL)
m_pProcess->deleteLater();
Expand Down Expand Up @@ -389,7 +398,7 @@ public slots:


QProcess* m_pProcess = NULL;
ProcessThread* m_pThread = NULL;
//ProcessThread* m_pThread = NULL;
bool m_bWindowsProcNoHandle = false;
QString m_sProgram;
QString m_sParam;
Expand Down
2 changes: 1 addition & 1 deletion src/app/TCPExtendedBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TCPExtendedBuffer : public ExtendedThreadBuffer
~TCPExtendedBuffer()
{

this->stopTransmissions();
//this->stopTransmissions();

m_pServer->deleteLater();

Expand Down
33 changes: 27 additions & 6 deletions src/bioGUIapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,38 @@ class bioGUIapp : public QApplication {
{

ExecutionNetwork* pNetwork = NULL;
ExecutionRunThread* pThread = NULL;

if (m_pExecThread != NULL)
{
LOGERROR("QUIT");
m_pExecThread->quit();
LOGERROR("WAIT");
m_pExecThread->wait();
LOGERROR("DELETE");
m_pExecThread->deleteLater();

m_pExecThread = NULL;
}


this->disableActions();

XMLParserExecution* pParseExecution = new XMLParserExecution();
std::string sCurrentFilePath = m_pWindowParser->getCurrentDocumentPath();
pParseExecution->initializeFile(sCurrentFilePath);

pThread = new ExecutionRunThread(m_pWindowParser, pParseExecution, sProgramToRun);
m_pExecThread = new ExecutionRunThread(m_pWindowParser, pParseExecution, sProgramToRun);
bioGUIapp* pApp = this;

this->connect(pThread, &QThread::started, pThread, &ExecutionRunThread::startExecution);
this->connect(pThread, &ExecutionRunThread::executionFinished, this, &bioGUIapp::programFinished);
this->connect(pThread, &ExecutionRunThread::executionFinished, pThread, &ExecutionRunThread::deleteLater);
this->connect(m_pExecThread, &QThread::started, m_pExecThread, &ExecutionRunThread::startExecution);
this->connect(m_pExecThread, &ExecutionRunThread::executionFinished, [pApp] () {

pThread->start();
pApp->programFinished();

});
//this->connect(pThread, &ExecutionRunThread::executionFinished, pThread, &ExecutionRunThread::deleteLater);

m_pExecThread->start();

}

Expand Down Expand Up @@ -380,6 +397,10 @@ public slots:
QString m_sDownloadServerLocation = "";


/** TEST PLAYGROUND **/
ExecutionRunThread* m_pExecThread = NULL;


};


Expand Down
4 changes: 2 additions & 2 deletions src/parsing/nodes/ExecutionExecuteNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ class ExecutionExecuteNode : public ExecutionExecutableNode {

ProcessLauncher* pLauncher = new ProcessLauncher(QString(sProgram.c_str()), QString(sCLArg.c_str()), bWSL);

this->evaluateChildren(pID2Node, pInputID2Value, pInputID2FunctionWidget, pLauncher->getProcess(), pLauncher->getThread(), false);
this->evaluateChildren(pID2Node, pInputID2Value, pInputID2FunctionWidget, pLauncher->getProcess(), NULL, false); //

pLauncher->connect(pLauncher, &ProcessLauncher::finished,
[pLauncher, pID2Node, pInputID2Value, pInputID2FunctionWidget, bEmitSignal, this](){

this->evaluateChildren(pID2Node, pInputID2Value, pInputID2FunctionWidget, pLauncher->getProcess(), pLauncher->getThread(), true);
this->evaluateChildren(pID2Node, pInputID2Value, pInputID2FunctionWidget, pLauncher->getProcess(), NULL, true);
pLauncher->deleteLater();

// calculation finished!
Expand Down
7 changes: 4 additions & 3 deletions src/parsing/nodes/ExecutionIfNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ class ExecutionIfNode : public ExecutionExecutableNode {
* Any method that needs value2
*
*/
std::cerr << "Val 1: " << sValue1 << std::endl;
std::cerr << "Val 2: " << sValue2 << std::endl;
std::cerr << "Evaluating else node: " << m_bEvaluateElse << std::endl;
LOGERROR("IF ID: " + m_sID);
LOGERROR("Val 1: " + sValue1);
LOGERROR("Val 2: " + sValue2);
LOGERROR("Go into Else? " + std::to_string(m_bEvaluateElse));

sReturn = this->evaluateChildren(pID2Node, pInputID2Value, pInputID2FunctionWidget, bEmitSignal);

Expand Down
2 changes: 2 additions & 0 deletions src/parsing/nodes/ExecutionNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class ExecutionNetwork : public QObject{

if (oIt == m_vExecNodes.end())
{
LOGERROR("EXECUTION FINISHED!")

emit executionFinished();
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/parsing/nodes/ExecutionOutputNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ class ExecutionOutputNode : public ExecutionDeferredNode {

} else {

LOGERROR("Deferred Output Node");

pTextEdit->finishProcess(pProcess);
pTextEdit->finishThread(pThread);

Expand Down
6 changes: 3 additions & 3 deletions templates/WSL_install.gui
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@
<const>&quot;</const>
</add>
<value from="addtopath"/>
<if comp="EQUALS" value1="templpath_sel" value2="true" sep=" ">
<if id="templpath_sel_if" comp="EQUALS" value1="templpath_sel" value2="true" sep=" ">
<value from="localip"/>
<const>33333</const>
</if>
</add>

<add id="template_path" sep="">
<if comp="EQUALS" value1="templpath_sel" value2="true">
<if id="script_else" comp="EQUALS" value1="templpath_sel" value2="true">
<script argv="${templpath},${loc_appdir}">
<![CDATA[
function evaluate(gvnPath, appdir)
Expand Down Expand Up @@ -121,7 +121,7 @@ end
<output id="outcout" type="COUT" color="green" to="outputstream1" />
<output id="outcout2" type="CERR" color="red" to="outputstream2" />
<output type="TCP" host="" port="33333" color="blue" to="savetemplate" />
<output deferred="true" type="FILE" from="template_path" to="savetemplate" />
<output deferred="true" type="FILE" from="${template_path}" to="savetemplate" />
</execute>

</execution>
Expand Down

0 comments on commit 8634ed7

Please sign in to comment.