AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxNet::CoSimulationClient Class Reference

Class for receiving serialized agxSDK::Simulation:s from remote host. More...

#include <CoSimulationClient.h>

+ Inheritance diagram for agxNet::CoSimulationClient:

Public Member Functions

 CoSimulationClient (const IPAddress &address)
 Constructor. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
bool checkConnection ()
 
virtual void dropConnection ()
 Drop the connection to the remote host and wait for a new one. More...
 
agx::String getMessage ()
 
int getReferenceCount () const
 
bool initInput (const agx::RealVector &input, agx::RealVector &output)
 
template<typename T >
bool is () const
 Subclass test. More...
 
virtual bool isConnected ()
 
bool isWaitingForConnection () const
 Is the client still waiting for connection? More...
 
bool preloadScript (const agx::String &filename)
 Preloads the scene, parsing the file and obtaining information about input and output sizes. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void setTimeStep (double timeStep)
 
bool stepInput (const agx::RealVector &input, agx::RealVector &output)
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
virtual bool waitForConnection ()
 

Static Public Member Functions

template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~CoSimulationClient ()
 
void allocateObserverVector () const
 
bool connectToServer ()
 
void deleteUsingDeleteHandler () const
 
virtual void handleConnectionDrop ()
 
size_t receiveData (uint8_t *data, size_t numBytes)
 Receive data from remote party. More...
 
void receivePacket (Header &header)
 
size_t sendData (const uint8_t *data, size_t numBytes)
 Transmit data to remote party. More...
 
void sendPacket (Header &header)
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

agx::Vector< char > m_buffer
 
agx::Mutex m_connectionMutex
 
bool m_isShutdown
 
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 
TCPSocketRef m_socket
 

Detailed Description

Class for receiving serialized agxSDK::Simulation:s from remote host.

Definition at line 33 of file CoSimulationClient.h.

Constructor & Destructor Documentation

agxNet::CoSimulationClient::CoSimulationClient ( const IPAddress &  address)

Constructor.

Parameters
address- Address of server running a simulation
virtual agxNet::CoSimulationClient::~CoSimulationClient ( )
protectedvirtual

Member Function Documentation

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
bool agxNet::CoSimulationClient::checkConnection ( )
bool agxNet::CoSimulationClient::connectToServer ( )
protected
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
virtual void agxNet::CoSimulationBase::dropConnection ( )
virtualinherited

Drop the connection to the remote host and wait for a new one.

Reimplemented in agxNet::CoSimulationServer.

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
agx::String agxNet::CoSimulationClient::getMessage ( )
int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
virtual void agxNet::CoSimulationClient::handleConnectionDrop ( )
protectedvirtual

Reimplemented from agxNet::CoSimulationBase.

bool agxNet::CoSimulationClient::initInput ( const agx::RealVector &  input,
agx::RealVector &  output 
)
template<typename T >
bool agx::Referenced::is ( ) const
inherited
virtual bool agxNet::CoSimulationBase::isConnected ( )
virtualinherited
Returns
true if we are connected to a remote party
bool agxNet::CoSimulationClient::isWaitingForConnection ( ) const

Is the client still waiting for connection?

bool agxNet::CoSimulationClient::preloadScript ( const agx::String &  filename)

Preloads the scene, parsing the file and obtaining information about input and output sizes.

Parameters
filenameThe name of the script (python or lua) file. Has to have a buildScene(sim, app) function.
Return values
Hasthe loading succeeded?
size_t agxNet::CoSimulationBase::receiveData ( uint8_t *  data,
size_t  numBytes 
)
protectedinherited

Receive data from remote party.

Parameters
data- pointer to address where data will be written
numBytes- size of memory storage.
Returns
number of bytes read.
void agxNet::CoSimulationBase::receivePacket ( Header &  header)
protectedinherited
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

size_t agxNet::CoSimulationBase::sendData ( const uint8_t *  data,
size_t  numBytes 
)
protectedinherited

Transmit data to remote party.

Data block can be chopped up into smaller chunks.

Parameters
data- bit stream that should be transmitted to remote client
numBytes- number of bytes to be transmitted.
Returns
number of bytes sent
void agxNet::CoSimulationBase::sendPacket ( Header &  header)
protectedinherited
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxNet::CoSimulationClient::setTimeStep ( double  timeStep)
bool agxNet::CoSimulationClient::stepInput ( const agx::RealVector &  input,
agx::RealVector &  output 
)
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited
virtual bool agxNet::CoSimulationClient::waitForConnection ( )
virtual

Member Data Documentation

agx::Vector<char> agxNet::CoSimulationBase::m_buffer
protectedinherited

Definition at line 112 of file CoSimulationBase.h.

agx::Mutex agxNet::CoSimulationBase::m_connectionMutex
protectedinherited

Definition at line 114 of file CoSimulationBase.h.

bool agxNet::CoSimulationBase::m_isShutdown
protectedinherited

Definition at line 116 of file CoSimulationBase.h.

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

TCPSocketRef agxNet::CoSimulationBase::m_socket
protectedinherited

Definition at line 115 of file CoSimulationBase.h.


The documentation for this class was generated from the following file: