Newer
Older
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// ============================================================================
//
// = CONTEXT
// TANGO Project - Keithley Electrometer Support Library
//
// = FILENAME
// TangoGpibLink.cpp
//
// = AUTHOR
// X. Elattaoui
//
// ============================================================================
// ============================================================================
// DEPENDENCIES
// ============================================================================
#include <string>
#include <iostream>
#include "TangoGpibLink.h"
// ============================================================================
// TangoGpibLink::TangoGpibLink
// ============================================================================
TangoGpibLink::TangoGpibLink (std::string& gpib_device_name)
: CommunicationLink(gpib_device_name),
_gpib_proxy (0),
_is_gpib_proxy_created (false)
{
std::cout << "TangoGpibLink::TangoGpibLink <-" << std::endl;
response.erase();
std::cout << "TangoGpibLink::TangoGpibLink ->" << std::endl;
}
// ============================================================================
// TangoGpibLink::~TangoGpibLink
// ============================================================================
TangoGpibLink::~TangoGpibLink (void)
{
std::cout << "TangoGpibLink::~TangoGpibLink <-" << std::endl;
if(_is_gpib_proxy_created)
{
delete _gpib_proxy;
_gpib_proxy = 0;
_is_gpib_proxy_created = false;
}
std::cout << "TangoGpibLink::~TangoGpibLink ->" << std::endl;
}
// ============================================================================
// TangoGpibLink::create_gpib_proxy
// ============================================================================
void TangoGpibLink::create_gpib_proxy (void) throw (Tango::DevFailed)
{
TangoSys_OMemStream description;
try
{
//- try
this->_gpib_proxy = new Tango::DeviceProxyHelper(_communication_Device_name);
_is_gpib_proxy_created = true;
}
catch(Tango::DevFailed& df )
{
description << "Unable to create proxy on : " << _communication_Device_name << ends;
_is_gpib_proxy_created = false;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.str(),
(const char*)"TangoGpibLink::create_gpib_proxy");
}
}
// ============================================================================
// TangoGpibLink::write
// ============================================================================
void TangoGpibLink::write (std::string command_to_send) throw (Tango::DevFailed)
{
TangoSys_OMemStream description;
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command_in("Write", command_to_send);
}
catch(Tango::DevFailed& df )
{
description << "Unable to write command : " << command_to_send << ends;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.str(),
(const char*)"TangoGpibLink::write");
}
}
// ============================================================================
// TangoGpibLink::read
// ============================================================================
std::string TangoGpibLink::read (void) throw (Tango::DevFailed)
{
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command_out("Read", this->response);
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
(const char*)"Unable to perform a read operation",
(const char*)"TangoGpibLink::read");
}
return this->response ;
}
// ============================================================================
// TangoGpibLink::write_read
// ============================================================================
std::string TangoGpibLink::write_read (std::string command_to_send) throw (Tango::DevFailed)
{
TangoSys_OMemStream description;
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command_inout("WriteRead", command_to_send, response);
return this->response;
}
catch(Tango::DevFailed& df )
{
description << "Unable to write command : " << command_to_send << " and read device response." << ends;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.str(),
(const char*)"TangoGpibLink::write_read");
}
}
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// ============================================================================
// TangoGpibLink::isSRQLineUp
// ============================================================================
bool TangoGpibLink::isSRQLineUp (void) throw (Tango::DevFailed)
{
TangoSys_OMemStream description;
bool result = false;
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->read_attribute("isSRQLineAsserted", result);
return result;
}
catch(Tango::DevFailed& df )
{
description << "Unable to get Gpib SRQ line state." << ends;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.str(),
(const char*)"TangoGpibLink::isSRQLineUp");
}
}
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// ============================================================================
// TangoGpibLink::clear
// ============================================================================
void TangoGpibLink::clear (void) throw (Tango::DevFailed)
{
TangoSys_OMemStream description;
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command("Clear");
}
catch(Tango::DevFailed& df )
{
description << "Unable send Clear Device command." << ends;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.str(),
(const char*)"TangoGpibLink::clear");
}
}
// ============================================================================
// TangoGpibLink::trigger
// ============================================================================
void TangoGpibLink::trigger (void) throw (Tango::DevFailed)
{
TangoSys_OMemStream description;
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command("Trigger");
}
catch(Tango::DevFailed& df )
{
description << "Unable send Trigger command." << ends;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.str(),
(const char*)"TangoGpibLink::clear");
}
}