65 const bool saveLocationParams =
getProperty(
"LocationParameters");
66 const std::string filename =
getProperty(
"Filename");
74 std::map<ComponentID, std::vector<boost::tuple<std::string, std::string, std::string>>> toSave;
77 Progress prog(
this, 0.0, 0.3, params->size());
80 for (
auto ¶msIt : *params) {
83 prog.
report(
"Generating parameters");
85 const std::string pName = paramsIt.second->name();
86 const std::string pType = paramsIt.second->
type();
87 const std::string pValue = paramsIt.second->asString();
89 if (pName ==
"x" || pName ==
"y" || pName ==
"z" || pName ==
"r-position" || pName ==
"t-position" ||
90 pName ==
"p-position" || pName ==
"rotx" || pName ==
"roty" || pName ==
"rotz") {
91 g_log.
warning() <<
"The parameter name '" << pName <<
"' is reserved and has not been saved. "
92 <<
"Please contact the Mantid team for more information.";
97 if (saveLocationParams) {
99 std::istringstream pValueSS(pValue);
101 toSave[cID].emplace_back(
"x",
"double", boost::lexical_cast<std::string>(pos.
X()));
102 toSave[cID].emplace_back(
"y",
"double", boost::lexical_cast<std::string>(pos.
Y()));
103 toSave[cID].emplace_back(
"z",
"double", boost::lexical_cast<std::string>(pos.
Z()));
105 }
else if (pName ==
"rot") {
106 if (saveLocationParams) {
108 std::istringstream pValueSS(pValue);
110 toSave[cID].emplace_back(
"rotx",
"double", boost::lexical_cast<std::string>(rot.
X()));
111 toSave[cID].emplace_back(
"roty",
"double", boost::lexical_cast<std::string>(rot.
Y()));
112 toSave[cID].emplace_back(
"rotz",
"double", boost::lexical_cast<std::string>(rot.
Z()));
118 if (pType ==
"fitting") {
122 const auto &fitParam = paramsIt.second->value<
FitParameter>();
123 const std::string fpName = fitParam.
getFunction() +
":" + fitParam.getName();
124 std::stringstream fpValue;
125 fpValue <<
"<formula";
126 fpValue <<
" eq=\"" << fitParam.getFormula() <<
"\"";
127 fpValue <<
" unit=\"" << fitParam.getFormulaUnit() <<
"\"";
128 fpValue <<
" result-unit=\"" << fitParam.getResultUnit() <<
"\"";
130 toSave[cID].emplace_back(boost::make_tuple(fpName,
"fitting", fpValue.str()));
132 toSave[cID].emplace_back(boost::make_tuple(pName, pType, pValue));
137 std::ofstream file(filename.c_str(), std::ofstream::trunc);
138 file <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
139 file <<
"<parameter-file instrument=\"" << instrument->getName() <<
"\"";
140 file <<
" valid-from=\"" << instrument->getValidFromDate().toISO8601String() <<
"\">\n";
142 prog.
resetNumSteps(
static_cast<int64_t
>(toSave.size()), 0.6, 1.0);
145 for (
const auto &comp : toSave) {
148 prog.
report(
"Saving parameters");
155 file <<
" <component-link";
157 file <<
" id=\"" << cDetID <<
"\"";
158 file <<
" name=\"" << cFullName <<
"\">\n";
159 for (
const auto ¶m : comp.second) {
160 const std::string pName = param.get<0>();
161 const std::string pType = param.get<1>();
162 const std::string pValue = param.get<2>();
166 if (pType ==
"fitting") {
167 file <<
" <parameter name=\"" << pName <<
"\" type=\"fitting\" >\n";
168 file <<
" " << pValue <<
"\n";
169 file <<
" </parameter>\n";
171 file <<
" <parameter name=\"" << pName <<
"\"" << (pType ==
"string" ?
" type=\"string\"" :
"")
173 file <<
" <value val=\"" << pValue <<
"\"/>\n";
174 file <<
" </parameter>\n";
177 file <<
" </component-link>\n";
179 file <<
"</parameter-file>\n";