Skip to content
Snippets Groups Projects
Commit a473da6d authored by Jens Georg's avatar Jens Georg
Browse files

D_xy: Add support for axis settings

parent 17ef6f8e
No related branches found
Tags 00.12.00
No related merge requests found
......@@ -120,9 +120,17 @@ namespace ChimeraTK {
/********************************************************************************************************************/
struct XyDescription : public PropertyDescription, public PropertyAttributes {
struct Axis {
std::string label;
int logarithmic;
float start;
float stop;
};
ChimeraTK::RegisterPath xSource;
ChimeraTK::RegisterPath ySource;
std::string description;
std::map<std::string, Axis> axis;
XyDescription(ChimeraTK::RegisterPath const& xSource_ = "", ChimeraTK::RegisterPath const& ySource_ = "",
std::string const& location_ = "", std::string const& name_ = "", bool hasHistory_ = true)
......
......@@ -220,8 +220,21 @@ namespace ChimeraTK {
getDecorator<float>(xProcessVariable, DecoratorType::C_style_conversion),
getDecorator<float>(yProcessVariable, DecoratorType::C_style_conversion), _updater));
if(not xyDescription.description.empty())
boost::dynamic_pointer_cast<DoocsXy>(doocsPV)->description(xyDescription.description);
auto xy = boost::dynamic_pointer_cast<DoocsXy>(doocsPV);
if(not xyDescription.description.empty()) xy->description(xyDescription.description);
auto const xIt = xyDescription.axis.find("x");
if(xIt != xyDescription.axis.cend()) {
auto const& axis = xIt->second;
xy->xegu(axis.logarithmic, axis.start, axis.stop, axis.label.c_str());
}
auto const yIt = xyDescription.axis.find("y");
if(yIt != xyDescription.axis.cend()) {
auto const& axis = yIt->second;
xy->egu(axis.logarithmic, axis.start, axis.stop, axis.label.c_str());
}
doocsPV->set_ro_access();
......
......@@ -268,6 +268,36 @@ namespace ChimeraTK {
auto descriptionNode = xyXml->get_first_child("description");
xyDescription->description = getContentString(descriptionNode);
auto unitNodes = xyXml->get_children("unit");
for(const auto unit : unitNodes) {
auto unitElement = asXmlElement(unit);
auto axis = getAttributeValue(unitElement, "axis");
if(axis != "x" && axis != "y")
throw std::invalid_argument("Unsupported axis in D_xy, must be \"x\" or \"y\": " + axis);
std::string label;
if(not unit->get_children().empty()) label = getContentString(unit);
xyDescription->axis[axis].label = label;
try {
xyDescription->axis[axis].logarithmic = std::stoi(getAttributeValue(unitElement, "logarithmic"));
}
catch(std::invalid_argument&) {
}
try {
xyDescription->axis[axis].start = std::stof(getAttributeValue(unitElement, "start"));
}
catch(std::invalid_argument&) {
}
try {
xyDescription->axis[axis].stop = std::stof(getAttributeValue(unitElement, "stop"));
}
catch(std::invalid_argument&) {
}
}
addDescription(xyDescription, {xAbsoluteSource, yAbsoluteSource});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment