Robox Library for Cpp: BCC/31 module 1.0.0
RLibCpp BCC/31 protocol implementation
Public Member Functions | Protected Member Functions | Friends | List of all members
TcpIpConnection Class Reference

The connection class for the BCC protocol with the standard single socket TCP/IP transport. More...

#include <tcpipconnection.h>

Inheritance diagram for TcpIpConnection:
Connection

Public Member Functions

 TcpIpConnection ()
 Class constructor.
 
virtual ~TcpIpConnection ()
 Class destructor.
 
bool active () override
 The activation state of the connection.
 
bool connected ()
 The state of the underlying TCP socket connection.

 
String & serverIp ()
 Get the server IP destination address to which you want to connect.
 
void setServerIp (const String &value)
 Set the server IP destination address to which you want to connect.
 
int serverPort () const
 Get the server TCP port to which you want to connect (1-65535).
 
void setServerPort (int value)
 Set the server TCP port to which you want to connect (1-65535).
 
Tool::ThreadHelper::ScheduleTypes scheduleType () const
 Get the schedule type for the connection.
 
void setScheduleType (Tool::ThreadHelper::ScheduleTypes value)
 Set the schedule type for the connection.
 
- Public Member Functions inherited from Connection
 Connection ()
 The constructor.
 
virtual ~Connection ()
 The destructor.
 
String vtxPath ()
 Get the VtxManager path.
 
void setVtxPath (const String &value)
 Set the VtxManager path.
 
virtual Globals::Results getClient (Client *&client)
 Obtain a new (default configured) communication client for the connection.
 
virtual Globals::Results getClient (Client *&client, int targetId, int targetCh, int sourceCh)
 Obtain a new communication client for the connection.
 
virtual Globals::Results releaseClient (Client *client)
 Release a communication client for the connection.
 
virtual Globals::Results start ()
 Start and activate the connection.
 
virtual Globals::Results stop ()
 Deactivate and stop the connection.
 
virtual Globals::Results getMonitor (Monitor *&monitor)
 Obtain a new (default configured) monitor for the connection.
 
virtual Globals::Results getMonitor (Monitor *&monitor, int targetId, int targetCh, int sourceCh)
 Obtain a new monitor for the connection.
 
virtual Globals::Results releaseMonitor (Monitor *monitor)
 Release a monitor for the connection.
 
virtual Globals::Results getOscilloscope (Oscilloscope *&oscilloscope)
 Obtain a new (default configured) oscilloscope for the connection.
 
virtual Globals::Results getOscilloscope (Oscilloscope *&oscilloscope, int targetId, int targetCh, int sourceCh)
 Obtain a new oscilloscope for the connection.
 
virtual Globals::Results releaseOscilloscope (Oscilloscope *oscilloscope)
 Release a oscilloscope for the connection.
 
uint32_t addToVarsCache (const String &name, const String &extraTag="")
 Adds a variable to the cache.
 
uint32_t findInVarsCache (const String &name, const String &extraTag="")
 Check if the variable of specified in name with extraTag is cached.
 
Globals::Results removeFromVarsCache (uint32_t cacheId)
 Removes the variable specified by cacheId from the cache.
 
void clearVarsCache ()
 Clears the variables' cache removing all the cached variables.
 
Globals::Results updateVarsCache ()
 Performs a refresh of the variables' cache if needed (i.e. reparses the cached variable from the variable dictionary)
 
bool existsInVarsCache (uint32_t cacheId)
 Check if the specified cacheId is a valid id stored into the variable cache.
 
Globals::Results dataTypeForCachedVar (uint32_t cacheId, Message::DataTypes &type)
 Get the data type for the specified cacheId stored into the variable cache.
 
Globals::Results testCachedVar (uint32_t cacheId)
 Check the integrity of the variable for the specified cacheId stored into the variable cache.
 
uint64_t id () const
 Get the object identifier.
 
Tool::ThreadHelper::ScheduleTypes scheduleType () const
 Get the schedule type for the connection.
 
void setScheduleType (Tool::ThreadHelper::ScheduleTypes value)
 Set the schedule type for the connection.
 
EventDispatcherThread * eventsThread () const
 Get the thread for event dispatching.
 

Protected Member Functions

Globals::Results doGetClient (Client *&client, int targetId, int targetCh, int sourceCh) override
 Obtain a new communication client for the connection.
 
Globals::Results doReleaseClient (Client *client) override
 Release a communication client for the connection.
 
Globals::Results doStart () override
 Start and activate the connection.
 
