Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

mitk::TrackingDevice Class Reference

Interface for all Tracking Devices. More...

#include <mitkTrackingDevice.h>

Inheritance diagram for mitk::TrackingDevice:
Inheritance graph
[legend]

List of all members.

Public Types

enum  TrackingDeviceState { Setup, Ready, Tracking }
typedef TrackingDevice Self
typedef itk::Object Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual bool OpenConnection ()=0
 Opens a connection to the device.
virtual bool CloseConnection ()=0
 Closes the connection to the device.
virtual bool StartTracking ()=0
 start retrieving tracking data from the device.
virtual bool StopTracking ()
 stop retrieving tracking data from the device. stop retrieving tracking data from the device. This may only be called after StartTracking was called (e.g. the object is in Tracking mode). This will change the object state from Tracking to Ready.
virtual TrackingToolGetTool (unsigned int toolNumber) const =0
 Return tool with index toolNumber.
virtual mitk::TrackingToolGetToolByName (std::string name) const
 Returns the tool with the given tool name.
virtual unsigned int GetToolCount () const =0
 Returns number of tracking tools.
virtual const char * GetErrorMessage () const
 return current error message
TrackingDeviceState GetState () const
 return current object state (Setup, Ready or Tracking)
virtual TrackingDeviceType GetType () const
 return device type identifier
virtual void SetType (TrackingDeviceType _arg)
 set device type

Protected Member Functions

virtual void SetErrorMessage (const char *_arg)
 set error message
void SetState (TrackingDeviceState state)
 change object state
 TrackingDevice ()
virtual ~TrackingDevice ()

Protected Attributes

TrackingDeviceType m_Type
 current device type
TrackingDeviceState m_State
 current object state (Setup, Ready or Tracking)
bool m_StopTracking
 signal stop to tracking thread
itk::FastMutexLock::Pointer m_StopTrackingMutex
 mutex to control access to m_StopTracking
itk::FastMutexLock::Pointer m_TrackingFinishedMutex
 mutex to manage control flow of StopTracking()
itk::FastMutexLock::Pointer m_StateMutex
 mutex to control access to m_State
std::string m_ErrorMessage
 current error message

Detailed Description

Interface for all Tracking Devices.

Documentation Defines the methods that are common for all tracking devices.

Definition at line 39 of file mitkTrackingDevice.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::TrackingDevice::ConstPointer
typedef itk::SmartPointer<Self> mitk::TrackingDevice::Pointer
typedef itk::Object mitk::TrackingDevice::Superclass

Member Enumeration Documentation

Enumerator:
Setup 
Ready 
Tracking 

Definition at line 44 of file mitkTrackingDevice.h.


Constructor & Destructor Documentation

mitk::TrackingDevice::TrackingDevice (  ) [protected]

Definition at line 26 of file mitkTrackingDevice.cpp.

References m_StateMutex, m_StopTrackingMutex, and m_TrackingFinishedMutex.

                                   :
  m_Type(TrackingSystemNotSpecified),
  m_State(mitk::TrackingDevice::Setup),
  m_StopTracking(false), m_ErrorMessage("")

{
  m_StopTrackingMutex = itk::FastMutexLock::New();
  m_StateMutex = itk::FastMutexLock::New();
  m_TrackingFinishedMutex = itk::FastMutexLock::New();
  m_TrackingFinishedMutex->Lock();  // execution rights are owned by the application thread at the beginning
}
mitk::TrackingDevice::~TrackingDevice (  ) [protected, virtual]

Definition at line 39 of file mitkTrackingDevice.cpp.


Member Function Documentation

virtual bool mitk::TrackingDevice::CloseConnection (  ) [pure virtual]

Closes the connection to the device.

This may only be called if there is currently a connection to the device, but tracking is not running (e.g. object is in Ready state) Closes the connection with the device

Implemented in mitk::ClaronTrackingDevice, mitk::MicroBirdTrackingDevice, mitk::NDITrackingDevice, mitk::VirtualTrackingDevice, and TrackingDeviceTestClass.

virtual const char* mitk::TrackingDevice::GetClassName (  ) const [virtual]
virtual const char* mitk::TrackingDevice::GetErrorMessage (  ) const [virtual]

return current error message

Reimplemented in mitk::MicroBirdTrackingDevice.

mitk::TrackingDevice::TrackingDeviceState mitk::TrackingDevice::GetState (  ) const

return current object state (Setup, Ready or Tracking)

Definition at line 46 of file mitkTrackingDevice.cpp.

{
  MutexLockHolder lock(*m_StateMutex);
  return m_State;
}
virtual TrackingTool* mitk::TrackingDevice::GetTool ( unsigned int  toolNumber ) const [pure virtual]

Return tool with index toolNumber.

tools are numbered from 0 to GetToolCount() - 1.

Implemented in mitk::ClaronTrackingDevice, mitk::NDITrackingDevice, mitk::VirtualTrackingDevice, and TrackingDeviceTestClass.

mitk::TrackingTool * mitk::TrackingDevice::GetToolByName ( std::string  name ) const [virtual]

