16 std::string host,
int port,
bool server)
17 :
mitk::
USDevice(manufacturer, model), m_Host(host), m_Port(port)
19 m_ControlInterfaceCustom = mitk::USVideoDeviceCustomControls::New(
this);
22 m_Device = mitk::IGTLServer::New(
true);
26 m_Device = mitk::IGTLClient::New(
true);
28 m_Device->SetPortNumber(m_Port);
29 m_Device->SetHostname(m_Host);
30 m_Device->SetName(manufacturer +
" - " + model);
33 m_TransformDeviceSource->SetIGTLDevice(m_Device);
34 m_TransformDeviceSource->RegisterAsMicroservice();
37 m_DeviceSource->SetIGTLDevice(m_Device);
38 m_DeviceSource->RegisterAsMicroservice();
41 m_Filter->SetNumberOfExpectedOutputs(1);
42 m_Filter->ConnectTo(m_DeviceSource);
49 return m_Filter.GetPointer();
54 return m_ControlInterfaceCustom.GetPointer();
59 m_DeviceSource->UnRegisterMicroservice();
60 m_TransformDeviceSource->UnRegisterMicroservice();
68 MITK_INFO <<
"No probes exist for this USVideDevice. Empty vector is returned";
80 if (m_CurrentProbe.IsNotNull())
82 return m_CurrentProbe;
92 m_Probes.push_back(probe);
97 for (std::vector<mitk::USProbe::Pointer>::iterator it = m_Probes.begin(); it != m_Probes.end(); it++)
99 if (name.compare((*it)->GetName()) == 0)
102 MITK_INFO <<
"No probe with given name " << name <<
" was found.";
108 for (std::vector<mitk::USProbe::Pointer>::iterator it = m_Probes.begin(); it != m_Probes.end(); it++)
110 if (name.compare((*it)->GetName()) == 0)
116 MITK_INFO <<
"No Probe with given name " << name <<
" was found";
121 if (m_Probes.size() == 0)
123 std::string name =
"default";
125 m_Probes.push_back(defaultProbe);
128 m_CurrentProbe = m_Probes.at(0);
129 MITK_INFO <<
"SetDefaultProbeAsCurrentProbe()";
136 MITK_INFO <<
"SetCurrentProbe() " << probename;
142 spacing[0] = xSpacing;
143 spacing[1] = ySpacing;
147 if (m_CurrentProbe.IsNotNull())
149 m_CurrentProbe->SetSpacingForGivenDepth(m_CurrentProbe->GetCurrentDepth(), spacing);
153 MITK_WARN <<
"Cannot set spacing. Current ultrasound probe not set.";
161 if (m_Device->GetState() == mitk::IGTLDevice::IGTLDeviceState::Running ||
162 m_Device->GetState() == mitk::IGTLDevice::IGTLDeviceState::Ready)
164 MITK_INFO <<
"Device is ready or running. So return true";
167 return m_Device->OpenConnection();
172 return m_Device->CloseConnection();
177 if (m_Device->GetState() == mitk::IGTLDevice::IGTLDeviceState::Running )
179 MITK_INFO <<
"Device is running. So return true";
182 return m_Device->StartCommunication();
187 return m_Device->StopCommunication();
192 Superclass::GenerateData();
193 if (
m_ImageVector.size() == 0 || this->GetNumberOfIndexedOutputs() == 0)
200 if (
image.IsNotNull() &&
image->IsInitialized() && m_CurrentProbe.IsNotNull())
203 image->GetGeometry()->SetSpacing(m_CurrentProbe->GetSpacingForGivenDepth(m_CurrentProbe->GetCurrentDepth()));
bool OnActivation() override
Is called during the activation process. After this method is finished, the device should be generati...
void AddNewProbe(mitk::USProbe::Pointer probe) override
adds a new probe to the device
A device holds information about it's model, make and the connected probes. It is the common super cl...
bool OnConnection() override
Is called during the connection process. Override this method in a subclass to handle the actual conn...
void DeleteAllProbes() override
Cleans the std::vector containing all configured probes.
itk::SmartPointer< USAbstractControlInterface > GetControlInterfaceCustom() override
void SetSpacing(double xSpacing, double ySpacing) override
Sets the given spacing of the current depth of the current probe.
virtual void SetGeometry(BaseGeometry *aGeometry3D)
Set the BaseGeometry of the data, which will be referenced (not copied!). Assumes the data object has...
DataCollection - Class to facilitate loading/accessing structured data.
bool OnInitialization() override
Is called during the initialization process. Override this method in a subclass to handle the actual ...
void SetCurrentProbe(std::string probename) override
Sets the probe with the given name as current probe if the named probe exists.
USImageSource::Pointer GetUSImageSource() override
mitk::USProbe::Pointer GetCurrentProbe() override
Return current active probe for this USDevice Returns a pointer to the probe that is currently in use...
void ProbeChanged(std::string probename)
To be called when the used probe changed. Will update the service properties.
std::vector< mitk::USProbe::Pointer > GetAllProbes() override
Return all probes for this USVideoDevice or an empty vector it no probes were set Returns a std::vect...
USIGTLDevice(std::string manufacturer, std::string model, std::string host, int port, bool server)
void UnregisterOnService()
Remove the IGTLDevice from the micro service.
mitk::Image::Pointer image
void UnregisterOnService()
Remove this device from the micro service.
mitk::USProbe::Pointer GetProbeByName(std::string name) override
get the probe by its name Returns a pointer to the probe identified by the given name. If no probe of given name exists for this Device 0 is returned.
void RemoveProbeByName(std::string name) override
Removes the Probe with the given name.
std::vector< mitk::Image::Pointer > m_ImageVector
std::string GetDeviceClass() override
Returns the Class of the Device. This Method must be reimplemented by every Inheriting Class...
OutputType * GetOutput()
Get the output data of this image source object.
bool OnDeactivation() override
Is called during the deactivation process. After a call to this method the device should still be con...
void SetDefaultProbeAsCurrentProbe() override
Sets the first existing probe or the default probe of the video device as the current probe of it...
itk::FastMutexLock::Pointer m_ImageMutex
mutex for images provided by the image source
void GenerateData() override
Grabs the next frame from the Video input. This method is called internally, whenever Update() is inv...
bool OnDisconnection() override
Is called during the disconnection process. Override this method in a subclass to handle the actual d...