Globals::Results doStop () override
 Deactivate and stop the connection.
 
- Protected Member Functions inherited from Connection
Globals::Results queryDeviceInfo (Client *client, bool force, bool &devInfoChanged)
 Retrives informations from connected device and stoes into the RVar::DevInfo property.
 
Globals::Results ensureSynchronized (Client *client, bool force, bool useCoherentValues)
 Make sure that the connection is synchronized and all structures updated.
 
void onAboutToSynchronize ()
 Wrapper to fire the AboutToSynchronize event.
 
void onSynchronizeCompleted (Globals::Results re)
 Wrapper to fire the synchronizeCompleted event.
 
void onStarted ()
 Wrapper to fire the started event.
 
void onStopped ()
 Wrapper to fire the stopped event.
 
Globals::Results parseVar (const String &name, RVar::Dict::VarData::PtrVector &varDataList, RVar::Dict::ParseFlags parseFlags=RVar::Dict::pfDefault)
 Wrapper for variable parsing.
 
Globals::Results parseVar (const String &name, uint32_t startMsgOffset, uint32_t msgOffset, RVar::Dict::VarData::PtrVector &varDataList, RVar::Index &srcIndex, RVar::Dict::ParseFlags parseFlags=RVar::Dict::pfDefault)
 Wrapper for variable parsing.
 
void invoke (long tagData) override
 The method to be invoked for event dispatch.
 
void doInvokeEvent (const Event &event)
 The method that effectively invokes the event.
 
void onEvent (const Event &event)
 Helper for firing the event of specified type.
 
Globals::Results getVariablesCacheItem (Client *client, uint32_t cacheId, bool forceVarDictUpdate, bool useCoherentValues, bool checkFullVar, VariablesCacheItem *&vcache)
 Query a cached item given its ID.
 
Globals::Results getVariablesCacheItem (Client *client, uint32_t cacheId, bool forceVarDictUpdate, bool useCoherentValues, bool checkFullVar, uint32_t startMsgOffset, uint32_t splitOffset, VariablesCacheItem *&vcache)
 Query a cached item given its ID.
 
void doDisposeCaches ()
 Internal method to dispose Monitor and Oscilloscope chaches on derived class destruction.
 
Monitor::PtrVectormonitorsCache ()
 Get the list of monitors created with the getMonitor(Monitor *&) or getMonitor(Monitor *&, int, int, int) methods and not jet released
 
Oscilloscope::PtrVectoroscilloscopesCache ()
 Get the list of oscilloscopes created with the getOscilloscope(Oscilloscope *&) or getOscilloscope(Oscilloscope *&, int32_t, int32_t, int32_t) methods and not jet released
 
RVar::DevInfo & devInfo ()
 Get the device information read from the connected device.
 
bool devInfoValid () const
 Get the to indicate if devInfo() contains valid information or has to be updated (read from the device)
 
void setEventsThread (EventDispatcherThread *value)
 Set the thread for event dispatching.
 

Friends

class Client
 

Additional Inherited Members

- Public Attributes inherited from Connection
Signal1< uint64_t > aboutToSynchronize
 Event fired when the connection ia about to be synchronized.
 
Signal2< uint64_t, RLibCpp::Bcc::Globals::ResultssynchronizeCompleted
 Event fired when the connection synchronizaztion has been completed.
 
Signal1< uint64_t > started
 Event fired when the connection has been started.
 
Signal1< uint64_t > stopped
 Event fired when the connection has been stopped.
 
- Protected Attributes inherited from Connection
bool m_stoppedOnDispose
 Flags to indicate that che connection has been stopped after destruxtion.
 

Detailed Description

The connection class for the BCC protocol with the standard single socket TCP/IP transport.

Example of connecting to a Robox device with a TCP single socket connection.

// Create the connection
TcpIpConnection myConnection;
myConnection.setServerIp("10.0.17.1"); // Can use a FQDN also
myConnection.setServerPort(8100);
// Connect to device
if (myConnection.start() == Globals::resSuccess)
{
// Obtain a communication client
Client *myClient;
if (myConnection.getClient(myClient) == Globals::resSuccess)
{
// Operate with the obtained client
// ...
myClient->command(...);
// Release the communication client
myConnection.releaseClient(myClient);
}
// Disconnect from the device
myConnection.stop();
}
Communication client declaration.
Definition client.h:4639
virtual Globals::Results command(Message *cmd, Message *asw, ClientStruct::OperationData *data)
Execute a generic command sequence on the connected device.
virtual Globals::Results start()
Start and activate the connection.
virtual Globals::Results getClient(Client *&client)
Obtain a new (default configured) communication client for the connection.
virtual Globals::Results stop()
Deactivate and stop the connection.
virtual Globals::Results releaseClient(Client *client)
Release a communication client for the connection.
@ resSuccess
The operation completed successfully.
Definition globals.h:39
The connection class for the BCC protocol with the standard single socket TCP/IP transport.
Definition tcpipconnection.h:70
void setServerIp(const String &value)
Set the server IP destination address to which you want to connect.
void setServerPort(int value)
Set the server TCP port to which you want to connect (1-65535).


