Skip to content
Snippets Groups Projects
Commit ef7ea4eb authored by Martin Killenberg's avatar Martin Killenberg
Browse files

VariableMapper is creating spectrum descriptions. Tests running, but not sensitive yet.

parent de64954b
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,7 @@ namespace ChimeraTK{
void processLocationNode(xmlpp::Node const * locationNode);
void processPropertyNode(xmlpp::Node const * propertyNode, std::string locationName);
void processSpectrumNode(xmlpp::Node const * node, std::string locationName);
void processArrayNode(xmlpp::Node const * node, std::string locationName);
void processImportNode(xmlpp::Node const * importNode, std::string importLocationName=std::string());
void import(std::string importSource, std::string importLocationName, std::string directory="");
......
......@@ -50,6 +50,8 @@ namespace ChimeraTK{
locationInfo.isWriteable = evaluateBool(getContentString(node));
}else if (node->get_name() == "D_spectrum"){
processSpectrumNode(node, locationName);
}else if (node->get_name() == "D_array"){
processArrayNode(node, locationName);
}else{
throw std::invalid_argument(std::string("Error parsing xml file in location ") + locationName + ": Unknown node '"+node->get_name()+"'");
}
......@@ -149,6 +151,40 @@ namespace ChimeraTK{
addDescription(spectrumDescription, absoluteSource);
}
void VariableMapper::processArrayNode(xmlpp::Node const * node, std::string locationName){
auto arrayXml = asXmlElement(node);
// the "main source" of a spectum
std::string source = getAttributeValue(arrayXml, "source");
std::string name = determineName(arrayXml, source);
const xmlpp::Attribute* typeAttribute = arrayXml->get_attribute("type");
std::map< std::string, ArrayDescription::DataType > dataTypeMap(
{ {"auto", ArrayDescription::DataType::Auto},
{"byte", ArrayDescription::DataType::Byte},
{"short", ArrayDescription::DataType::Short},
{"int", ArrayDescription::DataType::Int},
{"long", ArrayDescription::DataType::Long},
{"float", ArrayDescription::DataType::Float},
{"double", ArrayDescription::DataType::Double} });
ArrayDescription::DataType type;
if (typeAttribute){
type = dataTypeMap[typeAttribute->get_value()];
}else{
type = ArrayDescription::DataType::Auto;
}
std::string absoluteSource = getAbsoluteSource(source, locationName);
// prepare the property description
auto arrayDescription = std::make_shared<ArrayDescription>(absoluteSource, locationName, name);
processHistoryAndWritableAttributes(arrayDescription, arrayXml, locationName);
addDescription(arrayDescription, absoluteSource);
}
void VariableMapper::processImportNode(xmlpp::Node const * importNode, std::string importLocationName){
const xmlpp::Element* importElement = dynamic_cast<const xmlpp::Element*>(importNode);
std::string directory;
......
......@@ -41,7 +41,7 @@ void testReadWrite(){
// running update now does not change anything, the application has not acted yet
DoocsServerTestHelper::runUpdate();
auto notIntArray = DoocsServerTestHelper::doocsGetArray<float>("//INT/FROM_DEVICE_ARRAY");
auto notIntArray = DoocsServerTestHelper::doocsGetArray<float>("//INT/MY_RENAMED_INTARRAY");
for (auto val : notIntArray){
BOOST_CHECK( std::fabs(val) < 0.001 );
}
......@@ -53,7 +53,7 @@ void testReadWrite(){
// run the application loop. Still no changes until we run the doocs server update
referenceTestApplication.runMainLoopOnce();
notIntArray = DoocsServerTestHelper::doocsGetArray<float>("//INT/FROM_DEVICE_ARRAY");
notIntArray = DoocsServerTestHelper::doocsGetArray<float>("//INT/MY_RENAMED_INTARRAY");
for (auto val : notIntArray){
BOOST_CHECK( std::fabs(val) < 0.001 );
}
......@@ -65,7 +65,7 @@ void testReadWrite(){
// now finally after the next update we should see the new data in doocs
DoocsServerTestHelper::runUpdate();
notIntArray = DoocsServerTestHelper::doocsGetArray<float>("//INT/FROM_DEVICE_ARRAY");
notIntArray = DoocsServerTestHelper::doocsGetArray<float>("//INT/MY_RENAMED_INTARRAY");
int testVal = 140;
for (auto val : notIntArray){
BOOST_CHECK( std::fabs(val - testVal++) < 0.001 );
......
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