1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
|
/*=========================================================================
Program: Image Guided Surgery Software Toolkit
Module: $RCSfile: igstkTrackerConfiguration.h,v $
Language: C++
Date: $Date: 2009-01-30 20:48:01 $
Version: $Revision: 1.1 $
Copyright (c) ISC Insight Software Consortium. All rights reserved.
See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __igstkTrackerConfiguration_h
#define __igstkTrackerConfiguration_h
#include "igstkSerialCommunication.h"
namespace igstk
{
/**
* \class TrackerConfiguration
*
* \brief Superclass for the different tracker configurations.
*
* This class functions as an adapter between GUI/file reader classes and
* the TrackerController class. Its sole purpose is to serve as a container for
* the parameters defining the desired tracker and tool setup.
*
* In this header file, we also define a base class for all trackers that
* communicate using a serial port.
*
* The tracker classes only perform "static" error checking. That is, they check
* the data for adherence to known values (e.g. tracker frequency is within the
* manufacturer specified bounds). "Dynamic" error checking is relegated to the
* TrackerController (e.g. com port can be opened for serial communication).
*/
/**
* \class TrackerToolConfiguration Generic tracker tool settings container with
* the variables common to all tools (name and rigid calibration
* transformation).
*/
class TrackerToolConfiguration
{
public:
TrackerToolConfiguration();
TrackerToolConfiguration(const TrackerToolConfiguration &other);
virtual ~TrackerToolConfiguration();
/**
* Set and Get the tool's calibration transform.
*/
igstkSetMacro( CalibrationTransform, igstk::Transform );
igstkGetMacro( CalibrationTransform, igstk::Transform );
/**
* Set and Get the tool's human readable name. Note that this is not the
* unique tool identifier we get when invoking
* igstk::TrackerTool::GetTrackerToolIdentifier(), that identifier is set
* internally by the tracker. This identifier is later used by the user to
* retrieve the specific tool from the tracker controller.
*/
igstkSetMacro( ToolName, std::string );
igstkGetMacro( ToolName, std::string );
/**
*Get the tracker tool type as a string. The only reason that this method
*exists is to make the TrackerToolConfiguration class an abstract base class.
*/
virtual std::string GetToolTypeAsString() = 0;
protected:
//the tool's calibration transformation
igstk::Transform m_CalibrationTransform;
//the tool's name
std::string m_ToolName;
};
/**
* \class TrackerConfiguration Abstract base class for all tracker
* configurations.
*/
class TrackerConfiguration : public Object
{
public:
friend class TrackerController;
//standard typedefs
igstkStandardClassBasicTraitsMacro( TrackerConfiguration, igstk::Object )
/** This event is generated when the frequency was set successfuly. */
igstkEventMacro( FrequencySetEvent, IGSTKEvent );
/**
* This event is generated when the frequency setting fails
* (user specified a value that was zero, negative, or greater than the
* tracker's maximal refresh rate).
*/
igstkEventMacro( FrequencySetErrorEvent, IGSTKErrorWithStringEvent );
/** This event is generated when a tool was added successfuly. */
igstkEventMacro( AddToolSuccessEvent, IGSTKEvent );
/**
* This event is generated when the tool was not added. This can happen
* when the internal tool data is invalid (e.g. wireless polaris tool with
* an empty srom file specification) or if the specified tool does not match
* the tracker type (e.g. MicronToolConfiguration given to a
* PolarisTrackerConfiguration).
*/
igstkLoadedEventMacro( AddToolFailureEvent, IGSTKErrorEvent, std::string )
/**
* This method sets the data acquisition frequency.
*
* The method generates two events: FrequencySetSuccessEvent and
* FrequencySetErrorEvent.
*/
void RequestSetFrequency( double frequency );
/**
* This method adds a tool to the tracker configuration.
*
* @param tool The tool configuration we want to set.
*
* NOTE: This tool will not be used as a dynamic reference. If you want to
* add the tool as a dynamic reference use the RequestAddReferenceTool()
* method.
* The method generates two events: AddToolSuccessEvent and
* AddToolFailureEvent.
*/
void RequestAddTool( const TrackerToolConfiguration *tool );
/**
* This method adds the tool as the dynamic reference for the tracker
* configuration.
*
* NOTE: This tool will be the dynamic reference. The last invocation will be
* the one used.
* The method generates two events: AddToolSuccessEvent and
* AddToolFailureEvent.
*/
void RequestAddReference( const TrackerToolConfiguration *tool );
/**
* Each tracker has its manufacturer specified maximal refresh rate.
*/
virtual double GetMaximalRefreshRate()=0;
igstkGetMacro( Frequency, double );
protected:
TrackerConfiguration();
virtual ~TrackerConfiguration();
virtual void InternalAddTool( const TrackerToolConfiguration *tool,
bool isReference )=0;
//the frequency at which the tracker is queried for new transforms [Hz]
double m_Frequency;
//the list of tools we want to connect to the tracker (excluding
//the reference tool)
std::map<std::string, TrackerToolConfiguration *> m_TrackerToolList;
TrackerToolConfiguration * m_ReferenceTool;
};
/**
* \class SerialCommunicatingTrackerConfiguration A base class for all tracker
* configurations that require serial communication.
*/
class SerialCommunicatingTrackerConfiguration : public TrackerConfiguration
{
public:
//standard typedefs
igstkStandardClassBasicTraitsMacro( SerialCommunicatingTrackerConfiguration,
TrackerConfiguration )
/** This event is generated when the COM port was set successfuly. */
igstkEventMacro( ComPortSetEvent, IGSTKEvent );
/**
* This event is generated when the given COM port is invalid.
*/
igstkEventMacro( ComPortSetErrorEvent, IGSTKErrorWithStringEvent );
/**
* Set the com port to the given value. Generates ComPortSetEvent if
* successful otherwise ComPortSetErrorEvent.*/
void RequestSetCOMPort( igstk::SerialCommunication::PortNumberType
portNumber);
igstkGetMacro( COMPort, igstk::SerialCommunication::PortNumberType );
/** This event is generated when the baud rate was set successfuly. */
igstkEventMacro( BaudRateSetEvent, IGSTKEvent );
/**
* This event is generated when the given baud rate is invalid.
*/
igstkEventMacro( BaudRateSetErrorEvent, IGSTKErrorWithStringEvent );
/**
* Set the baud rate to the given value. Generates BaudRateSetEvent if
* successful otherwise BaudRateSetErrorEvent.*/
void RequestSetBaudRate( igstk::SerialCommunication::BaudRateType baudRate );
igstkGetMacro( BaudRate, igstk::SerialCommunication::BaudRateType );
igstkEventMacro( DataBitsSetEvent, IGSTKEvent );
igstkEventMacro( DataBitsSetErrorEvent, IGSTKErrorWithStringEvent );
void RequestSetDataBits( igstk::SerialCommunication::DataBitsType dataBits );
igstkGetMacro( DataBits, igstk::SerialCommunication::DataBitsType );
igstkEventMacro( ParitySetEvent, IGSTKEvent );
igstkEventMacro( ParitySetErrorEvent, IGSTKErrorWithStringEvent );
void RequestSetParity( igstk::SerialCommunication::ParityType parity);
igstkGetMacro( Parity, igstk::SerialCommunication::ParityType );
igstkEventMacro( StopBitsSetEvent, IGSTKEvent );
igstkEventMacro( StopBitsSetErrorEvent, IGSTKErrorWithStringEvent );
void RequestSetStopBits( igstk::SerialCommunication::StopBitsType stopBits );
igstkGetMacro( StopBits, igstk::SerialCommunication::StopBitsType );
igstkEventMacro( HandshakeSetEvent, IGSTKEvent );
igstkEventMacro( HandshakeSetErrorEvent, IGSTKErrorWithStringEvent );
void RequestSetHandshake( igstk::SerialCommunication::HandshakeType
handShake );
igstkGetMacro( Handshake, igstk::SerialCommunication::HandshakeType );
protected:
SerialCommunicatingTrackerConfiguration();
virtual ~SerialCommunicatingTrackerConfiguration();
private:
igstk::SerialCommunication::PortNumberType m_COMPort;
igstk::SerialCommunication::BaudRateType m_BaudRate;
igstk::SerialCommunication::DataBitsType m_DataBits;
igstk::SerialCommunication::ParityType m_Parity;
igstk::SerialCommunication::StopBitsType m_StopBits;
igstk::SerialCommunication::HandshakeType m_Handshake;
};
} // end of name space
#endif
|