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_