34 #include <visp3/ustk_grabber/usNetworkGrabber.h>
36 #if defined(USTK_HAVE_QT5) || defined(USTK_HAVE_VTK_QT)
40 #include <visp3/io/vpImageIo.h>
42 #include <QtCore/QDataStream>
43 #include <QtCore/QEventLoop>
53 m_ip =
"192.168.100.2";
133 std::cout <<
"ip listening : " <<
m_ip.c_str() << std::endl;
134 QHostAddress addr(
m_ip.c_str());
140 connect(
m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
this,
145 std::cout <<
"socket is open." << std::endl;
149 std::cout <<
"socket not is open." << std::endl;
155 std::cout <<
"socket is readable." << std::endl;
168 std::cout <<
"connected to server" << std::endl;
169 std::cout <<
"local port : " <<
m_tcpSocket->localPort() << std::endl;
170 std::cout <<
"local addr : " <<
m_tcpSocket->localAddress().toString().toStdString() << std::endl;
171 std::cout <<
"peer port : " <<
m_tcpSocket->peerPort() << std::endl;
172 std::cout <<
"peer addr : " <<
m_tcpSocket->peerAddress().toString().toStdString() << std::endl;
182 std::cout <<
"Disconnected .... \n";
193 throw(vpException(vpException::fatalError,
m_tcpSocket->errorString().toStdString()));
213 QDataStream out(&block, QIODevice::WriteOnly);
214 #if (defined(USTK_HAVE_QT5) || defined(USTK_HAVE_VTK_QT5))
215 out.setVersion(QDataStream::Qt_5_0);
216 #elif defined(USTK_HAVE_VTK_QT4)
217 out.setVersion(QDataStream::Qt_4_8);
219 throw(vpException(vpException::fatalError,
"your Qt version is not managed in ustk"));
231 std::cout <<
"INIT SENT, waiting server confirmation..." << std::endl;
233 QEventLoop *loop =
new QEventLoop;
258 QDataStream out(&block, QIODevice::WriteOnly);
259 #if (defined(USTK_HAVE_QT5) || defined(USTK_HAVE_VTK_QT5))
260 out.setVersion(QDataStream::Qt_5_0);
261 #elif defined(USTK_HAVE_VTK_QT4)
262 out.setVersion(QDataStream::Qt_4_8);
264 throw(vpException(vpException::fatalError,
"your Qt version is not managed in ustk"));
276 std::cout <<
"INIT SENT, waiting server confirmation..." << std::endl;
278 QEventLoop *loop =
new QEventLoop;
316 QDataStream stream(&block, QIODevice::WriteOnly);
317 #if (defined(USTK_HAVE_QT5) || defined(USTK_HAVE_VTK_QT5))
318 stream.setVersion(QDataStream::Qt_5_0);
319 #elif defined(USTK_HAVE_VTK_QT4)
320 stream.setVersion(QDataStream::Qt_4_8);
322 throw(vpException(vpException::fatalError,
"your Qt version is not managed in ustk"));
342 std::cout <<
"UPDATE SENT : " << std::endl;
359 std::cout <<
"waiting server confirmation..." << std::endl;
362 QEventLoop *loop =
new QEventLoop;
386 int transmitFrequency;
387 int samplingFrequency;
398 int transmitFrequencyMin;
399 int samplingFrequencyMin;
403 int motorPositionMin;
404 int framesPerVolumeMin;
405 int anglePerFrameMin;
406 int transmitFrequencyMax;
407 int samplingFrequencyMax;
411 int motorPositionMax;
412 int framesPerVolumeMax;
413 int anglePerFrameMax;
415 stream >> transmitFrequency;
416 stream >> samplingFrequency;
417 stream >> imagingMode;
418 stream >> postScanMode;
419 stream >> postScanHeigh;
420 stream >> postScanWidth;
421 stream >> imageDepth;
423 stream >> activateMotor;
424 stream >> motorPosition;
425 stream >> framesPerVolume;
426 stream >> anglePerFrame;
427 stream >> transmitFrequencyMin;
428 stream >> samplingFrequencyMin;
429 stream >> imagingModeMin;
430 stream >> imageDepthMin;
432 stream >> motorPositionMin;
433 stream >> framesPerVolumeMin;
434 stream >> anglePerFrameMin;
435 stream >> transmitFrequencyMax;
436 stream >> samplingFrequencyMax;
437 stream >> imagingModeMax;
438 stream >> imageDepthMax;
440 stream >> motorPositionMax;
441 stream >> framesPerVolumeMax;
442 stream >> anglePerFrameMax;
445 std::cout <<
"transmitFrequency = " << transmitFrequency << std::endl;
446 std::cout <<
"samplingFrequency = " << samplingFrequency << std::endl;
447 std::cout <<
"imagingMode = " << imagingMode << std::endl;
448 std::cout <<
"postScanMode = " << postScanMode << std::endl;
449 std::cout <<
"postScanHeigh = " << postScanHeigh << std::endl;
450 std::cout <<
"postScanWidth = " << postScanWidth << std::endl;
451 std::cout <<
"imageDepth = " << imageDepth << std::endl;
452 std::cout <<
"sector = " << sector << std::endl;
453 std::cout <<
"activateMotor = " << activateMotor << std::endl;
454 std::cout <<
"motorPosition = " << motorPosition << std::endl;
455 std::cout <<
"framesPerVolume = " << framesPerVolume << std::endl;
456 std::cout <<
"anglePerFrame = " << anglePerFrame << std::endl;
457 std::cout <<
"transmitFrequencyMin = " << transmitFrequencyMin << std::endl;
458 std::cout <<
"samplingFrequencyMin = " << samplingFrequencyMin << std::endl;
459 std::cout <<
"imagingModeMin = " << imagingModeMin << std::endl;
460 std::cout <<
"imageDepthMin = " << imageDepthMin << std::endl;
461 std::cout <<
"sectorMin = " << sectorMin << std::endl;
462 std::cout <<
"motorPositionMin = " << motorPositionMin << std::endl;
463 std::cout <<
"framesPerVolumeMin = " << framesPerVolumeMin << std::endl;
464 std::cout <<
"anglePerFrameMin = " << anglePerFrameMin << std::endl;
465 std::cout <<
"transmitFrequencyMax = " << transmitFrequencyMax << std::endl;
466 std::cout <<
"samplingFrequencyMax = " << samplingFrequencyMax << std::endl;
467 std::cout <<
"imagingModeMax = " << imagingModeMax << std::endl;
468 std::cout <<
"imageDepthMax = " << imageDepthMax << std::endl;
469 std::cout <<
"sectorMax = " << sectorMax << std::endl;
470 std::cout <<
"motorPositionMax = " << motorPositionMax << std::endl;
471 std::cout <<
"framesPerVolumeMax = " << framesPerVolumeMax << std::endl;
472 std::cout <<
"anglePerFrameMax = " << anglePerFrameMax << std::endl;
486 if (anglePerFrame == 0)
488 else if (anglePerFrame == 2)
490 else if (anglePerFrame == 4)
492 else if (anglePerFrame == 8)
494 else if (anglePerFrame == 16)
496 else if (anglePerFrame == 32)
505 if (anglePerFrame == 0)
507 else if (anglePerFrame == 2)
509 else if (anglePerFrame == 4)
511 else if (anglePerFrame == 8)
513 else if (anglePerFrame == 16)
515 else if (anglePerFrame == 32)
525 if (anglePerFrame == 0)
527 else if (anglePerFrame == 2)
529 else if (anglePerFrame == 4)
531 else if (anglePerFrame == 8)
533 else if (anglePerFrame == 16)
535 else if (anglePerFrame == 32)
562 framesPerVolume % 2 == 0)
563 throw(vpException(vpException::badValue),
564 "Number of frames per volume must be odd, and between min and max values");
574 throw(vpException(vpException::badValue),
"Image depth must be included between min and max values");
585 throw(vpException(vpException::badValue),
"Imaging mode out of range");
596 throw(vpException(vpException::badValue),
"Motor poisition out of range");
622 throw(vpException(vpException::badValue),
"Sampling frequency out of range");
632 throw(vpException(vpException::badValue),
"Sector out of range");
643 throw(vpException(vpException::badValue),
"Transmit frequency out of range");
686 QDataStream out(&block, QIODevice::WriteOnly);
687 #if (defined(USTK_HAVE_QT5) || defined(USTK_HAVE_VTK_QT5))
688 out.setVersion(QDataStream::Qt_5_0);
689 #elif defined(USTK_HAVE_VTK_QT4)
690 out.setVersion(QDataStream::Qt_4_8);
692 throw(vpException(vpException::fatalError,
"your Qt version is not managed in ustk"));
Class to store acquisition parameters for ultrasound station.
void setFramesPerVolumeMax(int framesPerVolumeMax)
int getFramesPerVolume() const
void setImageDepthMin(int imageDepthMin)
void setImageDepth(int imageDepth)
void setPostScanHeigh(int postScanHeigh)
int getImageDepthMax() const
bool getPostScanMode() const
void setImageDepthMax(int imageDepthMax)
void setFramesPerVolume(int framesPerVolume)
int getMotorPositionMax() const
void setImagingMode(int imagingMode)
void setPostScanWidth(int postScanWidth)
void setImagingModeMin(int imagingModeMin)
int getSamplingFrequency() const
void setMotorPositionMin(int motorPositionMin)
int getPostScanWidth() const
usMotorStep
For 4DC7 3D probe motor movement.
@ US_STATIC_MOTOR
motor not moving (2D case)
@ US_ANGLE_PITCH_1
2 motor steps per frame = 0.36585 degrees. Not working for 4DC7 probe !
@ US_ANGLE_PITCH_3
8 motor steps per frame = 1.4634 degrees
@ US_ANGLE_PITCH_5
8 motor steps per frame = 5.8536 degrees. Not working for 4DC7 probe !
@ US_ANGLE_PITCH_4
8 motor steps per frame = 2.9268 degrees. Not working for 4DC7 probe !
@ US_ANGLE_PITCH_2
4 motor steps per frame = 0.7317 degrees
int getPostScanHeigh() const
void setSamplingFrequency(int samplingFrequency)
void setSamplingFrequencyMax(int samplingFrequencyMax)
void setTransmitFrequency(int transmitFrequency)
void setSector(int sector)
void setTransmitFrequencyMax(int transmitFrequencyMax)
void setSamplingFrequencyMin(int samplingFrequencyMin)
int getTransmitFrequencyMax() const
void setTransmitFrequencyMin(int transmitFrequencyMin)
void setPostScanMode(bool postScanMode)
void setImagingModeMax(int imagingModeMax)
int getImagingModeMin() const
void setActivateMotor(bool activateMotor)
int getImagingModeMax() const
int getMotorPosition() const
int getImageDepthMin() const
void setMotorPositionMax(int motorPositionMax)
void setSepsPerFrameMin(usMotorStep anglePerFrameMin)
void setSectorMin(int sectorMin)
void setSepsPerFrameMax(usMotorStep anglePerFrameMax)
void setSepsPerFrame(usMotorStep anglePerFrame)
int getSamplingFrequencyMin() const
void setSectorMax(int sectorMax)
int getImagingMode() const
void setMotorPosition(int motorPosition)
int getMotorPositionMin() const
int getImageDepth() const
int getSamplingFrequencyMax() const
int getFramesPerVolumeMin() const
bool getActivateMotor() const
int getTransmitFrequency() const
int getFramesPerVolumeMax() const
int getTransmitFrequencyMin() const
usMotorStep getSepsPerFrame() const
int getTransmitFrequency()
void serverUpdated(bool sucess)
void setTransmitFrequency(int transmitFrequency)
usInitHeaderConfirmation m_confirmHeader
void sendAcquisitionParametersSignal()
void readAcquisitionParameters(QDataStream &stream)
void setFramesPerVolume(int framesPerVolume)
bool initAcquisition(const usNetworkGrabber::usInitHeaderSent &header)
bool sendAcquisitionParameters()
void serverUpdateEnded(bool success)
us::usImageHeader m_imageHeader
void setIPAddress(const std::string &s_ip)
void setPostScanWidth(int postScanWidth)
void processConnectionToServer()
void setPostScanHeigh(int postScanHeigh)
usAcquisitionParameters::usMotorStep getStepsPerFrame()
void initAcquisitionSlot(usNetworkGrabber::usInitHeaderSent header)
bool m_updateParametersSucess
void setImagingMode(int imagingMode)
bool getMotorActivation()
void setSector(int sector)
void setPostScanMode(bool postScanMode)
void handleError(QAbstractSocket::SocketError err)
usNetworkGrabber(QObject *parent=0)
void setImageDepth(int imageDepth)
void acquisitionInitialized(bool)
void runAcquisitionSignal(bool run)
void disconnectFromServer()
void center3DProbeMotor()
void setSamplingFrequency(int samplingFrequency)
void sendRunSignal(bool run)
void setStepsPerFrame(usAcquisitionParameters::usMotorStep stepsPerFrame)
usAcquisitionParameters m_acquisitionParameters
void sendAcquisitionParametersSlot()
int getSamplingFrequency()
void setMotorActivation(bool activateMotor)
void setMotorPosition(int motorPosition)