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

D_spectrum: Add possibility to provide EGUs

This will be used unless overriden in doocs server conf
parent 3f678e36
No related branches found
No related tags found
No related merge requests found
......@@ -121,12 +121,21 @@ namespace ChimeraTK {
/********************************************************************************************************************/
struct SpectrumDescription : public PropertyDescription, public PropertyAttributes {
struct Axis {
std::string label;
int logarithmic;
float start;
float stop;
};
ChimeraTK::RegisterPath source;
ChimeraTK::RegisterPath startSource;
ChimeraTK::RegisterPath incrementSource;
float start;
float increment;
size_t numberOfBuffers;
std::string description;
std::map<std::string, Axis> axis;
SpectrumDescription(ChimeraTK::RegisterPath const& source_ = "", std::string location_ = "", std::string name_ = "",
bool hasHistory_ = true, bool isWriteable_ = true)
......
......@@ -204,6 +204,18 @@ namespace ChimeraTK {
boost::dynamic_pointer_cast<DoocsSpectrum>(doocsPV)->publishZeroMQ();
}
auto const xIt = spectrumDescription.axis.find("x");
if(xIt != spectrumDescription.axis.cend()) {
auto const& axis = xIt->second;
spectrum->xegu(axis.logarithmic, axis.start, axis.stop, axis.label.c_str());
}
auto const yIt = spectrumDescription.axis.find("y");
if(yIt != spectrumDescription.axis.cend()) {
auto const& axis = yIt->second;
spectrum->egu(axis.logarithmic, axis.start, axis.stop, axis.label.c_str());
}
// set data matching mode (need to call before setMacroPulseNumberSource, as the mode is checked there)
boost::dynamic_pointer_cast<DoocsSpectrum>(doocsPV)->_consistencyGroup.setMatchingMode(
spectrumDescription.dataMatching);
......
......@@ -279,6 +279,38 @@ namespace ChimeraTK {
usedVariables.push_back(numberOfBuffers);
}
auto descriptionNode = spectrumXml->get_first_child("description");
if(descriptionNode != nullptr) spectrumDescription->description = getContentString(descriptionNode);
auto unitNodes = spectrumXml->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_spectrum, must be \"x\" or \"y\": " + axis);
std::string label;
if(not unit->get_children().empty()) label = getContentString(unit);
spectrumDescription->axis[axis].label = label;
try {
spectrumDescription->axis[axis].logarithmic = std::stoi(getAttributeValue(unitElement, "logarithmic"));
}
catch(std::invalid_argument&) {
}
try {
spectrumDescription->axis[axis].start = std::stof(getAttributeValue(unitElement, "start"));
}
catch(std::invalid_argument&) {
}
try {
spectrumDescription->axis[axis].stop = std::stof(getAttributeValue(unitElement, "stop"));
}
catch(std::invalid_argument&) {
}
}
addDescription(spectrumDescription, usedVariables);
}
......
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