Commit 49f741f8 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

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.
parent fc93cf0e
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include <dynamic_reconfigure/Reconfigure.h> #include <dynamic_reconfigure/Reconfigure.h>
#include <iri_ros_tools/module_service.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 * \brief Dynamic reconfigure client wrapper
* *
...@@ -54,6 +58,12 @@ class CModuleDynReconf : protected CModuleService<dynamic_reconfigure::Reconfigu ...@@ -54,6 +58,12 @@ class CModuleDynReconf : protected CModuleService<dynamic_reconfigure::Reconfigu
* sure the value has been changed correctly. * sure the value has been changed correctly.
*/ */
double double_value; double double_value;
/**
* \brief Status of the last service call
*
*
*/
dyn_reconf_status_t dyn_reconf_status;
protected: protected:
/** /**
* \brief Service data check callback * \brief Service data check callback
...@@ -150,6 +160,15 @@ class CModuleDynReconf : protected CModuleService<dynamic_reconfigure::Reconfigu ...@@ -150,6 +160,15 @@ class CModuleDynReconf : protected CModuleService<dynamic_reconfigure::Reconfigu
* changed (true) or not (false) * changed (true) or not (false)
*/ */
bool set_parameter(const std::string &name,double value); 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 * \brief Destructor
* *
...@@ -159,6 +178,7 @@ class CModuleDynReconf : protected CModuleService<dynamic_reconfigure::Reconfigu ...@@ -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) 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_max_num_retries(1);
this->set_call_check_function(boost::bind(&CModuleDynReconf::check_dyn_reconf,this,_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) ...@@ -172,8 +192,14 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg)
{ {
if(msg.response.config.bools[i].value!=this->bool_value) if(msg.response.config.bools[i].value!=this->bool_value)
{ {
this->dyn_reconf_status=DYN_RECONF_NO_CHANGE;
return false; return false;
} }
else
{
this->dyn_reconf_status=DYN_RECONF_SUCCESSFULL;
return true;
}
} }
} }
for(i=0;i<msg.response.config.ints.size();i++) for(i=0;i<msg.response.config.ints.size();i++)
...@@ -182,8 +208,14 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg) ...@@ -182,8 +208,14 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg)
{ {
if(msg.response.config.ints[i].value!=this->int_value) if(msg.response.config.ints[i].value!=this->int_value)
{ {
this->dyn_reconf_status=DYN_RECONF_NO_CHANGE;
return false; return false;
} }
else
{
this->dyn_reconf_status=DYN_RECONF_SUCCESSFULL;
return true;
}
} }
} }
for(i=0;i<msg.response.config.strs.size();i++) for(i=0;i<msg.response.config.strs.size();i++)
...@@ -192,8 +224,14 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg) ...@@ -192,8 +224,14 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg)
{ {
if(msg.response.config.strs[i].value!=this->string_value) if(msg.response.config.strs[i].value!=this->string_value)
{ {
this->dyn_reconf_status=DYN_RECONF_NO_CHANGE;
return false; return false;
} }
else
{
this->dyn_reconf_status=DYN_RECONF_SUCCESSFULL;
return true;
}
} }
} }
for(i=0;i<msg.response.config.doubles.size();i++) for(i=0;i<msg.response.config.doubles.size();i++)
...@@ -202,12 +240,19 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg) ...@@ -202,12 +240,19 @@ bool CModuleDynReconf::check_dyn_reconf(dynamic_reconfigure::Reconfigure &msg)
{ {
if(msg.response.config.doubles[i].value!=this->double_value) if(msg.response.config.doubles[i].value!=this->double_value)
{ {
this->dyn_reconf_status=DYN_RECONF_NO_CHANGE;
return false; 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) bool CModuleDynReconf::set_parameter(const std::string &name,bool value)
...@@ -310,6 +355,11 @@ bool CModuleDynReconf::set_parameter(const std::string &name,double 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() CModuleDynReconf::~CModuleDynReconf()
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment