Commit 216961a1 authored by Renne Thomas's avatar Renne Thomas
Browse files

get Work Status on msIdListThread

parent 3ec75997
......@@ -27,33 +27,55 @@
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/exception/exceptionnotfound.h>
#include <unistd.h>
#include "msidlistworkerthread.h"
#include <gui/lists/ms_identification_run_list_view/msidentificationtablemodel.h>
MsIdListWorkerStatus::MsIdListWorkerStatus()
MsIdListWorkerStatus::MsIdListWorkerStatus(MsIdListWorkerThread *worker)
{
connect(this,
&MsIdListWorkerStatus::computeMsNumber,
worker,
&MsIdListWorkerThread::doComputeMsNumber);
connect(worker,
&MsIdListWorkerThread::MsNumberComputing,
this,
&MsIdListWorkerStatus::setRunningIdData);
}
MsIdListWorkerStatus::~MsIdListWorkerStatus()
{
}
bool
MsIdListWorkerStatus::isWorking(
WorkerStatus
MsIdListWorkerStatus::getStatus(
IdentificationDataSourceSp identificationDataSource)
{
if(std::find(list_idSources.begin(),
list_idSources.end(),
identificationDataSource) != list_idSources.end())
if(std::find(m_list_idSources.begin(),
m_list_idSources.end(),
identificationDataSource) != m_list_idSources.end())
{
return true;
if(identificationDataSource == m_runningIdData)
{
return WorkerStatus::Running;
}
else
{
return WorkerStatus::Waiting;
}
}
else
{
return false;
emit computeMsNumber(identificationDataSource);
m_list_idSources.push_back(identificationDataSource);
return WorkerStatus::Waiting;
}
return WorkerStatus::Waiting;
}
void
MsIdListWorkerStatus::setWorking(
MsIdListWorkerStatus::setRunningIdData(
IdentificationDataSourceSp identificationDataSource)
{
list_idSources.push_back(identificationDataSource);
m_runningIdData = identificationDataSource;
}
......@@ -26,19 +26,39 @@
#include <QObject>
#include "core/msrun.h"
#include "../msidentificationtablemodel.h"
#include "core/identification_sources/identificationdatasource.h"
class MsIdentificationTableModel;
enum class WorkerStatus : std::int8_t
{
Running = 0,
Waiting = 1,
Nothing = 2,
};
class MsIdListWorkerThread;
class MsIdListWorkerStatus : public QObject
{
Q_OBJECT
public:
MsIdListWorkerStatus();
MsIdListWorkerStatus(MsIdListWorkerThread *worker);
virtual ~MsIdListWorkerStatus();
bool isWorking(IdentificationDataSourceSp identificationDataSource);
void setWorking(IdentificationDataSourceSp identificationDataSource);
WorkerStatus getStatus(IdentificationDataSourceSp identificationDataSource);
public slots:
void setRunningIdData(IdentificationDataSourceSp identificationDataSource);
signals:
void
computeMsNumber(IdentificationDataSourceSp identificationDataSource) const;
protected:
IdentificationDataSourceSp m_runningIdData;
private:
std::vector<IdentificationDataSourceSp> list_idSources;
std::vector<IdentificationDataSourceSp> m_list_idSources;
};
......@@ -27,15 +27,14 @@
*implementation
******************************************************************************/
#include <tuple>
#include "msidlistworkerthread.h"
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/exception/exceptionnotfound.h>
#include <unistd.h>
MsIdListWorkerThread::MsIdListWorkerThread(MsIdentificationTableModel *parent)
MsIdListWorkerThread::MsIdListWorkerThread()
{
}
MsIdListWorkerThread::~MsIdListWorkerThread()
{
}
......@@ -44,21 +43,12 @@ void
MsIdListWorkerThread::doComputeMsNumber(
IdentificationDataSourceSp identificationDataSource)
{
if(std::find(m_vectorWorking.begin(),
m_vectorWorking.end(),
identificationDataSource.get()) != m_vectorWorking.end())
{
qDebug() << " TEST";
emit MsNumberComputed();
}
else
emit MsNumberComputing(identificationDataSource);
if(identificationDataSource->getMsRunSp()->findMsRunFile())
{
m_vectorWorking.push_back(identificationDataSource.get());
if(identificationDataSource->getMsRunSp()->findMsRunFile())
{
identificationDataSource->getMsRunSp()->checkMsRunStatistics();
}
identificationDataSource->getMsRunSp()->freeMsRunReaderSp();
identificationDataSource->getMsRunSp()->checkMsRunStatistics();
}
identificationDataSource->getMsRunSp()->freeMsRunReaderSp();
emit MsNumberComputed();
}
......@@ -33,7 +33,7 @@ class MsIdListWorkerThread : public QObject
Q_OBJECT
public:
MsIdListWorkerThread(MsIdentificationTableModel *parent);
MsIdListWorkerThread();
virtual ~MsIdListWorkerThread();
public slots:
......@@ -41,6 +41,7 @@ class MsIdListWorkerThread : public QObject
signals:
void MsNumberComputed();
void MsNumberComputing(IdentificationDataSourceSp identificationDataSource);
private:
std::vector<IdentificationDataSource *> m_vectorWorking;
......
......@@ -36,18 +36,19 @@ MsIdentificationTableModel::MsIdentificationTableModel(
{
m_ms_id_list_window = ms_id_list_window;
MsIdListWorkerThread *p_worker = new MsIdListWorkerThread(this);
MsIdListWorkerThread *p_worker = new MsIdListWorkerThread();
p_worker->moveToThread(&m_ms_id_list_thread);
m_ms_id_list_thread.start();
msp_workerStatus = std::make_shared<MsIdListWorkerStatus>(p_worker);
connect(this,
&MsIdentificationTableModel::computeMsNumber,
p_worker,
&MsIdListWorkerThread::doComputeMsNumber);
connect(p_worker,
&MsIdListWorkerThread::MsNumberComputed,
this,
&MsIdentificationTableModel::onMsIdentificationDataChanged);
connect(this,
&MsIdentificationTableModel::ComputeMsNumber,
p_worker,
&MsIdListWorkerThread::doComputeMsNumber);
}
MsIdentificationTableModel::~MsIdentificationTableModel()
......@@ -341,7 +342,21 @@ MsIdentificationTableModel::data(const QModelIndex &index, int role) const
->getMsRunStatistics(MsRunStatistics::total_spectra_ms1);
if(nb_ms1.isNull())
{
emit computeMsNumber(m_identificationDataSourceSpList.at(row));
WorkerStatus temp = msp_workerStatus.get()->getStatus(
m_identificationDataSourceSpList.at(row));
if(temp == WorkerStatus::Running)
{
return QVariant("Running");
}
else if(temp == WorkerStatus::Waiting)
{
return QVariant("Wait");
}
else
{
return QVariant("Error");
}
}
else
{
......@@ -357,15 +372,22 @@ MsIdentificationTableModel::data(const QModelIndex &index, int role) const
->getMsRunStatistics(MsRunStatistics::total_spectra_ms2);
if(nb_ms2.isNull())
{
msp_workerStatus.get()->isworking(
WorkerStatus temp = msp_workerStatus.get()->getStatus(
m_identificationDataSourceSpList.at(row));
emit computeMsNumber(m_identificationDataSourceSpList.at(row));
if(temp == WorkerStatus::Running)
{
return QVariant("Running");
}
else
{
return QVariant("Wait");
}
}
else
{
return nb_ms2;
}
return QVariant("Wait2");
}
case Qt::ToolTipRole:
if(col == (std::int8_t)msIdentificationListColumn::id_file)
......@@ -393,3 +415,10 @@ MsIdentificationTableModel::onMsIdentificationDataChanged()
emit layoutAboutToBeChanged();
emit layoutChanged();
}
void
MsIdentificationTableModel::doComputeMsNumber(
IdentificationDataSourceSp identificationDataSource)
{
emit ComputeMsNumber(identificationDataSource);
}
......@@ -27,7 +27,7 @@
#include "../../../core/project.h"
#include <QThread>
#include <memory>
#include <gui/lists/ms_identification_run_list_view/ms_identification_worker/msidlistworkerstatus.h>
#include "ms_identification_worker/msidlistworkerstatus.h"
/** \def msIdentificationListColumn list of available fields to display in ms
......@@ -84,10 +84,10 @@ class MsIdentificationTableModel : public QAbstractTableModel
public slots:
void onMsIdentificationDataChanged();
void doComputeMsNumber(IdentificationDataSourceSp identificationDataSource);
signals:
void
computeMsNumber(IdentificationDataSourceSp identificationDataSource) const;
void ComputeMsNumber(IdentificationDataSourceSp identificationDataSource);
private:
static int getColumnWidth(int column);
......@@ -96,6 +96,5 @@ class MsIdentificationTableModel : public QAbstractTableModel
std::vector<IdentificationDataSourceSp> m_identificationDataSourceSpList;
MsIdentificationListWindow *m_ms_id_list_window;
QThread m_ms_id_list_thread;
std::vector<bool> m_list_done;
std::shared_ptr<MsIdListWorkerStatus> msp_workerStatus;
std::shared_ptr<MsIdListWorkerStatus> msp_workerStatus = nullptr;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment