UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-11-21)
usNetworkGrabber Class Referenceabstract

#include <visp3/ustk_grabber/usNetworkGrabber.h>

+ Inheritance diagram for usNetworkGrabber:

Classes

struct  usInitHeaderConfirmation
 
struct  usInitHeaderSent
 
struct  usRunControlHeaderSent
 

Public Types

enum  usDataPositionInBuffer { OUTPUT_FRAME_POSITION_IN_VEC = 0 , MOST_RECENT_FRAME_POSITION_IN_VEC = 1 , CURRENT_FILLED_FRAME_POSITION_IN_VEC = 2 }
 
enum  usVolumeField { ODD = 0 , EVEN = 1 , ODD_EVEN = 2 }
 

Public Slots

void center3DProbeMotor ()
 
void connected ()
 
void connectToServer ()
 
void connectToServer (QHostAddress address)
 
virtual void dataArrived ()=0
 
void disconnected ()
 
void disconnectFromServer ()
 
void handleError (QAbstractSocket::SocketError err)
 
void initAcquisitionSlot (usNetworkGrabber::usInitHeaderSent header)
 
void processConnectionToServer ()
 
void runAcquisition ()
 
void stopAcquisition ()
 

Signals

void serverUpdateEnded (bool success)
 
void endBlockingLoop ()
 
void runAcquisitionSignal (bool run)
 
void sendAcquisitionParametersSignal ()
 
void endConnection ()
 
void acquisitionInitialized (bool)
 

Public Member Functions

 usNetworkGrabber (QObject *parent=0)
 
 ~usNetworkGrabber ()
 
void disconnect ()
 
bool initAcquisition (const usNetworkGrabber::usInitHeaderSent &header)
 
bool getMotorActivation ()
 
usAcquisitionParameters::usMotorStep getStepsPerFrame ()
 
int getFramesPerVolume ()
 
int getImageDepth ()
 
int getImagingMode ()
 
int getMotorPosition ()
 
int getPostScanHeigh ()
 
bool getPostScanMode ()
 
int getPostScanWidth ()
 
int getSamplingFrequency ()
 
int getSector ()
 
int getTransmitFrequency ()
 
void readAcquisitionParameters (QDataStream &stream)
 
bool sendAcquisitionParameters ()
 
void setIPAddress (const std::string &s_ip)
 
void setMotorActivation (bool activateMotor)
 
void setStepsPerFrame (usAcquisitionParameters::usMotorStep stepsPerFrame)
 
void setFramesPerVolume (int framesPerVolume)
 
void setImageDepth (int imageDepth)
 
void setImagingMode (int imagingMode)
 
void setMotorPosition (int motorPosition)
 
void setPostScanHeigh (int postScanHeigh)
 
void setPostScanMode (bool postScanMode)
 
void setPostScanWidth (int postScanWidth)
 
void setSamplingFrequency (int samplingFrequency)
 
void setSector (int sector)
 
void setTransmitFrequency (int transmitFrequency)
 
void setVerbose (bool verbose)
 

Protected Slots

void serverUpdated (bool sucess)
 
void sendRunSignal (bool run)
 
void sendAcquisitionParametersSlot ()
 

Protected Attributes

bool m_verbose
 
QTcpSocket * m_tcpSocket
 
bool m_connect
 
std::string m_ip
 
int m_bytesLeftToRead
 
usAcquisitionParameters m_acquisitionParameters
 
bool m_updateParametersSucess
 
usInitHeaderConfirmation m_confirmHeader
 
us::usImageHeader m_imageHeader
 
bool m_isInit
 
bool m_isRunning
 
QThread * m_thread
 

Detailed Description

Generic abstract class to manage tcp connection to grab ultrasound frames (on port 8080).

This class contains all the network process to manage the remote control the acquisition (the code for server side is on lagadic gitlab).

The following figure details the network communication process and summarizes the steps to follow to acquire ultrasound images :

Definition at line 71 of file usNetworkGrabber.h.

Member Enumeration Documentation

◆ usDataPositionInBuffer

