本文整理汇总了C++中Algorithm_sptr::isExecuted方法的典型用法代码示例。如果您正苦于以下问题:C++ Algorithm_sptr::isExecuted方法的具体用法?C++ Algorithm_sptr::isExecuted怎么用?C++ Algorithm_sptr::isExecuted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Algorithm_sptr
的用法示例。
在下文中一共展示了Algorithm_sptr::isExecuted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retrieveInstrumentParameters
void EstimatePDDetectorResolution::retrieveInstrumentParameters()
{
#if 0
// Call SolidAngle to get solid angles for all detectors
Algorithm_sptr calsolidangle = createChildAlgorithm("SolidAngle", -1, -1, true);
calsolidangle->initialize();
calsolidangle->setProperty("InputWorkspace", m_inputWS);
calsolidangle->execute();
if (!calsolidangle->isExecuted())
throw runtime_error("Unable to run solid angle. ");
m_solidangleWS = calsolidangle->getProperty("OutputWorkspace");
if (!m_solidangleWS)
throw runtime_error("Unable to get solid angle workspace from SolidAngle(). ");
size_t numspec = m_solidangleWS->getNumberHistograms();
for (size_t i = 0; i < numspec; ++i)
g_log.debug() << "[DB]: " << m_solidangleWS->readY(i)[0] << "\n";
#endif
// Calculate centre neutron velocity
Property* cwlproperty = m_inputWS->run().getProperty("LambdaRequest");
if (!cwlproperty)
throw runtime_error("Unable to locate property LambdaRequest as central wavelength. ");
TimeSeriesProperty<double>* cwltimeseries = dynamic_cast<TimeSeriesProperty<double>* >(cwlproperty);
if (!cwltimeseries)
throw runtime_error("LambdaReqeust is not a TimeSeriesProperty in double. ");
if (cwltimeseries->size() != 1)
throw runtime_error("LambdaRequest should contain 1 and only 1 entry. ");
double centrewavelength = cwltimeseries->nthValue(0);
string unit = cwltimeseries->units();
if (unit.compare("Angstrom") == 0)
centrewavelength *= 1.0E-10;
else
throw runtime_error("Unit is not recognized");
m_centreVelocity = PhysicalConstants::h/PhysicalConstants::NeutronMass/centrewavelength;
g_log.notice() << "Centre wavelength = " << centrewavelength << ", Centre neutron velocity = " << m_centreVelocity << "\n";
// Calcualte L1 sample to source
Instrument_const_sptr instrument = m_inputWS->getInstrument();
V3D samplepos = instrument->getSample()->getPos();
V3D sourcepos = instrument->getSource()->getPos();
m_L1 = samplepos.distance(sourcepos);
g_log.notice() << "L1 = " << m_L1 << "\n";
return;
}
示例2: exec
/** Execute the algorithm.
*/
void LoadLiveData::exec() {
// The full, post-processed output workspace
m_outputWS = this->getProperty("OutputWorkspace");
// Validate inputs
if (this->hasPostProcessing()) {
if (this->getPropertyValue("AccumulationWorkspace").empty())
throw std::invalid_argument("Must specify the AccumulationWorkspace "
"parameter if using PostProcessing.");
// The accumulated but not post-processed output workspace
m_accumWS = this->getProperty("AccumulationWorkspace");
} else {
// No post-processing, so the accumulation and output are the same
m_accumWS = m_outputWS;
}
// Get or create the live listener
ILiveListener_sptr listener = this->getLiveListener();
// Do we need to reset the data?
bool dataReset = listener->dataReset();
// The listener returns a MatrixWorkspace containing the chunk of live data.
Workspace_sptr chunkWS;
bool dataNotYetGiven = true;
while (dataNotYetGiven) {
try {
chunkWS = listener->extractData();
dataNotYetGiven = false;
} catch (Exception::NotYet &ex) {
g_log.warning() << "The " << listener->name()
<< " is not ready to return data: " << ex.what() << "\n";
g_log.warning()
<< "Trying again in 10 seconds - cancel the algorithm to stop.\n";
const int tenSeconds = 40;
for (int i = 0; i < tenSeconds; ++i) {
Poco::Thread::sleep(10000 / tenSeconds); // 250 ms
this->interruption_point();
}
}
}
// TODO: Have the ILiveListener tell me exactly the time stamp
DateAndTime lastTimeStamp = DateAndTime::getCurrentTime();
this->setPropertyValue("LastTimeStamp", lastTimeStamp.toISO8601String());
// Now we process the chunk
Workspace_sptr processed = this->processChunk(chunkWS);
bool PreserveEvents = this->getProperty("PreserveEvents");
EventWorkspace_sptr processedEvent =
boost::dynamic_pointer_cast<EventWorkspace>(processed);
if (!PreserveEvents && processedEvent) {
// Convert the monitor workspace, if there is one and it's necessary
MatrixWorkspace_sptr monitorWS = processedEvent->monitorWorkspace();
auto monitorEventWS =
boost::dynamic_pointer_cast<EventWorkspace>(monitorWS);
if (monitorEventWS) {
auto monAlg = this->createChildAlgorithm("ConvertToMatrixWorkspace");
monAlg->setProperty("InputWorkspace", monitorEventWS);
monAlg->executeAsChildAlg();
if (!monAlg->isExecuted())
g_log.error(
"Failed to convert monitors from events to histogram form.");
monitorWS = monAlg->getProperty("OutputWorkspace");
}
// Now do the main workspace
Algorithm_sptr alg = this->createChildAlgorithm("ConvertToMatrixWorkspace");
alg->setProperty("InputWorkspace", processedEvent);
std::string outputName = "__anonymous_livedata_convert_" +
this->getPropertyValue("OutputWorkspace");
alg->setPropertyValue("OutputWorkspace", outputName);
alg->execute();
if (!alg->isExecuted())
throw std::runtime_error("Error when calling ConvertToMatrixWorkspace "
"(since PreserveEvents=False). See log.");
// Replace the "processed" workspace with the converted one.
MatrixWorkspace_sptr temp = alg->getProperty("OutputWorkspace");
if (monitorWS)
temp->setMonitorWorkspace(monitorWS); // Set back the monitor workspace
processed = temp;
}
// How do we accumulate the data?
std::string accum = this->getPropertyValue("AccumulationMethod");
// If the AccumulationWorkspace does not exist, we always replace the
// AccumulationWorkspace.
// Also, if the listener said we are resetting the data, then we clear out the
// old.
if (!m_accumWS || dataReset)
accum = "Replace";
g_log.notice() << "Performing the " << accum << " operation.\n";
// Perform the accumulation and set the AccumulationWorkspace workspace
//.........这里部分代码省略.........