libvisiontransfer  10.8.0
Public Member Functions | List of all members
visiontransfer::internal::ParameterTransfer Class Reference

Detailed Description

Allows a configuration of device parameters over the network.

A TCP connection is established to a parameter server. The protocol allows writing and reading of individual parameters, which are identified by a unique ID. There are three supported types of parameters: integers, double precision floating point values, and booleans.

This class is only used internally. Users should use the class DeviceParameters instead.

Definition at line 72 of file parametertransfer.h.

#include <visiontransfer/internal/parametertransfer.h>

Public Member Functions

 ParameterTransfer (const char *address, const char *service="7683")
 Creates an object and connects to the given server. More...
 
bool isConnected () const
 Returns whether the background connection is currently up and running (it may be temporarily false during a disconnected/auto-reconnection phase). More...
 
int readIntParameter (const char *id)
 Reads an integer value from the parameter server. More...
 
double readDoubleParameter (const char *id)
 Reads a double precision floating point value from the parameter server. More...
 
bool readBoolParameter (const char *id)
 Reads a boolean value from the parameter server. More...
 
void writeIntParameter (const char *id, int value)
 Writes an integer value to a parameter of the parameter server. More...
 
void writeDoubleParameter (const char *id, double value)
 Writes a double precision floating point value to a parameter of the parameter server. More...
 
void writeBoolParameter (const char *id, bool value)
 Writes a boolean value to a parameter of the parameter server. More...
 
template<typename T >
void writeParameter (const char *id, const T &value, bool synchronous=true)
 Writes a scalar value to a parameter of the parameter server. More...
 
template<typename T >
void writeParameterTransactionGuarded (const char *id, const T &value)
 Writes a scalar value to a parameter of the parameter server, transparently deferring for a batch update if a transaction has been started. More...
 
template<typename T >
void writeParameterTransactionUnguarded (const char *id, const T &value)
 Writes a scalar value to a parameter of the parameter server, using 'fire-and-forget' for real-time commands (no replies expected). More...
 
std::map< std::string, ParameterInfogetAllParameters ()
 Enumerates all parameters as reported by the device. More...
 
bool hasParameter (const std::string &uid) const
 Returns true if the matching parameter UID is present in the parameter set. More...
 
param::Parameter getParameter (const std::string &uid) const
 Returns a disconnected copy of the matching parameter from the parameter set; exception if not found. More...
 
param::Parameter pollParameter (const std::string &uid, bool blockingCall)
 Returns a disconnected copy of the matching parameter from the parameter set after polling for its current value; exception if not found. More...
 
param::ParameterSetgetParameterSet ()
 Returns a reference to the internal parameter set (once the network handshake is complete) More...
 
param::ParameterSet const & getParameterSet () const
 Returns a reference to the internal parameter set (once the network handshake is complete) More...
 
void setParameterUpdateCallback (std::function< void(const std::string &uid)> callback, bool threaded)
 
void transactionStartQueue ()
 Start batch parameter transaction. More...
 
void transactionCommitQueue (int maxWaitMilliseconds)
 Complete the started parameter transaction. More...
 
void persistParameters (const std::vector< std::string > &uids, bool synchronous=true)
 Requests to save the current values for the specified parameter UIDs to permanent storage. More...
 
void setConnectionStateChangeCallback (std::function< void(visiontransfer::ConnectionState)> callback)
 Sets the callback function to inform of background disconnection / reconnection. More...
 
template<>
void writeParameter (const char *id, const std::string &value, bool synchronous)
 
template<>
void writeParameterTransactionGuarded (const char *id, const std::string &value)
 
template<>
void writeParameterTransactionGuarded (const char *id, const double &value)
 
template<>
void writeParameterTransactionGuarded (const char *id, const int &value)
 
template<>
void writeParameterTransactionGuarded (const char *id, const bool &value)
 
template<>
void writeParameterTransactionUnguarded (const char *id, const bool &value)
 

Constructor & Destructor Documentation

◆ ParameterTransfer()

visiontransfer::internal::ParameterTransfer::ParameterTransfer ( const char *  address,
const char *  service = "7683" 
)

Creates an object and connects to the given server.

Parameters
addressIP address or host name of the server.
serviceThe port number that should be used as string or as textual service name.

Definition at line 43 of file parametertransfer.cpp.

Member Function Documentation

◆ getAllParameters()

std::map< std::string, ParameterInfo > visiontransfer::internal::ParameterTransfer::getAllParameters ( )

Enumerates all parameters as reported by the device.

Definition at line 336 of file parametertransfer.cpp.

◆ getParameter()

Parameter visiontransfer::internal::ParameterTransfer::getParameter ( const std::string &  uid) const

Returns a disconnected copy of the matching parameter from the parameter set; exception if not found.

Definition at line 714 of file parametertransfer.cpp.

◆ getParameterSet() [1/2]

ParameterSet const & visiontransfer::internal::ParameterTransfer::getParameterSet ( )

Returns a reference to the internal parameter set (once the network handshake is complete)

Definition at line 685 of file parametertransfer.cpp.

◆ getParameterSet() [2/2]

param::ParameterSet const& visiontransfer::internal::ParameterTransfer::getParameterSet ( ) const

Returns a reference to the internal parameter set (once the network handshake is complete)

◆ hasParameter()

bool visiontransfer::internal::ParameterTransfer::hasParameter ( const std::string &  uid) const

Returns true if the matching parameter UID is present in the parameter set.

Definition at line 703 of file parametertransfer.cpp.

◆ isConnected()

bool visiontransfer::internal::ParameterTransfer::isConnected ( ) const

