Skip to content
Snippets Groups Projects
Commit ba2488b8 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Merge branch 'SubmitJobFix' into develop

parents 636c6971 70bd5c16
No related branches found
No related tags found
No related merge requests found
......@@ -22,16 +22,17 @@
namespace
{
const QString RUN_IMMEDIATELY = "Immediately";
const QString RUN_IN_BACKGROUND = "In background";
const QString RUN_SUBMIT_ONLY = "Submit only";
QMap<QString, QString> initializeRunPolicies()
{
QMap<QString, QString> result;
result[RUN_IMMEDIATELY] = QString("Start simulation immediately, switch to Jobs view automatically when completed");
result[RUN_IN_BACKGROUND] = QString("Start simulation immediately, do not switch to Jobs view when completed");
result[RUN_SUBMIT_ONLY] = QString("Only submit simulation for consequent execution, has to be started from Jobs view explicitely");
result[Constants::JOB_RUN_IMMEDIATELY] =
QString("Start simulation immediately, switch to Jobs view automatically when completed");
result[Constants::JOB_RUN_IN_BACKGROUND] =
QString("Start simulation immediately, do not switch to Jobs view when completed");
result[Constants::JOB_RUN_SUBMIT_ONLY] =
QString("Only submit simulation for consequent execution,"
" has to be started from Jobs view explicitely");
return result;
}
......@@ -75,7 +76,9 @@ JobItem::JobItem(ParameterizedItem *parent)
registerProperty(P_NTHREADS, -1, PropertyAttribute(PropertyAttribute::HIDDEN));
ComboProperty policy;
policy << RUN_IMMEDIATELY <<RUN_IN_BACKGROUND << RUN_SUBMIT_ONLY;
policy << Constants::JOB_RUN_IMMEDIATELY
<< Constants::JOB_RUN_IN_BACKGROUND
<< Constants::JOB_RUN_SUBMIT_ONLY;
registerProperty(P_RUN_POLICY, policy.getVariant(), PropertyAttribute(PropertyAttribute::HIDDEN));
addToValidChildren(Constants::IntensityDataType);
......@@ -228,14 +231,21 @@ void JobItem::setNumberOfThreads(int number_of_threads)
setRegisteredProperty(P_NTHREADS, number_of_threads);
}
void JobItem::setRunPolicy(const QString &run_policy)
{
ComboProperty combo_property = getRegisteredProperty(JobItem::P_RUN_POLICY).value<ComboProperty>();
combo_property.setValue(run_policy);
setRegisteredProperty(JobItem::P_RUN_POLICY, combo_property.getVariant());
}
bool JobItem::runImmediately() const
{
ComboProperty combo_property = getRegisteredProperty(P_RUN_POLICY).value<ComboProperty>();
return combo_property.getValue() == RUN_IMMEDIATELY;
return combo_property.getValue() == Constants::JOB_RUN_IMMEDIATELY;
}
bool JobItem::runInBackground() const
{
ComboProperty combo_property = getRegisteredProperty(P_RUN_POLICY).value<ComboProperty>();
return combo_property.getValue() == RUN_IN_BACKGROUND;
return combo_property.getValue() == Constants::JOB_RUN_IN_BACKGROUND;
}
......@@ -72,6 +72,8 @@ public:
int getNumberOfThreads() const;
void setNumberOfThreads(int number_of_threads);
void setRunPolicy(const QString &run_policy);
static QMap<QString, QString> getRunPolicies() { return m_run_policies; }
bool runImmediately() const;
......
......@@ -75,9 +75,10 @@ JobItem *JobModel::addJob(SampleModel *sampleModel, InstrumentModel *instrumentM
jobItem->setIdentifier(generateJobIdentifier());
jobItem->setNumberOfThreads(numberOfThreads);
ComboProperty combo_property = jobItem->getRegisteredProperty(JobItem::P_RUN_POLICY).value<ComboProperty>();
combo_property.setValue(run_policy);
jobItem->setRegisteredProperty(JobItem::P_RUN_POLICY, combo_property.getVariant());
// ComboProperty combo_property = jobItem->getRegisteredProperty(JobItem::P_RUN_POLICY).value<ComboProperty>();
// combo_property.setValue(run_policy);
// jobItem->setRegisteredProperty(JobItem::P_RUN_POLICY, combo_property.getVariant());
jobItem->setRunPolicy(run_policy);
if(jobItem->runImmediately() || jobItem->runInBackground())
m_queue_data->runJob(jobItem);
......@@ -91,7 +92,9 @@ JobItem *JobModel::addJob(SampleModel *sampleModel, InstrumentModel *instrumentM
void JobModel::runJob(const QModelIndex &index)
{
qDebug() << "NJobModel::runJob(const QModelIndex &index)";
m_queue_data->runJob(getJobItemForIndex(index));
JobItem *jobItem = getJobItemForIndex(index);
jobItem->setRunPolicy(Constants::JOB_RUN_IMMEDIATELY);
m_queue_data->runJob(jobItem);
}
void JobModel::cancelJob(const QModelIndex &index)
......
......@@ -160,6 +160,10 @@ const ModelType GRADIENT_HUES = "Hues";
const ModelType AXIS_FIXED_BINNING = "Fixed";
const ModelType AXIS_CONSTK_BINNING = "Const KBin";
const ModelType JOB_RUN_IMMEDIATELY = "Immediately";
const ModelType JOB_RUN_IN_BACKGROUND = "In background";
const ModelType JOB_RUN_SUBMIT_ONLY = "Submit only";
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment