7 #include "PlusConfigure.h" 8 #include "vtksys/CommandLineArguments.hxx" 10 #include "vtkSmartPointer.h" 11 #include "vtkCommand.h" 12 #include "vtkCallbackCommand.h" 14 void PrintLogsCallback(vtkObject* obj,
unsigned long eid,
void* clientdata,
void* calldata);
17 int main(
int argc,
char **argv)
21 bool printHelp(
false);
23 vtksys::CommandLineArguments args;
24 args.Initialize(argc, argv);
26 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
28 args.AddArgument(
"--device-name", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &
deviceName,
"Name of the OpenHaptics device to connect");
29 args.AddArgument(
"--frame-rate", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &frameRate,
"Requested acquisition frame rate (in FPS, default = 30)");
30 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
31 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
35 std::cerr <<
"Problem parsing arguments" << std::endl;
36 std::cout <<
"\n\nvtkPlusOpenHapticsDeviceTest help:" << args.GetHelp() << std::endl;
44 std::cout <<
"\n\nvtkPlusOpenHapticsDeviceTest help:" << args.GetHelp() << std::endl;
48 vtkSmartPointer<vtkPlusOpenHapticsDevice> openHapticsDevice = vtkSmartPointer<vtkPlusOpenHapticsDevice>::New();
50 openHapticsDevice->SetAcquisitionRate(frameRate);
53 vtkSmartPointer<vtkCallbackCommand> callbackCommand = vtkSmartPointer<vtkCallbackCommand>::New();
55 openHapticsDevice->AddObserver(
"WarningEvent", callbackCommand);
56 openHapticsDevice->AddObserver(
"ErrorEvent", callbackCommand);
58 LOG_INFO(
"Initialize...");
62 LOG_ERROR(
"Unable to connect to device");
66 LOG_INFO(
"Start recording...");
69 LOG_ERROR(
"Unable to connect to device");
74 openHapticsDevice->StopRecording();
75 openHapticsDevice->Disconnect();
76 LOG_INFO(
"Exit successfully");
83 if (eid == vtkCommand::GetEventIdFromString(
"WarningEvent"))
85 LOG_WARNING((
const char*)calldata);
87 else if (eid == vtkCommand::GetEventIdFromString(
"ErrorEvent"))
89 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)