Robox Library for Cpp: BCC/31 module 1.0.0
RLibCpp BCC/31 protocol implementation
|
Communication client declaration. More...
#include <connection.h>
Classes | |
class | VariablesCache |
The class to handle variable caches. More... | |
class | VariablesCacheItem |
Class to handle an item in the variables cache. More... | |
class | VariablesDict |
The variable dictionay. More... | |
Public Member Functions | |
Connection () | |
The constructor. | |
virtual | ~Connection () |
The destructor. | |
virtual bool | active () |
Get the activation state of the connection. | |
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. | |
Public Attributes | |
Signal1< uint64_t > | aboutToSynchronize |
Event fired when the connection ia about to be synchronized. | |
Signal2< uint64_t, RLibCpp::Bcc::Globals::Results > | synchronizeCompleted |
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 Member Functions | |
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. | |
virtual Globals::Results | doStart ()=0 |
Internal method to start the connection. | |
virtual Globals::Results | doStop ()=0 |
Internal method to stop the connection. | |
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. | |
virtual Globals::Results | doGetClient (Client *&client, int targetId, int targetCh, int sourceCh)=0 |
Internal method to get the client. | |
virtual Globals::Results | doReleaseClient (Client *client)=0 |
Internal method to release the client. | |
void | doDisposeCaches () |
Internal method to dispose Monitor and Oscilloscope chaches on derived class destruction. | |
Monitor::PtrVector & | monitorsCache () |
Get the list of monitors created with the getMonitor(Monitor *&) or getMonitor(Monitor *&, int, int, int) methods and not jet released | |
Oscilloscope::PtrVector & | oscilloscopesCache () |
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. | |
Protected Attributes | |
bool | m_stoppedOnDispose |
Flags to indicate that che connection has been stopped after destruxtion. | |
Friends | |
class | BaseMonitor |
class | Oscilloscope |
class | Client |
Communication client declaration.
Connection | ( | ) |
The 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
|
virtual |
The destructor.
|
virtual |
Get the activation state of the connection.
Reimplemented in TcpIpConnection.
uint32_t addToVarsCache | ( | const String & | name, |
const String & | extraTag = "" ) |
Adds a variable to the cache.
name | The name of the variable to add to the cache |
extraTag | The optional extra data used in cache id calculation: you can set this to different values to force caching of distinct entries of the same variable |
All successive operation onto the variable (Client.readVariable(ClientStruct::ReadVariableData &) , Client.writeVariable(ClientStruct::WriteVariableData &) etc) must refer to returned cache identifier
Variable naming convention must the same as RDE.
Using different extraTag values for the same name may be useful to maximize performance when accessing the same variable from Monitor, Client ( e.g. Client.readVariable(ClientStruct::ReadVariableData &), Client.writeVariable(ClientStruct::WriteVariableData &) , Monitor::read(MonitorStruct::ReadData &), etc) or Oscilloscope: in that cases, using different extraTag values (e.g. "MON", "CLIENT", "OSC" ) will force the caching of distinct entry , improving the overall performance
void clearVarsCache | ( | ) |
Clears the variables' cache removing all the cached variables.
Globals::Results dataTypeForCachedVar | ( | uint32_t | cacheId, |
Message::DataTypes & | type ) |
Get the data type for the specified cacheId stored into the variable cache.
cacheId | The variable cache identifier to check |
type | The data type for the specified cacheId stored into the variable cache or Message::DataTypes::dtUndef if cacheId wasn't found into the cache |
|
protected |
Get the device information read from the connected device.
|
protected |
Get the to indicate if devInfo() contains valid information or has to be updated (read from the device)
|
protected |
Internal method to dispose Monitor and Oscilloscope chaches on derived class destruction.
|
protectedpure virtual |
Internal method to get the client.
client | Reference to the communication client. |
targetId | Required target ID. |
targetCh | Required target channel, when applicable (0=default). |
sourceCh | Required source channel, when applicable (-1=default). |
Implemented in TcpIpConnection.
|
protected |
The method that effectively invokes the event.
|
protectedpure virtual |
Internal method to release the client.
client | The communication client to release. |
Implemented in TcpIpConnection.
|
protectedpure virtual |
Internal method to start the connection.
Implemented in TcpIpConnection.
|
protectedpure virtual |
Internal method to stop the connection.
Implemented in TcpIpConnection.
|
protected |
Make sure that the connection is synchronized and all structures updated.
client | The client to use for comunicate to the device. |
force | Flag to force the dictionary update , otherwise the dictionary is updated only if devInfoValid() is false |
useCoherentValues | Flag to indicate that coherent values operations are required |
If client is null, a temporary client will be used to perform the operation.
EventDispatcherThread * eventsThread | ( | ) | const |
Get the thread for event dispatching.
bool existsInVarsCache | ( | uint32_t | cacheId | ) |
Check if the specified cacheId is a valid id stored into the variable cache.
cacheId | The variable cache identifier to check |
uint32_t findInVarsCache | ( | const String & | name, |
const String & | extraTag = "" ) |
Check if the variable of specified in name with extraTag is cached.
name | The name of the variable to earch for |
extraTag | The optional extra tag used in cache id calculation |
The search is case insensitive: leading and traling whites char are trimmed.
|
virtual |
Obtain a new (default configured) communication client for the connection.
client | Reference to the communication client. |
In case you need more clients and you run out of them in this connection, you can instantiate a second connection for managing an additional set of clients.
|
virtual |
Obtain a new communication client for the connection.
client | Reference to the communication client. |
targetId | Required target ID. |
targetCh | Required target channel, when applicable (0=default). |
sourceCh | Required source channel, when applicable (-1=default). |
|
virtual |
Obtain a new (default configured) monitor for the connection.
monitor | Reference to the monitor. |
In case you need more monitor and you run out of them in this connection, you can instantiate a second connection for managing an additional set of monitors.
|
virtual |
Obtain a new monitor for the connection.
monitor | Reference to the monitor. |
targetId | Required target ID. |
targetCh | Required target channel, when applicable (0=default). |
sourceCh | Required source channel, when applicable (-1=default). |
In case you need more monitor and you run out of them in this connection, you can instantiate a second connection for managing an additional set of monitors.
|
virtual |
Obtain a new (default configured) oscilloscope for the connection.
oscilloscope | Reference to the oscilloscope. |
In case you need more oscilloscope and you run out of them in this connection, you can instantiate a second connection for managing an additional set of oscilloscopes.
|
virtual |
Obtain a new oscilloscope for the connection.
oscilloscope | Reference to the oscilloscope. |
targetId | Required target ID. |
targetCh | Required target channel, when applicable (0=default). |
sourceCh | Required source channel, when applicable (-1=default). |
In case you need more oscilloscope and you run out of them in this connection, you can instantiate a second connection for managing an additional set of oscilloscopes.
|
protected |
Query a cached item given its ID.
client | The client to use for comunicate to the device. |
cacheId | The Id of the variable into the cache |
forceVarDictUpdate | Flag to force the update of the variable dictionary |
useCoherentValues | Flag to use coherent values operations |
checkFullVar | Flag to enable the variable full check when parsing |
startMsgOffset | Message offset to be used on new var |
splitOffset | Offset to be applyed to the to the parsing variable logic to properly split the variable. Thats applies when a variable has to be fitted into a BCC message which contains other data (tipcally when using monitors) |
vcache | The cache object , or null if some error occurred |
If client is null, a temporary client will be used to perform the operation.
|
protected |
Query a cached item given its ID.
client | The client to use for comunicate to the device. |
cacheId | The Id of the variable into the cache |
forceVarDictUpdate | Flag to force the update of the variable dictionary |
useCoherentValues | Flag to use coherent values operations |
checkFullVar | Flag to enable the variable full check when parsing |
vcache | The cache object , or null if some error occurred |
If client is null, a temporary client will be used to perform the operation.
uint64_t id | ( | ) | const |
Get the object identifier.
|
overrideprotected |
The method to be invoked for event dispatch.
|
protected |
Get the list of monitors created with the getMonitor(Monitor *&) or getMonitor(Monitor *&, int, int, int) methods and not jet released
|
protected |
Wrapper to fire the AboutToSynchronize event.
|
protected |
Helper for firing the event of specified type.
event | The event to send |
|
protected |
Wrapper to fire the started event.
|
protected |
Wrapper to fire the stopped event.
|
protected |
Wrapper to fire the synchronizeCompleted event.
re | The result code of the update operation |
|
protected |
Get the list of oscilloscopes created with the getOscilloscope(Oscilloscope *&) or getOscilloscope(Oscilloscope *&, int32_t, int32_t, int32_t) methods and not jet released
|
protected |
Wrapper for variable parsing.
name | Name of the variable |
varDataList | The returned list of RVar::Dict::VarData |
parseFlags | Parsing flags (RVar::Dict::ParseFlags). Optional : default value is RVar::Dict::pfDefault |
|
protected |
Wrapper for variable parsing.
name | Name of the variable |
startMsgOffset | Message offset to be used on new var |
msgOffset | Message offset for the first var |
varDataList | The returned list of RVar::Dict::VarData |
srcIndex | The returned source indes RVar::Index |
parseFlags | Parsing flags (RVar::Dict::ParseFlags). Optional : default value is RVar::Dict::pfDefault |
|
protected |
Retrives informations from connected device and stoes into the RVar::DevInfo property.
client | The client to use for comunicate to the device. |
force | Flag to force device info data read: if resetted the device will be queried only if devInfoValid() is false |
devInfoChanged | Flag setted if the device informations has been changed since last read (the value stored into the RVar::DevInfo property) |
If client is null, a temporary client will be used to perform the operation.
|
virtual |
Release a communication client for the connection.
client | The communication client to release. |
It is best practise to explictly release the client or dispose when done with the client. Otherwise it will be released when the object is destroyed.
|
virtual |
Release a monitor for the connection.
monitor | The monitor to release. |
It is best practise to explictly release the monitor or dispose when done with the client. Otherwise it will be released when the object is destroyed.
|
virtual |
Release a oscilloscope for the connection.
oscilloscope | The oscilloscope to release. |
It is best practise to explictly release the oscilloscope or dispose when done with the client. Otherwise it will be released when the object is destroyed.
Globals::Results removeFromVarsCache | ( | uint32_t | cacheId | ) |
Removes the variable specified by cacheId from the cache.
cacheId | The cache identifier to remove |
Tool::ThreadHelper::ScheduleTypes scheduleType | ( | ) | const |
Get the schedule type for the connection.
|
protected |
Set the thread for event dispatching.
void setScheduleType | ( | Tool::ThreadHelper::ScheduleTypes | value | ) |
Set the schedule type for the connection.
value | The value to set |
void setVtxPath | ( | const String & | value | ) |
Set the VtxManager path.
value | The value to set |
|
virtual |
Start and activate the connection.
|
virtual |
Deactivate and stop the connection.
Globals::Results testCachedVar | ( | uint32_t | cacheId | ) |
Check the integrity of the variable for the specified cacheId stored into the variable cache.
cacheId | The variable cache identifier to check |
Globals::Results updateVarsCache | ( | ) |
Performs a refresh of the variables' cache if needed (i.e. reparses the cached variable from the variable dictionary)
String vtxPath | ( | ) |
Get the VtxManager path.
The default assigned value is "../etc/vtx" relative to the executing assembly path
|
friend |
|
friend |
|
friend |
Signal1<uint64_t> aboutToSynchronize |
Event fired when the connection ia about to be synchronized.
senderId | This objetc identifier |
|
protected |
Flags to indicate that che connection has been stopped after destruxtion.
Signal1<uint64_t> started |
Event fired when the connection has been started.
senderId | This objetc identifier |
Signal1<uint64_t> stopped |
Event fired when the connection has been stopped.
senderId | This objetc identifier |
Signal2<uint64_t, RLibCpp::Bcc::Globals::Results> synchronizeCompleted |
Event fired when the connection synchronizaztion has been completed.
senderId | This objetc identifier |
re | The operation result code |