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.cxx,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.
=========================================================================*/
#include "igstkTrackerConfiguration.h"
namespace igstk
{
TrackerConfiguration::TrackerConfiguration() : m_ReferenceTool( NULL )
{
}
TrackerConfiguration::~TrackerConfiguration()
{
std::map<std::string, TrackerToolConfiguration *>::iterator it;
std::map<std::string, TrackerToolConfiguration *>::iterator endIt =
this->m_TrackerToolList.end();
for(it=this->m_TrackerToolList.begin(); it != endIt; it++)
{
delete (it->second);
}
this->m_TrackerToolList.clear();
if ( m_ReferenceTool )
{
delete this->m_ReferenceTool;
}
}
void
TrackerConfiguration::RequestSetFrequency( double frequency )
{
if( frequency<=0 || frequency>GetMaximalRefreshRate() )
{
std::ostringstream msg;
msg.str("");
msg<<"Invalid tracker frequency specified ("<<frequency<<").";
msg<< " Valid values are in [0,"<<GetMaximalRefreshRate()<<"].";
FrequencySetErrorEvent evt;
evt.Set( msg.str() );
this->InvokeEvent( evt );
}
else
{
this->m_Frequency = frequency;
this->InvokeEvent( FrequencySetEvent() );
}
}
void
TrackerConfiguration::RequestAddTool( const TrackerToolConfiguration *tool )
{
AddToolFailureEvent fe;
std::map<std::string, TrackerToolConfiguration *>::iterator it =
this->m_TrackerToolList.find( tool->GetToolName() );
if( it!= this->m_TrackerToolList.end() )
{
fe.Set( "Tool name is not unique." );
this->InvokeEvent( fe );
return;
}
InternalAddTool( tool, false );
}
void
TrackerConfiguration::RequestAddReference( const TrackerToolConfiguration *tool )
{
InternalAddTool( tool, true );
}
SerialCommunicatingTrackerConfiguration::
SerialCommunicatingTrackerConfiguration()
{
igstk::SerialCommunication::PortNumberType DEFAULT_COM_PORT =
igstk::SerialCommunication::PortNumber0;
igstk::SerialCommunication::BaudRateType DEFAULT_BAUD_RATE =
igstk::SerialCommunication::BaudRate115200;
igstk::SerialCommunication::DataBitsType DEFAULT_DATA_BITS =
igstk::SerialCommunication::DataBits8;
igstk::SerialCommunication::ParityType DEFAULT_PARITY =
igstk::SerialCommunication::NoParity;
igstk::SerialCommunication::StopBitsType DEFAULT_STOP_BITS =
igstk::SerialCommunication::StopBits1;
igstk::SerialCommunication::HandshakeType DEFAULT_HANDSHAKE =
igstk::SerialCommunication::HandshakeOff;
m_COMPort = DEFAULT_COM_PORT;
m_BaudRate = DEFAULT_BAUD_RATE;
m_DataBits = DEFAULT_DATA_BITS;
m_Parity = DEFAULT_PARITY;
m_StopBits = DEFAULT_STOP_BITS;
m_Handshake = DEFAULT_HANDSHAKE;
}
SerialCommunicatingTrackerConfiguration::
~SerialCommunicatingTrackerConfiguration()
{
}
void
SerialCommunicatingTrackerConfiguration::RequestSetCOMPort(
igstk::SerialCommunication::PortNumberType portNumber)
{
switch( portNumber )
{
case igstk::SerialCommunication::PortNumber0:
case igstk::SerialCommunication::PortNumber1:
case igstk::SerialCommunication::PortNumber2:
case igstk::SerialCommunication::PortNumber3:
case igstk::SerialCommunication::PortNumber4:
case igstk::SerialCommunication::PortNumber5:
case igstk::SerialCommunication::PortNumber6:
case igstk::SerialCommunication::PortNumber7:
this->m_COMPort = portNumber;
this->InvokeEvent( ComPortSetEvent() );
break;
default:
ComPortSetErrorEvent errorEvt;
std::ostringstream msg;
msg<<"Invalid COM port ("<<portNumber<<"). Supported ports are ";
msg<<"in the range ["<<igstk::SerialCommunication::PortNumber0<<",";
msg<<igstk::SerialCommunication::PortNumber7<<"].";
errorEvt.Set( msg.str() );
this->InvokeEvent( errorEvt );
}
}
void
SerialCommunicatingTrackerConfiguration::RequestSetBaudRate(
igstk::SerialCommunication::BaudRateType baudRate)
{
switch( baudRate )
{
case igstk::SerialCommunication::BaudRate9600:
case igstk::SerialCommunication::BaudRate19200:
case igstk::SerialCommunication::BaudRate38400:
case igstk::SerialCommunication::BaudRate57600:
case igstk::SerialCommunication::BaudRate115200:
this->m_BaudRate = baudRate;
this->InvokeEvent( BaudRateSetEvent() );
break;
default:
BaudRateSetErrorEvent errorEvt;
std::ostringstream msg;
msg<<"Invalid baud rate ("<<baudRate<<")";
errorEvt.Set( msg.str() );
this->InvokeEvent( errorEvt );
}
}
void
SerialCommunicatingTrackerConfiguration::RequestSetDataBits(
igstk::SerialCommunication::DataBitsType dataBits)
{
switch( dataBits )
{
case igstk::SerialCommunication::DataBits7:
case igstk::SerialCommunication::DataBits8:
this->m_DataBits = dataBits;
this->InvokeEvent( DataBitsSetEvent() );
break;
default:
DataBitsSetErrorEvent errorEvt;
std::ostringstream msg;
msg<<"Invalid data bits value ("<<dataBits<<")";
errorEvt.Set( msg.str() );
this->InvokeEvent( errorEvt );
}
}
void
SerialCommunicatingTrackerConfiguration::RequestSetParity(
igstk::SerialCommunication::ParityType parity)
{
switch( parity )
{
case igstk::SerialCommunication::NoParity:
case igstk::SerialCommunication::OddParity:
case igstk::SerialCommunication::EvenParity:
this->m_Parity = parity;
this->InvokeEvent( ParitySetEvent() );
default:
ParitySetErrorEvent errorEvt;
std::ostringstream msg;
msg<<"Invalid parity value ("<<parity<<")";
errorEvt.Set( msg.str() );
this->InvokeEvent( errorEvt );
}
}
void
SerialCommunicatingTrackerConfiguration::RequestSetStopBits(
igstk::SerialCommunication::StopBitsType stopBits)
{
switch( stopBits )
{
case igstk::SerialCommunication::StopBits1:
case igstk::SerialCommunication::StopBits2:
this->m_StopBits = stopBits;
this->InvokeEvent( StopBitsSetEvent() );
default:
StopBitsSetErrorEvent errorEvt;
std::ostringstream msg;
msg<<"Invalid stop bits value ("<<stopBits<<")";
errorEvt.Set( msg.str() );
this->InvokeEvent( errorEvt );
}
}
void
SerialCommunicatingTrackerConfiguration::RequestSetHandshake(
igstk::SerialCommunication::HandshakeType handShake)
{
switch( handShake )
{
case igstk::SerialCommunication::HandshakeOff:
case igstk::SerialCommunication::HandshakeOn:
this->m_Handshake = handShake;
this->InvokeEvent( HandshakeSetEvent() );
default:
HandshakeSetErrorEvent errorEvt;
std::ostringstream msg;
msg<<"Invalid handshake value ("<<handShake<<")";
errorEvt.Set( msg.str() );
this->InvokeEvent( errorEvt );
}
}
TrackerToolConfiguration::TrackerToolConfiguration()
{
this->m_CalibrationTransform.SetToIdentity(
igstk::TimeStamp::GetLongestPossibleTime());
}
TrackerToolConfiguration::TrackerToolConfiguration(const
TrackerToolConfiguration &other)
{
this->m_CalibrationTransform = other.m_CalibrationTransform;
this->m_ToolName = other.m_ToolName;
}
TrackerToolConfiguration::~TrackerToolConfiguration()
{
}
} // end of name space
|