This type of connection use a single TCP socket, regardless of the number of clients obtained.

In case you need more clients and you run out of them in the first connection, you can instantiate a second connection managing an additional set of clients: in this case, the second connection will use a different (and indipendent) TCP socket.

See also
Client

Constructor & Destructor Documentation

◆ TcpIpConnection()

Class constructor.

This method creates the VtxManager object which relies on the current Globals::language() value to set up the proper localized vtx file, so make sure to have invoked the Globals::setLocale() method with proper values before create any Connection object

◆ ~TcpIpConnection()

virtual ~TcpIpConnection ( )
virtual

Class destructor.

Member Function Documentation

◆ active()

bool active ( )
overridevirtual

The activation state of the connection.

Get the activation state of the connection.

Returns
The activation state of the connection.

Reimplemented from Connection.

◆ connected()

bool connected ( )

The state of the underlying TCP socket connection.

◆ doGetClient()

Globals::Results doGetClient ( Client *& client,
int targetId,
int targetCh,
int sourceCh )
overrideprotectedvirtual

Obtain a new communication client for the connection.

Parameters
clientReference to the communication client.
targetIdRequired target ID.
targetChRequired target channel (0=default).
sourceChRequired source channel (-1=default).
Returns
Return the operation result code.

Implements Connection.

◆ doReleaseClient()

Globals::Results doReleaseClient ( Client * client)
overrideprotectedvirtual

Release a communication client for the connection.

Parameters
clientThe communication client.
Returns
Return the operation result code.

Implements Connection.

◆ doStart()

Globals::Results doStart ( )
overrideprotectedvirtual

Start and activate the connection.

Returns
Return the operation result code.

Implements Connection.

◆ doStop()

Globals::Results doStop ( )
overrideprotectedvirtual

Deactivate and stop the connection.

Returns
Return the operation result code.

Implements Connection.

◆ scheduleType()

Tool::ThreadHelper::ScheduleTypes scheduleType ( ) const

Get the schedule type for the connection.

Returns
The parameter value
Remarks
You can change the schedule type when the connection is active, but it will not be assumed until the connection is restarted.
Set the scheduling type as scheduleTypeFast or scheduleTypeAggressive may have side effects on the PC, such as increased frequency of scheduler and/or increase the activity of the processor and battery consumption, etc.

◆ serverIp()

QString & serverIp ( )

Get the server IP destination address to which you want to connect.

Returns
The parameter value
Remarks
The address can be a numeric IPv4 or a fully qualified domain name (FQDN): in this case you must have a valid DNS configuration in order to correctly resolve the name.

◆ serverPort()

int32_t serverPort ( ) const

Get the server TCP port to which you want to connect (1-65535).

Returns
The parameter value
Remarks
The default value is 8100 for Robox SpA devices, if not differently configured.

◆ setScheduleType()

void setScheduleType ( Tool::ThreadHelper::ScheduleTypes value)

Set the schedule type for the connection.

Parameters
valueThe value to set
Remarks
You can change the schedule type when the connection is active, but it will not be assumed until the connection is restarted.
Set the scheduling type as scheduleTypeFast or scheduleTypeAggressive may have side effects on the PC, such as increased frequency of scheduler and/or increase the activity of the processor and battery consumption, etc.

◆ setServerIp()

void setServerIp ( const String & value)

Set the server IP destination address to which you want to connect.

Parameters
valueThe value to set
Remarks
The address can be a numeric IPv4 or a fully qualified domain name (FQDN): in this case you must have a valid DNS configuration in order to correctly resolve the name.

◆ setServerPort()

void setServerPort ( int value)

Set the server TCP port to which you want to connect (1-65535).

Parameters
valueThe value to set
Remarks
The default value is 8100 for Robox SpA devices, if not differently configured.

Friends And Related Symbol Documentation

◆ Client

friend class Client
friend