Exemple #1
0
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;

  // Unregister
  m_ServiceRegistration.Unregister();
  m_ServiceRegistration = 0;

  // Undo the manual registration done in Connect(). Pointer will invalidte, if no one holds a reference to this object anymore.
  this->UnRegister();
  return true;
}
Exemple #2
0
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;
}
Exemple #3
0
bool mitk::USDevice::Connect()
{
  if (GetIsConnected())
  {
    MITK_WARN << "Tried to connect an ultrasound device that was already connected. Ignoring call...";
    return false;
  }
  // Prepare connection, fail if this fails.
  if (! this->OnConnection()) return false;

  // Get Context and Module
  mitk::ModuleContext* context = GetModuleContext();
  ServiceProperties props = ConstructServiceProperties();

  m_ServiceRegistration = context->RegisterService<mitk::USDevice>(this, props);

  // This makes sure that the SmartPointer to this device does not invalidate while the device is connected
  this->Register();

  return true;
}