-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathChannelAccess.h
80 lines (61 loc) · 1.82 KB
/
ChannelAccess.h
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
#ifndef channelaccess_h
#define channelaccess_h
// Base
#include <cadef.h>
// Local
#include "MCAError.h"
// Wrapper around CAC context
class ChannelAccess
{
public:
// Constructor creates CA context
ChannelAccess() : debug(false)
{
mexPrintf("MCA Initialized\n");
SetDefaultTimeouts();
int status = ca_context_create(ca_enable_preemptive_callback);
if (status != ECA_NORMAL)
MCAError::Error("context_create: %s\n", ca_message(status));
}
// Destructor destroys CA context
virtual ~ChannelAccess()
{
ca_context_destroy();
mexPrintf("MCA Finalized\n");
}
bool debugMode() const
{ return debug; }
void setDebug(bool mode)
{ debug = mode; }
void SetDefaultTimeouts()
{
const double DEFAULT_TIMEOUT = 10.0;
MCA_SEARCH_TIMEOUT = DEFAULT_TIMEOUT;
MCA_GET_TIMEOUT = DEFAULT_TIMEOUT;
MCA_PUT_TIMEOUT = DEFAULT_TIMEOUT;
}
void SetSearchTimeout(double SearchTimeOut )
{ MCA_SEARCH_TIMEOUT = SearchTimeOut; }
double GetSearchTimeout() const
{ return (MCA_SEARCH_TIMEOUT); }
int WaitForSearch() const
{ return ca_pend_io(MCA_SEARCH_TIMEOUT); }
void SetGetTimeout(double GetTimeOut)
{ MCA_GET_TIMEOUT = GetTimeOut; }
double GetGetTimeout() const
{ return MCA_GET_TIMEOUT; }
int WaitForGet() const
{ return ca_pend_io(MCA_GET_TIMEOUT); }
void SetPutTimeout(double PutTimeOut)
{ MCA_PUT_TIMEOUT = PutTimeOut; }
double GetPutTimeout() const
{ return MCA_PUT_TIMEOUT; }
int Flush() const
{ return ca_flush_io(); }
private:
bool debug;
double MCA_SEARCH_TIMEOUT;
double MCA_GET_TIMEOUT;
double MCA_PUT_TIMEOUT;
};
#endif // channelaccess_h