diff --git a/Modules/US/USControlInterfaces/mitkUSControlInterfaceBMode.cpp b/Modules/US/USControlInterfaces/mitkUSControlInterfaceBMode.cpp index 1d4b815a01..a25dd9dc3d 100644 --- a/Modules/US/USControlInterfaces/mitkUSControlInterfaceBMode.cpp +++ b/Modules/US/USControlInterfaces/mitkUSControlInterfaceBMode.cpp @@ -1,68 +1,95 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkUSControlInterfaceBMode.h" #include "mitkUSDevice.h" mitk::USControlInterfaceBMode::USControlInterfaceBMode( itk::SmartPointer device ) : mitk::USAbstractControlInterface(device) { if (device.IsNull()) { MITK_ERROR << "USDevice must not be null for USControlInterfaceBMode."; mitkThrow() << "USDevice must not be null for USControlInterfaceBMode."; } } mitk::USControlInterfaceBMode::~USControlInterfaceBMode() { } +void mitk::USControlInterfaceBMode::Initialize() +{ + m_Device->UpdateServiceProperty( + mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_FREQUENCY, + this->GetScanningFrequency()); + + m_Device->UpdateServiceProperty( + mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_POWER, + this->GetScanningPower()); + + m_Device->UpdateServiceProperty( + mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DEPTH, + this->GetScanningDepth()); + + m_Device->UpdateServiceProperty( + mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_GAIN, + this->GetScanningGain()); + + m_Device->UpdateServiceProperty( + mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_REJECTION, + this->GetScanningRejection()); + + m_Device->UpdateServiceProperty( + mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DYNAMIC_RANGE, + this->GetScanningDynamicRange()); +} + void mitk::USControlInterfaceBMode::SetScanningFrequency( double frequency ) { this->OnSetScanningFrequency(frequency); m_Device->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_FREQUENCY, frequency); } void mitk::USControlInterfaceBMode::SetScanningPower( double power ) { this->OnSetScanningPower(power); m_Device->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_POWER, power); } void mitk::USControlInterfaceBMode::SetScanningDepth( double depth ) { this->OnSetScanningDepth(depth); m_Device->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DEPTH, depth); } void mitk::USControlInterfaceBMode::SetScanningGain( double gain ) { this->OnSetScanningGain(gain); m_Device->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_GAIN, gain); } void mitk::USControlInterfaceBMode::SetScanningRejection( double rejection ) { this->OnSetScanningRejection(rejection); m_Device->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_REJECTION, rejection); } void mitk::USControlInterfaceBMode::SetScanningDynamicRange( double dynamicRange ) { this->OnSetScanningDynamicRange(dynamicRange); m_Device->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DYNAMIC_RANGE, dynamicRange); } diff --git a/Modules/US/USControlInterfaces/mitkUSControlInterfaceBMode.h b/Modules/US/USControlInterfaces/mitkUSControlInterfaceBMode.h index 77411095a4..b569c828bd 100644 --- a/Modules/US/USControlInterfaces/mitkUSControlInterfaceBMode.h +++ b/Modules/US/USControlInterfaces/mitkUSControlInterfaceBMode.h @@ -1,249 +1,258 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKUSControlInterfaceBMode_H_HEADER_INCLUDED_ #define MITKUSControlInterfaceBMode_H_HEADER_INCLUDED_ #include "mitkUSAbstractControlInterface.h" namespace mitk { /** * \brief Interface defining methods for scanning mode b of ultrasound devices. * It consists of methods for scanning depth, scanning gaing and scanning * rejection. * * Scanning Depth: Defines the clipping of the ultrasound image. Small depth * for looking at structures just below the skin. Great depth for seeing deeper * structures. * * Scanning Gain: Defines amplification of ultrasound echo. * * Scanning Rejection: Defines range of the received values from the ultrasound * signal. * * Scanning Dynamic Range: Ability of displaying strong and weak signals at the same * time. High dynamic range means that strong and weak signals can be distinguished. * Lower dynamic range can lead to more contrast. * * There is a getter and a setter defined for each kind of value. Additionaly * there are methods for getting the range of the possible values. For * uniformly distributed values there are three methods GetMin(), * GetMax() and GetTick(). For non-uniformly distributed values * there is one method GetValues() which shoule return a list of all * possible values. * * All getters of this interface must be implemented in a concrete * subclass. Additionally all OnSet* methods must be implemented. They handle * the acutal setting of the values at the device api. The Set* methods are * already implemented in this class and should not be overwritten. There are * some pure virtual methods in the superclass * mitk::USAbstractControlInterface which must be implemented, too. * */ class MitkUS_EXPORT USControlInterfaceBMode : public USAbstractControlInterface { public: mitkClassMacro(USControlInterfaceBMode, USAbstractControlInterface); + /** + * \brief Initializes the microservice properties with the current values from the device. + * This method must be called before one would like to get the + * b mode values (e.g. frequency, power, ...) from the microservice + * and after the device is ready to deliver the values by the methods + * of this control interface. + */ + void Initialize(); + /** * \return current frequency value */ virtual double GetScanningFrequency( ) = 0; /** * \param depth new frequency value * Do not override this method in a subclass. Implement * mitk::USControlInterfaceBMode::OnSetScanningFrequency instead. */ void SetScanningFrequency( double frequency ); /** * \brief Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningFrequency. */ virtual void OnSetScanningFrequency( double frequency ) = 0; /** * \return vector of all possible frequency values for the utrasound device */ virtual std::vector GetScanningFrequencyValues( ) = 0; /** * \return current power value */ virtual double GetScanningPower( ) = 0; /** * \param depth new power value * Do not override this method in a subclass. Implement * mitk::USControlInterfaceBMode::OnSetScanningPower instead. */ void SetScanningPower( double power ); /** * \brief Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningPower. * Implement this method to handle the actual setting of the * value at the device api. */ virtual void OnSetScanningPower( double power ) = 0; /** * \return minimum power value for the ultrasound device */ virtual double GetScanningPowerMin( ) = 0; /** * \return maximum power value for the ultrasound device */ virtual double GetScanningPowerMax( ) = 0; /** * \return interval between two power values for the ultrasound device */ virtual double GetScanningPowerTick( ) = 0; /** * \return current depth value */ virtual double GetScanningDepth( ) = 0; /** * \param depth new depth value * Do not override this method in a subclass. Implement * mitk::USControlInterfaceBMode::OnSetScanningDepth instead. */ void SetScanningDepth( double depth ); /** * \brief Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningDepth. * Implement this method to handle the actual setting of the * value at the device api. */ virtual void OnSetScanningDepth( double depth ) = 0; /** * \return vector of all possible depth values for the utrasound device */ virtual std::vector GetScanningDepthValues( ) = 0; /** * \return current scanning gain */ virtual double GetScanningGain( ) = 0; /** * \param gain new gain value * Do not override this method in a subclass. Implement * mitk::USControlInterfaceBMode::OnSetScanningGain instead. */ void SetScanningGain( double gain ); /** * \brief Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningGain. * Implement this method to handle the actual setting of the * value at the device api. */ virtual void OnSetScanningGain( double gain ) = 0; /** * \return minimum gain value for the ultrasound device */ virtual double GetScanningGainMin( ) = 0; /** * \return maximum gain value for the ultrasound device */ virtual double GetScanningGainMax( ) = 0; /** * \return interval between two gain values for the ultrasound device */ virtual double GetScanningGainTick( ) = 0; /** * \return current scanning rejection */ virtual double GetScanningRejection( ) = 0; /** * \param rejection new rejection value * Do not override this method in a subclass. Implement * mitk::USControlInterfaceBMode::OnSetScanningRejection instead. */ void SetScanningRejection( double rejection ); /** * \brief Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningRejection. * Implement this method to handle the actual setting of the * value at the device api. */ virtual void OnSetScanningRejection( double rejection ) = 0; /** * \return minimum rejection value for the ultrasound device */ virtual double GetScanningRejectionMin( ) = 0; /** * \return maximum rejection value for the ultrasound device */ virtual double GetScanningRejectionMax( ) = 0; /** * \return interval between two rejection values for the ultrasound device */ virtual double GetScanningRejectionTick( ) = 0; /** * \return current scanning dynamic range */ virtual double GetScanningDynamicRange( ) = 0; /** * \param rejection new dynamic range value * Do not override this method in a subclass. Implement * mitk::USControlInterfaceBMode::OnSetScanningDynamicRange instead. */ virtual void SetScanningDynamicRange( double dynamicRange ); /** * \brief Virtual method which is called inside mitk::USControlInterfaceBMode::SetScanningDynamicRange. * Implement this method to handle the actual setting of the * value at the device api. */ virtual void OnSetScanningDynamicRange( double dynamicRange ) = 0; /** * \return minimum dynamic range value for the ultrasound device */ virtual double GetScanningDynamicRangeMin( ) = 0; /** * \return maximum dynamic range value for the ultrasound device */ virtual double GetScanningDynamicRangeMax( ) = 0; /** * \return interval between two dynamic range values for the ultrasound device */ virtual double GetScanningDynamicRangeTick( ) = 0; protected: USControlInterfaceBMode( itk::SmartPointer device ); virtual ~USControlInterfaceBMode( ); }; } // namespace mitk #endif // MITKUSControlInterfaceBMode_H_HEADER_INCLUDED_ \ No newline at end of file diff --git a/Modules/US/USModel/mitkUSDevice.cpp b/Modules/US/USModel/mitkUSDevice.cpp index 75e1e80bbe..bc30a64a57 100644 --- a/Modules/US/USModel/mitkUSDevice.cpp +++ b/Modules/US/USModel/mitkUSDevice.cpp @@ -1,529 +1,533 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkUSDevice.h" #include "mitkImageReadAccessor.h" // US Control Interfaces #include "mitkUSControlInterfaceProbes.h" #include "mitkUSControlInterfaceBMode.h" #include "mitkUSControlInterfaceDoppler.h" // Microservices #include #include #include #include mitk::USDevice::PropertyKeys mitk::USDevice::GetPropertyKeys() { static mitk::USDevice::PropertyKeys propertyKeys; return propertyKeys; } mitk::USDevice::USImageCropArea mitk::USDevice::GetCropArea() { MITK_INFO << "Return Crop Area L:" << m_CropArea.cropLeft << " R:" << m_CropArea.cropRight << " T:" << m_CropArea.cropTop << " B:" << m_CropArea.cropBottom; return m_CropArea; } mitk::USDevice::USDevice(std::string manufacturer, std::string model) : mitk::ImageSource(), m_IsFreezed(false), m_DeviceState(State_NoState), m_SpawnAcquireThread(true), m_MultiThreader(itk::MultiThreader::New()), m_ImageMutex(itk::FastMutexLock::New()), m_ThreadID(-1), m_UnregisteringStarted(false) { // Initialize Members m_Metadata = mitk::USImageMetadata::New(); m_Metadata->SetDeviceManufacturer(manufacturer); m_Metadata->SetDeviceModel(model); USImageCropArea empty; empty.cropBottom = 0; empty.cropTop = 0; empty.cropLeft = 0; empty.cropRight = 0; this->m_CropArea = empty; //set number of outputs this->SetNumberOfIndexedOutputs(1); //create a new output mitk::Image::Pointer newOutput = mitk::Image::New(); this->SetNthOutput(0,newOutput); } mitk::USDevice::USDevice(mitk::USImageMetadata::Pointer metadata) : mitk::ImageSource(), m_IsFreezed(false), m_DeviceState(State_NoState), m_SpawnAcquireThread(true), m_MultiThreader(itk::MultiThreader::New()), m_ImageMutex(itk::FastMutexLock::New()), m_ThreadID(-1), m_UnregisteringStarted(false) { m_Metadata = metadata; USImageCropArea empty; empty.cropBottom = 0; empty.cropTop = 0; empty.cropLeft = 0; empty.cropRight = 0; this->m_CropArea = empty; //set number of outputs this->SetNumberOfIndexedOutputs(1); //create a new output mitk::Image::Pointer newOutput = mitk::Image::New(); this->SetNthOutput(0,newOutput); } mitk::USDevice::~USDevice() { if (m_ThreadID >= 0) { m_MultiThreader->TerminateThread(m_ThreadID); } // make sure that the us device is not registered at the micro service // anymore after it is destructed this->UnregisterOnService(); } mitk::USAbstractControlInterface::Pointer mitk::USDevice::GetControlInterfaceCustom() { MITK_INFO << "Custom control interface does not exist for this object."; return 0; } mitk::USControlInterfaceBMode::Pointer mitk::USDevice::GetControlInterfaceBMode() { MITK_INFO << "Control interface BMode does not exist for this object."; return 0; } mitk::USControlInterfaceProbes::Pointer mitk::USDevice::GetControlInterfaceProbes() { MITK_INFO << "Control interface Probes does not exist for this object."; return 0; } mitk::USControlInterfaceDoppler::Pointer mitk::USDevice::GetControlInterfaceDoppler() { MITK_INFO << "Control interface Doppler does not exist for this object."; return 0; } us::ServiceProperties mitk::USDevice::ConstructServiceProperties() { mitk::USDevice::PropertyKeys propertyKeys = mitk::USDevice::GetPropertyKeys(); us::ServiceProperties props; props[propertyKeys.US_PROPKEY_ISCONNECTED] = this->GetIsConnected() ? "true" : "false"; props[propertyKeys.US_PROPKEY_ISACTIVE] = this->GetIsActive() ? "true" : "false"; props[propertyKeys.US_PROPKEY_LABEL] = this->GetServicePropertyLabel(); // get identifier of selected probe if there is one selected mitk::USControlInterfaceProbes::Pointer probesControls = this->GetControlInterfaceProbes(); if (probesControls.IsNotNull() && probesControls->GetIsActive()) { mitk::USProbe::Pointer probe = probesControls->GetSelectedProbe(); if (probe.IsNotNull()) { props[propertyKeys.US_PROPKEY_PROBES_SELECTED] = probe->GetName(); } } props[ propertyKeys.US_PROPKEY_CLASS ] = GetDeviceClass(); props[ mitk::USImageMetadata::PROP_DEV_MANUFACTURER ] = m_Metadata->GetDeviceManufacturer(); props[ mitk::USImageMetadata::PROP_DEV_MODEL ] = m_Metadata->GetDeviceModel(); props[ mitk::USImageMetadata::PROP_DEV_COMMENT ] = m_Metadata->GetDeviceComment(); props[ mitk::USImageMetadata::PROP_PROBE_NAME ] = m_Metadata->GetProbeName(); props[ mitk::USImageMetadata::PROP_PROBE_FREQUENCY ] = m_Metadata->GetProbeFrequency(); props[ mitk::USImageMetadata::PROP_ZOOM ] = m_Metadata->GetZoom(); m_ServiceProperties = props; return props; } void mitk::USDevice::UnregisterOnService() { // unregister on micro service if ( m_ServiceRegistration && ! m_UnregisteringStarted) { // make sure that unregister is not started a second // time due to a callback during unregister for example m_UnregisteringStarted = true; m_ServiceRegistration.Unregister(); m_ServiceRegistration = 0; } } bool mitk::USDevice::Initialize() { if (! this->OnInitialization() ) { return false; } m_DeviceState = State_Initialized; // Get Context and Module us::ModuleContext* context = us::GetModuleContext(); us::ServiceProperties props = this->ConstructServiceProperties(); m_ServiceRegistration = context->RegisterService(this, props); return true; } bool mitk::USDevice::Connect() { if ( this->GetIsConnected() ) { MITK_INFO("mitkUSDevice") << "Tried to connect an ultrasound device that was already connected. Ignoring call..."; return true; } if ( ! this->GetIsInitialized() ) { MITK_ERROR("mitkUSDevice") << "Cannot connect device if it is not in initialized state."; return false; } // Prepare connection, fail if this fails. if ( ! this->OnConnection() ) { return false; } // Update state m_DeviceState = State_Connected; this->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISCONNECTED, true); return true; } void mitk::USDevice::ConnectAsynchron() { this->m_MultiThreader->SpawnThread(this->ConnectThread, this); } bool mitk::USDevice::Disconnect() { if ( ! GetIsConnected()) { MITK_WARN << "Tried to disconnect an ultrasound device that was not connected. Ignoring call..."; return false; } // Prepare connection, fail if this fails. if (! this->OnDisconnection()) return false; // Update state m_DeviceState = State_Initialized; this->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISCONNECTED, false); return true; } bool mitk::USDevice::Activate() { if (! this->GetIsConnected()) { MITK_INFO("mitkUSDevice") << "Cannot activate device if it is not in connected state."; return true; } if ( OnActivation() ) { m_DeviceState = State_Activated; m_FreezeBarrier = itk::ConditionVariable::New(); // spawn thread for aquire images if us device is active if (m_SpawnAcquireThread) { this->m_ThreadID = this->m_MultiThreader->SpawnThread(this->Acquire, this); } this->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISACTIVE, true); this->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_LABEL, this->GetServicePropertyLabel()); + + // initialize the b mode control properties of the micro service + mitk::USControlInterfaceBMode::Pointer bmodeControls = this->GetControlInterfaceBMode(); + if ( bmodeControls.IsNotNull() ) { bmodeControls->Initialize(); } } return m_DeviceState == State_Activated; } void mitk::USDevice::Deactivate() { if ( ! this->GetIsActive() ) { MITK_WARN("mitkUSDevice") << "Cannot deactivate a device which is not activae."; return; } if ( ! OnDeactivation() ) { return; } m_DeviceState = State_Connected; this->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISACTIVE, false); this->UpdateServiceProperty(mitk::USDevice::GetPropertyKeys().US_PROPKEY_LABEL, this->GetServicePropertyLabel()); } void mitk::USDevice::SetIsFreezed(bool freeze) { if ( ! this->GetIsActive() ) { MITK_WARN("mitkUSDevice") << "Cannot freeze or unfreeze if device is not active."; return; } this->OnFreeze(freeze); if ( freeze ) { m_IsFreezed = true; } else { m_IsFreezed = false; // wake up the image acquisition thread m_FreezeBarrier->Signal(); } } bool mitk::USDevice::GetIsFreezed() { if ( ! this->GetIsActive() ) { MITK_WARN("mitkUSDevice")("mitkUSTelemedDevice") << "Cannot get freeze state if the hardware interface is not ready. Returning false..."; return false; } return m_IsFreezed; } void mitk::USDevice::PushFilter(AbstractOpenCVImageFilter::Pointer filter) { mitk::USImageSource::Pointer imageSource = this->GetUSImageSource(); if ( imageSource.IsNull() ) { MITK_ERROR << "ImageSource must not be null when pushing a filter."; mitkThrow() << "ImageSource must not be null when pushing a filter."; } imageSource->PushFilter(filter); } void mitk::USDevice::PushFilterIfNotPushedBefore(AbstractOpenCVImageFilter::Pointer filter) { mitk::USImageSource::Pointer imageSource = this->GetUSImageSource(); if ( imageSource.IsNull() ) { MITK_ERROR << "ImageSource must not be null when pushing a filter."; mitkThrow() << "ImageSource must not be null when pushing a filter."; } if ( ! imageSource->GetIsFilterInThePipeline(filter) ) { imageSource->PushFilter(filter); } } bool mitk::USDevice::RemoveFilter(AbstractOpenCVImageFilter::Pointer filter) { mitk::USImageSource::Pointer imageSource = this->GetUSImageSource(); if ( imageSource.IsNull() ) { MITK_ERROR << "ImageSource must not be null when pushing a filter."; mitkThrow() << "ImageSource must not be null when removing a filter."; } return imageSource->RemoveFilter(filter); } void mitk::USDevice::UpdateServiceProperty(std::string key, std::string value) { m_ServiceProperties[ key ] = value; m_ServiceRegistration.SetProperties(m_ServiceProperties); } void mitk::USDevice::UpdateServiceProperty(std::string key, double value) { std::stringstream stream; stream << value; this->UpdateServiceProperty(key, stream.str()); } void mitk::USDevice::UpdateServiceProperty(std::string key, bool value) { this->UpdateServiceProperty(key, value ? std::string("true") : std::string("false")); } /** mitk::Image* mitk::USDevice::GetOutput() { if (this->GetNumberOfOutputs() < 1) return NULL; return static_cast(this->ProcessObject::GetPrimaryOutput()); } mitk::Image* mitk::USDevice::GetOutput(unsigned int idx) { if (this->GetNumberOfOutputs() < 1) return NULL; return static_cast(this->ProcessObject::GetOutput(idx)); } void mitk::USDevice::GraftOutput(itk::DataObject *graft) { this->GraftNthOutput(0, graft); } void mitk::USDevice::GraftNthOutput(unsigned int idx, itk::DataObject *graft) { if ( idx >= this->GetNumberOfOutputs() ) { itkExceptionMacro(<<"Requested to graft output " << idx << " but this filter only has " << this->GetNumberOfOutputs() << " Outputs."); } if ( !graft ) { itkExceptionMacro(<<"Requested to graft output with a NULL pointer object" ); } itk::DataObject* output = this->GetOutput(idx); if ( !output ) { itkExceptionMacro(<<"Requested to graft output that is a NULL pointer" ); } // Call Graft on USImage to copy member data output->Graft( graft ); } */ void mitk::USDevice::GrabImage() { mitk::Image::Pointer image = this->GetUSImageSource()->GetNextImage(); m_ImageMutex->Lock(); this->SetImage(image); m_ImageMutex->Unlock(); } //########### GETTER & SETTER ##################// bool mitk::USDevice::GetIsInitialized() { return m_DeviceState == State_Initialized; } bool mitk::USDevice::GetIsActive() { return m_DeviceState == State_Activated; } bool mitk::USDevice::GetIsConnected() { return m_DeviceState == State_Connected; } std::string mitk::USDevice::GetDeviceManufacturer(){ return this->m_Metadata->GetDeviceManufacturer(); } std::string mitk::USDevice::GetDeviceModel(){ return this->m_Metadata->GetDeviceModel(); } std::string mitk::USDevice::GetDeviceComment(){ return this->m_Metadata->GetDeviceComment(); } void mitk::USDevice::GenerateData() { m_ImageMutex->Lock(); if ( m_Image.IsNull() || ! m_Image->IsInitialized() ) { m_ImageMutex->Unlock(); return; } mitk::Image::Pointer output = this->GetOutput(); if ( ! output->IsInitialized() || output->GetDimension(0) != m_Image->GetDimension(0) || output->GetDimension(1) != m_Image->GetDimension(1) ) { output->Initialize(m_Image->GetPixelType(), m_Image->GetDimension(), m_Image->GetDimensions()); } mitk::ImageReadAccessor inputReadAccessor(m_Image, m_Image->GetSliceData(0,0,0)); output->SetSlice(inputReadAccessor.GetData()); m_ImageMutex->Unlock(); }; std::string mitk::USDevice::GetServicePropertyLabel() { std::string isActive; if (this->GetIsActive()) { isActive = " (Active)"; } else { isActive = " (Inactive)"; } // e.g.: Zonare MyLab5 (Active) return m_Metadata->GetDeviceManufacturer() + " " + m_Metadata->GetDeviceModel() + isActive; } ITK_THREAD_RETURN_TYPE mitk::USDevice::Acquire(void* pInfoStruct) { /* extract this pointer from Thread Info structure */ struct itk::MultiThreader::ThreadInfoStruct * pInfo = (struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct; mitk::USDevice* device = (mitk::USDevice*) pInfo->UserData; while (device->GetIsActive()) { // lock this thread when ultrasound device is freezed if ( device->m_IsFreezed ) { itk::SimpleMutexLock* mutex = &(device->m_FreezeMutex); mutex->Lock(); if (device->m_FreezeBarrier.IsNotNull()) { device->m_FreezeBarrier->Wait(mutex); } } device->GrabImage(); } return ITK_THREAD_RETURN_VALUE; } ITK_THREAD_RETURN_TYPE mitk::USDevice::ConnectThread(void* pInfoStruct) { /* extract this pointer from Thread Info structure */ struct itk::MultiThreader::ThreadInfoStruct * pInfo = (struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct; mitk::USDevice* device = (mitk::USDevice*) pInfo->UserData; device->Connect(); return ITK_THREAD_RETURN_VALUE; }