Request

Request

Request/Reply communication is used to send commands to a motorcortex server.

Classes

Name
class mcx_cpp::Request

Functions

Name
Request() =delete
Request(const ParameterTree & parameter_tree)
Create new Request.
~Request()
Destructor.
std::string url() const
Return connection url.
ConnectionReply connect(std::string url, size_t timeout_ms =0)
Open a request connection.
ConnectionReply connect(std::string url, const ConnectionOptions & connection_options)
Open a request connection.
void close()
Closes connection to the server.
StatusReply login(std::string login, std::string password) const
Send a login request to the server.
ParameterTreeReply getParameterTree(size_t timeout_ms =0) const
Request a parameter tree from the server.
StatusReply setParameter(SetParameter value) const
Set new value to a parameter.
template <typename T >
StatusReply
setParameter(const std::string & path, const T & value) const
Set new value to a parameter.
template <typename T >
StatusReply
setParameter(const std::string & path, const std::initializer_list< T > & value) const
Set new value to a multichannel parameter.
template <typename T >
StatusReply
setParameter(const std::string & path, const std::vector< T > & value) const
Set new value to a multichannel parameter.
GetParameterReply getParameter(const std::string & path) const
Request a parameter with description and value from the server.
SubscriptionReply createGroup(std::vector< std::string > path_list, const std::string & group_alias, size_t frequency_divider) const
Create a subscription group for a list of the parameters.
StatusReply removeGroup(const std::string & group_alias) const
Unsubscribe from the group.

Attributes

Name
std::string certificate
size_t timeout_ms
StateUpdateCb state_update

Functions Documentation

function Request

Request() =delete

function Request

explicit Request(
    const ParameterTree & parameter_tree
)

Create new Request.

Parameters:

  • parameter_tree - reference to a Parameter Tree instance.

function ~Request

~Request()

Destructor.

function url

std::string url() const

Return connection url.

Return: connection url.

function connect

ConnectionReply connect(
    std::string url,
    size_t timeout_ms =0
)

Open a request connection.

Parameters:

  • url - motorcortex server URL
  • timeout_ms - connection timeout in milliseconds

Return: status of the connection.

function connect

ConnectionReply connect(
    std::string url,
    const ConnectionOptions & connection_options
)

Open a request connection.

Parameters:

  • url - motorcortex server URL
  • connection_options - additional options, e.g. certificate, timeout and connection state callback

Return: status of the connection.

function close

void close()

Closes connection to the server.

function login

StatusReply login(
    std::string login,
    std::string password
) const

Send a login request to the server.

Parameters:

  • login - user login
  • password - user password

Return: status of the login.

function getParameterTree

ParameterTreeReply getParameterTree(
    size_t timeout_ms =0
) const

Request a parameter tree from the server.

Parameters:

  • timeout_ms - request timeout in milliseconds

Return: status of the request, resolves when the parameter tree is received or fails

function setParameter

StatusReply setParameter(
    SetParameter value
) const

Set new value to a parameter.

Parameters:

  • value - path, type and new value of the parameter

Return: status of the request, resolves when the parameter is set

function setParameter

template <typename T >
inline StatusReply setParameter(
    const std::string & path,
    const T & value
) const

Set new value to a parameter.

Parameters:

  • path - path of the parameter
  • path - value of the parameter

Return: status of the request, resolves when the parameter is set

function setParameter

template <typename T >
inline StatusReply setParameter(
    const std::string & path,
    const std::initializer_list< T > & value
) const

Set new value to a multichannel parameter.

Parameters:

  • path - path of the parameter
  • path - list of new values of the parameter

Return: status of the request, resolves when the parameter is set

function setParameter

template <typename T >
inline StatusReply setParameter(
    const std::string & path,
    const std::vector< T > & value
) const

Set new value to a multichannel parameter.

Parameters:

  • path - path of the parameter
  • path - list of new values of the parameter

Return: status of the request, resolves when the parameter is set

function getParameter

GetParameterReply getParameter(
    const std::string & path
) const

Request a parameter with description and value from the server.

Parameters:

  • path - path of the parameter

Return: status of the request and value of the parameter

function createGroup

SubscriptionReply createGroup(
    std::vector< std::string > path_list,
    const std::string & group_alias,
    size_t frequency_divider
) const

Create a subscription group for a list of the parameters.

Parameters:

  • path - list of the parameters to subscribe to
  • group_alias - name of the group
  • frq_divider - frequency divider is a downscaling factor for the group publish rate

Return: status of the request, resolves when the group is created

function removeGroup

StatusReply removeGroup(
    const std::string & group_alias
) const

Unsubscribe from the group.

Parameters:

  • group_alias - name of the group

Return: status of the request, resolves when the parameter is removed

Attributes Documentation

variable certificate

std::string certificate;

Certificate to connect to the server

variable timeout_ms

size_t timeout_ms;

Connection timeout

variable state_update

StateUpdateCb state_update;

Connection state update callback


Updated on 2022-06-27 at 11:57:14 +0200

Last modified June 27, 2022: added cpp documentation (3758d051)