From 49f741f89dfd9b46a1e8ff31f1258b4abbfe3216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu> Date: Wed, 18 Oct 2017 15:01:40 +0000 Subject: [PATCH] Added a function to get the status of the last call. The new errors taken into account are: * the parameter does not exist. * the parameter has not been changed. --- include/iri_ros_tools/module_dyn_reconf.h | 52 ++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/include/iri_ros_tools/module_dyn_reconf.h b/include/iri_ros_tools/module_dyn_reconf.h index 091a051..e589f66 100644 --- a/include/iri_ros_tools/module_dyn_reconf.h +++ b/include/iri_ros_tools/module_dyn_reconf.h @@ -4,6 +4,10 @@ #include <dynamic_reconfigure/Reconfigure.h> #include <iri_ros_tools/module_service.h> +typedef enum {DYN_RECONF_NO_SUCH_PARAM, + DYN_RECONF_NO_CHANGE, + DYN_RECONF_SUCCESSFULL} dyn_reconf_status_t; + /** * \brief Dynamic reconfigure client wrapper * @@ -54,6 +58,12 @@ class CModuleDynReconf : protected CModuleService<dynamic_reconfigure::Reconfigu * sure the value has been changed correctly. */ double double_value; + /** + * \brief Status of the last service call + * + * + */ + dyn_reconf_status_t dyn_reconf_status; protected: /** * \brief Service data check callback @@ -150,6 +160,15 @@ class CModuleDynReconf : protected CModuleService<dynamic_reconfigure::Reconfigu * changed (true) or not (false) */ bool set_parameter(const std::string &name,double value); + /** + * \brief returns the las call status + * + * This function returns the status of the last service call, which can be + * one of the dyn_reconf_status_t data type values. + * + * \return the status of the last service call. + */ + dyn_reconf_status_t get_status(void); /** * \brief Destructor * @@ -159,6 +178,7 @@ class CModuleDynReconf : protected CModuleService<dynamic_reconfigure::Reconfigu CModuleDynReconf::CModuleDynReconf(const std::string &name,const std::string &name_space) : CModuleService(name,name_space) { + this->dyn_reconf_status=DYN_RECONF_SUCCESSFULL; this->set_max_num_retries(1); this->set_call_check_function(boost::bind(&CModuleDynReconf::check_dyn_reconf,this,_1)); } @@ -172,8 +192,14 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg) { if(msg.response.config.bools[i].value!=this->bool_value) { + this->dyn_reconf_status=DYN_RECONF_NO_CHANGE; return false; } + else + { + this->dyn_reconf_status=DYN_RECONF_SUCCESSFULL; + return true; + } } } for(i=0;i<msg.response.config.ints.size();i++) @@ -182,8 +208,14 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg) { if(msg.response.config.ints[i].value!=this->int_value) { + this->dyn_reconf_status=DYN_RECONF_NO_CHANGE; return false; } + else + { + this->dyn_reconf_status=DYN_RECONF_SUCCESSFULL; + return true; + } } } for(i=0;i<msg.response.config.strs.size();i++) @@ -192,8 +224,14 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg) { if(msg.response.config.strs[i].value!=this->string_value) { + this->dyn_reconf_status=DYN_RECONF_NO_CHANGE; return false; } + else + { + this->dyn_reconf_status=DYN_RECONF_SUCCESSFULL; + return true; + } } } for(i=0;i<msg.response.config.doubles.size();i++) @@ -202,12 +240,19 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg) { if(msg.response.config.doubles[i].value!=this->double_value) { + this->dyn_reconf_status=DYN_RECONF_NO_CHANGE; return false; } + else + { + this->dyn_reconf_status=DYN_RECONF_SUCCESSFULL; + return true; + } } } - return true; + this->dyn_reconf_status=DYN_RECONF_NO_SUCH_PARAM; + return false; } bool CModuleDynReconf::set_parameter(const std::string &name,bool value) @@ -310,6 +355,11 @@ bool CModuleDynReconf::set_parameter(const std::string &name,double value) } } +dyn_reconf_status_t CModuleDynReconf::get_status(void) +{ + return this->dyn_reconf_status; +} + CModuleDynReconf::~CModuleDynReconf() { -- GitLab