Newer
Older
// ============================================================================
//
// = 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),
{
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;
{
delete _gpib_proxy;
_gpib_proxy = 0;
}
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);
}
catch(Tango::DevFailed& df )
{
description = "Unable to create proxy on : " + _communication_Device_name;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
}
// ============================================================================
// TangoGpibLink::write
// ============================================================================
void TangoGpibLink::write (std::string command_to_send) throw (Tango::DevFailed)
{
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",
(const char*)"TangoGpibLink::write");
}
}
// ============================================================================
// TangoGpibLink::read
// ============================================================================
std::string TangoGpibLink::read (void) throw (Tango::DevFailed)
{
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)
{
this->_gpib_proxy->command_inout("WriteRead", command_to_send, response);
description = "Unable to write command : " + command_to_send + " and read device response.";
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
// ============================================================================
// ============================================================================
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
}
// ============================================================================
// TangoGpibLink::readStatusByteRegister
// ============================================================================
short TangoGpibLink::readStatusByteRegister (void) throw (Tango::DevFailed)
{
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->read_attribute("statusByteRegister", result);
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
// ============================================================================
// TangoGpibLink::clear
// ============================================================================
void TangoGpibLink::clear (void) throw (Tango::DevFailed)
{
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command("Clear");
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
}
// ============================================================================
// TangoGpibLink::trigger
// ============================================================================
void TangoGpibLink::trigger (void) throw (Tango::DevFailed)
{
create_gpib_proxy();
try
{
//- try
this->_gpib_proxy->command("Trigger");
}
catch(Tango::DevFailed& df )
{
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",