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);
32 m_TransformDeviceSource = mitk::IGTLTrackingDataDeviceSource::New();
33 m_TransformDeviceSource->SetIGTLDevice(m_Device);
34 m_TransformDeviceSource->RegisterAsMicroservice();
36 m_DeviceSource = mitk::IGTL2DImageDeviceSource::New();
37 m_DeviceSource->SetIGTLDevice(m_Device);
38 m_DeviceSource->RegisterAsMicroservice();
40 m_Filter = mitk::IGTLMessageToUSImageFilter::New();
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";
124 mitk::USProbe::Pointer defaultProbe = mitk::USProbe::New(name);
125 m_Probes.push_back(defaultProbe);
128 m_CurrentProbe = m_Probes.at(0);
129 MITK_INFO <<
"SetDefaultProbeAsCurrentProbe()";
130 this->ProbeChanged(m_CurrentProbe->GetName());
135 m_CurrentProbe = this->GetProbeByName(probename);
136 MITK_INFO <<
"SetCurrentProbe() " << probename;
141 mitk::Vector3D spacing;
142 spacing[0] = xSpacing;
143 spacing[1] = ySpacing;
145 MITK_INFO <<
"Spacing: " << spacing;
147 if (m_CurrentProbe.IsNotNull())
149 m_CurrentProbe->SetSpacingForGivenDepth(m_CurrentProbe->GetCurrentDepth(), spacing);
153 MITK_WARN <<
"Cannot set spacing. Current ultrasound probe not set.";
164 MITK_INFO <<
"Device is ready or running. So return true";
167 return m_Device->OpenConnection();
172 return m_Device->CloseConnection();
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)
199 auto& image = m_ImageVector[0];
200 if (image.IsNotNull() && image->IsInitialized() && m_CurrentProbe.IsNotNull())
203 image->GetGeometry()->SetSpacing(m_CurrentProbe->GetSpacingForGivenDepth(m_CurrentProbe->GetCurrentDepth()));
204 this->GetOutput(0)->SetGeometry(image->GetGeometry());
206 m_ImageMutex.unlock();
A device holds information about it's model, make and the connected probes. It is the common super cl...
void UnregisterOnService()
Remove this device from the micro service.
USImageSource::Pointer GetUSImageSource() override
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....
bool OnDeactivation() override
Is called during the deactivation process. After a call to this method the device should still be con...
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...
void UnregisterOnService()
Remove the IGTLDevice from the micro service.
void SetDefaultProbeAsCurrentProbe() override
Sets the first existing probe or the default probe of the video device as the current probe of it.
void SetSpacing(double xSpacing, double ySpacing) override
Sets the given spacing of the current depth of the current probe.
itk::SmartPointer< USAbstractControlInterface > GetControlInterfaceCustom() override
void SetCurrentProbe(std::string probename) override
Sets the probe with the given name as current probe if the named probe exists.
void DeleteAllProbes() override
Cleans the std::vector containing all configured probes.
bool OnInitialization() override
Is called during the initialization process. Override this method in a subclass to handle the actual ...
bool OnConnection() override
Is called during the connection process. Override this method in a subclass to handle the actual conn...
bool OnActivation() override
Is called during the activation process. After this method is finished, the device should be generati...
mitk::USProbe::Pointer GetCurrentProbe() override
Return current active probe for this USDevice Returns a pointer to the probe that is currently in use...
void GenerateData() override
Grabs the next frame from the Video input. This method is called internally, whenever Update() is inv...
void RemoveProbeByName(std::string name) override
Removes the Probe with the given name.
USIGTLDevice(std::string manufacturer, std::string model, std::string host, int port, bool server)
void AddNewProbe(mitk::USProbe::Pointer probe) override
adds a new probe to the device
std::string GetDeviceClass() override
Returns the Class of the Device. This Method must be reimplemented by every Inheriting Class.
bool OnDisconnection() override
Is called during the disconnection process. Override this method in a subclass to handle the actual d...