IGSTK
igstkAscension3DGTracker.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkAscension3DGTracker.h,v $
5  Language: C++
6  Date: $Date: 2011-02-08 15:00:55 $
7  Version: $Revision: 1.3 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __igstkAscension3DGTracker_h
19 #define __igstkAscension3DGTracker_h
20 
22 #include "igstkTracker.h"
23 
24 namespace igstk
25 {
30 
33 };
34 
39  enum ToolEvents{
48  };
49 
51 
54 
56  int toolID;
57 
60 };
61 
62  igstkLoadedEventMacro( Ascension3DGErrorEvent, IGSTKErrorEvent,
64  igstkLoadedEventMacro( Ascension3DGToolEvent, IGSTKEvent,
66 
87 {
88 public:
89 
92 
93 
94  igstkGetMacro( NumberOfTools, unsigned int )
95 
96 
102  void RequestSensorAttached(int sensorID);
103 
111 
119  void RequestSensorSaturated(int sensorID);
120 
127  void RequestSensorInMotionBox(int sensorID);
128 
129 protected:
131  Ascension3DGTracker(void);
132  virtual ~Ascension3DGTracker(void);
133 
136 
138  virtual ResultType InternalOpen( void );
139 
141  virtual ResultType InternalClose( void );
142 
144  virtual ResultType InternalStartTracking( void );
145 
147  virtual ResultType InternalStopTracking( void );
148 
150  virtual ResultType InternalUpdateStatus( void );
151 
155 
158  const TrackerToolType * trackerTool );
159 
161  virtual ResultType ValidateSpecifiedFrequency( double frequencyInHz );
162 
165  TrackerToolType * trackerTool );
166 
169  const TrackerToolType * trackerTool );
170 
172  virtual ResultType InternalReset( void );
173 
175  virtual void PrintSelf( std::ostream& os, ::itk::Indent indent ) const;
176 
177 private:
178 
179  Ascension3DGTracker(const Self&); //purposely not implemented
180  void operator=(const Self&); //purposely not implemented
181 
184  typedef Ascension3DGTrackerToolType::Pointer Ascension3DGTrackerToolPointer;
186  Ascension3DGTrackerToolConstPointer;
187 
190  void EnableToolPorts( void );
191 
193  void DisableToolPorts( void );
194 
197  int CheckAPIReturnStatus(int status);
198 
200  unsigned int m_NumberOfTools;
201 
202  enum {TRANSMITTER_OFF = -1};
203 
205  itk::MutexLock::Pointer m_BufferLock;
206 
207  typedef std::map< std::string, std::vector < double > >
208  TrackerToolTransformContainerType;
210  TrackerToolTransformContainerType m_ToolTransformBuffer;
211 
212  typedef std::map< unsigned int, std::string> ErrorCodeContainerType;
214  static ErrorCodeContainerType m_ErrorCodeContainer;
215 
216  enum ToolAvailabilityStatus {TOOL_UNAVAILABLE, TOOL_AVAILABLE};
218  std::map< std::string, ToolAvailabilityStatus > m_ToolStatusContainer;
219 
221  static unsigned short ConvertToolNameToSensorID(const std::string &name);
223  static std::string ConvertSensorIDToToolName(unsigned short id);
224 
225  //The tool status from the last update. It would be better if this were in the
226  //Ascension3DGTrackerTool class, but that does not seem workable. The Tracker
227  //baseclass keeps its container of tracker tools private. It only has a const
228  //getter. From within Ascension3DGTracker, we cannot directly modify
229  //TrackerTools or call non-const TrackerTools member methods. Our only access
230  //to the tools is through the public and protected methods the Tracker base
231  //provides.
232  std::vector<bool> m_SensorSaturated;
233  std::vector<bool> m_SensorAttached;
234  std::vector<bool> m_SensorInMotionBox;
235  bool m_TransmitterAttached;
236 
238  void InvokeSensorToolEvent(std::string sensorName, int sensorID,
240 
242  void NoProcessing(){};
243 
244  void ReportSensorSaturationProcessing();
245  void ReportSensorAttachedProcessing();
246  void ReportTransmitterAttachedProcessing();
247  void ReportSensorInMotionBoxProcessing();
248 
249  //used to keep the sensor id as we go through the state machine
250  int m_sensorID;
251 
252  //states
253  igstkDeclareStateMacro(Idle);
254  igstkDeclareStateMacro(Initialized);
255  igstkDeclareStateMacro(AttemptingToGetSaturation);
256  igstkDeclareStateMacro(AttemptingToGetSensorAttached);
257  igstkDeclareStateMacro(AttemptingToGetTransmitterAttached);
258  igstkDeclareStateMacro(AttemptingToGetSensorInMotionBox);
259 
260  //inputs
261  igstkDeclareInputMacro(Initialize);
262  igstkDeclareInputMacro(GetSensorSaturation);
263  igstkDeclareInputMacro(GetSensorAttached);
264  igstkDeclareInputMacro(GetTransmitterAttached);
265  igstkDeclareInputMacro(GetSensorInMotionBox);
266 };
267 
268 }
269 
270 #endif //__igstk_Ascension3DGTracker_h_
ToolEvents EventType
the type of notification
Structure holding a notification event.
void RequestSensorSaturated(int sensorID)
Request whether the particular sensor (0 based), is too close to the magnetic transmitter and is satu...
a tool that was connected has been disconnected
a sensor that was out of the motion box is now back in
#define igstkGetMacro(name, type)
Get built-in type.
Definition: igstkMacros.h:105
a sensor that was saturated is no longer saturated
virtual ~Ascension3DGTracker(void)
EventHelperType::StringType ToolIdentifier
a text descriptor of the tool the notificatrion is for
std::string StringType
Definition: igstkEvents.h:60
Base class for all the IGSTK classes.
Definition: igstkObject.h:40
virtual ResultType RemoveTrackerToolFromInternalDataContainers(const TrackerToolType *trackerTool)
Remove tracker tool from internal containers.
void RequestSensorInMotionBox(int sensorID)
Request whether the particular sensor (0 based), is outside of the tracking motion box...
virtual ResultType AddTrackerToolToInternalDataContainers(const TrackerToolType *trackerTool)
Add tracker tool entry from internal containers.
igstkStandardClassTraitsMacro(Ascension3DGTracker, Tracker) virtual unsigned int GetNumberOfTools()
Macro with standard traits declarations.
virtual ResultType InternalOpen(void)
Open communication with the tracking device.
Structure holding the Ascension 3DG error type.
void RequestTransmitterAttached()
Request whether a transmitter, is attached.
Ascension specific TrackerTool class for the 3D Guidance family of trackers.
virtual ResultType InternalStopTracking(void)
Take the tracking device out of tracking mode.
virtual void PrintSelf(std::ostream &os,::itk::Indent indent) const
Print object information.
virtual ResultType InternalThreadedUpdateStatus(void)
Update the status and the transforms.
virtual ResultType InternalUpdateStatus(void)
Update the status and the transforms for all TrackerTools.
::itk::SmartPointer< Self > Pointer
Definition: igstkObject.h:50
Tracker::ResultType ResultType
typedef for internal boolean return type
Ascension3DGTracker(void)
protected constructor
virtual ResultType InternalClose(void)
Close communication with the tracking device.
Abstract superclass for concrete IGSTK Tracker classes.
Definition: igstkTracker.h:96
a tool that was disconnected has been reconnected
void RequestSensorAttached(int sensorID)
Request whether the particular sensor (0 based), is attached.
a sensor is too close to the transmitter and has saturated
a transmitter that was attached has been disconnected
EventHelperType::StringType ErrorString
String describing the error, as returned from the Ascension tracker.
a sensor that was within the motion box is now out
virtual ResultType InternalReset(void)
Reset the tracking device to put it back to its original state.
igstkStandardAbstractClassTraitsMacro(Tracker, Object) public typedef TrackerTool TrackerToolType
Macro with standard traits declarations.
Definition: igstkTracker.h:101
int AscensionErrorCode
Error code returned from the tracker.
::itk::SmartPointer< const Self > ConstPointer
Definition: igstkObject.h:51
virtual ResultType InternalStartTracking(void)
Put the tracking device into tracking mode.
int toolID
the id number of the tool the notification is for
igstkLoadedEventMacro(Ascension3DGErrorEvent, IGSTKErrorEvent, Ascension3DGEventErrorType)
virtual ResultType VerifyTrackerToolInformation(const TrackerToolType *trackerTool)
Verify tracker tool information.
virtual ResultType ValidateSpecifiedFrequency(double frequencyInHz)
Verify the specified tracker measurement frequency.
Provides support for the Ascension 3D Guidance trackers.