[IGSTK-Users] igstkPolarisTrackerToolTest

Anka Kochanowska anka at bic.mni.mcgill.ca
Wed Oct 15 12:03:40 EDT 2008


Hi!
There are some problems with this test, but really I dom not know what 
is tested:-(
Here is how it could be written, my changes are commented //Anka:


int igstkPolarisTrackerToolTest( int argc, char * argv[] )
{
 
  igstk::RealTimeClock::Initialize();

  typedef igstk::Object::LoggerType   LoggerType;
  typedef itk::StdStreamLogOutput     LogOutputType;

  if( argc < 2 )
    {
    std::cerr << " Usage: " << argv[0] << "\t"
                            << "Type( 0 for Wireless, 1 for Wired ) \t"
                            << "Port Number\t"
                            << "[SROM file]\t"
                            << "[tool Id]\t" << std::endl;
    return EXIT_FAILURE;
    }
  LoggerType::Pointer   logger = LoggerType::New();
  LogOutputType::Pointer logOutput = LogOutputType::New();
  logOutput->SetStream( std::cout );
  logger->AddLogOutput( logOutput );
  logger->SetPriorityLevel( itk::Logger::DEBUG );

  // Create an igstk::VTKLoggerOutput and then test it.
  igstk::VTKLoggerOutput::Pointer vtkLoggerOutput
                                                = 
igstk::VTKLoggerOutput::New();
  vtkLoggerOutput->OverrideVTKWindow();
  vtkLoggerOutput->SetLogger(logger);  // redirect messages from
                                       // VTK OutputWindow -> logger

  typedef igstk::PolarisTrackerTool      TrackerToolType;
  typedef TrackerToolType::TransformType TransformType;
   
  TrackerToolType::Pointer trackerTool = TrackerToolType::New();

  trackerTool->SetLogger( logger );
 
  // Select tracker tool to be wired or wireless
//  if ( argv[0] ) //Anka
  if ( atoi(argv[1]) == 0 )
    {
    trackerTool->RequestSelectWirelessTrackerTool();
    }
  else
    {
    trackerTool->RequestSelectWiredTrackerTool();
    }

  //try setting invalid port number ( the maximum is 11 )
  unsigned int invalidPortNumber = 255;
  trackerTool->RequestSetPortNumber( invalidPortNumber );

  // Set the port number
//  std::istringstream inputstream( argv[1] ); //Anka
  std::istringstream inputstream( argv[2] );
 
  unsigned int portNumber;

  inputstream >> portNumber;

  trackerTool->RequestSetPortNumber( portNumber );


  // Set the SROM filename if specified
  if ( argc >= 3 )
    {
//    std::string sromFile = argv[2]; // Anka
    std::string sromFile = argv[3];
    trackerTool->RequestSetSROMFileName( sromFile );
    }
  else
    {
    // set invalid SROM filename for testing
    std::string invalidSROMFile = "";
    trackerTool->RequestSetSROMFileName( invalidSROMFile );
    }

  // set a tool part number if specified
//  if ( argc >= 4 ) //Anka
  if ( argc > 4 )
    {
//    std::string  partNumber = argv[3]; //Anka
    std::string  partNumber = argv[4];
    trackerTool->RequestSetPartNumber( partNumber );
    }
  else
    {
    std::string invalidPartNumber = "";
    trackerTool->RequestSetPartNumber( invalidPartNumber );

    std::string validPartNumber = "NDI-112-11";
    trackerTool->RequestSetPartNumber( validPartNumber );
    }

  trackerTool->RequestConfigure();

  trackerTool->Print( std::cout );
  return EXIT_SUCCESS;
}



More information about the IGSTK-Users mailing list