Skip to content

Commit

Permalink
Add non-active parameterXML property re #8546
Browse files Browse the repository at this point in the history
I also drilled it down into the execManually method changing its arguments.

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Dec 5, 2013
1 parent c963574 commit a6a122b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Expand Up @@ -84,7 +84,7 @@ namespace Mantid
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "DataHandling\\Instrument";}

static void execManually(std::string filename, Mantid::API::ExperimentInfo_sptr localWorkspace);
static void execManually(bool useString, std::string filename, std::string parameterString, Mantid::API::ExperimentInfo_sptr localWorkspace);

private:
/// Sets documentation strings for this algorithm
Expand Down
Expand Up @@ -90,7 +90,7 @@ void LoadIDFFromNexus::runLoadParameterFile(const MatrixWorkspace_sptr & workspa
const std::string paramFile = directory + instrumentName + "_Parameters.xml";

try {
LoadParameterFile::execManually(paramFile, workspace);
LoadParameterFile::execManually(false, paramFile,"", workspace);
} catch ( std::runtime_error& ) {
g_log.notice() << "File " << paramFile << " not found or un-parsable. "
"However, the instrument has been loaded successfully.\n";
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp
Expand Up @@ -237,7 +237,7 @@ namespace Mantid
try
{
// To allow the use of ExperimentInfo instead of workspace, we call it manually
LoadParameterFile::execManually(fullPathParamIDF, m_workspace);
LoadParameterFile::execManually(false, fullPathParamIDF, "", m_workspace);
g_log.debug("Parameters loaded successfully.");
} catch (std::invalid_argument& e)
{
Expand Down
16 changes: 10 additions & 6 deletions Code/Mantid/Framework/DataHandling/src/LoadParameterFile.cpp
Expand Up @@ -59,8 +59,8 @@ DECLARE_ALGORITHM(LoadParameterFile)
/// Sets documentation strings for this algorithm
void LoadParameterFile::initDocs()
{
this->setWikiSummary("Loads instrument parameters into a [[workspace]]. where these parameters are associated component names as defined in Instrument Definition File ([[InstrumentDefinitionFile|IDF]]).");
this->setOptionalMessage("Loads instrument parameters into a workspace. where these parameters are associated component names as defined in Instrument Definition File (IDF).");
this->setWikiSummary("Loads instrument parameters into a [[workspace]]. where these parameters are associated component names as defined in Instrument Definition File ([[InstrumentDefinitionFile|IDF]]) or a string consisting of the contents of such..");
this->setOptionalMessage("Loads instrument parameters into a workspace. where these parameters are associated component names as defined in Instrument Definition File (IDF) or a string consisting of the contents of such.");
}


Expand All @@ -80,8 +80,9 @@ void LoadParameterFile::init()
declareProperty(
new WorkspaceProperty<MatrixWorkspace>("Workspace","Anonymous",Direction::InOut),
"The name of the workspace to load the instrument parameters into." );
declareProperty(new FileProperty("Filename","", FileProperty::Load, ".xml"),
"The filename (including its full or relative path) of a parameter defintion file. The file extension must either be .xml or .XML.");
declareProperty(new FileProperty("Filename","", FileProperty::OptionalLoad, ".xml"),
"The filename (including its full or relative path) of a parameter definition file. The file extension must either be .xml or .XML.");
declareProperty("ParameterXML","","The parameter definition XML as a string.");
}

/** Executes the algorithm. Reading in the file and creating and populating
Expand All @@ -95,13 +96,16 @@ void LoadParameterFile::exec()
// Retrieve the filename from the properties
std::string filename = getPropertyValue("Filename");

// Retrieve the parameter XML string from the properties
std::string parameterXML = getPropertyValue("ParameterXML");

// Get the input workspace
const MatrixWorkspace_sptr localWorkspace = getProperty("Workspace");

execManually(filename, localWorkspace);
execManually(false, filename, parameterXML, localWorkspace);
}

void LoadParameterFile::execManually(std::string filename, Mantid::API::ExperimentInfo_sptr localWorkspace)
void LoadParameterFile::execManually(bool useString, std::string filename, std::string parameterXML, Mantid::API::ExperimentInfo_sptr localWorkspace)
{
// TODO: Refactor to remove the need for the const cast
Instrument_sptr instrument = boost::const_pointer_cast<Instrument>(localWorkspace->getInstrument()->baseInstrument());
Expand Down

0 comments on commit a6a122b

Please sign in to comment.