Returns whether the background connection is currently up and running (it may be temporarily false during a disconnected/auto-reconnection phase).

Definition at line 65 of file parametertransfer.cpp.

◆ persistParameters()

void visiontransfer::internal::ParameterTransfer::persistParameters ( const std::vector< std::string > &  uids,
bool  synchronous = true 
)

Requests to save the current values for the specified parameter UIDs to permanent storage.

Definition at line 839 of file parametertransfer.cpp.

◆ pollParameter()

Parameter visiontransfer::internal::ParameterTransfer::pollParameter ( const std::string &  uid,
bool  blockingCall 
)

Returns a disconnected copy of the matching parameter from the parameter set after polling for its current value; exception if not found.

Definition at line 887 of file parametertransfer.cpp.

◆ readBoolParameter()

bool visiontransfer::internal::ParameterTransfer::readBoolParameter ( const char *  id)

Reads a boolean value from the parameter server.

Parameters
idUnique ID of the parameter to be read.
Returns
If successful, the value of the parameter that has been read

If reading the parameter fails, then an exception of type TransferException or ParameterException is thrown.

Definition at line 311 of file parametertransfer.cpp.

◆ readDoubleParameter()

double visiontransfer::internal::ParameterTransfer::readDoubleParameter ( const char *  id)

Reads a double precision floating point value from the parameter server.

Parameters
idUnique ID of the parameter to be read.
Returns
If successful, the value of the parameter that has been read

If reading the parameter fails, then an exception of type TransferException or ParameterException is thrown.

Definition at line 298 of file parametertransfer.cpp.

◆ readIntParameter()

int visiontransfer::internal::ParameterTransfer::readIntParameter ( const char *  id)

Reads an integer value from the parameter server.

Parameters
idUnique ID of the parameter to be read.
Returns
If successful, the value of the parameter that has been read

If reading the parameter fails, then an exception of type TransferException or ParameterException is thrown.

Definition at line 285 of file parametertransfer.cpp.

◆ setConnectionStateChangeCallback()

void visiontransfer::internal::ParameterTransfer::setConnectionStateChangeCallback ( std::function< void(visiontransfer::ConnectionState)>  callback)

Sets the callback function to inform of background disconnection / reconnection.

Definition at line 926 of file parametertransfer.cpp.

◆ transactionCommitQueue()

void visiontransfer::internal::ParameterTransfer::transactionCommitQueue ( int  maxWaitMilliseconds)

Complete the started parameter transaction.

Bundles all queued writes into a single locked request and sends them.

Definition at line 746 of file parametertransfer.cpp.

◆ transactionStartQueue()

void visiontransfer::internal::ParameterTransfer::transactionStartQueue ( )

Start batch parameter transaction.

Queues all remote set operations for writing in one batch; used for robust dependent parameter recalculation.

Definition at line 735 of file parametertransfer.cpp.

◆ writeBoolParameter()

void visiontransfer::internal::ParameterTransfer::writeBoolParameter ( const char *  id,
bool  value 
)

Writes a boolean value to a parameter of the parameter server.

Parameters
idUnique ID of the parameter to be written.
valueValue that should be written to the parameter.

If writing the parameter fails, then an exception of type TransferException or ParameterException is thrown.

Definition at line 332 of file parametertransfer.cpp.

◆ writeDoubleParameter()

void visiontransfer::internal::ParameterTransfer::writeDoubleParameter ( const char *  id,
double  value 
)

Writes a double precision floating point value to a parameter of the parameter server.

Parameters
idUnique ID of the parameter to be written.
valueValue that should be written to the parameter.

If writing the parameter fails, then an exception of type TransferException or ParameterException is thrown.

Definition at line 328 of file parametertransfer.cpp.

◆ writeIntParameter()

void visiontransfer::internal::ParameterTransfer::writeIntParameter ( const char *  id,
int  value 
)

Writes an integer value to a parameter of the parameter server.

Parameters
idUnique ID of the parameter to be written.
valueValue that should be written to the parameter.

If writing the parameter fails, then an exception of type TransferException or ParameterException is thrown.

Definition at line 324 of file parametertransfer.cpp.

◆ writeParameter()

template<typename T >
void visiontransfer::internal::ParameterTransfer::writeParameter ( const char *  id,
const T &  value,
bool  synchronous = true 
)

Writes a scalar value to a parameter of the parameter server.

Parameters
idUnique ID of the parameter to be written.
valueValue that should be written to the parameter.

If writing the parameter fails, then an exception of type TransferException or ParameterException is thrown.

Definition at line 133 of file parametertransfer.cpp.

◆ writeParameterTransactionGuarded()

template<typename T >
void visiontransfer::internal::ParameterTransfer::writeParameterTransactionGuarded ( const char *  id,
const T &  value 
)

Writes a scalar value to a parameter of the parameter server, transparently deferring for a batch update if a transaction has been started.

Parameters
idUnique ID of the parameter to be written.
valueValue that should be written to the parameter.

If writing the parameter fails, then an exception of type TransferException or ParameterException is thrown.

◆ writeParameterTransactionUnguarded()

template<typename T >
void visiontransfer::internal::ParameterTransfer::writeParameterTransactionUnguarded ( const char *  id,
const T &  value 
)

Writes a scalar value to a parameter of the parameter server, using 'fire-and-forget' for real-time commands (no replies expected).

Parameters
idUnique ID of the parameter to be written.
valueValue that should be written to the parameter.

If writing the parameter fails immediately, an exception of type TransferException is thrown.


The documentation for this class was generated from the following files:
Allied Vision