Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load module feature #128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions include/abb_librws/rws_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*/
Expand Down
20 changes: 20 additions & 0 deletions include/abb_librws/rws_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down
21 changes: 21 additions & 0 deletions include/abb_librws/rws_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
29 changes: 29 additions & 0 deletions src/rws_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path to the file should be a direct path, i.e. "{directory}/{filename}", but generateFilePath(resource) adds "fileservice/" at the beginning.


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;
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/rws_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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";
Expand Down
10 changes: 10 additions & 0 deletions src/rws_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down