Enumerator
OUTPUT_FRAME_POSITION_IN_VEC 
MOST_RECENT_FRAME_POSITION_IN_VEC 
CURRENT_FILLED_FRAME_POSITION_IN_VEC 

Definition at line 75 of file usNetworkGrabber.h.

◆ usVolumeField

Enum to specify types of volumes to grab

Enumerator
ODD 

Grab only odd volumes

EVEN 

Grab only even volumes

ODD_EVEN 

Grab every volumes

Definition at line 82 of file usNetworkGrabber.h.

Constructor & Destructor Documentation

◆ usNetworkGrabber()

usNetworkGrabber::usNetworkGrabber ( QObject *  parent = 0)
explicit

◆ ~usNetworkGrabber()

usNetworkGrabber::~usNetworkGrabber ( )

Destructor.

Definition at line 80 of file usNetworkGrabber.cpp.

References m_tcpSocket, m_thread, and stopAcquisition().

Member Function Documentation

◆ acquisitionInitialized

void usNetworkGrabber::acquisitionInitialized ( bool  )
signal

Referenced by initAcquisitionSlot().

◆ center3DProbeMotor

void usNetworkGrabber::center3DProbeMotor ( )
slot

Sets the motor position of 4DC7 probe to the middle.

Definition at line 768 of file usNetworkGrabber.cpp.

References sendAcquisitionParameters(), and setMotorPosition().

◆ connected

void usNetworkGrabber::connected ( )
slot

Slot called when the grabber is connected to the server. Prints connection informations.

Definition at line 165 of file usNetworkGrabber.cpp.

References m_tcpSocket, and m_verbose.

Referenced by processConnectionToServer().

◆ connectToServer [1/2]

◆ connectToServer [2/2]

void usNetworkGrabber::connectToServer ( QHostAddress  address)
slot

Method used to connect to the server.

Definition at line 105 of file usNetworkGrabber.cpp.

References m_connect, processConnectionToServer(), and setIPAddress().

◆ dataArrived

◆ disconnect()

void usNetworkGrabber::disconnect ( )

Method to close the connection.

Examples
tutorial-ultrasonix-qt-grabbing-pre-scan-confidence-control.cpp.

Definition at line 293 of file usNetworkGrabber.cpp.

References m_tcpSocket.

◆ disconnected

void usNetworkGrabber::disconnected ( )
slot

Slot called when the grabber is disconnected from the server. Prints information, and closes socket.

Definition at line 179 of file usNetworkGrabber.cpp.

References m_tcpSocket, and m_verbose.

Referenced by disconnectFromServer(), and processConnectionToServer().

◆ disconnectFromServer

void usNetworkGrabber::disconnectFromServer ( )
slot

◆ endBlockingLoop

void usNetworkGrabber::endBlockingLoop ( )
signal

◆ endConnection

void usNetworkGrabber::endConnection ( )
signal

◆ getFramesPerVolume()

int usNetworkGrabber::getFramesPerVolume ( )

Getter for the number of frames per volume, in 3D acquisition.

Definition at line 718 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getFramesPerVolume(), and m_acquisitionParameters.

◆ getImageDepth()

int usNetworkGrabber::getImageDepth ( )

Getter for image depth (meters).

Definition at line 723 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getImageDepth(), and m_acquisitionParameters.

◆ getImagingMode()

int usNetworkGrabber::getImagingMode ( )

Getter for imaging mode (0 : B-Mode, 12 : RF).

Definition at line 728 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getImagingMode(), and m_acquisitionParameters.

◆ getMotorActivation()

bool usNetworkGrabber::getMotorActivation ( )

Getter for motor activation : true to sweep the motor the motor during the acquisition, false to let it static.

Definition at line 705 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getActivateMotor(), and m_acquisitionParameters.

◆ getMotorPosition()

int usNetworkGrabber::getMotorPosition ( )

Getter for a static motor position (in angle from the beginning position).

Definition at line 733 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getMotorPosition(), and m_acquisitionParameters.

◆ getPostScanHeigh()

