diff --git a/include/abb_librws/rws_client.h b/include/abb_librws/rws_client.h index a1b3743e..122ac3d4 100644 --- a/include/abb_librws/rws_client.h +++ b/include/abb_librws/rws_client.h @@ -592,6 +592,27 @@ class RWSClient : public POCOClient */ RWSResult setSpeedRatio(unsigned int ratio); + /** + * \brief A method for loading a module to the robot controller. + * + * \param task specifying the RAPID task. + * \param resource specifying the file's directory and name. + * \param replace indicating if the actual module into the controller must be replaced by the new one or not. + * + * \return RWSResult containing the result. + */ + RWSResult loadModuleIntoTask(const std::string& task, const FileResource& resource, const bool replace = false); + + /** + * \brief A method for unloading a module to the robot controller. + * + * \param task specifying the RAPID task. + * \param resource specifying the file's directory and name. + * + * \return RWSResult containing the result. + */ + RWSResult unloadModuleFromTask(const std::string& task, const FileResource& resource); + /** * \brief A method for retrieving a file from the robot controller. * @@ -825,6 +846,15 @@ class RWSClient : public POCOClient */ std::string generateFilePath(const FileResource& resource); + /** + * \brief Method for generating a task resource URI path. + * + * \param task for the task name. + * + * \return std::string containing the path. + */ + std::string generateRAPIDTasksPath(const std::string& task); + /** * \brief Static constant for the log's size. */ diff --git a/include/abb_librws/rws_common.h b/include/abb_librws/rws_common.h index 52b823e4..fb93f137 100644 --- a/include/abb_librws/rws_common.h +++ b/include/abb_librws/rws_common.h @@ -598,6 +598,16 @@ struct SystemConstants */ static const std::string MOC; + /** + * \brief Module name. + */ + static const std::string MODULE; + + /** + * \brief Module path. + */ + static const std::string MODULEPATH; + /** * \brief Motion task. */ @@ -694,6 +704,11 @@ struct SystemConstants */ struct ABB_LIBRWS_EXPORT Queries { + /** + * \brief Load module action query. + */ + static const std::string ACTION_LOAD_MODULE; + /** * \brief Release action query. */ @@ -734,6 +749,11 @@ struct SystemConstants */ static const std::string ACTION_STOP; + /** + * \brief Unload module action query. + */ + static const std::string ACTION_UNLOAD_MODULE; + /** * \brief Task query. */ diff --git a/include/abb_librws/rws_interface.h b/include/abb_librws/rws_interface.h index 26806709..74150769 100644 --- a/include/abb_librws/rws_interface.h +++ b/include/abb_librws/rws_interface.h @@ -762,6 +762,27 @@ class RWSInterface */ bool setSpeedRatio(unsigned int ratio); + /** + * \brief A method for loading a module to the robot controller. + * + * \param task specifying the RAPID task. + * \param resource specifying the file's directory and name. + * \param replace indicating if the actual module into the controller must be replaced by the new one or not. + * + * \return bool indicating if the communication was successful or not. + */ + bool loadModuleIntoTask(const std::string& task, const RWSClient::FileResource& resource, const bool replace = false); + + /** + * \brief A method for unloading a module to the robot controller. + * + * \param task specifying the RAPID task. + * \param resource specifying the file's directory and name. + * + * \return bool indicating if the communication was successful or not. + */ + bool unloadModuleFromTask(const std::string& task, const RWSClient::FileResource& resource); + /** * \brief A method for retrieving a file from the robot controller. * diff --git a/src/rws_client.cpp b/src/rws_client.cpp index 256caf70..2f43358a 100644 --- a/src/rws_client.cpp +++ b/src/rws_client.cpp @@ -474,6 +474,30 @@ RWSClient::RWSResult RWSClient::setSpeedRatio(unsigned int ratio) return evaluatePOCOResult(httpPost(uri, content), evaluation_conditions); } +RWSClient::RWSResult RWSClient::loadModuleIntoTask(const std::string& task, const FileResource& resource, const bool replace) +{ + std::string uri = generateRAPIDTasksPath(task) + "?" + Queries::ACTION_LOAD_MODULE; + std::string content = Identifiers::MODULEPATH + "=" + generateFilePath(resource) + "&replace=" + ((replace) ? "true" : "false"); + + EvaluationConditions evaluation_conditions; + evaluation_conditions.parse_message_into_xml = false; + evaluation_conditions.accepted_outcomes.push_back(HTTPResponse::HTTP_NO_CONTENT); + + return evaluatePOCOResult(httpPost(uri, content), evaluation_conditions); +} + +RWSClient::RWSResult RWSClient::unloadModuleFromTask(const std::string& task, const FileResource& resource) +{ + std::string uri = generateRAPIDTasksPath(task) + "?" + Queries::ACTION_UNLOAD_MODULE; + std::string content = Identifiers::MODULE + "=" + resource.filename; + + EvaluationConditions evaluation_conditions; + evaluation_conditions.parse_message_into_xml = false; + evaluation_conditions.accepted_outcomes.push_back(HTTPResponse::HTTP_NO_CONTENT); + + return evaluatePOCOResult(httpPost(uri, content), evaluation_conditions); +} + RWSClient::RWSResult RWSClient::getFile(const FileResource& resource, std::string* p_file_content) { RWSResult rws_result; @@ -798,5 +822,10 @@ std::string RWSClient::generateFilePath(const FileResource& resource) return Services::FILESERVICE + "/" + resource.directory + "/" + resource.filename; } +std::string RWSClient::generateRAPIDTasksPath(const std::string& task) +{ + return Resources::RW_RAPID_TASKS + "/" + task; +} + } // end namespace rws } // end namespace abb diff --git a/src/rws_common.cpp b/src/rws_common.cpp index 56a37c8f..3c1f0bfe 100644 --- a/src/rws_common.cpp +++ b/src/rws_common.cpp @@ -273,6 +273,8 @@ const std::string Identifiers::LVALUE = "lvalue"; const std::string Identifiers::MECHANICAL_UNIT = "mechanical_unit"; const std::string Identifiers::MECHANICAL_UNIT_GROUP = "mechanical_unit_group"; const std::string Identifiers::MOC = "moc"; +const std::string Identifiers::MODULE = "module"; +const std::string Identifiers::MODULEPATH = "modulepath"; const std::string Identifiers::MOTIONTASK = "motiontask"; const std::string Identifiers::NAME = "name"; const std::string Identifiers::OPMODE = "opmode"; @@ -291,6 +293,7 @@ const std::string Identifiers::TYPE = "type"; const std::string Identifiers::VALUE = "value"; const std::string Identifiers::CLASS = "class"; const std::string Identifiers::OPTION = "option"; +const std::string Queries::ACTION_LOAD_MODULE = "action=loadmod"; const std::string Queries::ACTION_RELEASE = "action=release"; const std::string Queries::ACTION_REQUEST = "action=request"; const std::string Queries::ACTION_RESETPP = "action=resetpp"; @@ -299,6 +302,7 @@ 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::ACTION_UNLOAD_MODULE = "action=unloadmod"; const std::string Queries::TASK = "task="; const std::string Services::CTRL = "/ctrl"; const std::string Services::FILESERVICE = "/fileservice"; diff --git a/src/rws_interface.cpp b/src/rws_interface.cpp index b964aee9..5a86635f 100644 --- a/src/rws_interface.cpp +++ b/src/rws_interface.cpp @@ -978,6 +978,16 @@ bool RWSInterface::getRAPIDSymbolData(const std::string& task, return rws_client_.getRAPIDSymbolData(RWSClient::RAPIDResource(task, symbol), p_data).success; } +bool RWSInterface::loadModuleIntoTask(const std::string& task, const RWSClient::FileResource& resource, const bool replace) +{ + return rws_client_.loadModuleIntoTask(task, resource, replace).success; +} + +bool RWSInterface::unloadModuleFromTask(const std::string& task, const RWSClient::FileResource& resource) +{ + return rws_client_.unloadModuleFromTask(task, resource).success; +} + bool RWSInterface::getFile(const RWSClient::FileResource& resource, std::string* p_file_content) { return rws_client_.getFile(resource, p_file_content).success;