14#include "mitkImageReadAccessor.h"
23m_Probe(0), m_UsgDataView(0), m_ProbesCollection(0)
25 SetNumberOfIndexedOutputs(1);
26 SetNthOutput(0, this->MakeOutput(0));
35 return "org.mitk.modules.us.USTelemedDevice";
40 return m_ControlsBMode.GetPointer();
45 return m_ControlsProbes.GetPointer();
50 return m_ControlsDoppler.GetPointer();
55 CoInitialize(
nullptr);
65 hr = CoCreateInstance(Usgfw2Lib::CLSID_Usgfw2,
nullptr, CLSCTX_INPROC_SERVER, Usgfw2Lib::IID_IUsgfw2,(LPVOID*) &m_UsgMainInterface);
69 MITK_ERROR(
"USDevice")(
"USTelemedDevice") <<
"Error at connecting to ultrasound device (" << hr <<
").";
73 this->ConnectDeviceChangeSink();
81 m_ControlsBMode->SetIsActive(
false);
82 m_ControlsDoppler->SetIsActive(
false);
83 m_ControlsProbes->SetIsActive(
false);
93 m_ControlsProbes->SetIsActive(
true);
95 if ( m_ControlsProbes->GetProbesCount() < 1 )
97 MITK_WARN(
"USDevice")(
"USTelemedDevice") <<
"No probe found.";
102 m_ControlsProbes->SelectProbe(0);
106 HRESULT hr = m_UsgDataView->put_ScanMode(Usgfw2Lib::SCAN_MODE_B);
109 MITK_ERROR(
"USDevice")(
"USTelemedDevice") <<
"Could not set scan mode b (" << hr <<
").";
114 hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_RUN);
117 MITK_ERROR(
"USDevice")(
"USTelemedDevice") <<
"Start scanning failed (" << hr <<
").";
121 m_ControlsBMode->ReinitializeControls();
128 this->StopScanning();
136 m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_FREEZE);
140 m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_RUN);
148 Superclass::GenerateData();
153 return m_ImageSource.GetPointer();
158 if (m_UsgDataView) { this->StopScanning(); };
168 if ( ! m_UsgDataView )
170 MITK_WARN(
"USDevice")(
"USTelemedDevice") <<
"Cannot stop scanning as Telemed Data View is null.";
175 hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_STOP);
179 MITK_ERROR(
"USDevice")(
"USTelemedDevice") <<
"Stop scanning failed (" << hr <<
").";
180 mitkThrow() <<
"Stop scanning failed (" << hr <<
").";
185 return m_ControlsProbes->GetProbeSet();
189 return m_ControlsProbes->GetSelectedProbe();
193 for (mitk::USProbe::Pointer p : m_ControlsProbes->GetProbeSet()){
194 if (p->GetName().compare(name)==0) {
return p;}
201 return m_UsgMainInterface;
207 if ( m_UsgDataView != usgDataView )
211 m_UsgDataView = usgDataView;
212 if ( ! m_ImageSource->CreateAndConnectConverterPlugin(m_UsgDataView, Usgfw2Lib::SCAN_MODE_B)) {
return; }
215 m_ControlsBMode->SetUsgDataView(m_UsgDataView);
221 IConnectionPointContainer* cpc =
nullptr;
222 HRESULT hr = m_UsgMainInterface->QueryInterface(IID_IConnectionPointContainer, (
void**)&cpc);
227 hr = cpc->FindConnectionPoint(Usgfw2Lib::IID_IUsgDeviceChangeSink, &m_UsgDeviceChangeCpnt);
231 m_UsgDeviceChangeCpnt =
nullptr;
232 m_UsgDeviceChangeCpntCookie = 0;
236 if (m_UsgDeviceChangeCpnt !=
nullptr)
237 hr = m_UsgDeviceChangeCpnt->Advise((IUnknown*)((Usgfw2Lib::IUsgDeviceChangeSink*)
this), &m_UsgDeviceChangeCpntCookie);
251 if ( this->GetIsActive() ) { this->Deactivate(); }
260 m_ControlsProbes->ProbeAdded(
static_cast<unsigned int>(*probeIndex));
269 m_ControlsProbes->ProbeRemoved(
static_cast<unsigned int>(*probeIndex));
271 if ( this->GetIsActive() ) { this->Deactivate(); }
290 if (riid == IID_IUnknown || riid == Usgfw2Lib::IID_IUsgDeviceChangeSink)
292 *ppv = (IUsgDeviceChangeSink*)
this;
295 if (riid == IID_IDispatch)
297 *ppv = (IDispatch*)
this;
300 return E_NOINTERFACE;
305 if (pctinfo ==
nullptr)
return E_INVALIDARG;
312 if (pptinfo ==
nullptr)
return E_INVALIDARG;
314 if(itinfo != 0)
return DISP_E_BADINDEX;
324HRESULT
mitk::USTelemedDevice::Invoke(DISPID dispIdMember,
const IID &riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
326 if ( (dispIdMember >= 1) && (dispIdMember <= 6) )
328 if (pDispParams->cArgs != 2)
331 IUnknown *unkn =
nullptr;
332 ULONG *res =
nullptr;
336 p1 = pDispParams->rgvarg;
339 if (p->vt == (VT_BYREF|VT_UI4))
344 if (p->vt == VT_UNKNOWN)
345 unkn = (IUnknown*)(p->punkVal);
347 if (dispIdMember == 1)
348 OnProbeArrive(unkn, res);
349 else if (dispIdMember == 2)
350 OnBeamformerArrive(unkn, res);
351 else if (dispIdMember == 3)
352 OnProbeRemove(unkn, res);
353 else if (dispIdMember == 4)
354 OnBeamformerRemove(unkn, res);
355 else if (dispIdMember == 5)
356 OnProbeStateChanged(unkn, res);
357 else if (dispIdMember == 6)
358 OnBeamformerStateChanged(unkn, res);
A device holds information about it's model, make and the connected probes. It is the common super cl...
Implementation of mitk::USControlInterfaceBMode for Telemed ultrasound devices. See documentation of ...
void GenerateData() override
Grabs the next frame from the Video input. This method is called internally, whenever Update() is inv...
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
virtual HRESULT __stdcall raw_OnProbeArrive(IUnknown *pUsgProbe, ULONG *reserved)
virtual HRESULT __stdcall raw_OnProbeRemove(IUnknown *pUsgProbe, ULONG *reserved)
USTelemedDevice(std::string manufacturer, std::string model)
USImageSource::Pointer GetUSImageSource()
virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo)
Usgfw2Lib::IUsgfw2 * GetUsgMainInterface()
Getter for main Telemed API object. This method is for being called by Telemed control interfaces.
virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo)
virtual bool OnActivation()
Is called during the activation process. After this method is finished, the device is generating imag...
void ReleaseUsgControls()
virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, const IID &riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
void StopScanning()
Stop ultrasound scanning by Telemed API call.
void SetActiveDataView(Usgfw2Lib::IUsgDataView *)
Changes active IUsgDataView of the device. This method is for being called by Telemed control interfa...
virtual bool OnInitialization()
Is called during the initialization process. There is nothing done on the initialization of a mik::US...
mitk::USProbe::Pointer GetProbeByName(std::string name)
get the probe by its name Returns a pointer to the probe identified by the given name....
virtual ~USTelemedDevice()
mitk::USProbe::Pointer GetCurrentProbe()
Return current active probe for this USDevice Returns a pointer to the probe that is currently in use...
virtual void OnFreeze(bool freeze)
Changes scan state of the device if freeze is toggeled in mitk::USDevice.
virtual USControlInterfaceBMode::Pointer GetControlInterfaceBMode()
Default getter for the b mode control interface. Has to be implemented in a subclass if a b mode cont...
virtual HRESULT __stdcall raw_OnBeamformerRemove(IUnknown *pUsgBeamformer, ULONG *reserved)
virtual std::string GetDeviceClass()
Returns the class of the device.
virtual bool OnDisconnection()
Is called during the disconnection process. Deactivate and remove all Telemed API controls....
std::vector< mitk::USProbe::Pointer > GetAllProbes()
Returns all probes for this device or an empty vector it no probes were set Returns a std::vector of ...
virtual USControlInterfaceProbes::Pointer GetControlInterfaceProbes()
Default getter for the probes control interface. Has to be implemented in a subclass if a probes cont...
virtual USControlInterfaceDoppler::Pointer GetControlInterfaceDoppler()
Default getter for the doppler control interface. Has to be implemented in a subclass if a doppler co...
void ConnectDeviceChangeSink()
virtual HRESULT __stdcall raw_OnBeamformerArrive(IUnknown *pUsgBeamformer, ULONG *reserved)
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(const IID &riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid)
virtual bool OnConnection()
Is called during the connection process. Connect to the Telemed API and try to get available probes f...
virtual bool OnDeactivation()
Is called during the deactivation process. After a call to this method the device is connected,...
Implementation of mitk::USControlInterfaceDoppler for Telemed ultrasound devices. See documentation o...
Implementation of mitk::USImageSource for Telemed API devices. The method mitk::USImageSource::GetNex...
virtual void GetNextRawImage(std::vector< mitk::Image::Pointer > &)
Implementation of mitk::USControlInterfaceProbes for Telemed ultrasound devices. See documentation of...
STDMETHODIMP_(ULONG) mitk