-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNavigationTestBase.h
More file actions
98 lines (73 loc) · 2.68 KB
/
NavigationTestBase.h
File metadata and controls
98 lines (73 loc) · 2.68 KB
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
/*=========================================================================
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.
=========================================================================*/
#ifndef __NavigationTestBase_h
#define __NavigationTestBase_h
#include "igtlSocket.h"
#include "igtlMath.h"
#include "igtlMessageBase.h"
#include "TestBase.h"
#define DEFULT_TIMEOUT_SHORT 500
#define DEFULT_TIMEOUT_MEDIUM 1000
#define DEFULT_TIMEOUT_LONG 5000
class NavigationTestBase : public TestBase
{
public:
// This type is used to return the check point in the test. The upper 16 bits
// represents the step ID, while the lower 16 bits represents the point ID.
// 0xFFFFFFFE and 0xFFFFFFFF are reserved for UNKOWN FAILURE and SUCCESS.
// Error() function may be used to generate ErrorPointType value.
// To decode ErrorPointType values, use GetStep() and GetPoint().
typedef unsigned int ErrorPointType;
enum {
UNKNOWN_FAILURE = 0xFFFFFFFE,
SUCCESS = 0xFFFFFFFF,
};
int TimeoutShort;
int TimeoutMedium;
int TimeoutLong;
public:
NavigationTestBase();
~NavigationTestBase();
virtual const char* Name()=0;
virtual int Exec();
inline ErrorPointType Error(unsigned short step, unsigned short point)
{
ErrorPointType ret;
ret = step;
ret = (ret << 16) | point;
return ret;
}
inline unsigned short GetStep(ErrorPointType error)
{
unsigned short ret;
ret = error >> 16 & 0xFFFF;
return ret;
}
inline unsigned short GetPoint(ErrorPointType error)
{
unsigned short ret;
ret = error & 0xFFFF;
return ret;
}
// Testing protocol implementation. This must be implemented in a child class.
// Test() returns ErrorPoint data.
virtual ErrorPointType Test() = 0;
// Set/Get timeout values. All timeout values are in millisecond
inline void SetTimeoutShort(int ms) { this->TimeoutShort = ms; }
inline void SetTimeoutMedium(int ms) { this->TimeoutMedium = ms; }
inline void SetTimeoutLong(int ms) { this->TimeoutLong = ms; }
inline int GetTimeoutShort() { return this->TimeoutShort; }
inline int GetTimeoutMedium() { return this->TimeoutMedium; }
inline int GetTimeoutLong() { return this->TimeoutLong; }
protected:
};
#endif //__NavigationTestBase_h