16#include <Poco/DOM/AutoPtr.h>
17#include <Poco/DOM/DOMParser.h>
18#include <Poco/DOM/Document.h>
19#include <Poco/DOM/Element.h>
20#include <Poco/DOM/NodeFilter.h>
21#include <Poco/DOM/NodeIterator.h>
22#include <Poco/DOM/NodeList.h>
26using Poco::XML::AutoPtr;
27using Poco::XML::Document;
28using Poco::XML::DOMParser;
29using Poco::XML::Element;
35using namespace Kernel;
37using Geometry::Instrument;
45 "The name of the workspace to load the instrument parameters into.");
47 "The filename (including its full or relative path) of a parameter "
48 "definition file. The file extension must either be .xml or .XML.");
49 declareProperty(
"ParameterXML",
"",
"The parameter definition XML as a string.");
68 if (filename.empty() && parameterXMLProperty->
isDefault()) {
70 "property of LoadParameterFile most be "
71 "specified to load an IDF",
79 Instrument_sptr instrument = std::const_pointer_cast<Instrument>(localWorkspace->getInstrument()->baseInstrument());
83 AutoPtr<Document> pDoc;
88 prog.
report(
"Parsing XML");
93 pDoc = pParser.parseString(parameterXML);
94 }
catch (Poco::Exception &exc) {
102 Poco::File ipfFile(filename);
103 if (!ipfFile.exists()) {
104 Poco::Path filePath(filename);
107 .setFileName(filePath.getFileName())
111 pDoc = pParser.parse(filename);
112 }
catch (Poco::Exception &exc) {
120 Element *pRootElem = pDoc->documentElement();
121 if (!pRootElem->hasChildNodes()) {
128 loadInstr.
setComponentLinks(instrument, pRootElem, &prog, localWorkspace->getWorkspaceStartDate());
131 localWorkspace->populateInstrumentParameters();
132 if (!filename.empty()) {
133 localWorkspace->instrumentParameters().addParameterFilename(filename);
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
Helper class for reporting progress from algorithms.
A property class for workspaces.
void init() override
Initialisation method.
void exec() override
Executes the algorithm.
Creates an instrument data from a XML instrument description file.
void setComponentLinks(std::shared_ptr< Geometry::Instrument > &instrument, Poco::XML::Element *pRootElem, Kernel::ProgressBase *progress=nullptr, const std::string &requestedDate=std::string())
Add/overwrite any parameters specified in instrument with param values specified in <component-link> ...
Records the filename and the description of failure.
Exception for errors associated with the instrument definition.
void information(const std::string &msg)
Logs at information level.
void resetNumSteps(int64_t nsteps, double start, double end)
Change the number of steps between start/end.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
Base class for properties.
virtual bool isDefault() const =0
Overriden function that returns if property has the same value that it was initialised with,...
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
@ InOut
Both an input & output workspace.