Skip to content
Snippets Groups Projects
Commit cde6b772 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

Do not stop server (even through assert -> undefined behaviour without Debug...

Do not stop server (even through assert -> undefined behaviour without Debug flags!) when trying to create a string array. Instead the property is simply ignored and a warning is printed.
parent 20950ea0
No related branches found
No related tags found
No related merge requests found
...@@ -6,22 +6,22 @@ ...@@ -6,22 +6,22 @@
namespace ChimeraTK{ namespace ChimeraTK{
bool CSAdapterEqFct::emptyLocationVariablesHandled = false; bool CSAdapterEqFct::emptyLocationVariablesHandled = false;
CSAdapterEqFct::CSAdapterEqFct(int fctCode, CSAdapterEqFct::CSAdapterEqFct(int fctCode,
boost::shared_ptr<ControlSystemPVManager> const & controlSystemPVManager, boost::shared_ptr<ControlSystemPVManager> const & controlSystemPVManager,
boost::shared_ptr<DoocsUpdater> const & updater, std::string fctName ) boost::shared_ptr<DoocsUpdater> const & updater, std::string fctName )
// The second argument in EqFct has to be a pointer to string, and NULL pointer is // The second argument in EqFct has to be a pointer to string, and NULL pointer is
// used when the name is coming from the config file. This interface is so ugly that // used when the name is coming from the config file. This interface is so ugly that
// I changed it to std::string and need the ?: trick to get a NULL pointer in // I changed it to std::string and need the ?: trick to get a NULL pointer in
// if the string is empty // if the string is empty
: EqFct ("NAME = CSAdapterEqFct", fctName.empty()?NULL:&fctName), : EqFct ("NAME = CSAdapterEqFct", fctName.empty()?NULL:&fctName),
controlSystemPVManager_(controlSystemPVManager), controlSystemPVManager_(controlSystemPVManager),
fctCode_(fctCode), updater_(updater){ fctCode_(fctCode), updater_(updater){
registerProcessVariablesInDoocs(); registerProcessVariablesInDoocs();
} }
CSAdapterEqFct::~CSAdapterEqFct(){ CSAdapterEqFct::~CSAdapterEqFct(){
//stop the updater thread before any of the process variables go out of scope //stop the updater thread before any of the process variables go out of scope
updater_->stop(); updater_->stop();
...@@ -43,7 +43,13 @@ namespace ChimeraTK{ ...@@ -43,7 +43,13 @@ namespace ChimeraTK{
doocsProperties_.reserve( mappingForThisLocation.size() ); doocsProperties_.reserve( mappingForThisLocation.size() );
for (auto & propertyDescrition : mappingForThisLocation){ for (auto & propertyDescrition : mappingForThisLocation){
doocsProperties_.push_back( factory.create( propertyDescrition ) ); try {
doocsProperties_.push_back( factory.create( propertyDescrition ) );
}
catch(std::invalid_argument &e) {
std::cerr << "**** WARNING: Could not create property for variable '" << propertyDescrition->location << "/" <<
propertyDescrition->name << "': " << e.what() << ". Skipping this property." << std::endl;
}
} }
} }
......
...@@ -170,8 +170,9 @@ namespace ChimeraTK { ...@@ -170,8 +170,9 @@ namespace ChimeraTK {
} else if (valueType == typeid(double)) { } else if (valueType == typeid(double)) {
return typedCreateScalarOrArray<double, D_double, double, D_doublearray, double>(*processVariable, *autoPropertyDescription, DecoratorType::range_checking, ArrayDescription::DataType::Double); return typedCreateScalarOrArray<double, D_double, double, D_doublearray, double>(*processVariable, *autoPropertyDescription, DecoratorType::range_checking, ArrayDescription::DataType::Double);
} else if (valueType == typeid(std::string)) { } else if (valueType == typeid(std::string)) {
//@todo FIXME returning scalar also for arrays. This should result in an error return typedCreateScalarOrArray<std::string, D_string, std::string,
return createDoocsScalar<std::string, D_string>(*autoPropertyDescription, DecoratorType::range_checking); std::nullptr_t, std::nullptr_t>(*processVariable, *autoPropertyDescription,
DecoratorType::range_checking, ArrayDescription::DataType::Auto);
} else { } else {
throw std::invalid_argument("unsupported value type"); throw std::invalid_argument("unsupported value type");
} }
...@@ -194,6 +195,12 @@ namespace ChimeraTK { ...@@ -194,6 +195,12 @@ namespace ChimeraTK {
return doocsPV; return doocsPV;
} }
// template specialisation for cases with no matching DOOCS array type (e.g. string)
template<>
boost::shared_ptr<D_fct> DoocsPVFactory::typedCreateDoocsArray<std::nullptr_t,std::nullptr_t>(ArrayDescription const &){
throw std::invalid_argument("Type not supported as an array");
}
boost::shared_ptr<D_fct> DoocsPVFactory::createDoocsArray( std::shared_ptr<ArrayDescription> const & arrayDescription){ boost::shared_ptr<D_fct> DoocsPVFactory::createDoocsArray( std::shared_ptr<ArrayDescription> const & arrayDescription){
if(arrayDescription->dataType == ArrayDescription::DataType::Auto){ if(arrayDescription->dataType == ArrayDescription::DataType::Auto){
// leave the desision which array to produce to the auto creation algorithm. We need it there anyway // leave the desision which array to produce to the auto creation algorithm. We need it there anyway
......
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