From 7cc701da8379b602f9f9738bb7f22be1802f799f Mon Sep 17 00:00:00 2001 From: jontje Date: Thu, 7 Mar 2019 13:24:47 +0100 Subject: [PATCH 1/4] Added support for retrieving present options and modules --- include/abb_librws/rws_client.h | 31 ++++++++++- include/abb_librws/rws_common.h | 54 +++++++++++++++++- include/abb_librws/rws_interface.h | 89 ++++++++++++++++++++++++++---- src/rws_client.cpp | 27 +++++++++ src/rws_common.cpp | 38 ++++++++----- src/rws_interface.cpp | 47 +++++++++++++++- 6 files changed, 256 insertions(+), 30 deletions(-) diff --git a/include/abb_librws/rws_client.h b/include/abb_librws/rws_client.h index 93a7ff76..f7fdb2fa 100644 --- a/include/abb_librws/rws_client.h +++ b/include/abb_librws/rws_client.h @@ -347,6 +347,16 @@ class RWSClient : public POCOClient logout(); } + /** + * \brief A method for retrieving the configuration instances of a type, belonging to a specific configuration topic. + * + * \param topic specifying the configuration topic. + * \param type specifying the type in the configuration topic. + * + * \return RWSResult containing the result. + */ + RWSResult getConfigurationInstances(const std::string topic, const std::string type); + /** * \brief A method for retrieving the value of an IO signal. * @@ -408,7 +418,16 @@ class RWSClient : public POCOClient * \return RWSResult containing the result. */ RWSResult getRAPIDExecution(); - + + /** + * \brief A method for retrieving information about the RAPID modules of a RAPID task. + * + * \param task specifying the RAPID task. + * + * \return RWSResult containing the result. + */ + RWSResult getRAPIDModulesInfo(const std::string task); + /** * \brief A method for retrieving the RAPID tasks that are defined in the robot controller system. * @@ -656,6 +675,16 @@ class RWSClient : public POCOClient */ RWSResult evaluatePOCOResult(const POCOResult& poco_result, const EvaluationConditions& conditions); + /** + * \brief Method for generating a configuration URI path. + * + * \param topic for the configuration topic. + * \param type for the configuration type (belonging to the topic). + * + * \return std::string containing the path. + */ + std::string generateConfigurationPath(const std::string& topic, const std::string& type); + /** * \brief Method for generating an IO signal URI path. * diff --git a/include/abb_librws/rws_common.h b/include/abb_librws/rws_common.h index d964b454..3236ef71 100644 --- a/include/abb_librws/rws_common.h +++ b/include/abb_librws/rws_common.h @@ -353,6 +353,11 @@ struct SystemConstants */ struct XMLAttributes { + /** + * \brief Class & cfg-ia-t-li. + */ + static const XMLAttribute CLASS_CFG_IA_T_LI; + /** * \brief Class & controller execution state. */ @@ -393,11 +398,16 @@ struct SystemConstants */ static const XMLAttribute CLASS_OPMODE; + /** + * \brief Class & rap-module-info-li. + */ + static const XMLAttribute CLASS_RAP_MODULE_INFO_LI; + /** * \brief Class & rap-task-li. */ static const XMLAttribute CLASS_RAP_TASK_LI; - + /** * \brief Class & RobotWare version name. */ @@ -434,11 +444,16 @@ struct SystemConstants */ static const std::string CLASS; + /** + * \brief Configuration list item. + */ + static const std::string CFG_IA_T_LI; + /** * \brief Controller execution state. */ static const std::string CTRLEXECSTATE; - + /** * \brief Controller state. */ @@ -479,6 +494,16 @@ struct SystemConstants */ static const std::string OPMODE; + /** + * \brief Present options. + */ + static const std::string PRESENT_OPTIONS; + + /** + * \brief RAPID module info list item. + */ + static const std::string RAP_MODULE_INFO_LI; + /** * \brief RAPID task list item. */ @@ -493,6 +518,11 @@ struct SystemConstants * \brief State. */ static const std::string STATE; + + /** + * \brief Sys. + */ + static const std::string SYS; /** * \brief Sys system list item. @@ -554,6 +584,11 @@ struct SystemConstants * \brief Stop action query. */ static const std::string ACTION_STOP; + + /** + * \brief Task query. + */ + static const std::string TASK; }; /** @@ -561,6 +596,11 @@ struct SystemConstants */ struct Resources { + /** + * \brief Instances. + */ + static const std::string INSTANCES; + /** * \brief Jointtarget. */ @@ -576,6 +616,11 @@ struct SystemConstants */ static const std::string ROBTARGET; + /** + * \brief Configurations. + */ + static const std::string RW_CFG; + /** * \brief Signals. */ @@ -606,6 +651,11 @@ struct SystemConstants */ static const std::string RW_RAPID_EXECUTION; + /** + * \brief RAPID modules. + */ + static const std::string RW_RAPID_MODULES; + /** * \brief RAPID symbol data. */ diff --git a/include/abb_librws/rws_interface.h b/include/abb_librws/rws_interface.h index 38654051..0c862c8e 100644 --- a/include/abb_librws/rws_interface.h +++ b/include/abb_librws/rws_interface.h @@ -64,11 +64,67 @@ class RWSInterface */ std::string system_name; }; - + /** - * \brief A struct for containing information about the RAPID tasks defined in the robot controller. + * \brief A struct for containing information about a RobotWare option. */ - struct RAPIDTask + struct RobotWareOptionInfo + { + /** + * \brief A constructor. + * + * \param name for the name of the option. + * \param description for the description of the option. + */ + RobotWareOptionInfo(std::string name, std::string description) + : + name(name), + description(description) + {} + + /** + * \brief The option's name. + */ + std::string name; + + /** + * \brief The options's description. + */ + std::string description; + }; + + /** + * \brief A struct for containing information about a RAPID module. + */ + struct RAPIDModuleInfo + { + /** + * \brief A constructor. + * + * \param name for the name of the module. + * \param type for the type of the module. + */ + RAPIDModuleInfo(std::string name, std::string type) + : + name(name), + type(type) + {} + + /** + * \brief The module's name. + */ + std::string name; + + /** + * \brief The module's type. + */ + std::string type; + }; + + /** + * \brief A struct for containing information about a RAPID task. + */ + struct RAPIDTaskInfo { /** * \brief A constructor. @@ -76,7 +132,7 @@ class RWSInterface * \param name for the name of the task. * \param is_motion_task indicating if the task is a motion task or not. */ - RAPIDTask(std::string name, bool is_motion_task) + RAPIDTaskInfo(std::string name, bool is_motion_task) : name(name), is_motion_task(is_motion_task) @@ -101,7 +157,7 @@ class RWSInterface /** * \brief Information about the defined RAPID tasks. */ - std::vector rapid_tasks; + std::vector rapid_tasks; /** * \brief System information. @@ -204,17 +260,24 @@ class RWSInterface /** * \brief A method for collecting runtime information of the robot controller. * - * \return RuntimeInfo container for the runtime information. + * \return RuntimeInfo containing the runtime information. */ RuntimeInfo collectRuntimeInfo(); /** * \brief A method for collecting static information (at least during runtime) of the robot controller. * - * \return StaticInfo container for the static information (at least during runtime). + * \return StaticInfo containing the static information (at least during runtime). */ StaticInfo collectStaticInfo(); - + + /** + * \brief A method for retrieving the RobotWare options present in the active robot controller system. + * + * \return std::vector containing a list of the present RobotWare options. + */ + std::vector getPresentRobotWareOptions(); + /** * \brief A method for retrieving the value if an IO signal. * @@ -271,13 +334,19 @@ class RWSInterface bool getRAPIDSymbolData(const std::string task, const RWSClient::RAPIDSymbolResource symbol, RAPIDSymbolDataAbstract* p_data); + /** + * \brief A method for retrieving information about the RAPID modules of a RAPID task defined in the robot controller. + * + * \return std::vector containing the RAPID modules information. + */ + std::vector getRAPIDModulesInfo(const std::string task); /** * \brief A method for retrieving information about the RAPID tasks defined in the robot controller. * - * \return std::vector container for the RAPID tasks information. + * \return std::vector containing the RAPID tasks information. */ - std::vector getRAPIDTasks(); + std::vector getRAPIDTasks(); /** * \brief A method for retrieving some system information from the robot controller. diff --git a/src/rws_client.cpp b/src/rws_client.cpp index 2bf19215..541267e9 100644 --- a/src/rws_client.cpp +++ b/src/rws_client.cpp @@ -102,6 +102,17 @@ void RWSClient::SubscriptionResources::add(const std::string resource_uri, const * Primary methods */ +RWSClient::RWSResult RWSClient::getConfigurationInstances(const std::string topic, const std::string type) +{ + uri_ = generateConfigurationPath(topic, type) + Resources::INSTANCES; + + evaluation_conditions_.reset(); + evaluation_conditions_.parse_message_into_xml = true; + evaluation_conditions_.accepted_outcomes.push_back(HTTPResponse::HTTP_OK); + + return evaluatePOCOResult(httpGet(uri_), evaluation_conditions_); +} + RWSClient::RWSResult RWSClient::getIOSignal(const std::string iosignal) { uri_ = generateIOSignalPath(iosignal); @@ -146,6 +157,17 @@ RWSClient::RWSResult RWSClient::getRAPIDExecution() return evaluatePOCOResult(httpGet(uri_), evaluation_conditions_); } +RWSClient::RWSResult RWSClient::getRAPIDModulesInfo(const std::string task) +{ + uri_ = Resources::RW_RAPID_MODULES + "?" + Queries::TASK + task; + + evaluation_conditions_.reset(); + evaluation_conditions_.parse_message_into_xml = true; + evaluation_conditions_.accepted_outcomes.push_back(HTTPResponse::HTTP_OK); + + return evaluatePOCOResult(httpGet(uri_), evaluation_conditions_); +} + RWSClient::RWSResult RWSClient::getRAPIDTasks() { uri_ = Resources::RW_RAPID_TASKS; @@ -622,6 +644,11 @@ std::string RWSClient::getLogText(const bool verbose) return ss.str(); } +std::string RWSClient::generateConfigurationPath(const std::string& topic, const std::string& type) +{ + return Resources::RW_CFG + "/" + topic + "/" + type; +} + std::string RWSClient::generateIOSignalPath(const std::string& iosignal) { return Resources::RW_IOSYSTEM_SIGNALS + "/" + iosignal; diff --git a/src/rws_common.cpp b/src/rws_common.cpp index 83192249..0435e95d 100644 --- a/src/rws_common.cpp +++ b/src/rws_common.cpp @@ -201,6 +201,7 @@ const std::string SystemConstants::RAPID::TYPE_DNUM = "dnum"; const std::string SystemConstants::RAPID::TYPE_NUM = "num"; const std::string SystemConstants::RAPID::TYPE_STRING = "string"; +const std::string Identifiers::CFG_IA_T_LI = "cfg-ia-t-li"; const std::string Identifiers::CTRLEXECSTATE = "ctrlexecstate"; const std::string Identifiers::CTRLSTATE = "ctrlstate"; const std::string Identifiers::DATTYP = "dattyp"; @@ -210,9 +211,12 @@ const std::string Identifiers::LVALUE = "lvalue"; const std::string Identifiers::MOTIONTASK = "motiontask"; const std::string Identifiers::NAME = "name"; const std::string Identifiers::OPMODE = "opmode"; +const std::string Identifiers::PRESENT_OPTIONS = "present_options"; +const std::string Identifiers::RAP_MODULE_INFO_LI = "rap-module-info-li"; const std::string Identifiers::RAP_TASK_LI = "rap-task-li"; const std::string Identifiers::RW_VERSION_NAME = "rwversionname"; const std::string Identifiers::STATE = "state"; +const std::string Identifiers::SYS = "sys"; const std::string Identifiers::SYS_SYSTEM_LI = "sys-system-li"; const std::string Identifiers::TYPE = "type"; const std::string Identifiers::VALUE = "value"; @@ -225,39 +229,45 @@ const std::string Queries::ACTION_SETCTRLSTATE = "action=setctrls const std::string Queries::ACTION_SET_LOCALE = "action=set-locale"; const std::string Queries::ACTION_START = "action=start"; const std::string Queries::ACTION_STOP = "action=stop"; +const std::string Queries::TASK = "task="; const std::string Services::CTRL = "/ctrl"; const std::string Services::FILESERVICE = "/fileservice"; const std::string Services::RW = "/rw"; const std::string Services::SUBSCRIPTION = "/subscription"; const std::string Services::USERS = "/users"; +const std::string Resources::INSTANCES = "/instances"; const std::string Resources::JOINTTARGET = "/jointtarget"; const std::string Resources::LOGOUT = "/logout"; const std::string Resources::ROBTARGET = "/robtarget"; +const std::string Resources::RW_CFG = Services::RW + "/cfg"; const std::string Resources::RW_IOSYSTEM_SIGNALS = Services::RW + "/iosystem/signals"; const std::string Resources::RW_MASTERSHIP = Services::RW + "/mastership"; const std::string Resources::RW_MOTIONSYSTEM_MECHUNITS = Services::RW + "/motionsystem/mechunits"; const std::string Resources::RW_PANEL_CTRLSTATE = Services::RW + "/panel/ctrlstate"; const std::string Resources::RW_PANEL_OPMODE = Services::RW + "/panel/opmode"; const std::string Resources::RW_RAPID_EXECUTION = Services::RW + "/rapid/execution"; +const std::string Resources::RW_RAPID_MODULES = Services::RW + "/rapid/modules"; const std::string Resources::RW_RAPID_SYMBOL_DATA_RAPID = Services::RW + "/rapid/symbol/data/RAPID"; const std::string Resources::RW_RAPID_SYMBOL_PROPERTIES_RAPID = Services::RW + "/rapid/symbol/properties/RAPID"; const std::string Resources::RW_RAPID_TASKS = Services::RW + "/rapid/tasks"; const std::string Resources::RW_SYSTEM = Services::RW + "/system"; -const XMLAttribute XMLAttributes::CLASS_CTRLEXECSTATE(Identifiers::CLASS , Identifiers::CTRLEXECSTATE); -const XMLAttribute XMLAttributes::CLASS_CTRLSTATE(Identifiers::CLASS , Identifiers::CTRLSTATE); -const XMLAttribute XMLAttributes::CLASS_DATTYP(Identifiers::CLASS , Identifiers::DATTYP); -const XMLAttribute XMLAttributes::CLASS_IOS_SIGNAL(Identifiers::CLASS , Identifiers::IOS_SIGNAL); -const XMLAttribute XMLAttributes::CLASS_LVALUE(Identifiers::CLASS , Identifiers::LVALUE); -const XMLAttribute XMLAttributes::CLASS_MOTIONTASK(Identifiers::CLASS , Identifiers::MOTIONTASK); -const XMLAttribute XMLAttributes::CLASS_NAME(Identifiers::CLASS , Identifiers::NAME); -const XMLAttribute XMLAttributes::CLASS_OPMODE(Identifiers::CLASS , Identifiers::OPMODE); -const XMLAttribute XMLAttributes::CLASS_RAP_TASK_LI(Identifiers::CLASS , Identifiers::RAP_TASK_LI); -const XMLAttribute XMLAttributes::CLASS_RW_VERSION_NAME(Identifiers::CLASS, Identifiers::RW_VERSION_NAME); -const XMLAttribute XMLAttributes::CLASS_STATE(Identifiers::CLASS , Identifiers::STATE); -const XMLAttribute XMLAttributes::CLASS_SYS_SYSTEM_LI(Identifiers::CLASS , Identifiers::SYS_SYSTEM_LI); -const XMLAttribute XMLAttributes::CLASS_TYPE(Identifiers::CLASS , Identifiers::TYPE); -const XMLAttribute XMLAttributes::CLASS_VALUE(Identifiers::CLASS , Identifiers::VALUE); +const XMLAttribute XMLAttributes::CLASS_CFG_IA_T_LI(Identifiers::CLASS , Identifiers::CFG_IA_T_LI); +const XMLAttribute XMLAttributes::CLASS_CTRLEXECSTATE(Identifiers::CLASS , Identifiers::CTRLEXECSTATE); +const XMLAttribute XMLAttributes::CLASS_CTRLSTATE(Identifiers::CLASS , Identifiers::CTRLSTATE); +const XMLAttribute XMLAttributes::CLASS_DATTYP(Identifiers::CLASS , Identifiers::DATTYP); +const XMLAttribute XMLAttributes::CLASS_IOS_SIGNAL(Identifiers::CLASS , Identifiers::IOS_SIGNAL); +const XMLAttribute XMLAttributes::CLASS_LVALUE(Identifiers::CLASS , Identifiers::LVALUE); +const XMLAttribute XMLAttributes::CLASS_MOTIONTASK(Identifiers::CLASS , Identifiers::MOTIONTASK); +const XMLAttribute XMLAttributes::CLASS_NAME(Identifiers::CLASS , Identifiers::NAME); +const XMLAttribute XMLAttributes::CLASS_OPMODE(Identifiers::CLASS , Identifiers::OPMODE); +const XMLAttribute XMLAttributes::CLASS_RAP_MODULE_INFO_LI(Identifiers::CLASS, Identifiers::RAP_MODULE_INFO_LI); +const XMLAttribute XMLAttributes::CLASS_RAP_TASK_LI(Identifiers::CLASS , Identifiers::RAP_TASK_LI); +const XMLAttribute XMLAttributes::CLASS_RW_VERSION_NAME(Identifiers::CLASS , Identifiers::RW_VERSION_NAME); +const XMLAttribute XMLAttributes::CLASS_STATE(Identifiers::CLASS , Identifiers::STATE); +const XMLAttribute XMLAttributes::CLASS_SYS_SYSTEM_LI(Identifiers::CLASS , Identifiers::SYS_SYSTEM_LI); +const XMLAttribute XMLAttributes::CLASS_TYPE(Identifiers::CLASS , Identifiers::TYPE); +const XMLAttribute XMLAttributes::CLASS_VALUE(Identifiers::CLASS , Identifiers::VALUE); } // end namespace rws } // end namespace abb \ No newline at end of file diff --git a/src/rws_interface.cpp b/src/rws_interface.cpp index 58aad25a..3ea3fa6c 100644 --- a/src/rws_interface.cpp +++ b/src/rws_interface.cpp @@ -47,6 +47,7 @@ namespace rws typedef SystemConstants::ContollerStates ContollerStates; typedef SystemConstants::RAPID RAPID; +typedef SystemConstants::RWS::Identifiers Identifiers; typedef SystemConstants::RWS::XMLAttributes XMLAttributes; /*********************************************************************************************************************** @@ -81,6 +82,27 @@ RWSInterface::StaticInfo RWSInterface::collectStaticInfo() return static_info; } +std::vector RWSInterface::getPresentRobotWareOptions() +{ + std::vector result; + + RWSClient::RWSResult rws_result = rws_client_.getConfigurationInstances(Identifiers::SYS, + Identifiers::PRESENT_OPTIONS); + + std::vector node_list = xmlFindNodes(rws_result.p_xml_document, XMLAttributes::CLASS_CFG_IA_T_LI); + + for (size_t i = 0; i < node_list.size(); i+=2) + { + if (i + 1 < node_list.size()) + { + result.push_back(RobotWareOptionInfo(xmlFindTextContent(node_list.at(i), XMLAttributes::CLASS_VALUE), + xmlFindTextContent(node_list.at(i+1), XMLAttributes::CLASS_VALUE))); + } + } + + return result; +} + std::string RWSInterface::getIOSignal(const std::string iosignal) { std::string result; @@ -208,9 +230,28 @@ bool RWSInterface::setMotorsOff() return rws_client_.setMotorsOff().success; } -std::vector RWSInterface::getRAPIDTasks() +std::vector RWSInterface::getRAPIDModulesInfo(const std::string task) +{ + std::vector result; + + RWSClient::RWSResult rws_result = rws_client_.getRAPIDModulesInfo(task); + std::vector node_list = xmlFindNodes(rws_result.p_xml_document, + XMLAttributes::CLASS_RAP_MODULE_INFO_LI); + + for (size_t i = 0; i < node_list.size(); ++i) + { + std::string name = xmlFindTextContent(node_list.at(i), XMLAttributes::CLASS_NAME); + std::string type = xmlFindTextContent(node_list.at(i), XMLAttributes::CLASS_TYPE); + + result.push_back(RAPIDModuleInfo(name, type)); + } + + return result; +} + +std::vector RWSInterface::getRAPIDTasks() { - std::vector result; + std::vector result; RWSClient::RWSResult rws_result = rws_client_.getRAPIDTasks(); std::vector node_list = xmlFindNodes(rws_result.p_xml_document, XMLAttributes::CLASS_RAP_TASK_LI); @@ -220,7 +261,7 @@ std::vector RWSInterface::getRAPIDTasks() std::string name = xmlFindTextContent(node_list.at(i), XMLAttributes::CLASS_NAME); bool is_motion_task = xmlFindTextContent(node_list.at(i), XMLAttributes::CLASS_MOTIONTASK) == RAPID::RAPID_TRUE; - result.push_back(RAPIDTask(name, is_motion_task)); + result.push_back(RAPIDTaskInfo(name, is_motion_task)); } return result; From 98111b5af2e7824739f0b2fb334ed621c79e03a6 Mon Sep 17 00:00:00 2001 From: "G.A. vd. Hoorn" Date: Mon, 11 Mar 2019 15:12:56 +0100 Subject: [PATCH 2/4] Update include/abb_librws/rws_common.h Co-Authored-By: jontje --- include/abb_librws/rws_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/abb_librws/rws_common.h b/include/abb_librws/rws_common.h index 3236ef71..4880cf65 100644 --- a/include/abb_librws/rws_common.h +++ b/include/abb_librws/rws_common.h @@ -495,7 +495,7 @@ struct SystemConstants static const std::string OPMODE; /** - * \brief Present options. + * \brief Options present on the controller. */ static const std::string PRESENT_OPTIONS; From dcb9c780baee6f1be6f85345e67fae1d781c4810 Mon Sep 17 00:00:00 2001 From: "G.A. vd. Hoorn" Date: Mon, 11 Mar 2019 15:13:59 +0100 Subject: [PATCH 3/4] Update include/abb_librws/rws_interface.h Co-Authored-By: jontje --- include/abb_librws/rws_interface.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/abb_librws/rws_interface.h b/include/abb_librws/rws_interface.h index 0c862c8e..32478349 100644 --- a/include/abb_librws/rws_interface.h +++ b/include/abb_librws/rws_interface.h @@ -272,7 +272,7 @@ class RWSInterface StaticInfo collectStaticInfo(); /** - * \brief A method for retrieving the RobotWare options present in the active robot controller system. + * \brief A method for retrieving the RobotWare options present on the active robot controller system. * * \return std::vector containing a list of the present RobotWare options. */ @@ -580,4 +580,4 @@ class RWSInterface } // end namespace rws } // end namespace abb -#endif \ No newline at end of file +#endif From 4f14e88b27f76575b5f10d67c6b88ba1300f2f16 Mon Sep 17 00:00:00 2001 From: jontje Date: Mon, 11 Mar 2019 15:20:28 +0100 Subject: [PATCH 4/4] Clarification of comment --- include/abb_librws/rws_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/abb_librws/rws_common.h b/include/abb_librws/rws_common.h index 4880cf65..6dde3425 100644 --- a/include/abb_librws/rws_common.h +++ b/include/abb_librws/rws_common.h @@ -520,7 +520,7 @@ struct SystemConstants static const std::string STATE; /** - * \brief Sys. + * \brief Controller topic in the system configurations (abbreviated as sys). */ static const std::string SYS;