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

Python Wrapper #132

Open
wants to merge 4 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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ install(
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
)

add_subdirectory(python)
98 changes: 98 additions & 0 deletions include/abb_librws/rws_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ namespace moc
*/
struct Arm
{

/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const Arm& rhs)
{
return name == rhs.name;
}

/**
* \brief The instance's name.
*/
Expand All @@ -96,6 +109,19 @@ struct Arm
*/
struct Joint
{

/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const Joint& rhs)
{
return name == rhs.name;
}

/**
* \brief The instance's name.
*/
Expand Down Expand Up @@ -127,6 +153,18 @@ struct Joint
*/
struct MechanicalUnit
{
/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const MechanicalUnit& rhs)
{
return name == rhs.name;
}

/**
* \brief The instance's name.
*/
Expand All @@ -148,6 +186,18 @@ struct MechanicalUnit
*/
struct Robot
{
/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const Robot& rhs)
{
return name == rhs.name;
}

/**
* \brief The instance's name.
*/
Expand Down Expand Up @@ -179,6 +229,18 @@ struct Robot
*/
struct Single
{
/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const Single& rhs)
{
return name == rhs.name;
}

/**
* \brief The instance's name.
*/
Expand Down Expand Up @@ -210,6 +272,18 @@ struct Single
*/
struct Transmission
{
/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const Transmission& rhs)
{
return name == rhs.name;
}

/**
* \brief The instance's name.
*/
Expand All @@ -232,6 +306,18 @@ namespace sys
*/
struct MechanicalUnitGroup
{
/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const MechanicalUnitGroup& rhs)
{
return name == rhs.name;
}

/**
* \brief The instance's name.
*/
Expand All @@ -253,6 +339,18 @@ struct MechanicalUnitGroup
*/
struct PresentOption
{
/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const PresentOption& rhs)
{
return name == rhs.name;
}

/**
* \brief The instance's name.
*/
Expand Down
26 changes: 26 additions & 0 deletions include/abb_librws/rws_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,30 @@ class RWSClient : public POCOClient
const std::string& application = SystemConstants::General::EXTERNAL_APPLICATION,
const std::string& location = SystemConstants::General::EXTERNAL_LOCATION);


/**
* \brief A method for registering a user as remote.
*
* \param username specifying the user name.
* \param application specifying the external application.
* \param location specifying the location.
*
* \return RWSResult containing the result.
*/
RWSClient::RWSResult requestRMMP();


/**
* \brief A method for registering a user as remote.
*
* \param username specifying the user name.
* \param application specifying the external application.
* \param location specifying the location.
*
* \return RWSResult containing the result.
*/
RWSClient::RWSResult getRMMPState();

/**
* \brief Method for parsing a communication result into a XML document.
*
Expand All @@ -720,6 +744,8 @@ class RWSClient : public POCOClient
*/
std::string getLogTextLatestEvent(const bool verbose = false);



private:
/**
* \brief A struct for representing conditions, for the evaluation of an attempted RWS communication.
Expand Down
16 changes: 16 additions & 0 deletions include/abb_librws/rws_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ struct SystemConstants
* \brief Class & type.
*/
static const XMLAttribute CLASS_TYPE;

/**
* \brief Class User RMMP.
*/
static const XMLAttribute CLASS_USER_RMMP;

/**
* \brief Class & value.
Expand Down Expand Up @@ -677,6 +682,11 @@ struct SystemConstants
* \brief Type.
*/
static const std::string TYPE;

/**
* \brief User RMMP.
*/
static const std::string USER_RMMP;

/**
* \brief Value.
Expand Down Expand Up @@ -855,6 +865,12 @@ struct SystemConstants
* \brief User service.
*/
static const std::string USERS;

/**
* \brief RMMP Request Manual Mode Privileges.
*/
static const std::string RMMP;

};
};
};
Expand Down
79 changes: 79 additions & 0 deletions include/abb_librws/rws_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ class RWSInterface
type(type)
{}

