diff --git a/src/DoocsPVFactory.cc b/src/DoocsPVFactory.cc index eca80c3f11ea4ec2d8ff84bb8ebc769c38795681..79424cfbdc1db18d1a58ef18fc239710e28a1616 100644 --- a/src/DoocsPVFactory.cc +++ b/src/DoocsPVFactory.cc @@ -6,6 +6,7 @@ #include "DoocsPVFactory.h" #include "splitStringAtFirstSlash.h" +#include "VariableMapper.h" namespace ChimeraTK { @@ -25,6 +26,8 @@ namespace ChimeraTK { + processVariable->getValueType().name()); } + auto propertyDescription = VariableMapper::getInstance().getAllProperties().at(processVariable->getName()); + assert(processArray->getNumberOfChannels() == 1); if(processArray->getNumberOfSamples() > 1 ) { return boost::shared_ptr<D_fct>( new DoocsProcessArray<T>(_eqFct, processArray, *_syncUtility) ); @@ -33,11 +36,11 @@ namespace ChimeraTK { // Histories seem to be supported by DOOCS only for property names shorter than 64 characters, so disable history for longer names. // The DOOCS property name is the variable name without the location name and the separating slash between location and property name. if(processArray->getName().length() - 1 - std::strlen(_eqFct->name_str()) <= 64) { - return boost::shared_ptr<D_fct>( new DoocsProcessScalar<T, DOOCS_T, DOOCS_VALUE_T>(_eqFct, splitStringAtFirstSlash(processArray->getName()).second.c_str(), processArray, *_syncUtility) ); + return boost::shared_ptr<D_fct>( new DoocsProcessScalar<T, DOOCS_T, DOOCS_VALUE_T>(_eqFct, propertyDescription.name.c_str(), processArray, *_syncUtility) ); } else { std::cerr << "WARNING: Disabling history for " << processArray->getName() << ". Name is too long." << std::endl; - return boost::shared_ptr<D_fct>( new DoocsProcessScalar<T, DOOCS_T, DOOCS_VALUE_T>(splitStringAtFirstSlash(processArray->getName()).second.c_str(), _eqFct, processArray, *_syncUtility) ); + return boost::shared_ptr<D_fct>( new DoocsProcessScalar<T, DOOCS_T, DOOCS_VALUE_T>(propertyDescription.name.c_str(), _eqFct, processArray, *_syncUtility) ); } } } @@ -53,9 +56,11 @@ namespace ChimeraTK { + processVariable->getValueType().name()); } + auto propertyDescription = VariableMapper::getInstance().getAllProperties().at(processVariable->getName()); + assert(processArray->getNumberOfChannels() == 1); assert(processArray->getNumberOfSamples() == 1); // array of strings is not supported - return boost::shared_ptr<D_fct>( new DoocsProcessScalar<std::string, D_string, std::string>(_eqFct, splitStringAtFirstSlash(processArray->getName()).second.c_str(), processArray, *_syncUtility) ); + return boost::shared_ptr<D_fct>( new DoocsProcessScalar<std::string, D_string, std::string>(_eqFct, propertyDescription.name.c_str(), processArray, *_syncUtility) ); } boost::shared_ptr<D_fct> DoocsPVFactory::create( ProcessVariable::SharedPtr & processVariable ){ diff --git a/tests/src/testDoocsPVFactory.cpp b/tests/src/testDoocsPVFactory.cpp index b81d7fcb2a97ace3f099351cd8f2a97ddf6c227f..fa9916bf5c3b58609ceb370f4ea9044643c9f399 100644 --- a/tests/src/testDoocsPVFactory.cpp +++ b/tests/src/testDoocsPVFactory.cpp @@ -60,10 +60,11 @@ static void testCreateProcessScalar(typename ProcessVariable::SharedPtr processV DoocsProcessScalar<T, DOOCS_T, DOOCS_VALUE_T> * doocsScalarType = dynamic_cast< DoocsProcessScalar<T, DOOCS_T, DOOCS_VALUE_T> * > (doocsVariableAsDFct.get()); // if the cast succeeds the factory works as expected we are done - std::stringstream errorMessage; - errorMessage << "testCreateProcessScalar failed for type " << typeid(T).name(); - BOOST_CHECK_MESSAGE(doocsScalarType, errorMessage.str()); - BOOST_CHECK( expectedPropertyName == doocsVariableAsDFct->property_name() ); + std::string errorMessage = std::string("testCreateProcessScalar failed for type ") + typeid(T).name(); + BOOST_CHECK_MESSAGE(doocsScalarType, errorMessage); + errorMessage = std::string("Error checking property name: expectedPropertyName '") + + expectedPropertyName + "', property_name() '" + doocsVariableAsDFct->property_name() + "'"; + BOOST_CHECK_MESSAGE( expectedPropertyName == doocsVariableAsDFct->property_name() , errorMessage); } BOOST_AUTO_TEST_SUITE( PVManagerTestSuite ) @@ -96,35 +97,35 @@ BOOST_AUTO_TEST_CASE( testCreateScalars ) { // These checkpoints are always true. testCreateProcessScalar<int32_t, D_int, int>( boost::dynamic_pointer_cast<ProcessVariable>(csManager->getProcessArray<int32_t>("I/int32")), - factory, "int32"); + factory, "int32 ");// DOOCS property names always have a space (and potentially some description)" BOOST_CHECK(-32); testCreateProcessScalar<uint32_t, D_int, int>( boost::dynamic_pointer_cast<ProcessVariable>(csManager->getProcessArray<uint32_t>("U/uint32")), - factory, "uint32"); + factory, "uint32 "); BOOST_CHECK(32); testCreateProcessScalar<int16_t, D_int, int>( boost::dynamic_pointer_cast<ProcessVariable>(csManager->getProcessArray<int16_t>("I/int16")), - factory, "int16"); + factory, "int16 "); BOOST_CHECK(-16); testCreateProcessScalar<uint16_t, D_int, int>( boost::dynamic_pointer_cast<ProcessVariable>(csManager->getProcessArray<uint16_t>("U/uint16")), - factory, "uint16"); + factory, "uint16 "); BOOST_CHECK(16); testCreateProcessScalar<int8_t, D_int, int>( boost::dynamic_pointer_cast<ProcessVariable>(csManager->getProcessArray<int8_t>("I/int8")), - factory, "int8"); + factory, "int8 "); BOOST_CHECK(-8); testCreateProcessScalar<uint8_t, D_int, int>( boost::dynamic_pointer_cast<ProcessVariable>(csManager->getProcessArray<uint8_t>("U/uint8")), - factory, "uint8"); + factory, "uint8 "); BOOST_CHECK(8); testCreateProcessScalar<float, D_float, float>( boost::dynamic_pointer_cast<ProcessVariable>(csManager->getProcessArray<float>("FP/float")), - factory, "float"); + factory, "float "); BOOST_CHECK(0.5); testCreateProcessScalar<double, D_double, double>( boost::dynamic_pointer_cast<ProcessVariable>(csManager->getProcessArray<double>("FP/double")), - factory, "double"); + factory, "double "); }