-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNavigationTestSimulator.cxx
148 lines (127 loc) · 4.1 KB
/
NavigationTestSimulator.cxx
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
/*=========================================================================
Program: BRP Prostate Robot: Testing Simulator (Client)
Language: C++
Copyright (c) Brigham and Women's Hospital. All rights reserved.
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.
Please see
http://wiki.na-mic.org/Wiki/index.php/ProstateBRP_OpenIGTLink_Communication_June_2013
for the detail of the testing protocol.
=========================================================================*/
#include <iostream>
#include <math.h>
#include <cstdlib>
#include "igtlClientSocket.h"
#include "NavigationNormalOperationTest.h"
#include "NavigationStartUpErrorTest.h"
#include "NavigationCalibrationErrorTest.h"
#include "NavigationTargetingWithoutCalibrationTest.h"
#include "NavigationOutOfRangeTest.h"
#include "NavigationStopDuringOperationTest.h"
#include "NavigationEmergencyStopDuringOperationTest.h"
#include "NavigationMoveToWithoutTargetTest.h"
#include "NavigationAccidentalCommandDuringManualModeTest.h"
#include "NavigationHardwareErrorDuringOperationTest.h"
int main(int argc, char* argv[])
{
//------------------------------------------------------------
// Parse Arguments
if (argc != 4) // check number of arguments
{
// If not correct, print usage
std::cerr << "Usage: " << argv[0] << " <hostname> <port> <string>" << std::endl;
std::cerr << " <hostname> : IP or host name" << std::endl;
std::cerr << " <port> : Port # (18944 in Slicer default)" << std::endl;
std::cerr << " <test> : Test # (1-10)" << std::endl;
exit(0);
}
char* hostname = argv[1];
int port = atoi(argv[2]);
int test = atoi(argv[3]);
if (test <= 0 || test > 10)
{
std::cerr << "Invalid test" << std::endl;
exit(0);
}
//------------------------------------------------------------
// Establish Connection
igtl::ClientSocket::Pointer socket;
socket = igtl::ClientSocket::New();
int r = socket->ConnectToServer(hostname, port);
if (r != 0)
{
std::cerr << "Cannot connect to the server." << std::endl;
exit(0);
}
//------------------------------------------------------------
// Call Test
NavigationTestBase* navTest = NULL;
switch (test)
{
case 1:
{
navTest = (NavigationNormalOperationTest*) new NavigationNormalOperationTest();
break;
}
case 2:
{
navTest = (NavigationStartUpErrorTest*) new NavigationStartUpErrorTest();
break;
}
case 3:
{
navTest = (NavigationCalibrationErrorTest*) new NavigationCalibrationErrorTest();
break;
}
case 4:
{
navTest = (NavigationTargetingWithoutCalibrationTest*) new NavigationTargetingWithoutCalibrationTest();
break;
}
case 5:
{
navTest = (NavigationOutOfRangeTest*) new NavigationOutOfRangeTest();
break;
}
case 6:
{
navTest = (NavigationStopDuringOperationTest*) new NavigationStopDuringOperationTest();
break;
}
case 7:
{
navTest = (NavigationEmergencyStopDuringOperationTest*) new NavigationEmergencyStopDuringOperationTest();
break;
}
case 8:
{
navTest = (NavigationMoveToWithoutTargetTest*) new NavigationMoveToWithoutTargetTest();
break;
}
case 9:
{
navTest = (NavigationAccidentalCommandDuringManualModeTest*) new NavigationAccidentalCommandDuringManualModeTest();
break;
}
case 10:
{
navTest = (NavigationHardwareErrorDuringOperationTest*) new NavigationHardwareErrorDuringOperationTest();
break;
}
default:
break;
}
if (navTest)
{
// Set timeout values (ms)
navTest->SetTimeoutShort(1000);
navTest->SetTimeoutMedium(5000);
navTest->SetTimeoutMedium(10000);
navTest->SetSocket(socket);
navTest->Exec();
}
//------------------------------------------------------------
// Close connection
socket->CloseSocket();
}