49 #include "vtkImageData.h"
62 qRegisterMetaType<Transform3D>(
"Transform3D");
63 qRegisterMetaType<ImagePtr>(
"ImagePtr");
64 qRegisterMetaType<ImagePtr>(
"MeshPtr");
65 qRegisterMetaType<ProbeDefinitionPtr>(
"ProbeDefinitionPtr");
66 qRegisterMetaType<VoidFunctionType>(
"VoidFunctionType");
86 mAvailableDialects[value->getName()] = value;
92 QMetaObject::invokeMethod(
this,
95 Q_ARG(VoidFunctionType, func));
98 void NetworkConnection::onInvoke(VoidFunctionType func)
106 DialectMap::const_iterator it = mAvailableDialects.begin();
107 for( ; it!=mAvailableDialects.end() ; ++it)
117 if(mProtocol && (protocolname == mProtocol->getName()))
120 ProtocolPtr protocol = mAvailableDialects[protocolname];
123 CX_LOG_ERROR() <<
"\"" << protocolname <<
"\" is an unknown opentigtlink dialect.";
136 mProtocol = protocol;
143 mProtocol->setSynchronizeRemoteClock(!
mConnector->getInfo().isLocalhostConnection());
164 int sendSize = package->data()->size/1024;
165 int waitingSize =
mSocket->bytesToWrite()/1024;
166 double waitToSendRatio = double(waitingSize)/double(sendSize);
167 double waitToSendRatioThreshold = 0.5;
169 static int sentCounter =0;
170 static int dropCounter =0;
175 if (waitToSendRatio > waitToSendRatioThreshold)
178 CX_LOG_CHANNEL_DEBUG(
"igtl_test") << QString(
"dropped stream image: wanted to send %1kB but %2kB already waiting, sent=%3,drop=%4")
195 mSocket->write(reinterpret_cast<char*>(package->data()->pointer));
204 mSocket->write(package->data()->pointer, package->data()->size);
213 mSocket->write(package->data()->pointer, package->data()->size);
216 void NetworkConnection::internalDataAvailable()
224 if(mProtocol->readyToReceiveData())
228 if(this->
socketReceive(pack->data()->pointer, pack->data()->size))
231 pack->notifyDataArrived();
virtual void setConnectionInfo(ConnectionInfo info)
thread-safe
void probedefinition(QString devicename, ProbeDefinitionPtr definition)
#define CX_LOG_CHANNEL_SUCCESS(channel)
void transform(QString devicename, Transform3D transform, double timestamp)
void image(ImagePtr image)
bool socketReceive(void *packPointer, int packSize) const
void calibration(QString devicename, Transform3D calibration)
virtual ~NetworkConnection()
void transform(QString devicename, Transform3D transform, double timestamp)
boost::shared_ptr< class Image > ImagePtr
boost::shared_ptr< EncodedPackage > EncodedPackagePtr
void image(ImagePtr image)
virtual void setProtocol(QString protocolname)
ConnectionInfo getConnectionInfo()
thread-safe
void sendMesh(MeshPtr image)
not thread-safe: use invoke
NetworkConnection(QString uid, QObject *parent=0)
#define CX_OPENIGTLINK_CHANNEL_NAME
void sendImage(ImagePtr image)
not thread-safe: use invoke
#define CX_LOG_CHANNEL_DEBUG(channel)
QStringList getAvailableDialects() const
#define assertRunningInObjectThread()
void streamImage(ImagePtr image)
not thread-safe: use invoke
void calibration(QString devicename, Transform3D calibration)
void probedefinition(QString devicename, ProbeDefinitionPtr definition)
SocketConnectorPtr mConnector
boost::shared_ptr< class Mesh > MeshPtr
The PlusDialect class contains the knowhow on the packages sent from a PlusServer. For this class to function correctly, the Plus configuration file used by the PlusServer needs to set up correctly.
void invoke(boost::function< void()> func)
boost::shared_ptr< Protocol > ProtocolPtr