/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const RAPIDModuleInfo& rhs)
{
return name == rhs.name;
}

/**
* \brief The module's name.
*/
Expand Down Expand Up @@ -276,6 +288,18 @@ class RWSInterface
execution_state(execution_state)
{}

/**
* \brief Operator for equal to comparison.
*
* \param rhs for right hand side value.
*
* \return bool indicating if the comparision was equal or not.
*/
bool operator==(const RAPIDTaskInfo& rhs)
{
return name == rhs.name;
}

/**
* \brief The task's name.
*/
Expand Down Expand Up @@ -344,6 +368,44 @@ class RWSInterface
bool rws_connected;
};

struct RMMPState
{
/**
* \brief A default constructor.
*/
RMMPState() {}

/**
* \brief User id
*/
int userid;

/**
* \brief Alias for the user. For users on a Windows PC it is the Windows user name.
*/
std::string alias;

/**
* \brief User location. For users on a PC it is the PC's network name.
*/
std::string location;

/**
* \brief Name of the application the user is using. E.g., "RobotStudio-Online", "PickMaster"
*/
std::string application;

/**
* \brief {none|pending modify|modify|exec}
*/
std::string privilege;

/**
* \brief {true | false} whether the rmmp request and the current request are mady by same user.
*/
bool rmmpheldbyme;
};

/**
* \brief A constructor.
*
Expand Down Expand Up @@ -864,6 +926,23 @@ class RWSInterface
bool registerRemoteUser(const std::string& username = SystemConstants::General::DEFAULT_USERNAME,
const std::string& application = SystemConstants::General::EXTERNAL_APPLICATION,
const std::string& location = SystemConstants::General::EXTERNAL_LOCATION);
/**
* \brief A method for registering a user as remote.
*
* \param username specifying the user name.
* \param application specifying the external application.
* \param location specifying the location.
*
* \return bool indicating if the communication was successful or not.
*/
bool requestRMMP();

/**
* \brief A method for fetching RMMP State.
*
* \return RMMPState indicating if the communication was successful or not.
*/
bool getRMMPState(RMMPState &rmmp_state);

/**
* \brief A method for retrieving the internal log as a text string.
Expand Down
47 changes: 47 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
set(PYTHON_VERSIONS "2" "3")
foreach(PYTHON_VERSION ${PYTHON_VERSIONS})
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_DEFAULT_EXECUTABLE CACHE)
find_package(PythonInterp ${PYTHON_VERSION})
find_package(PythonLibs ${PYTHON_VERSION})

if(PYTHON_VERSION VERSION_LESS 3)
find_package(Boost COMPONENTS python)
else()
find_package(Boost COMPONENTS python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
endif()
if (NOT Boost_FOUND)
message(WARNING "Boost was not found for python ${PYTHON_VERSION}")
continue()
endif()

add_library(${PROJECT_NAME}_py${PYTHON_VERSION} rws_interface_py.cpp)
target_link_libraries(${PROJECT_NAME}_py${PYTHON_VERSION}
${PROJECT_NAME}
${Boost_LIBRARIES}
${Poco_LIBRARIES}
${PYTHON_LIBRARIES}
)
target_include_directories(${PROJECT_NAME}_py${PYTHON_VERSION} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_BINARY_DIR}>"
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
${Boost_INCLUDE_DIRS}
${Poco_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
)
set_target_properties(${PROJECT_NAME}_py${PYTHON_VERSION}
PROPERTIES
PREFIX ""
OUTPUT_NAME ${PROJECT_NAME}_py
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${PROJECT_NAME}_py${PYTHON_VERSION}/)

install(TARGETS ${PROJECT_NAME}_py${PYTHON_VERSION}
DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages/${PROJECT_NAME}"
)

install(FILES __init__.py
DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages/${PROJECT_NAME}"
)
endforeach()
Loading