int usNetworkGrabber::getPostScanHeigh ( )

Getter for post-scan image height.

Definition at line 738 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getPostScanHeigh(), and m_acquisitionParameters.

◆ getPostScanMode()

bool usNetworkGrabber::getPostScanMode ( )

Getter for post-scan mode : true for post-scan, false for pre-scan.

Definition at line 743 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getPostScanMode(), and m_acquisitionParameters.

◆ getPostScanWidth()

int usNetworkGrabber::getPostScanWidth ( )

Getter for post-scan image width.

Definition at line 748 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getPostScanWidth(), and m_acquisitionParameters.

◆ getSamplingFrequency()

int usNetworkGrabber::getSamplingFrequency ( void  )

Getter for samplingFrequency (Hz).

Definition at line 753 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getSamplingFrequency(), and m_acquisitionParameters.

◆ getSector()

int usNetworkGrabber::getSector ( )

Getter for sector (percentage of the number of transducers to use).

Definition at line 758 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getSector(), and m_acquisitionParameters.

◆ getStepsPerFrame()

usAcquisitionParameters::usMotorStep usNetworkGrabber::getStepsPerFrame ( )

Getter for steps between two sucessive frames (angle). See usAcquisitionParameters::usMotorSteps

Definition at line 710 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getSepsPerFrame(), and m_acquisitionParameters.

◆ getTransmitFrequency()

int usNetworkGrabber::getTransmitFrequency ( )

Getter for transmitFrequency (Hz).

Definition at line 763 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getTransmitFrequency(), and m_acquisitionParameters.

◆ handleError

void usNetworkGrabber::handleError ( QAbstractSocket::SocketError  err)
slot

Slot called if there is an error (or disruption) in the connection. Throws an exception and prints the error.

Definition at line 189 of file usNetworkGrabber.cpp.

References m_tcpSocket.

Referenced by processConnectionToServer().

◆ initAcquisition()

bool usNetworkGrabber::initAcquisition ( const usNetworkGrabber::usInitHeaderSent header)

Method called to init the ultrasonix station, by passing acquisition parameters. It is a blocking method : we wait the answer of the server to know if init was sucessfull.

Parameters
headerContains acquisition parameters to set up for the acquisition.
Returns
Boolean to say if init was sucessfull (true) or not (false).
See also
usNetworkGrabber::usInitHeaderSent
Examples
tutorial-elastography-2D-separate-displays.cpp, tutorial-elastography-2D.cpp, tutorial-elastography-3D-acquisition.cpp, tutorial-elastography-BMA-2D.cpp, tutorial-local-grabbing-elastography-display.cpp, tutorial-local-grabbing-pre-scan2D-display.cpp, tutorial-ultrasonix-qt-grabbing-RF-scan-conversion.cpp, tutorial-ultrasonix-qt-grabbing-RF.cpp, tutorial-ultrasonix-qt-grabbing-RF3D.cpp, tutorial-ultrasonix-qt-grabbing-post-scan-bi-plan.cpp, tutorial-ultrasonix-qt-grabbing-post-scan.cpp, tutorial-ultrasonix-qt-grabbing-post-scan3D.cpp, tutorial-ultrasonix-qt-grabbing-pre-scan-confidence-control.cpp, tutorial-ultrasonix-qt-grabbing-pre-scan-confidence.cpp, tutorial-ultrasonix-qt-grabbing-pre-scan.cpp, tutorial-ultrasonix-qt-grabbing-pre-scan3D-display.cpp, tutorial-ultrasonix-qt-grabbing-pre-scan3D.cpp, tutorial-ultrasonix-servo-target-confidence.cpp, tutorial-ustk-virtual-server-RF2D.cpp, tutorial-ustk-virtual-server-RF3D.cpp, tutorial-ustk-virtual-server-postScan2D.cpp, tutorial-ustk-virtual-server-preScan2D.cpp, and tutorial-ustk-virtual-server-preScan3D.cpp.

Definition at line 206 of file usNetworkGrabber.cpp.

