本文整理汇总了C++中IAlgorithm_sptr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::get方法的具体用法?C++ IAlgorithm_sptr::get怎么用?C++ IAlgorithm_sptr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cancel
/** Cancel the given algorithm's execution */
void AlgorithmMonitor::cancel(Mantid::API::AlgorithmID id,
QPushButton *cancelBtn = NULL) {
if ((cancelBtn) && (cancelBtn->text() == "Cancel")) {
cancelBtn->setText("Cancelling");
cancelBtn->setEnabled(false);
IAlgorithm_sptr a =
Mantid::API::AlgorithmManager::Instance().getAlgorithm(id);
if (!a.get())
return;
a->cancel();
}
}
示例2: showAlgo
void showAlgo(IAlgorithm_sptr alg, QStringList enabled, QStringList disabled, QApplication & app)
{
GenericDialog * dlg = new GenericDialog(NULL);
// Set the content
dlg->setAlgorithm(alg.get());
//dlg->setPresetValues(preset_values);
//dlg->isForScript(forScript);
dlg->setOptionalMessage(QString::fromStdString(alg->getOptionalMessage()));
dlg->addEnabledAndDisableLists(enabled, disabled);
// Setup the layout
dlg->initializeLayout();
// Show dialog
dlg->show();
app.exec();
dlg->close();
delete dlg;
}
示例3: exec
void SavePAR::exec() {
// Get the input workspace
MatrixWorkspace_sptr inputWorkspace = getProperty("InputWorkspace");
// Get the sample position
const Kernel::V3D samplePos =
inputWorkspace->getInstrument()->getSample()->getPos();
// Retrieve the filename from the properties
const std::string filename = getProperty("Filename");
// Get a pointer to the sample
IObjComponent_const_sptr sample =
inputWorkspace->getInstrument()->getSample();
std::ofstream outPAR_file(filename.c_str());
if (!outPAR_file) {
g_log.error("Failed to open (PAR) file:" + filename);
throw Kernel::Exception::FileError("Failed to open (PAR) file:",
filename);
}
// execute the subalgorithm to calculate the detector's parameters;
IAlgorithm_sptr spCalcDetPar = this->createSubAlgorithm("FindDetectorsPar", 0, 1, true, 1);
spCalcDetPar->initialize();
spCalcDetPar->setPropertyValue("InputWorkspace", inputWorkspace->getName());
// calculate linear rather then angular detector's sizes;
spCalcDetPar->setPropertyValue("ReturnLinearRanges", "1");
// in test mode, request the subalgortithm to create output workspace and add it to dataservice
if(!det_par_ws_name.empty()){
spCalcDetPar->setPropertyValue("OutputParTable",det_par_ws_name);
}
// let's not do this for the time being
/* std::string parFileName = this->getPropertyValue("ParFile");
if(!(parFileName.empty()||parFileName=="not_used.par")){
spCalcDetPar->setPropertyValue("ParFile",parFileName);
}*/
spCalcDetPar->execute();
//
FindDetectorsPar * pCalcDetPar = dynamic_cast<FindDetectorsPar *>(spCalcDetPar.get());
if(!pCalcDetPar){ // "can not get pointer to FindDetectorsPar algorithm"
throw(std::bad_cast());
}
const std::vector<double> & azimuthal = pCalcDetPar->getAzimuthal();
const std::vector<double> & polar = pCalcDetPar->getPolar();
const std::vector<double> & azimuthal_width = pCalcDetPar->getAzimWidth();
const std::vector<double> & polar_width = pCalcDetPar->getPolarWidth();
const std::vector<double> & secondary_flightpath= pCalcDetPar->getFlightPath();
const std::vector<size_t> & det_ID = pCalcDetPar->getDetID();
size_t nDetectors = pCalcDetPar->getNDetectors();
// Write the number of detectors to the file.
outPAR_file <<" "<< nDetectors << std::endl;
for (size_t i = 0; i < nDetectors; ++i) {
// verify if no detector defined;
volatile double NanID = azimuthal[i];
if(NanID !=azimuthal[i] )continue; // skip NaN -s
// Now write all the detector info.
outPAR_file << std::fixed << std::setprecision(3);
outPAR_file.width(10);
outPAR_file <<secondary_flightpath[i];
outPAR_file.width(10);
outPAR_file<< polar[i];
outPAR_file.width(10);
outPAR_file << (-azimuthal[i]);
outPAR_file.width(10);
outPAR_file << polar_width[i];
outPAR_file.width(10);
outPAR_file << azimuthal_width[i];
outPAR_file.width(10);
outPAR_file << det_ID[i] << std::endl;
}
// Close the file
outPAR_file.close();
}
示例4: exec
/** Execute the algorithm.
*/
void StartLiveData::exec()
{
// Validate the inputs
bool FromNow = getProperty("FromNow");
bool FromStartOfRun = getProperty("FromStartOfRun");
bool FromTime = getProperty("FromTime");
int numChecked = 0;
if (FromNow) numChecked++;
if (FromStartOfRun) numChecked++;
if (FromTime) numChecked++;
if (numChecked != 1)
throw std::runtime_error("Please check exactly one of FromNow, FromStartOfRun, FromTime.");
// Adjust the StartTime if you are starting from run/now.
if (FromNow)
this->setPropertyValue("StartTime", DateAndTime::getCurrentTime().toISO8601String());
else if (FromStartOfRun)
// TODO: implement
throw Kernel::Exception::NotImplementedError("Cannot start from the run start yet.");
// Get the listener (and start listening) as early as possible
ILiveListener_sptr listener = this->getLiveListener();
// TODO: Wait a bit to make sure something gets accumulated?
LoadLiveData loadAlg;
loadAlg.initialize();
loadAlg.setChild(true);
// Copy settings from THIS to LoadAlg
loadAlg.copyPropertyValuesFrom(*this);
// Force replacing the output workspace on the first run, to clear out old junk.
loadAlg.setPropertyValue("AccumulationMethod", "Replace");
// Give the listener directly to LoadLiveData (don't re-create it)
loadAlg.setLiveListener(listener);
// Run the LoadLiveData for the first time.
loadAlg.executeAsChildAlg();
// Copy the output workspace properties from LoadLiveData
Workspace_sptr outWS = loadAlg.getProperty("OutputWorkspace");
this->setProperty("OutputWorkspace", outWS);
Workspace_sptr accumWS = loadAlg.getProperty("AccumulationWorkspace");
this->setProperty("AccumulationWorkspace", accumWS);
double UpdateEvery = this->getProperty("UpdateEvery");
if (UpdateEvery > 0)
{
// Create the MonitorLiveData but DO NOT make a AlgorithmProxy to it
IAlgorithm_sptr algBase = AlgorithmManager::Instance().create("MonitorLiveData", -1, false);
MonitorLiveData * monitorAlg = dynamic_cast<MonitorLiveData*>(algBase.get());
if (!monitorAlg)
throw std::runtime_error("Error creating the MonitorLiveData algorithm");
// Copy settings from THIS to monitorAlg
monitorAlg->initialize();
monitorAlg->copyPropertyValuesFrom(*this);
monitorAlg->setProperty("UpdateEvery", UpdateEvery);
// Give the listener directly to LoadLiveData (don't re-create it)
monitorAlg->setLiveListener(listener);
// Launch asyncronously
monitorAlg->executeAsync();
}
}