Code owners
Assign users and groups as approvers for specific file changes. Learn more.
MCCE2Electrometers.cpp 86.87 KiB
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/NovelecElectro/src/MCCE2Electrometers.cpp,v 1.31 2012-11-14 13:24:22 xavela Exp $";
//+=============================================================================
//
// file : MCCE2Electrometers.cpp
//
// description : C++ source for the MCCE2Electrometers and its commands.
// The class is derived from Device. It represents the
// CORBA servant object which will be accessed from the
// network. All commands which can be executed on the
// MCCE2Electrometers are implemented in this file.
//
// project : TANGO Device Server
//
// $Author: xavela $
//
// $Revision: 1.31 $
//
// $Log: not supported by cvs2svn $
// Revision 1.26 2012/07/03 06:17:54 xavela
// bug at init fixed.
//
// Revision 1.25 2012/04/10 08:42:33 xavela
// std::cout commented !
//
//
// copyleft : European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
//===================================================================
//
// The following table gives the correspondence
// between commands and method name.
//
// Command name | Method name
// ----------------------------------------
// State | dev_state()
// Status | dev_status()
// RangeUP | range_up()
// RangeDOWN | range_down()
// SetZeroVFFunction | set_zero_vffunction()
// SetOffsetZeroV1Function | set_offset_zero_v1_function()
// SetLeakageZeroV2Function | set_leakage_zero_v2_function()
// SetTestFunction | set_test_function()
// SetMeasureFunction | set_measure_function()
// MCCE2_ON | mcce2__on()
// MCCE2_OFF | mcce2__off()
// Local | local()
// Remote | remote()
// Reset | reset()
// ClearRegisters | clear_registers()
// GetRange | get_range()
// SetRange | set_range()
// GetMode | get_mode()
// GetPolarity | get_polarity()
// SetPolarity | set_polarity()
// GetHzFilter | get_hz_filter()
// SetHzFilter | set_hz_filter()
// GetGain | get_gain()
// SetGain | set_gain()
//
//===================================================================
#include <tango.h>
#include <PogoHelper.h>
#include <Xstring.h>
#include <yat4tango/InnerAppender.h>
#include <yat4tango/YatLogAdapter.h>
#include <MCCE2Electrometers.h>
#include <MCCE2ElectrometersClass.h>
#include "N_PhotoVoltaique.h"
#include "N_PhotoConducteur.h"
const size_t MAX_STRING_LENGTH = 64;
const unsigned short ELETRO_CHANNEL_ONE = 1;
const unsigned short ELETRO_CHANNEL_TWO = 2;
namespace MCCE2Electrometers_ns
{
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::MCCE2Electrometers(string &s)
//
// description : constructor for simulated MCCE2Electrometers
// /home/experiences/diffabs/com-diffabs/DeviceServers/ds_MCCE2Electrometers
// in : - cl : Pointer to the DeviceClass object
// - s : Device name
//
//-----------------------------------------------------------------------------
MCCE2Electrometers::MCCE2Electrometers(Tango::DeviceClass *cl,string &s)
:Tango::Device_4Impl(cl,s.c_str())
{
init_device();
}
MCCE2Electrometers::MCCE2Electrometers(Tango::DeviceClass *cl,const char *s)
:Tango::Device_4Impl(cl,s)
{
init_device();
}
MCCE2Electrometers::MCCE2Electrometers(Tango::DeviceClass *cl,const char *s,const char *d)
:Tango::Device_4Impl(cl,s,d)
{
init_device();
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::delete_device()
//
// description : will be called at device destruction or at init command.
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::delete_device()
{
// Delete device's allocated object
if(this->_electrometerCH1)
{
delete this->_electrometerCH1;
this->_electrometerCH1 = 0;
}
if(this->_electrometerCH2)
{
delete this->_electrometerCH2;
this->_electrometerCH2 = 0;
}
DELETE_DEVSTRING_ATTRIBUTE(attr_range1_read);
DELETE_DEVSTRING_ATTRIBUTE(attr_range2_read);
DELETE_SCALAR_ATTRIBUTE(attr_electrometerChannel_read);
//- release the inner-appender
INFO_STREAM << "Remove the inner-appender." << endl;
yat4tango::InnerAppender::release(this);
INFO_STREAM << "Remove the log-adapter." << endl;
yat4tango::YatLogAdapter::release();
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::init_device()
//
// description : will be called at device initialization.
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::init_device()
{
INFO_STREAM << "MCCE2Electrometers::MCCE2Electrometers() create device " << device_name << endl;
yat4tango::YatLogAdapter::initialize(this);
// Initialize the inner appender.
yat4tango::InnerAppender::initialize(this);
// Initialise variables to default values
//--------------------------------------------
this->_electrometer = 0;
this->_electrometerCH1 = 0;
this->_electrometerCH2 = 0;
this->_missing_property = false;
attr_electrometerChannel_write = ELETRO_CHANNEL_ONE;
this->_updateRange1FromHW = true; //- force update after init.
this->_updateRange2FromHW = true; //- force update after init.
get_device_property();
if ( this->communicationLinkName.empty() )
this->_missing_property = true;
if ( !electrometer1Address && !electrometer2Address )
this->_missing_property = true;
INFO_STREAM << "electrometerTypeChx -> _missing_property = " << _missing_property << std::endl;
CREATE_SCALAR_ATTRIBUTE(attr_electrometerChannel_read);
CREATE_DEVSTRING_ATTRIBUTE(attr_range1_read, MAX_STRING_LENGTH, "Not updated yet.");
CREATE_DEVSTRING_ATTRIBUTE(attr_range2_read, MAX_STRING_LENGTH, "Not updated yet.");
this->_init_done = false;
if( !this->_init_done && !this->_missing_property )
{
INFO_STREAM << "init_device -> create_electrometers_obj : ... " << std::endl;
try
{
create_electrometers_obj();
}
catch(...)
{
FATAL_STREAM << "Device initialization Failed : check logs for more informations.";
set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected : communication caught[...]");
return;
}
}//- end if
INFO_STREAM << "Device up but not completly initialised!" << std::endl;
INFO_STREAM << "this->communicationLinkName = " << this->communicationLinkName << std::endl;
INFO_STREAM << "electrometer1Address = " << electrometer1Address << std::endl;
INFO_STREAM << "electrometer2Address = " << electrometer2Address << std::endl;
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::get_device_property()
//
// description : Read the device properties from database.
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::get_device_property()
{
// Initialize your default values here (if not done with POGO).
//------------------------------------------------------------------
communicationLinkName = "";
electrometer1Address = 0;
electrometer2Address = 0;
// Read device properties from database.(Automatic code generation)
//------------------------------------------------------------------
Tango::DbData dev_prop;
dev_prop.push_back(Tango::DbDatum("CommunicationLinkName"));
dev_prop.push_back(Tango::DbDatum("Electrometer1Address"));
dev_prop.push_back(Tango::DbDatum("Electrometer2Address"));
// Call database and extract values
//--------------------------------------------
if (Tango::Util::instance()->_UseDb==true)
get_db_device()->get_property(dev_prop);
Tango::DbDatum def_prop, cl_prop;
MCCE2ElectrometersClass *ds_class =
(static_cast<MCCE2ElectrometersClass *>(get_device_class()));
int i = -1;
// Try to initialize CommunicationLinkName from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> communicationLinkName;
else {
// Try to initialize CommunicationLinkName from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> communicationLinkName;
}
// And try to extract CommunicationLinkName value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> communicationLinkName;
// Try to initialize Electrometer1Address from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> electrometer1Address;
else {
// Try to initialize Electrometer1Address from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> electrometer1Address;
}
// And try to extract Electrometer1Address value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> electrometer1Address;
// Try to initialize Electrometer2Address from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> electrometer2Address;
else {
// Try to initialize Electrometer2Address from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> electrometer2Address;
}
// And try to extract Electrometer2Address value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> electrometer2Address;
// End of Automatic code generation
//------------------------------------------------------------------
//- Creates default property
Tango::DbData data_put;
if ( dev_prop[0].is_empty() )
{
Tango::DbDatum prop("CommunicationLinkName");
prop << communicationLinkName;
data_put.push_back(prop);
}
if ( dev_prop[1].is_empty() )
{
Tango::DbDatum prop("Electrometer1Address");
prop << electrometer1Address;
data_put.push_back(prop);
}
if ( dev_prop[2].is_empty() )
{
Tango::DbDatum prop("Electrometer2Address");
prop << electrometer2Address;
data_put.push_back(prop);
}
//- write default property if created
if( !data_put.empty() )
get_db_device()->put_property(data_put);
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::always_executed_hook()
//
// description : method always executed before any command is executed
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::always_executed_hook()
{
//- noop
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::read_attr_hardware
//
// description : Hardware acquisition for attributes.
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::read_attr_hardware(vector<long> &attr_list)
{
DEBUG_STREAM << "MCCE2Electrometers::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
// Add your own code here
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::read_range1
//
// description : Extract real attribute values for range1 acquisition result.
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::read_range1(Tango::Attribute &attr)
{
DEBUG_STREAM << "MCCE2Electrometers::read_range1(Tango::Attribute &attr) entering... "<< endl;
if ( !this->_electrometerCH1 )
{
*attr_range1_read = CORBA::string_dup("Not connected");
}
else
{
if ( this->_updateRange1FromHW && *attr_electrometerChannel_read == ELETRO_CHANNEL_ONE )
{
*attr_range1_read = this->get_range();
this->_updateRange1FromHW = false;
}
}
attr.set_value(attr_range1_read);
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::read_range2
//
// description : Extract real attribute values for range2 acquisition result.
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::read_range2(Tango::Attribute &attr)
{
DEBUG_STREAM << "MCCE2Electrometers::read_range2(Tango::Attribute &attr) entering... "<< endl;
if ( !this->_electrometerCH2 )
{
*attr_range2_read = CORBA::string_dup("Not connected");
}
else
{
if ( this->_updateRange2FromHW && *attr_electrometerChannel_read == ELETRO_CHANNEL_TWO )
{
*attr_range2_read = this->get_range();
this->_updateRange2FromHW = false;
}
}
attr.set_value(attr_range2_read);
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::read_electrometerChannel
//
// description : Extract real attribute values for electrometerChannel acquisition result.
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::read_electrometerChannel(Tango::Attribute &attr)
{
DEBUG_STREAM << "MCCE2Electrometers::read_electrometerChannel(Tango::Attribute &attr) entering... "<< endl;
Tango::DevUShort channelNumber = 0;
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::read_electrometerChannel()"
);
}
try
{
*attr_electrometerChannel_read = this->_electrometer->get_ElectroChannel();
attr.set_value(attr_electrometerChannel_read);
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to set the active channel value!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to get the active channel value : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to get the active channel value.",
"MCCE2Electrometers::read_electrometerChannel()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to set the active channel value!");
ERROR_STREAM << "Failed to get the active channel value : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to get the new active channel value!",
"MCCE2Electrometers::read_electrometerChannel()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to get the active channel value : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to set the active channel value!");
throw;
}
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::write_electrometerChannel
//
// description : Write electrometerChannel attribute values to hardware.
//
//-----------------------------------------------------------------------------
void MCCE2Electrometers::write_electrometerChannel(Tango::WAttribute &attr)
{
DEBUG_STREAM << "MCCE2Electrometers::write_electrometerChannel(Tango::WAttribute &attr) entering... "<< endl;
// if ( !this->_electrometer )
// {
// std::string err("There is no electrometer connected or the property\"electrometerTypeCh\" is not set");
// ERROR_STREAM << err << std::endl;
// Tango::Except::throw_exception(
// "MEMORY_ERROR",
// err.c_str(),
// "MCCE2Electrometers::write_electrometerChannel()"
// );
// }
attr.get_write_value(attr_electrometerChannel_write);
if ( attr_electrometerChannel_write == ELETRO_CHANNEL_ONE )
{
this->_electrometer = this->_electrometerCH1;
if ( this->_electrometerCH1 )
{
//- now force update from HW
this->_updateRange1FromHW = true;
}
else
{
WARN_STREAM << "Cannot control electrometer on this channel : seems that nothing is connected on!" << std::endl;
//- warn nothing is connected on this channel
*attr_range1_read = CORBA::string_dup("Not connected");
}
}
else if ( attr_electrometerChannel_write == ELETRO_CHANNEL_TWO )
{
this->_electrometer = this->_electrometerCH2;
if ( this->_electrometerCH2 )
{
//- now force update from HW
this->_updateRange2FromHW = true;
}
else
{
WARN_STREAM << "Cannot control electrometer on this channel : seems that nothing is connected on!" << std::endl;
//- warn nothing is connected on this channel
*attr_range2_read = CORBA::string_dup("Not connected");
}
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::range_up
*
* description: method to execute "RangeUP"
* Up the range of the electrometer.
* Throw :
* - electrometer::ElectrometerException if the range limit is reached
* - Tango::DevFailed if the command cannot be performed
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::range_up()
{
DEBUG_STREAM << "MCCE2Electrometers::range_up(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::range_up()"
);
}
try
{
this->_electrometer->range_up();
//- update range attr from hardware
if ( *attr_electrometerChannel_read == ELETRO_CHANNEL_ONE)
this->_updateRange1FromHW = true;
else if ( *attr_electrometerChannel_read == ELETRO_CHANNEL_TWO)
this->_updateRange2FromHW = true;
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to up the range!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to up the range : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to up the range.",
"MCCE2Electrometers::range_up()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to up the range!");
ERROR_STREAM << "Failed to up the range : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to up the range!",
"MCCE2Electrometers::range_up()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to up the range : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to up the range!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::range_down
*
* description: method to execute "RangeDOWN"
* Down the range of the electrometer.
* Throw :
* - electrometer::ElectrometerException if the range is negative
* - Tango::DevFailed if the command cannot be performed
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::range_down()
{
DEBUG_STREAM << "MCCE2Electrometers::range_down(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::range_down()"
);
}
try
{
this->_electrometer->range_down();
//- update range attr from hardware
if ( *attr_electrometerChannel_read == ELETRO_CHANNEL_ONE )
this->_updateRange1FromHW = true;
else if ( *attr_electrometerChannel_read == ELETRO_CHANNEL_TWO )
this->_updateRange2FromHW = true;
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to down the range!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to down the range : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to down the range.",
"MCCE2Electrometers::range_down()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to down the range!");
ERROR_STREAM << "Failed to down the range : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to down the range!",
"MCCE2Electrometers::range_down()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to down the range : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to down the range!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_zero_vffunction
*
* description: method to execute "SetZeroVFFunction"
* Enable the Zero V/F MCCE2 mode.
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_zero_vffunction()
{
DEBUG_STREAM << "MCCE2Electrometers::set_zero_vffunction(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_zero_vffunction()"
);
}
try
{
this->_electrometer->set_Zero_VonF_function();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable ZERO V/F function!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable ZERO V/F function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable ZERO V/F function.",
"MCCE2Electrometers::set_zero_vffunction()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable ZERO V/F function!");
ERROR_STREAM << "Failed to enable ZERO V/F function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable ZERO V/F function!",
"MCCE2Electrometers::set_zero_vffunction()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable ZERO V/F function : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable ZERO V/F function!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_offset_zero_v1_function
*
* description: method to execute "SetOffsetZeroV1Function"
* Enable the Offset or Zero V1 MCCE2 mode.
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_offset_zero_v1_function()
{
DEBUG_STREAM << "MCCE2Electrometers::set_offset_zero_v1_function(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_offset_zero_v1_function()"
);
}
try
{
this->_electrometer->set_Offset_ZeroV1_function();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable OFFSET or ZERO V1 function!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable OFFSET or ZERO V1 function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable OFFSET or ZERO V1 function.",
"MCCE2Electrometers::set_offset_zero_v1_function()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable OFFSET or ZERO V1 function!");
ERROR_STREAM << "Failed to enable OFFSET or ZERO V1 function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable OFFSET or ZERO V1 function!",
"MCCE2Electrometers::set_offset_zero_v1_function()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable OFFSET or ZERO V1 function : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable OFFSET or ZERO V1 function!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_leakage_zero_v2_function
*
* description: method to execute "SetLeakageZeroV2Function"
* Enable the Leakage or Zero V2 MCCE2 mode.
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_leakage_zero_v2_function()
{
DEBUG_STREAM << "MCCE2Electrometers::set_leakage_zero_v2_function(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_leakage_zero_v2_function()"
);
}
try
{
this->_electrometer->set_Leakage_ZeroV2_function();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable LEAKAGE or ZERO V2 function!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable LEAKAGE or ZERO V2 function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable LEAKAGE or ZERO V2 function.",
"MCCE2Electrometers::set_leakage_zero_v2_function()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable LEAKAGE or ZERO V2 function!");
ERROR_STREAM << "Failed to enable LEAKAGE or ZERO V2 function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable LEAKAGE or ZERO V2 function!",
"MCCE2Electrometers::set_leakage_zero_v2_function()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable LEAKAGE or ZERO V2 function : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable LEAKAGE or ZERO V2 function!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_test_function
*
* description: method to execute "SetTestFunction"
* Enable theTest MCCE2 mode.
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_test_function()
{
DEBUG_STREAM << "MCCE2Electrometers::set_test_function(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_test_function()"
);
}
try
{
this->_electrometer->set_Test_function();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable TEST function!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable TEST function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable TEST function.",
"MCCE2Electrometers::set_test_function()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable TEST function!");
ERROR_STREAM << "Failed to enable TEST function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable TEST function!",
"MCCE2Electrometers::set_test_function()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable TEST function : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable TEST function!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::mcce2__on
*
* description: method to execute "MCCE2_ON"
* Enables the function set. Parameters cannot be set (read only mode).
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::mcce2__on()
{
DEBUG_STREAM << "MCCE2Electrometers::mcce2__on(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::mcce2__on()"
);
}
try
{
this->_electrometer->mcce_on();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable MCCE ON function!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable MCCE ON function : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable MCCE ON function.",
"MCCE2Electrometers::mcce2__on()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable MCCE ON function!");
ERROR_STREAM << "Failed to enable MCCE ON function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable MCCE ON function!",
"MCCE2Electrometers::mcce2__on()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable MCCE2_ON function : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable MCCE ON function!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::mcce2__off
*
* description: method to execute "MCCE2_OFF"
* Disables the function set. Parameters can be changed.
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::mcce2__off()
{
DEBUG_STREAM << "MCCE2Electrometers::mcce2__off(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::mcce2__off()"
);
}
try
{
this->_electrometer->mcce_off();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable MCCE OFF function!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable MCCE OFF function : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable MCCE OFF function.",
"MCCE2Electrometers::mcce2__off()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable MCCE OFF function!");
ERROR_STREAM << "Failed to enable MCCE OFF function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable MCCE OFF function!",
"MCCE2Electrometers::mcce2__off()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable MCCE2_OFF function : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable MCCE OFF function!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::local
*
* description: method to execute "Local"
* Enable local keyboard and Key
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::local()
{
DEBUG_STREAM << "MCCE2Electrometers::local(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::local()"
);
}
try
{
this->_electrometer->local();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable local mode!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable local mode : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable local mode.",
"MCCE2Electrometers::local()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable local mode!");
ERROR_STREAM << "Failed to enable local function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable local mode!",
"MCCE2Electrometers::local()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable local mode : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable local mode!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::remote
*
* description: method to execute "Remote"
* Disable \"MODIFY\" and the \"ON-OFF\" keys
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::remote()
{
DEBUG_STREAM << "MCCE2Electrometers::remote(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::remote()"
);
}
try
{
this->_electrometer->remote();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable remote mode!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable remote mode : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable remote mode.",
"MCCE2Electrometers::remote()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable remote mode!");
ERROR_STREAM << "Failed to enable remote mode : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable remote mode!",
"MCCE2Electrometers::remote()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable remote mode : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable remote mode!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::reset
*
* description: method to execute "Reset"
* Restart the MCCE-2
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::reset()
{
DEBUG_STREAM << "MCCE2Electrometers::reset(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::reset()"
);
}
try
{
this->_electrometer->reset();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to enable reset mode!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to enable reset mode : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to enable reset mode.",
"MCCE2Electrometers::reset()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable reset mode!");
ERROR_STREAM << "Failed to enable reset mode : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable reset mode!",
"MCCE2Electrometers::reset()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable reset mode : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable reset mode!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::clear_registers
*
* description: method to execute "ClearRegisters"
* Clear error(s)
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::clear_registers()
{
DEBUG_STREAM << "MCCE2Electrometers::clear_registers(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::clear_registers()"
);
}
try
{
this->_electrometer->clear_registers();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to clear all errors!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to clear all errors : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to clear all errors.",
"MCCE2Electrometers::clear_registers()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to clear all errors!");
ERROR_STREAM << "Failed to clear all errors : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to clear all errors!",
"MCCE2Electrometers::clear_registers()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to clear errors : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to clear all errors!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::dev_state
*
* description: method to execute "State"
* This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
*
* @return State Code
*
*/
//+------------------------------------------------------------------
Tango::DevState MCCE2Electrometers::dev_state()
{
Tango::DevState argout = Tango::UNKNOWN;
DEBUG_STREAM << "MCCE2Electrometers::dev_state(): entering... !" << endl;
// Add your own code to control device here
try
{
//- check properties
if ( this->_missing_property )
{
argout = Tango::FAULT;
}
//- check device initialization
else if ( !this->_electrometerCH1 && !this->_electrometerCH2 )
{
argout = Tango::FAULT;
}
//- check if an electro is conencted on a channel
else if( attr_electrometerChannel_write == ELETRO_CHANNEL_ONE && !this->_electrometerCH1)
{
argout = Tango::DISABLE;
}
else if( attr_electrometerChannel_write == ELETRO_CHANNEL_TWO && !this->_electrometerCH2)
{
argout = Tango::DISABLE;
}
//- check channel number
else if ( attr_electrometerChannel_write != ELETRO_CHANNEL_ONE && attr_electrometerChannel_write != ELETRO_CHANNEL_TWO )
{
argout = Tango::ALARM;
}
else
{
//- update state
this->_electrometer->electrometer_status();
//- get electrometer state
short tmpState = _electrometer->electrometer_state();
switch(tmpState)
{
case Tango::ON :
argout = Tango::ON;
break;
case Tango::FAULT :
argout = Tango::FAULT;
break;
case Tango::ALARM :
argout = Tango::ALARM;
break;
/*case Tango::UNKNOWN:
default :
argout = Tango::UNKNOWN;
break;*/
}
}
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to get electrometer state!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Cannot perform get electrometer state : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to get electrometer state.",
"MCCE2Electrometers::dev_state()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to get electrometer state!");
ERROR_STREAM << "Failed to get electrometer state : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to get electrometer state!",
"MCCE2Electrometers::dev_state()",
Tango::ERR
);
}
catch(...)
{
set_state(Tango::ALARM);
set_status("Failed to get electrometer state!");
ERROR_STREAM << "Failed to get electrometer state : [...] EXCEPTION " << std::endl;
throw;
}
set_state(argout);
return argout;
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::dev_status
*
* description: method to execute "Status"
* This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
*
* @return Status descrition
*
*/
//+------------------------------------------------------------------
Tango::ConstDevString MCCE2Electrometers::dev_status()
{
DEBUG_STREAM << "MCCE2Electrometers::dev_status(): entering... !" << endl;
//- clear previous status
this->_statusStr.clear();
// Add your own code to control device here
try
{
if ( this->_missing_property )
{
_statusStr = "Device cannot be up while its properties are not set!";
}
//- check device initialization
else if ( !this->_electrometerCH1 && !_electrometerCH2 )
{
_statusStr = "No electrometer connected!";
}
//- check if an electro is connected on a channel
if( attr_electrometerChannel_write == ELETRO_CHANNEL_ONE && !this->_electrometerCH1)
{
_statusStr += "No electrometer on channel ONE!";
}
else if( attr_electrometerChannel_write == ELETRO_CHANNEL_TWO && !this->_electrometerCH2)
{
_statusStr += "No electrometer on channel TWO!";
}
else if ( attr_electrometerChannel_write != ELETRO_CHANNEL_ONE && attr_electrometerChannel_write != ELETRO_CHANNEL_TWO )
{
_statusStr += "Invalid electrometer channel set!";
}
else
{
//- add electrometer status info
_statusStr += this->_electrometer->electrometer_status();
}
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Cannot perform electrometer_status() command.");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Cannot perform electrometer_status() command : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to get electrometer status.",
"MCCE2Electrometers::dev_status()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Cannot perform electrometer_status() command!");
ERROR_STREAM << "Cannot perform electrometer_status() command : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Cannot perform electrometer_status() command!",
"MCCE2Electrometers::dev_status()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable remote mode : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Cannot perform electrometer_status() command : caugth [...] exception.");
throw;
}
set_status( _statusStr.c_str() );
return _statusStr.c_str();
}
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::electrometer_to_tango_exception()
//
// description : Extract real attribute values from
// hardware acquisition result.
//
//-----------------------------------------------------------------------------
Tango::DevFailed MCCE2Electrometers::electrometer_to_tango_exception(const electrometer::ElectrometerException& de)
{
Tango::DevErrorList error_list(de.errors.size());
error_list.length(de.errors.size());
for(unsigned int i = 0; i < de.errors.size(); i++)
{
error_list[i].reason = CORBA::string_dup(de.errors[i].reason.c_str());
error_list[i].desc = CORBA::string_dup(de.errors[i].desc.c_str());
error_list[i].origin = CORBA::string_dup(de.errors[i].origin.c_str());
switch(de.errors[i].severity)
{
case electrometer::WARN:
error_list[i].severity = Tango::WARN;
break;
case electrometer::PANIC:
error_list[i].severity = Tango::PANIC;
break;
case electrometer::ERR:
default:
error_list[i].severity = Tango::ERR;
break;
}
}
return Tango::DevFailed(error_list);
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_measure_function
*
* description: method to execute "SetMeasureFunction"
* Enable the Measure MCCE2 mode.
*
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_measure_function()
{
DEBUG_STREAM << "MCCE2Electrometers::set_measure_function(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_measure_function()"
);
}
try
{
this->_electrometer->set_Measure_function();
}
catch(const electrometer::ElectrometerException& ke)
{
Tango::DevFailed df = electrometer_to_tango_exception(ke);
set_state(Tango::ALARM);
set_status("Failed to enable MEASURE function!");
ERROR_STREAM << "Failed to enable MEASURE function : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable MEASURE function.",
"MCCE2Electrometers::set_measure_function()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to enable MEASURE function!");
ERROR_STREAM << "Failed to enable MEASURE function : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to enable MEASURE function!",
"MCCE2Electrometers::set_measure_function()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to enable MEASURE function : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to enable MEASURE function!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_range
*
* description: method to execute "SetRange"
* Apply the specified argin range, on the electrometer, if well formatted.
* Else an exception is thrown.
*
* @param argin The range to apply on the electrometer
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_range(Tango::DevString argin)
{
DEBUG_STREAM << "MCCE2Electrometers::set_range(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_range()"
);
}
try
{
this->_electrometer->set_ElectroMeterRange(std::string(argin));
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::ALARM);
set_status("Failed to write the range!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to write the range : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to write the range.",
"MCCE2Electrometers::set_range()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::ALARM);
set_status("Failed to write the range!");
ERROR_STREAM << "Failed to write the range : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to write the range!",
"MCCE2Electrometers::set_range()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to set the new range value : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to write the range!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_hz_filter
*
* description: method to execute "SetHzFilter"
* The Cut-off frequency in Hz
*
* @param argin The MCCE2 cut-off frequency in Hz
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_hz_filter(Tango::DevShort argin)
{
DEBUG_STREAM << "MCCE2Electrometers::set_hz_filter(): entering... !" << endl;
std::string dataStr("") ;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_hz_filter()"
);
}
try
{
dataStr = XString<short>::convertToString(argin);
this->_electrometer->set_ElectroMeterFrequency(dataStr);
}
catch(const electrometer::ElectrometerException& ke)
{
Tango::DevFailed df = electrometer_to_tango_exception(ke);
set_state(Tango::ALARM);
set_status("Failed to set the Hz Filter!");
ERROR_STREAM << "Failed to set the Hz Filter : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to set the Hz Filter.",
"MCCE2Electrometers::set_hz_filter()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
ERROR_STREAM << "Failed to set the Hz Filter : DevFailed EXCEPTION -> " << df << std::endl;
set_state(Tango::ALARM);
set_status("Failed to set the Hz Filter!");
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to set the Hz Filter!",
"MCCE2Electrometers::set_hz_filter()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to set the Hz Filter : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to set the Hz Filter!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::get_hz_filter
*
* description: method to execute "GetHzFilter"
* Returns the Cut-off frequency in Hz
*
* @return The MCCE2 cut-off frequency in Hz
*
*/
//+------------------------------------------------------------------
Tango::DevShort MCCE2Electrometers::get_hz_filter()
{
Tango::DevShort argout = 0;
DEBUG_STREAM << "MCCE2Electrometers::get_hz_filter(): entering... !" << endl;
// Add your own code to control device here
std::string dataStr("");
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::get_hz_filter()"
);
}
try
{
dataStr = this->_electrometer->get_ElectroMeterFrequency();
argout = XString<short>::convertFromString(dataStr);
}
catch(const electrometer::ElectrometerException& ke)
{
Tango::DevFailed df = electrometer_to_tango_exception(ke);
set_state(Tango::ALARM);
set_status("Failed to set the Hz Filter!");
ERROR_STREAM << "Failed to read the gain : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to read hzFilter.",
"hzFilterAttrib::get_hz_filter()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
ERROR_STREAM << "Failed to read the Hz Filter : DevFailed EXCEPTION -> " << df << std::endl;
set_state(Tango::ALARM);
set_status("Failed to set the Hz Filter!");
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to read the Hz Filter!",
"MCCE2Electrometers::get_hz_filter()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to read the Hz Filter : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to read the Hz Filter!");
throw;
}
return argout;
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::get_gain
*
* description: method to execute "GetGain"
* Returns the MCCE-2 gain
*
* @return The MCCE2 gain
*
*/
//+------------------------------------------------------------------
Tango::DevShort MCCE2Electrometers::get_gain()
{
Tango::DevShort argout = 0;
DEBUG_STREAM << "MCCE2Electrometers::get_gain(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::get_gain()"
);
}
try
{
std::string dataStr("");
dataStr = this->_electrometer->get_ElectroMeterGain();
argout = XString<short>::convertFromString(dataStr);
}
catch(const electrometer::ElectrometerException& ke)
{
Tango::DevFailed df = electrometer_to_tango_exception(ke);
set_state(Tango::ALARM);
set_status("Failed to read the gain!");
ERROR_STREAM << "Failed to read the gain : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to read the gain .",
"hzFilterAttrib::get_gain()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
ERROR_STREAM << "Failed to read the gain : DevFailed EXCEPTION -> " << df << std::endl;
set_state(Tango::ALARM);
set_status("Failed to read the gain!");
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to read the gain!",
"MCCE2Electrometers::get_gain()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to read the gain : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to read the gain!");
throw;
}
return argout;
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_gain
*
* description: method to execute "SetGain"
* Sets the new MCCE-2 gain value.
*
* @param argin The new MCCE-2 gain
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_gain(Tango::DevUShort argin)
{
DEBUG_STREAM << "MCCE2Electrometers::set_gain(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_gain()"
);
}
try
{
std::string dataStr("");
dataStr = XString<short>::convertToString(argin);
this->_electrometer->set_ElectroMeterGain(dataStr);
}
catch(const electrometer::ElectrometerException& ke)
{
Tango::DevFailed df = electrometer_to_tango_exception(ke);
set_state(Tango::ALARM);
set_status("Failed to set the gain!");
ERROR_STREAM << "Failed to set the gain : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to set the gain.",
"hzFilterAttrib::set_gain()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
ERROR_STREAM << "Failed to set the gain : DevFailed EXCEPTION -> " << df << std::endl;
set_state(Tango::ALARM);
set_status("Failed to set the gain!");
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to set the the gain!",
"MCCE2Electrometers::set_gain()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to set the gain : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to set the gain!");
throw;
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::get_range
*
* description: method to execute "GetRange"
* Returns the electrometer range.
*
* @return The actual electrometer range
*
*/
//+------------------------------------------------------------------
Tango::DevString MCCE2Electrometers::get_range()
{
// POGO has generated a method core with argout allocation.
// If you would like to use a static reference without copying,
// See "TANGO Device Server Programmer's Manual"
// (chapter : Writing a TANGO DS / Exchanging data)
//------------------------------------------------------------
// Add your own code to control device here
DEBUG_STREAM << "MCCE2Electrometers::get_range(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::get_range()"
);
}
Tango::DevString argout = 0;
try
{
std::string rangeStr("");
rangeStr = this->_electrometer->get_ElectroMeterRange();
argout = new char [rangeStr.size() + 1];
strcpy(argout, rangeStr.c_str());
}
catch(const electrometer::ElectrometerException& ke)
{
if ( argout )
delete [] argout;
Tango::DevFailed df = electrometer_to_tango_exception(ke);
set_state(Tango::ALARM);
set_status("Failed to read the range!");
ERROR_STREAM << "Failed to set read the range : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to read the range.",
"MCCE2Electrometers::get_range()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
if ( argout )
delete [] argout;
set_state(Tango::ALARM);
set_status("Failed to read the range!");
ERROR_STREAM << "Failed to read the range : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to read the range!",
"MCCE2Electrometers::get_range()",
Tango::ERR
);
}
catch(...)
{
if ( argout )
delete [] argout;
ERROR_STREAM << "Failed to read the range : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to read the range!");
throw;
}
return argout;
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::get_mode
*
* description: method to execute "GetMode"
* Returns the electrometer mode which can be one of the following values :
* MEASURE, V/F Zero, OFFSET, LEAKAGE or TEST.
*
* @return The electrometer mode (MEASURE, LEAKAGE ...)
*
*/
//+------------------------------------------------------------------
Tango::DevString MCCE2Electrometers::get_mode()
{
// POGO has generated a method core with argout allocation.
// If you would like to use a static reference without copying,
// See "TANGO Device Server Programmer's Manual"
// (chapter : Writing a TANGO DS / Exchanging data)
//------------------------------------------------------------
DEBUG_STREAM << "MCCE2Electrometers::get_mode(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::get_mode()"
);
}
Tango::DevString argout = 0;
try
{
std::string modeStr = this->_electrometer->get_ElectroMeterMode();
argout = new char [modeStr.size() + 1];
strcpy(argout, modeStr.c_str());
}
catch(const electrometer::ElectrometerException& ke)
{
if ( argout )
delete [] argout;
set_state(Tango::ALARM);
set_status("Failed to read the mode!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to set read the mode : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to read the mode.",
"MCCE2Electrometers::get_mode()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
if ( argout )
delete [] argout;
set_state(Tango::ALARM);
set_status("Failed to read the mode!");
ERROR_STREAM << "Failed to read the mode : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to read the mode!",
"MCCE2Electrometers::get_mode()",
Tango::ERR
);
}
catch(...)
{
if ( argout )
delete [] argout;
ERROR_STREAM << "Failed to read the mode : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to read the mode!");
throw;
}
return argout;
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::get_polarity
*
* description: method to execute "GetPolarity"
* Returns the electrometer polarity, which can be POSITIVE or NEGATIVE.
*
* @return The electrometer polarity
*
*/
//+------------------------------------------------------------------
Tango::DevString MCCE2Electrometers::get_polarity()
{
// POGO has generated a method core with argout allocation.
// If you would like to use a static reference without copying,
// See "TANGO Device Server Programmer's Manual"
// (chapter : Writing a TANGO DS / Exchanging data)
//------------------------------------------------------------
DEBUG_STREAM << "MCCE2Electrometers::get_polarity(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::get_polarity()"
);
}
Tango::DevString argout = 0;
try
{
std::string polarStr = this->_electrometer->get_ElectroMeterPolarity();
argout = new char [polarStr.size() + 1];
strcpy(argout, polarStr.c_str());
}
catch(const electrometer::ElectrometerException& ke)
{
if ( argout )
delete [] argout;
set_state(Tango::ALARM);
set_status("Failed to read the polarity!");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to set read the polarity : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to read the polarity.",
"MCCE2Electrometers::get_polarity()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
if ( argout )
delete [] argout;
set_state(Tango::ALARM);
set_status("Failed to read the polarity!");
ERROR_STREAM << "Failed to read the polarity : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to read the polarity!",
"MCCE2Electrometers::get_polarity()",
Tango::ERR
);
}
catch(...)
{
if ( argout )
delete [] argout;
ERROR_STREAM << "Failed to read the polarity : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to read the polarity!");
throw;
}
return argout;
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::create_electrometers_obj
*
* description: internal method to instanciate electrometer(s) obj
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::create_electrometers_obj()
{
//- instanciate channel 1
if ( !_electrometerCH1 && electrometer1Address )
{
AbstractElectrometerClass* mcce1;
mcce1 = new Novelec_MCCE2(communicationLinkName, electrometer1Address);
mcce1->init_protocol();
Novelec_MCCE2* nMCCE1 = dynamic_cast<Novelec_MCCE2*>(mcce1);
short type1 = 0;
//- find connected Novelec model
try
{
if(nMCCE1)
type1 = nMCCE1->get_electrometer_type();
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected : communication caught[...]");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
FATAL_STREAM << "Failed to find which Novelec type is connected : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to find which Novelec type is connected!",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected!");
FATAL_STREAM << "Failed to find which Novelec type is connected : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to find which Novelec type is connected!",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
catch(...)
{
set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected : communication caught[...]");
FATAL_STREAM << "Failed to find which Novelec type is connected : [...] EXCEPTION " << std::endl;
Tango::Except::throw_exception(
"UNKNOWN_ERROR",
"find which Novelec type is connected! [(...) exception]",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
switch(type1)
{
case 0 :
this->_electrometerCH1 = 0;
break;
case 1 :
case 2 :
case 3 :
// this->_electrometerCH1 = new N_PhotoVoltaique (communicationLinkName, channelNumber, electrometerTypeCh1);
this->_electrometerCH1 = new N_PhotoVoltaique (communicationLinkName, electrometer1Address);
break;
case 4 :
case 5 :
this->_electrometerCH1 = new N_PhotoConducteur(communicationLinkName, electrometer1Address);
break;
default :
FATAL_STREAM << "\nERROR : Electrometers::create_electrometers_obj() -> this " << electrometer1Address << " Novelec type is not supported now!" << endl;
return;
}
if ( mcce1 )
{
delete mcce1;
mcce1 = 0;
}
}
//- instanciate channel 2
if ( !this->_electrometerCH2 && electrometer2Address )
{
AbstractElectrometerClass* mcce2;
mcce2 = new Novelec_MCCE2(communicationLinkName, electrometer2Address);
mcce2->init_protocol();
Novelec_MCCE2* nMCCE2 = dynamic_cast<Novelec_MCCE2*>(mcce2);
short type2 = 0;
if(nMCCE2)
type2 = nMCCE2->get_electrometer_type();
switch(type2)
{
case 0 :
this->_electrometerCH2 = 0;
break;
case 1 :
case 2 :
case 3 :
this->_electrometerCH2 = new N_PhotoVoltaique (communicationLinkName, electrometer2Address);
break;
case 4 :
case 5 :
this->_electrometerCH2 = new N_PhotoConducteur(communicationLinkName, electrometer2Address);
break;
default :
FATAL_STREAM << "\nERROR : Electrometers::create_electrometers_obj() -> this " << electrometer2Address << " Novelec type is not supported now!" << endl;
return;
}
if ( mcce2 )
{
delete mcce2;
mcce2 = 0;
}
}
//- check
if (!this->_electrometerCH1 && !this->_electrometerCH2)
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Cannot build device comm obj!",
"MCCE2Electrometers::create_electrometers_obj()");
}
//- configure MCCE-2 : clear error(s), explicit response, mode MEASURE OFF
bool initCH1 = false;
bool initCH2 = false;
try
{
if ( this->_electrometerCH1 )
{
initCH1 = this->_electrometerCH1->init_protocol();
if ( initCH1 )
this->_electrometerCH1->mcce_init();
INFO_STREAM << "this->_electrometer = this->_electrometerCH1!" << std::endl;
}
else
WARN_STREAM << "WARN : !this->_electrometerCH1" << std::endl;
if ( this->_electrometerCH2 )
{
initCH2 = this->_electrometerCH2->init_protocol();
if ( initCH2 )
this->_electrometerCH2->mcce_init();
INFO_STREAM << "this->_electrometer = this->_electrometerCH2!" << std::endl;
}
//- start with channel one
if ( this->_electrometerCH1 )
{
this->_electrometer = this->_electrometerCH1;
this->_init_done = true;
}
//- if nothing connected on channel one, try with the second one
else if ( this->_electrometerCH2 )
{
this->_electrometer = this->_electrometerCH2;
this->_init_done = true;
}
else
this->_init_done = false;
}
catch(const electrometer::ElectrometerException& ke)
{
Tango::DevFailed df = electrometer_to_tango_exception(ke);
ERROR_STREAM << "Failed to set up the MCCE-2 module for a serial communication : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to set up the MCCE-2 module for a serial communication!",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::FAULT);
set_status("Failed to set up the MCCE-2 module for a serial communication!");
ERROR_STREAM << "Failed to set up the MCCE-2 module for a serial communication : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to set up the MCCE-2 module for a serial communication!",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
catch(...)
{
set_state(Tango::FAULT);
set_status("Failed to set up the MCCE-2 module for a serial communication caught[...]");
ERROR_STREAM << "Failed to set up the MCCE-2 module for a serial communication : [...] EXCEPTION " << std::endl;
Tango::Except::throw_exception(
"UNKNOWN_ERROR",
"Failed to set up the MCCE-2 module for a serial communication! [(...) exception]",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
}
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::set_polarity
*
* description: method to execute "SetPolarity"
* Sets the new electrometer polarity. <Br>
* NOTE : <Br>
* Value must be set in UPPER case !!!
*
* @param argin POSITIVE or NEGATIVE
*
*/
//+------------------------------------------------------------------
void MCCE2Electrometers::set_polarity(Tango::DevString argin)
{
DEBUG_STREAM << "MCCE2Electrometers::set_polarity(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometer )
{
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"Failed to build the electrometer obj : not enough memory!?",
"MCCE2Electrometers::set_polarity()"
);
}
try
{
this->_electrometer->set_ElectroMeterPolarity(argin);
}
catch(const electrometer::ElectrometerException& ke)
{
Tango::DevFailed df = electrometer_to_tango_exception(ke);
set_state(Tango::ALARM);
set_status("Failed to change electrometer polarity!");
ERROR_STREAM << "Failed to change electrometer polarity : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"UNKNOWN_ERROR",
"Failed to change electrometer polarity.",
"hzFilterAttrib::set_polarity()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
ERROR_STREAM << "Failed to change electrometer polarity : DevFailed EXCEPTION -> " << df << std::endl;
set_state(Tango::ALARM);
set_status("Failed to change electrometer polarity!");
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to change electrometer polarity!",
"MCCE2Electrometers::set_polarity()",
Tango::ERR
);
}
catch(...)
{
ERROR_STREAM << "Failed to change electrometer polarity : [...] EXCEPTION " << std::endl;
set_state(Tango::ALARM);
set_status("Failed to change electrometer polarity!");
throw;
}
}
} // namespace