References endBlockingLoop(), usNetworkGrabber::usInitHeaderSent::headerId, usNetworkGrabber::usInitHeaderSent::imagingMode, m_isInit, m_isRunning, m_tcpSocket, m_updateParametersSucess, m_verbose, usNetworkGrabber::usInitHeaderSent::probeId, usNetworkGrabber::usInitHeaderSent::slotId, and stopAcquisition().

◆ initAcquisitionSlot

void usNetworkGrabber::initAcquisitionSlot ( usNetworkGrabber::usInitHeaderSent  header)
slot

Slot to call to init the ultrasonix station, by passing acquisition parameters. It is a blocking method : we wait the answer of the server to know if init was sucessfull.

Returns
Boolean to say if init was sucessfull (true) or not (false).
See also
usNetworkGrabber::usInitHeaderSent

Definition at line 251 of file usNetworkGrabber.cpp.

References acquisitionInitialized(), endBlockingLoop(), usNetworkGrabber::usInitHeaderSent::headerId, usNetworkGrabber::usInitHeaderSent::imagingMode, m_isInit, m_isRunning, m_tcpSocket, m_updateParametersSucess, m_verbose, usNetworkGrabber::usInitHeaderSent::probeId, usNetworkGrabber::usInitHeaderSent::slotId, and stopAcquisition().

◆ processConnectionToServer

void usNetworkGrabber::processConnectionToServer ( )
slot

Method used to do all the process of the server connection.

Definition at line 129 of file usNetworkGrabber.cpp.

References connected(), disconnected(), endConnection(), handleError(), m_connect, m_ip, m_tcpSocket, and m_verbose.

Referenced by connectToServer().

◆ readAcquisitionParameters()

void usNetworkGrabber::readAcquisitionParameters ( QDataStream &  stream)

Method to read all parameters comming from the server (in answer to an update). It fills the usNetworkGrabber attribute.

Definition at line 383 of file usNetworkGrabber.cpp.

References m_acquisitionParameters, m_verbose, usAcquisitionParameters::setActivateMotor(), usAcquisitionParameters::setFramesPerVolume(), usAcquisitionParameters::setFramesPerVolumeMax(), usAcquisitionParameters::setImageDepth(), usAcquisitionParameters::setImageDepthMax(), usAcquisitionParameters::setImageDepthMin(), usAcquisitionParameters::setImagingMode(), usAcquisitionParameters::setImagingModeMax(), usAcquisitionParameters::setImagingModeMin(), usAcquisitionParameters::setMotorPosition(), usAcquisitionParameters::setMotorPositionMax(), usAcquisitionParameters::setMotorPositionMin(), usAcquisitionParameters::setPostScanHeigh(), usAcquisitionParameters::setPostScanMode(), usAcquisitionParameters::setPostScanWidth(), usAcquisitionParameters::setSamplingFrequency(), usAcquisitionParameters::setSamplingFrequencyMax(), usAcquisitionParameters::setSamplingFrequencyMin(), usAcquisitionParameters::setSector(), usAcquisitionParameters::setSectorMax(), usAcquisitionParameters::setSectorMin(), usAcquisitionParameters::setSepsPerFrame(), usAcquisitionParameters::setSepsPerFrameMax(), usAcquisitionParameters::setSepsPerFrameMin(), usAcquisitionParameters::setTransmitFrequency(), usAcquisitionParameters::setTransmitFrequencyMax(), usAcquisitionParameters::setTransmitFrequencyMin(), usAcquisitionParameters::US_ANGLE_PITCH_1, usAcquisitionParameters::US_ANGLE_PITCH_2, usAcquisitionParameters::US_ANGLE_PITCH_3, usAcquisitionParameters::US_ANGLE_PITCH_4, usAcquisitionParameters::US_ANGLE_PITCH_5, and usAcquisitionParameters::US_STATIC_MOTOR.

