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>
25using Poco::XML::AutoPtr;
26using Poco::XML::Document;
27using Poco::XML::DOMParser;
28using Poco::XML::Element;
34using namespace Kernel;
36using Geometry::Instrument;
44 "The name of the workspace to load the instrument parameters into.");
46 "The filename (including its full or relative path) of a parameter "
47 "definition file. The file extension must either be .xml or .XML.");
48 declareProperty(
"ParameterXML",
"",
"The parameter definition XML as a string.");
67 if (filename.empty() && parameterXMLProperty->
isDefault()) {
69 "property of LoadParameterFile most be "
70 "specified to load an IDF",
78 Instrument_sptr instrument = std::const_pointer_cast<Instrument>(localWorkspace->getInstrument()->baseInstrument());
82 AutoPtr<Document> pDoc;
87 prog.
report(
"Parsing XML");
92 pDoc = pParser.parseString(parameterXML);
93 }
catch (Poco::Exception &exc) {
101 std::filesystem::path ipfFile(filename);
102 if (!std::filesystem::exists(ipfFile)) {
103 std::filesystem::path filePath(filename);
105 (std::filesystem::path(Kernel::ConfigService::Instance().getInstrumentDirectory()) / filePath.filename())
109 pDoc = pParser.parse(filename);
110 }
catch (Poco::Exception &exc) {
118 Element *pRootElem = pDoc->documentElement();
119 if (!pRootElem->hasChildNodes()) {
126 loadInstr.
setComponentLinks(instrument, pRootElem, &prog, localWorkspace->getWorkspaceStartDate());
129 localWorkspace->populateInstrumentParameters();
130 if (!filename.empty()) {
131 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,...
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.