DDS
ver. 3.6
|
The main class of the Tools API. It represets a DDS session. More...
#include <Tools.h>
Classes | |
struct | SImpl |
Public Types | |
enum | EAgentState { EAgentState::active = 0, EAgentState::idle, EAgentState::executing } |
Public Member Functions | |
CSession () | |
Constructor of a DDS Session class. More... | |
~CSession () | |
A destructor. More... | |
boost::uuids::uuid | create () |
Creates a new DDS session. More... | |
void | attach (const std::string &_sid) |
Attaches to an existing DDS session. More... | |
void | attach (const boost::uuids::uuid &_sid) |
Attaches to an existing DDS session. More... | |
void | shutdown () |
Shutdown currently attached DDS session. More... | |
void | detach () |
Detach from the session without shutting it down. More... | |
bool | IsRunning () const |
Check if DDS session is running. More... | |
boost::uuids::uuid | getSessionID () const |
Returns DDS session ID. More... | |
void | blockCurrentThread () |
blockCurrentThread Blocks current thread. More... | |
void | unblockCurrentThread () |
Stop DDS session. More... | |
template<class T > | |
void | sendRequest (typename T::ptr_t _request) |
Sends the async request to DDS commander. More... | |
template<class Request_t > | |
void | syncSendRequest (const typename Request_t::request_t &_requestData, const std::chrono::seconds &_timeout=std::chrono::seconds(0), std::ostream *_out=nullptr) |
Sends the sync request to DDS commander. More... | |
template<class Request_t > | |
void | syncSendRequest (const typename Request_t::request_t &_requestData, typename Request_t::response_t &_responseData, const std::chrono::seconds &_timeout=std::chrono::seconds(0), std::ostream *_out=nullptr) |
Sends the sync request to DDS commander. More... | |
template<class Request_t > | |
void | syncSendRequest (const typename Request_t::request_t &_requestData, typename Request_t::responseVector_t &_responseDataVector, const std::chrono::seconds &_timeout=std::chrono::seconds(0), std::ostream *_out=nullptr) |
Sends the sync request to DDS commander. More... | |
template<CSession::EAgentState _state> | |
void | waitForNumAgents (size_t _numAgents, const std::chrono::seconds &_timeout=std::chrono::seconds(0), const std::chrono::milliseconds &_requestInterval=std::chrono::milliseconds(500), std::ostream *_out=nullptr) |
Wait for the required number of agents with a certain state. More... | |
std::string | userDefaultsGetValueForKey (const std::string &_key) const noexcept |
This method returns a configuration value for a given configuration key. It uses the DDS configuration of the current session. More... | |
template<CSession::EAgentState _state> | |
void | waitForNumAgents (size_t _numAgents, const std::chrono::seconds &_timeout, const std::chrono::milliseconds &_requestInterval, ostream *_out) |
Static Public Member Functions | |
static std::string | getDefaultSessionIDString () |
Returns the default DDS session ID as a string. More... | |
static boost::uuids::uuid | getDefaultSessionID () |
Returns the default DDS session ID. More... | |
static void | setup () |
Setups DDS environment. More... | |
The main class of the Tools API. It represets a DDS session.
It can be used to create new DDS sessions or attach to existing ones. Also, this class can be used to send and recieve Tools commands. Currently the following commands are ToolsProtocol.h
Please note, when you send a requests, server will respond with a corresponding reply with a following Done event. But the server can also send an error message. Once you receive either Done or an error, don't expect the server to send anything else in the regards of the request. So, you can then stop the API or send another request.
output> $HOME/.DDS/log/sessions/b383d852-19a7-4ac5-9cbe-dc00d686d36f
output> $HOME/.DDS/log
|
strong |
CSession::CSession | ( | ) |
Constructor of a DDS Session class.
CSession::~CSession | ( | ) |
A destructor.
void CSession::attach | ( | const std::string & | _sid | ) |
Attaches to an existing DDS session.
[in] | _sid | A destination DDS session ID |
void CSession::attach | ( | const boost::uuids::uuid & | _sid | ) |
Attaches to an existing DDS session.
[in] | _sid | A destination DDS session ID |
void CSession::blockCurrentThread | ( | ) |
blockCurrentThread Blocks current thread.
The function stops the thread and waits until one of the conditions is applied:
boost::uuids::uuid CSession::create | ( | ) |
Creates a new DDS session.
void CSession::detach | ( | ) |
Detach from the session without shutting it down.
|
static |
Returns the default DDS session ID.
|
static |
Returns the default DDS session ID as a string.
boost::uuids::uuid CSession::getSessionID | ( | ) | const |
Returns DDS session ID.
bool CSession::IsRunning | ( | ) | const |
Check if DDS session is running.
template void CSession::sendRequest< SAgentCommandRequest > | ( | typename T::ptr_t | _request | ) |
Sends the async request to DDS commander.
[in] | _request | Request object. If _request is nullptr than throws std::runtime_error |
|
static |
Setups DDS environment.
void CSession::shutdown | ( | ) |
Shutdown currently attached DDS session.
void CSession::syncSendRequest | ( | const typename Request_t::request_t & | _requestData, |
const std::chrono::seconds & | _timeout = std::chrono::seconds(0) , |
||
std::ostream * | _out = nullptr |
||
) |
Sends the sync request to DDS commander.
[in] | _requestData | Request data object. |
[in] | _timeout | Timeout in seconds. Timeout of 0 means no timeout is applied (default). |
[in] | _out | Pointer to output stream. nullptr means no output to stream (default). |
std::runtime_error |
void CSession::syncSendRequest | ( | const typename Request_t::request_t & | _requestData, |
typename Request_t::response_t & | _responseData, | ||
const std::chrono::seconds & | _timeout = std::chrono::seconds(0) , |
||
std::ostream * | _out = nullptr |
||
) |
Sends the sync request to DDS commander.
[in] | _requestData | Request data object. |
[out] | _responseData | Response data object. |
[in] | _timeout | Timeout in seconds. Timeout of 0 means no timeout is applied (default). |
[in] | _out | Pointer to output stream. nullptr means no output to stream (default). |
std::runtime_error |
void CSession::syncSendRequest | ( | const typename Request_t::request_t & | _requestData, |
typename Request_t::responseVector_t & | _responseDataVector, | ||
const std::chrono::seconds & | _timeout = std::chrono::seconds(0) , |
||
std::ostream * | _out = nullptr |
||
) |
Sends the sync request to DDS commander.
[in] | _requestData | Request data object. |
[out] | _responseDataVector | Vector of response data object. |
[in] | _timeout | Timeout in seconds. Timeout of 0 means no timeout is applied (default). |
[in] | _out | Pointer to output stream. nullptr means no output to stream (default). |
std::runtime_error |
void CSession::unblockCurrentThread | ( | ) |
Stop DDS session.
|
noexcept |
This method returns a configuration value for a given configuration key. It uses the DDS configuration of the current session.
[in] | _key | Configuration key. For example, to get the current working directory on the commander server use "server.work_dir". Currently support configuration keys can be found in the User's manual "Chapter 5. Configuration". |
Doesn't | throw |
void dds::tools_api::CSession::waitForNumAgents | ( | size_t | _numAgents, |
const std::chrono::seconds & | _timeout = std::chrono::seconds(0) , |
||
const std::chrono::milliseconds & | _requestInterval = std::chrono::milliseconds(500) , |
||
std::ostream * | _out = nullptr |
||
) |
Wait for the required number of agents with a certain state.
[in] | _numAgents | Required number of agents. Must be > 0. |
[in] | _timeout | Timeout per each request and total timeout in seconds. Timeout of 0 means no timeout is applied (default). |
[in] | _requestInterval | Interval between SAgentCountRequest requests in milliseconds. |
[in] | _out | Pointer to output stream. nullptr means no output to stream (default). |
std::runtime_error |
void dds::tools_api::CSession::waitForNumAgents | ( | size_t | _numAgents, |
const std::chrono::seconds & | _timeout, | ||
const std::chrono::milliseconds & | _requestInterval, | ||
ostream * | _out | ||
) |