Referenced by usNetworkGrabberPostScan2D::dataArrived(), usNetworkGrabberPostScanBiPlan::dataArrived(), usNetworkGrabberPreScan2D::dataArrived(), usNetworkGrabberPreScan3D::dataArrived(), usNetworkGrabberRF2D::dataArrived(), and usNetworkGrabberRF3D::dataArrived().

◆ runAcquisition

◆ runAcquisitionSignal

void usNetworkGrabber::runAcquisitionSignal ( bool  run)
signal

◆ sendAcquisitionParameters()

◆ sendAcquisitionParametersSignal

void usNetworkGrabber::sendAcquisitionParametersSignal ( )
signal

◆ sendAcquisitionParametersSlot

◆ sendRunSignal

void usNetworkGrabber::sendRunSignal ( bool  run)
protectedslot

Slot called to write on the socket the command run / stop.

Parameters
runBoolean to run the acquisition (true), or stop it (false).

Definition at line 680 of file usNetworkGrabber.cpp.

References usNetworkGrabber::usRunControlHeaderSent::headerId, m_isRunning, m_tcpSocket, and usNetworkGrabber::usRunControlHeaderSent::run.

Referenced by usNetworkGrabber().

◆ serverUpdated

void usNetworkGrabber::serverUpdated ( bool  sucess)
protectedslot

Slot called when we get the answer from the server to our reques to update aquisition parameters.

Definition at line 373 of file usNetworkGrabber.cpp.

References endBlockingLoop(), and m_updateParametersSucess.

Referenced by usNetworkGrabber().

◆ serverUpdateEnded

◆ setFramesPerVolume()

◆ setImageDepth()

◆ setImagingMode()

void usNetworkGrabber::setImagingMode ( int  imagingMode)

◆ setIPAddress()

◆ setMotorActivation()

void usNetworkGrabber::setMotorActivation ( bool  activateMotor)

◆ setMotorPosition()

◆ setPostScanHeigh()

void usNetworkGrabber::setPostScanHeigh ( int  postScanHeigh)

◆ setPostScanMode()

void usNetworkGrabber::setPostScanMode ( bool  postScanMode)

◆ setPostScanWidth()

void usNetworkGrabber::setPostScanWidth ( int  postScanWidth)

◆ setSamplingFrequency()

void usNetworkGrabber::setSamplingFrequency ( int  samplingFrequency)

◆ setSector()

void usNetworkGrabber::setSector ( int  sector)

Setter for sector (percentage of the number of transducers to use).

Definition at line 629 of file usNetworkGrabber.cpp.

References usAcquisitionParameters::getSectorMax(), usAcquisitionParameters::getSectorMin(), m_acquisitionParameters, and usAcquisitionParameters::setSector().

◆ setStepsPerFrame()

◆ setTransmitFrequency()

void usNetworkGrabber::setTransmitFrequency ( int  transmitFrequency)

◆ setVerbose()

void usNetworkGrabber::setVerbose ( bool  verbose)
inline

Definition at line 170 of file usNetworkGrabber.h.

◆ stopAcquisition

Member Data Documentation

◆ m_acquisitionParameters

◆ m_bytesLeftToRead

◆ m_confirmHeader

◆ m_connect

bool usNetworkGrabber::m_connect
protected

◆ m_imageHeader

◆ m_ip

std::string usNetworkGrabber::m_ip
protected

Definition at line 205 of file usNetworkGrabber.h.

Referenced by processConnectionToServer(), and usNetworkGrabber().

◆ m_isInit

bool usNetworkGrabber::m_isInit
protected

Definition at line 221 of file usNetworkGrabber.h.

Referenced by initAcquisition(), initAcquisitionSlot(), and usNetworkGrabber().

◆ m_isRunning

bool usNetworkGrabber::m_isRunning
protected

◆ m_tcpSocket

◆ m_thread

QThread* usNetworkGrabber::m_thread
protected

Definition at line 225 of file usNetworkGrabber.h.

Referenced by runAcquisition(), usNetworkGrabber(), and ~usNetworkGrabber().

◆ m_updateParametersSucess

bool usNetworkGrabber::m_updateParametersSucess
protected

◆ m_verbose