Returns the tool with the given tool name.

Note: subclasses can and should implement optimized versions of this method

Returns:
the given tool or NULL if no tool with that name exists

Reimplemented in mitk::NDITrackingDevice.

Definition at line 85 of file mitkTrackingDevice.cpp.

{
  unsigned int toolCount = this->GetToolCount();
  for (unsigned int i = 0; i < toolCount; ++i)
    if (name == this->GetTool(i)->GetToolName())
      return this->GetTool(i);
  return NULL;
}
virtual unsigned int mitk::TrackingDevice::GetToolCount (  ) const [pure virtual]
virtual TrackingDeviceType mitk::TrackingDevice::GetType (  ) const [virtual]

return device type identifier

virtual bool mitk::TrackingDevice::OpenConnection (  ) [pure virtual]

Opens a connection to the device.

This may only be called if there is currently no connection to the device. If OpenConnection() is successful, the object will change from Setup state to Ready state

Implemented in mitk::ClaronTrackingDevice, mitk::MicroBirdTrackingDevice, mitk::NDITrackingDevice, mitk::VirtualTrackingDevice, and TrackingDeviceTestClass.

virtual void mitk::TrackingDevice::SetErrorMessage ( const char *  _arg ) [protected, virtual]

set error message

Reimplemented in mitk::MicroBirdTrackingDevice.

void mitk::TrackingDevice::SetState ( TrackingDeviceState  state ) [protected]

change object state

Definition at line 53 of file mitkTrackingDevice.cpp.

Referenced by TrackingDeviceTestClass::StartTracking().

{
  itkDebugMacro("setting  m_State to " << state);

  MutexLockHolder lock(*m_StateMutex); // lock and unlock the mutex 
  if (m_State == state)
  { 
    return;
  }
  m_State = state;
  this->Modified();
}
virtual void mitk::TrackingDevice::SetType ( TrackingDeviceType  _arg ) [virtual]

set device type

Reimplemented in mitk::MicroBirdTrackingDevice, and mitk::NDITrackingDevice.

virtual bool mitk::TrackingDevice::StartTracking (  ) [pure virtual]

start retrieving tracking data from the device.

This may only be called after the connection to the device has been established with a call to OpenConnection() (E.g. object is in Ready mode). This will change the object state from Ready to Tracking

Implemented in mitk::ClaronTrackingDevice, mitk::MicroBirdTrackingDevice, mitk::NDITrackingDevice, mitk::VirtualTrackingDevice, and TrackingDeviceTestClass.

bool mitk::TrackingDevice::StopTracking (  ) [virtual]

stop retrieving tracking data from the device. stop retrieving tracking data from the device. This may only be called after StartTracking was called (e.g. the object is in Tracking mode). This will change the object state from Tracking to Ready.

Reimplemented in mitk::ClaronTrackingDevice, mitk::MicroBirdTrackingDevice, and mitk::VirtualTrackingDevice.

Definition at line 67 of file mitkTrackingDevice.cpp.

References mitk::TimeStamp::GetInstance(), and mitk::TimeStamp::Stop().

Referenced by mitk::MicroBirdTrackingDevice::StopTracking().

{
  if (this->GetState() == Tracking) // Only if the object is in the correct state
  {
    m_StopTrackingMutex->Lock();  // m_StopTracking is used by two threads, so we have to ensure correct thread handling
    m_StopTracking = true;
    m_StopTrackingMutex->Unlock();
    //we have to wait here that the other thread recognizes the STOP-command and executes it
    m_TrackingFinishedMutex->Lock();
    mitk::TimeStamp::GetInstance()->Stop(this); // notify realtime clock
    // StopTracking was called, thus the mode should be changed back
    //   to Ready now that the tracking loop has ended.
    this->SetState(Ready);
  }
  return true;
}

Member Data Documentation

std::string mitk::TrackingDevice::m_ErrorMessage [protected]

current error message

Reimplemented in mitk::MicroBirdTrackingDevice.

Definition at line 137 of file mitkTrackingDevice.h.

current object state (Setup, Ready or Tracking)

Definition at line 132 of file mitkTrackingDevice.h.

itk::FastMutexLock::Pointer mitk::TrackingDevice::m_StateMutex [protected]

mutex to control access to m_State

Definition at line 136 of file mitkTrackingDevice.h.

Referenced by TrackingDevice().

signal stop to tracking thread

Definition at line 133 of file mitkTrackingDevice.h.

itk::FastMutexLock::Pointer mitk::TrackingDevice::m_StopTrackingMutex [protected]

mutex to control access to m_StopTracking

Definition at line 134 of file mitkTrackingDevice.h.

Referenced by TrackingDevice().

itk::FastMutexLock::Pointer mitk::TrackingDevice::m_TrackingFinishedMutex [protected]

mutex to manage control flow of StopTracking()

Definition at line 135 of file mitkTrackingDevice.h.

Referenced by TrackingDeviceTestClass::StartTracking(), and TrackingDevice().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines