本文整理汇总了C++中IAlgorithm_sptr::executeAsync方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::executeAsync方法的具体用法?C++ IAlgorithm_sptr::executeAsync怎么用?C++ IAlgorithm_sptr::executeAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::executeAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fit
void ALCBaselineModellingModel::fit(IFunction_const_sptr function,
const std::vector<Section> §ions) {
// Create a copy of the data
IAlgorithm_sptr clone = AlgorithmManager::Instance().create("CloneWorkspace");
clone->setChild(true);
clone->setProperty("InputWorkspace",
boost::const_pointer_cast<MatrixWorkspace>(m_data));
clone->setProperty("OutputWorkspace", "__NotUsed__");
clone->execute();
Workspace_sptr cloned = clone->getProperty("OutputWorkspace");
MatrixWorkspace_sptr dataToFit =
boost::dynamic_pointer_cast<MatrixWorkspace>(cloned);
assert(dataToFit); // CloneWorkspace should take care of that
disableUnwantedPoints(dataToFit, sections);
IFunction_sptr funcToFit =
FunctionFactory::Instance().createInitialized(function->asString());
IAlgorithm_sptr fit = AlgorithmManager::Instance().create("Fit");
fit->setChild(true);
fit->setProperty("Function", funcToFit);
fit->setProperty("InputWorkspace", dataToFit);
fit->setProperty("CreateOutput", true);
// Run async so that progress can be shown
Poco::ActiveResult<bool> result(fit->executeAsync());
while (!result.available()) {
QCoreApplication::processEvents();
}
if (!result.error().empty()) {
throw std::runtime_error(result.error());
}
MatrixWorkspace_sptr fitOutput = fit->getProperty("OutputWorkspace");
m_parameterTable = fit->getProperty("OutputParameters");
enableDisabledPoints(fitOutput, m_data);
setErrorsAfterFit(fitOutput);
setCorrectedData(fitOutput);
setFittedFunction(funcToFit);
m_sections = sections;
}
示例2: fitPeaks
void ALCPeakFittingModel::fitPeaks(IFunction_const_sptr peaks)
{
IAlgorithm_sptr fit = AlgorithmManager::Instance().create("Fit");
fit->setChild(true);
fit->setProperty("Function", peaks->asString());
fit->setProperty("InputWorkspace", boost::const_pointer_cast<MatrixWorkspace>(m_data));
fit->setProperty("CreateOutput", true);
fit->setProperty("OutputCompositeMembers", true);
// Execute async so we can show progress bar
Poco::ActiveResult<bool> result(fit->executeAsync());
while (!result.available()) {
QCoreApplication::processEvents();
}
if (!result.error().empty()) {
throw std::runtime_error(result.error());
}
m_data = fit->getProperty("OutputWorkspace");
m_parameterTable = fit->getProperty("OutputParameters");
setFittedPeaks(static_cast<IFunction_sptr>(fit->getProperty("Function")));
}
示例3: load
/**
* Load new data and update the view accordingly
* @param lastFile :: [input] Last file in range (user-specified or auto)
*/
void ALCDataLoadingPresenter::load(const std::string &lastFile) {
m_view->disableAll();
// Use Path.toString() to ensure both are in same (native) format
Poco::Path firstRun(m_view->firstRun());
Poco::Path lastRun(lastFile);
// Before loading, check custom grouping (if used) is sensible
const bool groupingOK = checkCustomGrouping();
if (!groupingOK) {
m_view->displayError(
"Custom grouping not valid (bad format or detector numbers)");
m_view->enableAll();
return;
}
try {
IAlgorithm_sptr alg =
AlgorithmManager::Instance().create("PlotAsymmetryByLogValue");
alg->setChild(true); // Don't want workspaces in the ADS
alg->setProperty("FirstRun", firstRun.toString());
alg->setProperty("LastRun", lastRun.toString());
alg->setProperty("LogValue", m_view->log());
alg->setProperty("Function", m_view->function());
alg->setProperty("Type", m_view->calculationType());
alg->setProperty("DeadTimeCorrType", m_view->deadTimeType());
alg->setProperty("Red", m_view->redPeriod());
// If time limiting requested, set min/max times
if (auto timeRange = m_view->timeRange()) {
double timeMin = (*timeRange).first;
double timeMax = (*timeRange).second;
if (timeMin >= timeMax) {
throw std::invalid_argument("Invalid time limits");
}
alg->setProperty("TimeMin", timeMin);
alg->setProperty("TimeMax", timeMax);
}
// If corrections from custom file requested, set file property
if (m_view->deadTimeType() == "FromSpecifiedFile") {
alg->setProperty("DeadTimeCorrFile", m_view->deadTimeFile());
}
// If custom grouping requested, set forward/backward groupings
if (m_view->detectorGroupingType() == "Custom") {
alg->setProperty("ForwardSpectra", m_view->getForwardGrouping());
alg->setProperty("BackwardSpectra", m_view->getBackwardGrouping());
}
// If Subtract checkbox is selected, set green period
if (m_view->subtractIsChecked()) {
alg->setProperty("Green", m_view->greenPeriod());
}
alg->setPropertyValue("OutputWorkspace", "__NotUsed");
// Execute async so we can show progress bar
Poco::ActiveResult<bool> result(alg->executeAsync());
while (!result.available()) {
QCoreApplication::processEvents();
}
if (!result.error().empty()) {
throw std::runtime_error(result.error());
}
m_loadedData = alg->getProperty("OutputWorkspace");
// If errors are properly caught, shouldn't happen
assert(m_loadedData);
// If subtract is not checked, only one spectrum,
// else four spectra
if (!m_view->subtractIsChecked()) {
assert(m_loadedData->getNumberHistograms() == 1);
} else {
assert(m_loadedData->getNumberHistograms() == 4);
}
// Plot spectrum 0. It is either red period (if subtract is unchecked) or
// red - green (if subtract is checked)
m_view->setDataCurve(*(ALCHelper::curveDataFromWs(m_loadedData, 0)),
ALCHelper::curveErrorsFromWs(m_loadedData, 0));
emit dataChanged();
} catch (std::exception &e) {
m_view->displayError(e.what());
}
m_view->enableAll();
}