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 program feature #129

Open
wants to merge 3 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
38 changes: 38 additions & 0 deletions include/abb_librws/rws_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,26 @@ class RWSClient : public POCOClient
*/
RWSResult setSpeedRatio(unsigned int ratio);

/**
* \brief A method for loading a program 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 program into the controller must be replaced by the new one or not.
*
* \return RWSResult containing the result.
*/
RWSResult loadProgramIntoTask(const std::string& task, const FileResource& resource, const bool replace = false);

/**
* \brief A method for unloading a program to the robot controller.
*
* \param task specifying the RAPID task.
*
* \return RWSResult containing the result.
*/
RWSResult unloadProgramFromTask(const std::string& task);

/**
* \brief A method for retrieving a file from the robot controller.
*
Expand Down Expand Up @@ -825,6 +845,24 @@ 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 Method for generating a task program resource URI path.
*
* \param task for the task name.
*
* \return std::string containing the path.
*/
std::string generateRAPIDTasksProgramPath(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 @@ -623,6 +623,11 @@ struct SystemConstants
*/
static const std::string PRESENT_OPTIONS;

/**
* \brief Program path.
*/
static const std::string PROGRAM_PATH;

/**
* \brief RAPID module info list item.
*/
Expand Down Expand Up @@ -694,6 +699,11 @@ struct SystemConstants
*/
struct ABB_LIBRWS_EXPORT Queries
{
/**
* \brief Load program action query.
*/
static const std::string ACTION_LOAD_PROGRAM;

/**
* \brief Release action query.
*/
Expand Down Expand Up @@ -734,6 +744,11 @@ struct SystemConstants
*/
static const std::string ACTION_STOP;

/**
* \brief Unload program action query.
*/
static const std::string ACTION_UNLOAD_PROGRAM;

/**
* \brief Task query.
*/
Expand All @@ -760,6 +775,11 @@ struct SystemConstants
*/
static const std::string LOGOUT;

/**
* \brief RAPID tasks program.
*/
static const std::string PROGRAM;

/**
* \brief Robtarget.
*/
Expand Down
20 changes: 20 additions & 0 deletions include/abb_librws/rws_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,26 @@ class RWSInterface
*/
bool setSpeedRatio(unsigned int ratio);

/**
* \brief A method for loading a program 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 program into the controller must be replaced by the new one or not.
*
* \return bool indicating if the communication was successful or not.
*/
bool loadProgramIntoTask(const std::string& task, const RWSClient::FileResource& resource, const bool replace = false);

/**
* \brief A method for unloading a program to the robot controller.
*
* \param task specifying the RAPID task.
*
* \return bool indicating if the communication was successful or not.
*/
bool unloadProgramFromTask(const std::string& task);

/**
* \brief A method for retrieving a file from the robot controller.
*
Expand Down
34 changes: 34 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::loadProgramIntoTask(const std::string& task, const FileResource& resource, const bool replace)
{
std::string uri = generateRAPIDTasksProgramPath(task) + "?" + Queries::ACTION_LOAD_PROGRAM;
std::string content = Identifiers::PROGRAM_PATH + "=" + generateFilePath(resource) + "&loadmod=" + ((replace) ? "replace" : "add");

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::unloadProgramFromTask(const std::string& task)
{
std::string uri = generateRAPIDTasksProgramPath(task) + "?" + Queries::ACTION_UNLOAD_PROGRAM;
std::string content = "";

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,15 @@ 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;
}

std::string RWSClient::generateRAPIDTasksProgramPath(const std::string& task)
{
return generateRAPIDTasksPath(task) + Resources::PROGRAM;
}

} // 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 @@ -277,6 +277,7 @@ 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::PROGRAM_PATH = "progpath";
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::ROBOT = "robot";
Expand All @@ -291,6 +292,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_PROGRAM = "action=loadprog";
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 +301,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_PROGRAM = "action=unloadprog";
const std::string Queries::TASK = "task=";
const std::string Services::CTRL = "/ctrl";
const std::string Services::FILESERVICE = "/fileservice";
Expand All @@ -308,6 +311,7 @@ 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::PROGRAM = "/program";
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";
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::loadProgramIntoTask(const std::string& task, const RWSClient::FileResource& resource, const bool replace)
{
return rws_client_.loadProgramIntoTask(task, resource, replace).success;
}

bool RWSInterface::unloadProgramFromTask(const std::string &task)
{
return rws_client_.unloadProgramFromTask(task).success;
}

bool RWSInterface::getFile(const RWSClient::FileResource& resource, std::string* p_file_content)
{
return rws_client_.getFile(resource, p_file_content).success;
Expand Down