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
// ============================================================================
//
// = 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)
{
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;
_is_gpib_proxy_created = false;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
(const char*)"TangoGpibLink::create_gpib_proxy");
}
}
// ============================================================================
// TangoGpibLink::write
// ============================================================================
void TangoGpibLink::write (std::string command_to_send) throw (Tango::DevFailed)
{
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command_in("Write", command_to_send);
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
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
(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)
{
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.";
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
// ============================================================================
// ============================================================================
bool result = false;
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
return result;
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
(const char*)"TangoGpibLink::SRQLineState");
}
}
// ============================================================================
// TangoGpibLink::readStatusByteRegister
// ============================================================================
short TangoGpibLink::readStatusByteRegister (void) throw (Tango::DevFailed)
{
short result = -1;
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->read_attribute("statusByteRegister", result);
return result;
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
// ============================================================================
// TangoGpibLink::clear
// ============================================================================
void TangoGpibLink::clear (void) throw (Tango::DevFailed)
{
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command("Clear");
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
(const char*)"TangoGpibLink::clear");
}
}
// ============================================================================
// TangoGpibLink::trigger
// ============================================================================
void TangoGpibLink::trigger (void) throw (Tango::DevFailed)
{
if(!_is_gpib_proxy_created)
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command("Trigger");
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",