本文整理汇总了C++中mantid::api::IAlgorithm_sptr::executeAsync方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::executeAsync方法的具体用法?C++ IAlgorithm_sptr::executeAsync怎么用?C++ IAlgorithm_sptr::executeAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid::api::IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::executeAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeAsynchronously
/**
* Execute the given algorithm asynchronously.
* @param algorithm :: The algorithm to execute.
*/
void CatalogHelper::executeAsynchronously(
const Mantid::API::IAlgorithm_sptr &algorithm) {
Poco::ActiveResult<bool> result(algorithm->executeAsync());
while (!result.available()) {
QCoreApplication::processEvents();
}
}
示例2: algName
/** This method executes the ListInstruments algorithm
* and fills the instrument box with instrument lists returned by ICat API
* @return shared pointer to workspace which contains instrument names
*/
std::vector<std::string> ICatUtils::executeListInstruments()
{
QString algName("CatalogListInstruments");
const int version=-1;
Mantid::API::IAlgorithm_sptr alg;
try
{
alg = Mantid::API::AlgorithmManager::Instance().create(algName.toStdString(),version);
}
catch(...)
{
throw std::runtime_error("Error when Populating the instrument list box");
}
Poco::ActiveResult<bool> result(alg->executeAsync());
while( !result.available() )
{
QCoreApplication::processEvents();
}
if(!alg->isExecuted())
{
//if the algorithm failed check the session id passed is valid
if(!isSessionValid(alg))
{
//at this point session is invalid, popup loginbox to login
if(login())
{
//now populate instrument box
std::vector<std::string> instruments =executeListInstruments();
return instruments;
}
else
{
throw std::runtime_error("Please Login to the information catalog using the login menu provided to do the investigation search.");
}
}
else
{
return std::vector<std::string>();
}
}
std::vector<std::string>instrlist;
try
{
instrlist= alg->getProperty("InstrumentList");
}
catch (Mantid::Kernel::Exception::NotFoundError&)
{
throw;
}
return instrlist;
}
示例3: executeGetdataFiles
/// execute getdatafIles algorithm
ITableWorkspace_sptr ICatInvestigation::executeGetdataFiles()
{
QString algName("CatalogGetDataFiles");
const int version=1;
Mantid::API::ITableWorkspace_sptr ws_sptr;
Mantid::API::IAlgorithm_sptr alg;
try
{
alg = Mantid::API::AlgorithmManager::Instance().create(algName.toStdString(),version);
}
catch(...)
{
throw std::runtime_error("Error when loading the data files associated to the selected investigation ");
}
try
{
alg->setProperty("InvestigationId",m_invstId);
alg->setProperty("FilterLogFiles",isDataFilesChecked());
alg->setPropertyValue("OutputWorkspace","datafiles");
}
catch(std::invalid_argument& e)
{
emit error(e.what());
return ws_sptr;
}
catch (Mantid::Kernel::Exception::NotFoundError& e)
{
emit error(e.what());
return ws_sptr;
}
try
{
Poco::ActiveResult<bool> result(alg->executeAsync());
while( !result.available() )
{
QCoreApplication::processEvents();
}
}
catch(...)
{
return ws_sptr;
}
if(AnalysisDataService::Instance().doesExist("datafiles"))
{
ws_sptr = boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace>
(AnalysisDataService::Instance().retrieve("datafiles"));
}
return ws_sptr;
}
示例4: login
bool ICatUtils::login()
{
QString algName("CatalogLogin");
const int version =-1;
Mantid::API::IAlgorithm_sptr alg;
try
{
alg = Mantid::API::AlgorithmManager::Instance().create(algName.toStdString(),version);
}
catch(...)
{
throw std::runtime_error("Error when Populating the instrument list box");
}
if(!m_applicationWindow)
{return false;}
MantidQt::API::InterfaceManager interfaceManager;
MantidQt::API::AlgorithmDialog *dlg = interfaceManager.createDialog(alg.get(), m_applicationWindow);
if(!dlg) return false;
if(dlg->exec()==QDialog::Accepted)
{
delete dlg;
Poco::ActiveResult<bool> result(alg->executeAsync());
while( !result.available() )
{
QCoreApplication::processEvents();
}
if(!alg->isExecuted())
{
return false;
}
return true;
}
else
{
return false;
}
}
示例5: executeAlgorithmAsync
/**
* Execute the underlying algorithm
*/
void AlgorithmDialog::executeAlgorithmAsync() {
Mantid::API::IAlgorithm_sptr algToExec = m_algorithm;
// Clear any previous trackers so we know what state we are in
this->stopObserving(algToExec);
try {
// Add any custom AlgorithmObservers to the algorithm
for (auto it = m_observers.begin(); it != m_observers.end(); ++it) {
(*it)->observeAll(algToExec);
}
// Only need to observe finish events if we are staying open
if (m_keepOpenCheckBox && m_keepOpenCheckBox->isChecked()) {
this->observeFinish(algToExec);
this->observeError(algToExec);
m_statusTracked = true;
// Disable close button for a short period. If it is clicked to soon then
// Mantid crashes - https://github.com/mantidproject/mantid/issues/13836
if (m_exitButton) {
m_exitButton->setEnabled(false);
m_btnTimer.setInterval(1000);
connect(&m_btnTimer, SIGNAL(timeout()), this, SLOT(enableExitButton()));
} else {
m_statusTracked = false;
}
}
algToExec->executeAsync();
m_btnTimer.start();
if (m_okButton) {
m_okButton->setEnabled(false);
}
} catch (Poco::NoThreadAvailableException &) {
g_log.error() << "No thread was available to run the " << algToExec->name()
<< " algorithm in the background.\n";
}
}