예제 #1
0
void OpenIGTLinkProtocol::processPack()
{
    //creates deadlock....
    //QMutexLocker lock(&mPackMutex);

    //CX_LOG_DEBUG() << "1 processPack ";
    this->setReadyToReceive(false);
    //CX_LOG_DEBUG() << "2 processPack ";
    if(mPack->data()->size == mHeader->GetPackSize())
    {
        this->unpackHeader(mHeader);
        CX_LOG_DEBUG() << "HEADER: " << mHeader->GetDeviceType();
        if(this->isValid(mHeader))
            this->getReadyToReceiveBody();
        else
            this->getReadyToReceiveHeader();
    }
    else
    {
        this->unpackBody(mBody);
        CX_LOG_DEBUG() << "BODY: " << mBody->GetDeviceType();
        if(this->isValid(mBody))
            this->getReadyToReceiveHeader();
        else
            this->getReadyToReceiveBody();
    }

}
예제 #2
0
void PlusProtocol::translate(const igtl::TransformMessage::Pointer body)
{
    CX_LOG_DEBUG() << "Transform incoming to plusprotocol";
    QString deviceName = body->GetDeviceName();
    this->registerTransformDeviceName(deviceName);

    IGTLinkConversion converter;
    Transform3D matrix = converter.decode(body);

    if(this->isCalibration(deviceName))
    {
        Transform3D s_M_igtltool = matrix;
        Transform3D s_M_custustool = s_M_igtltool * igtltool_M_custustool;
        Transform3D sMt = s_M_custustool;
        QString calibrationBelongsToDeviceName = this->findDeviceForCalibration(deviceName);
        if(calibrationBelongsToDeviceName != "NOT_FOUND")
        {
            emit calibration(calibrationBelongsToDeviceName, sMt);
        }
    }
    else
    {
		IGTLinkConversionBase baseConverter;
		double timestamp_ms = baseConverter.decode_timestamp(body).toMSecsSinceEpoch();
		timestamp_ms = this->getSyncedTimestampForTransformsAndImages(timestamp_ms);
        Transform3D prMs = matrix;
        emit transform(deviceName, prMs, timestamp_ms);
    }
}
예제 #3
0
void PlusProtocol::translate(const igtl::ImageMessage::Pointer body)
{
    CX_LOG_DEBUG() << "Image incoming to plusprotocol";
    //DIMENSION
    int x = 0;
    int y = 1;
    int z = 2;

    //There seems to be a bug in the received images spacing from the plusserver
    /*
    float wrong_spacing[3];
    body->GetSpacing(wrong_spacing);
    float right_spacing[3];
    right_spacing[x] = wrong_spacing[x];
    right_spacing[y] = wrong_spacing[z];
    right_spacing[z] = 1;
    body->SetSpacing(right_spacing);
    */

    int dimensions_p[3];
    body->GetDimensions(dimensions_p);
    float spacing[3];
    body->GetSpacing(spacing);
    int extent_p[3];
    extent_p[x] = dimensions_p[x]-1;
    extent_p[y] = dimensions_p[y]-1;
    extent_p[z] = dimensions_p[z]-1;

    //IMAGE
    IGTLinkConversion converter;
    ImagePtr theImage = converter.decode(body);

	IGTLinkConversionBase baseConverter;
	double timestamp_ms = baseConverter.decode_timestamp(body).toMSecsSinceEpoch();
	timestamp_ms = this->getSyncedTimestampForTransformsAndImages(timestamp_ms);
    theImage->setAcquisitionTime(QDateTime::fromMSecsSinceEpoch(timestamp_ms));
    emit image(theImage);

    //PROBEDEFINITION
    ProbeDefinitionPtr definition(new ProbeDefinition);
    definition->setUseDigitalVideo(true);
    definition->setType(ProbeDefinition::tLINEAR);
    definition->setSpacing(Vector3D(spacing[x], spacing[y], spacing[z]));
    definition->setSize(QSize(dimensions_p[x], dimensions_p[y]));
    definition->setOrigin_p(Vector3D(dimensions_p[x]/2, 0, 0));
    double depthstart_mm = 0;
    double depthend_mm = extent_p[y]*spacing[y];
    double width_mm = extent_p[x]*spacing[x];
    definition->setSector(depthstart_mm, depthend_mm, width_mm);
    definition->setClipRect_p(DoubleBoundingBox3D(0, extent_p[x], 0, extent_p[y], 0, extent_p[z]));

    emit probedefinition(mProbeToTrackerName, definition);
}
예제 #4
0
void LogicManager::initializeServices()
{
	CX_LOG_INFO() << " --- Initialize services for " << qApp->applicationName() << "...";

	this->basicSetup();

	mPluginFramework->loadState();

	if (mComponent)
		mComponent->create();

	CX_LOG_DEBUG() << " --- End initialize services.";
}
예제 #5
0
void LogicManager::shutdownServices()
{
	CX_LOG_INFO() << " --- Shutting down " << qApp->applicationName() << "...";

	this->getPatientModelService()->autoSave();

	if (mComponent)
		mComponent->destroy(); // this is the GUI - delete first

	mPluginFramework->stop();

	this->shutdownLegacyStoredServices();
	mPluginFramework.reset();
	GPUImageBufferRepository::shutdown();
	Reporter::shutdown();
	ProfileManager::shutdown();

	CX_LOG_DEBUG() << " --- End shutdown services";
}
예제 #6
0
void HttpRequestHandler::handle_complete_request(QHttpRequest *req, QHttpResponse *resp)
{
    /* v2 - insert into front page
	   GET    /                                              : default page: short server info
	   GET    /screen                                        : get screenshot
	   GET    /layout/                                       : return list of all layouts

	   PUT    /layout/display?width=536,height=320,layout=mg_def  : create layout display of given size and layout
	   GET    /layout/display                                  : get image of layout
	   DELETE /layout/display                                  : delete display

	   PUT    /layout/display/stream?port=8086                 : start streamer on port
	   DELETE /layout/display/stream                           : stop streamer on port
	*/

    CX_LOG_DEBUG() << QString("Web server request [%1] from [%2]")
                      .arg(req->path())
                      .arg(req->remoteAddress());

    if (req->path() == "/")
    {
        this->process_mainpage(req, resp);
    }
    else if (req->path().startsWith("/screen"))
	{
        this->handle_screen(req, resp);
	}
    else if (req->path().startsWith("/layout"))
	{
        this->handle_layout(req, resp);
	}
	else
	{
        this->reply_notfound(resp);
	}
}