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

Fixed progress bar for MultiLayers with roughness simulation

parent cfa8fe86
No related branches found
No related tags found
No related merge requests found
......@@ -75,18 +75,26 @@ void ProgressHandler::init(Simulation *simulation, int param_combinations)
m_current_progress = 0;
m_nitems_max = 0;
// Analyzing sample for additional factors which will slow done the simulation
int roughness_factor(1);
MultiLayer *multilayer = dynamic_cast<MultiLayer *>(simulation->getSample());
double number_of_rounds_factor(0.0);
int nlayouts(0);
for(size_t i_layer=0; i_layer<multilayer->getNumberOfLayers(); ++i_layer) {
nlayouts += multilayer->getLayer(i_layer)->getNumberOfLayouts();
}
if(nlayouts > 0) number_of_rounds_factor += 1.0;
// Analyzing sample for additional factors which will slow done the simulation
int nroughness(0);
if(multilayer) {
for (size_t i=0; i<multilayer->getNumberOfInterfaces(); ++i) {
if(multilayer->getLayerInterface(i)->getRoughness() ) {
roughness_factor = 2;
break;
nroughness++;
}
}
}
if(nroughness>0) number_of_rounds_factor += 1.0;
// Simplified estimation of total number of items in DWBA simulation
m_nitems_max = roughness_factor*param_combinations*simulation->getNumberOfSimulationElements();
m_nitems_max = number_of_rounds_factor*param_combinations*simulation->getNumberOfSimulationElements();
}
......@@ -32,20 +32,6 @@
#include <memory>
//! Creates domain simulation from sample and instrument models for given names
//! of MultiLayer and Instrument
//GISASSimulation *DomainSimulationBuilder::getSimulation(SampleModel *sampleModel,
// const QString &sample_name,
// InstrumentModel *instrumentModel,
// const QString &instrument_name)
//{
// Q_ASSERT(sampleModel);
// Q_ASSERT(instrumentModel);
// MultiLayerItem *sampleItem = sampleModel->getMultiLayerItem(sample_name);
// InstrumentItem *instrumentItem = instrumentModel->getInstrumentItem(instrument_name);
// return getSimulation(sampleItem, instrumentItem);
//}
//! Creates domain simulation from sample and instrument models. First sample and first instrument
//! in the model will be used, if there are more than one.
GISASSimulation *DomainSimulationBuilder::getSimulation(SampleModel *sampleModel,
......
......@@ -32,10 +32,6 @@ class DocumentModel;
class DomainSimulationBuilder
{
public:
// static GISASSimulation *getSimulation(SampleModel *sampleModel, const QString &sample_name,
// InstrumentModel *instrumentModel,
// const QString &instrument_name);
static GISASSimulation *getSimulation(SampleModel *sampleModel,
InstrumentModel *instrumentModel,
DocumentModel *documentModel);
......@@ -43,7 +39,6 @@ public:
static GISASSimulation *getSimulation(const MultiLayerItem *sampleItem,
const InstrumentItem *instrumentItem,
const SimulationOptionsItem *optionsItem = 0);
};
#endif
......@@ -186,20 +186,7 @@ void JobQueueData::onFinishedJob()
JobItem *jobItem = m_jobModel->getJobItemForIdentifier(runner->getIdentifier());
QString end_time = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss");
jobItem->setEndTime(end_time);
jobItem->setDuration(runner->getSimulationDuration());
// propagating status of runner
jobItem->setStatus(runner->getStatus());
if(jobItem->isFailed()) {
jobItem->setComments(runner->getFailureMessage());
} else {
// propagating simulation results
GISASSimulation *simulation = getSimulation(runner->getIdentifier());
jobItem->setResults(simulation);
}
processFinishedJob(runner, jobItem);
// I tell to the thread to exit here (instead of connecting JobRunner::finished to the QThread::quit because of strange behaviour)
getThread(runner->getIdentifier())->quit();
......@@ -302,3 +289,25 @@ void JobQueueData::clearSimulation(const QString &identifier)
m_simulations.remove(identifier);
delete simulation;
}
//! Set all data of finished job
void JobQueueData::processFinishedJob(JobRunner *runner, JobItem *jobItem)
{
QString end_time = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss");
jobItem->setEndTime(end_time);
jobItem->setDuration(runner->getSimulationDuration());
// propagating status of runner
jobItem->setStatus(runner->getStatus());
if(jobItem->isFailed()) {
jobItem->setComments(runner->getFailureMessage());
} else {
// propagating simulation results
GISASSimulation *simulation = getSimulation(runner->getIdentifier());
jobItem->setResults(simulation);
}
// fixing job progress (if job was successfull, but due to wrong estimation, progress not 100%)
if(jobItem->isCompleted())
jobItem->setProgress(100);
}
......@@ -64,6 +64,7 @@ private:
void assignForDeletion(QThread *thread);
void assignForDeletion(JobRunner *runner);
void clearSimulation(const QString &identifier);
void processFinishedJob(JobRunner *runner, JobItem *jobItem);
void updateGlobalProgress();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment