7 #include "PlusConfigure.h" 8 #include "vtkCallbackCommand.h" 9 #include "vtkCommand.h" 11 #include "vtkSmartPointer.h" 13 #include "vtksys/CommandLineArguments.hxx" 14 #include "vtksys/SystemTools.hxx" 15 #include "igtlOSUtil.h" 17 void PrintLogsCallback(vtkObject* obj,
unsigned long eid,
void* clientdata,
void* calldata);
19 int main(
int argc,
char** argv)
22 bool printHelp(
false);
23 std::string inputConfigFileName =
"Testing/PlusDeviceSet_DataCollectionOnly_GenericSensor.xml";
25 vtksys::CommandLineArguments args;
26 args.Initialize(argc, argv);
28 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
29 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
30 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
31 args.AddArgument(
"--config-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputConfigFileName,
"Config file containing the device configuration.");
35 std::cerr <<
"Problem parsing arguments" << std::endl;
36 std::cout <<
"\n\nHelp:" << args.GetHelp() << std::endl;
44 std::cout <<
"\n\nHelp:" << args.GetHelp() << std::endl;
48 vtkNew<vtkPlusGenericSensorTracker> sensorTracker;
49 sensorTracker->SetDeviceId(
"TrackerDevice");
50 if (!vtksys::SystemTools::FileExists(inputConfigFileName))
52 LOG_ERROR(
"Bad configuration file: " << inputConfigFileName);
56 LOG_DEBUG(
"Reading config file: " << inputConfigFileName);
57 auto* configRead = vtkXMLUtilities::ReadElementFromFile(inputConfigFileName.c_str());
61 LOG_ERROR(
"Failed to read configuration file");
65 LOG_TRACE(
"Config file: " << *configRead);
66 if (sensorTracker->ReadConfiguration(configRead) !=
PLUS_SUCCESS)
68 LOG_ERROR(
"Failed to read configuration");
72 sensorTracker->CreateDefaultOutputChannel(NULL,
true);
75 vtkNew<vtkCallbackCommand> callbackCommand;
77 sensorTracker->AddObserver(
"WarningEvent", callbackCommand);
78 sensorTracker->AddObserver(
"ErrorEvent", callbackCommand);
80 sensorTracker->StartRecording();
82 sensorTracker->StopRecording();
84 LOG_INFO(
"Exit successfully");
92 if (eid == vtkCommand::GetEventIdFromString(
"WarningEvent"))
94 LOG_WARNING((
const char*)calldata);
96 else if (eid == vtkCommand::GetEventIdFromString(
"ErrorEvent"))
98 LOG_ERROR((
const char*)calldata);
int main(int argc, char **argv)
static vtkIGSIOLogger * Instance()
void PrintLogsCallback(vtkObject *obj, unsigned long eid, void *clientdata, void *calldata)