/**
  * Load the instrument
  * @param instrName :: Instrument name
  */
void ISISLiveEventDataListener::loadInstrument(const std::string &instrName) {
  // try to load the instrument. if it doesn't load give a warning and carry on
  if (instrName.empty()) {
    g_log.warning() << "Unable to read instrument name from DAE." << std::endl;
    return;
  }
  const char *warningMessage = "Failed to load instrument ";
  try {
    g_log.notice() << "Loading instrument " << instrName << " ... "
                   << std::endl;
    API::Algorithm_sptr alg =
        API::AlgorithmFactory::Instance().create("LoadInstrument", -1);
    alg->initialize();
    alg->setPropertyValue("InstrumentName", instrName);
    alg->setProperty("Workspace", m_eventBuffer[0]);
    alg->setProperty("RewriteSpectraMap", Mantid::Kernel::OptionalBool(false));
    alg->setChild(true);
    alg->execute();
    // check if the instrument was loaded
    if (!alg->isExecuted()) {
      g_log.warning() << warningMessage << instrName << std::endl;
    }
    g_log.notice() << "Instrument loaded." << std::endl;
  } catch (std::exception &e) {
    g_log.warning() << warningMessage << instrName << std::endl;
    g_log.warning() << e.what() << instrName << std::endl;
  }
}
Example #2
0
ResultType performBinaryOpWithDouble(const LHSType inputWS, const double value,
                                     const std::string &op,
                                     const std::string &name, bool inplace,
                                     bool reverse) {
  std::string algoName = op;

  // Create the single valued workspace first so that it is run as a top-level
  // algorithm
  // such that it's history can be recreated
  API::Algorithm_sptr alg = API::AlgorithmManager::Instance().createUnmanaged(
      "CreateSingleValuedWorkspace");
  alg->setChild(false);
  alg->initialize();
  alg->setProperty<double>("DataValue", value);
  const std::string tmp_name("__tmp_binary_operation_double");
  alg->setPropertyValue("OutputWorkspace", tmp_name);
  alg->execute();
  MatrixWorkspace_sptr singleValue;
  API::AnalysisDataServiceImpl &data_store =
      API::AnalysisDataService::Instance();
  if (alg->isExecuted()) {
    singleValue = boost::dynamic_pointer_cast<API::MatrixWorkspace>(
        data_store.retrieve(tmp_name));
  } else {
    throw std::runtime_error(
        "performBinaryOp: Error in execution of CreateSingleValuedWorkspace");
  }
  // Call the function above with the signle-value workspace
  ResultType result =
      performBinaryOp<LHSType, MatrixWorkspace_sptr, ResultType>(
          inputWS, singleValue, algoName, name, inplace, reverse);
  // Delete the temporary
  data_store.remove(tmp_name);
  return result;
}