Newer
Older
// ============================================================================
//
// = CONTEXT
// TANGO Project - NovelecElectrometer Support Library
//
// = FILENAME
// Novelec_MCCE2.cpp
//
// = AUTHOR
// X. Elattaoui
//
// ============================================================================
// ============================================================================
// DEPENDENCIES
// ============================================================================
#include <iostream>
#include <sstream>
#include <string>
#include "NovelecProtocol.h"
#include "Novelec_MCCE2.h"
// ============================================================================
// Novelec_MCCE2::Novelec_MCCE2
// ============================================================================
/*Novelec_MCCE2::Novelec_MCCE2 (std::string& comLink_device_name, unsigned short address, unsigned short novTypeNumber)
*/
// ============================================================================
// Novelec_MCCE2::Novelec_MCCE2
// ============================================================================
Novelec_MCCE2::Novelec_MCCE2 (std::string& comLink_device_name, unsigned short address)
: AbstractElectrometerClass(comLink_device_name),
_rangeLimit(0),
_address(address),
_MCCE2electroTypeNumber(0),
_MCCE2electroTypeStr("Unknown type")
{
std::cout << "\t\tNovelec_MCCE2::Novelec_MCCE2 <-" << std::endl;
std::cout << "\t\tNovelec_MCCE2::Novelec_MCCE2 ->" << std::endl;
}
// ============================================================================
// Novelec_MCCE2::~Novelec_MCCE2
// ============================================================================
Novelec_MCCE2::~Novelec_MCCE2 (void)
{
// ============================================================================
// Novelec_MCCE2::init_protocol
// ============================================================================
bool Novelec_MCCE2::init_protocol (void)
std::string description("");
bool success = false;
try
{
//- build the keithley Electrometer protocol obj
_electrometerProtocol = new NovelecProtocol(_device_proxy_name, _address);
success = _electrometerProtocol->build_communicationLink();
//- find electrometer type :
std::string elecTypeStr("");
NovelecProtocol* _pNP = dynamic_cast<NovelecProtocol*>(_electrometerProtocol);
if(_pNP)
elecTypeStr = _pNP->check_electrotype();
//- get the connected electrometer type :
if(_pNP)
this->_MCCE2electroTypeNumber = _pNP->get_electrometerType();
switch(_MCCE2electroTypeNumber)
{
case 1 : this->_MCCE2electroTypeStr = "Photovoltaque UHS";
case 2 : this->_MCCE2electroTypeStr = "Photovoltaque HS";
_rangeLimit = 7;
break;
case 3 : this->_MCCE2electroTypeStr = "Photovoltaque MS";
case 4 : this->_MCCE2electroTypeStr = "Photoconducteur HS";
_rangeLimit = 3;
break;
case 5 : this->_MCCE2electroTypeStr = "Photoconducteur MS";
_rangeLimit = 3;
break;
default : set_electroState(FAULT);
success = false;
Tango::Except::throw_exception ("COMMUNICATION_ERROR",
"Invalid electrometerType returned!",
"Novelec_MCCE2::init_protocol");
}
}
catch(Tango::DevFailed& df)
{
description = "FAILED to create proxy on : " + _device_proxy_name;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.c_str(),
(const char*)"Novelec_MCCE2::init_protocol");
}
catch(...)
{
description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...].";
Tango::Except::throw_exception (
(const char*)"COMMUNICATION_ERROR",
description.c_str(),
(const char*)"Novelec_MCCE2::init_protocol");
}
return success;
}
// ============================================================================
// Novelec_MCCE2::get_ElectroMeterPolarity
// ============================================================================
std::string Novelec_MCCE2::get_ElectroMeterPolarity (void)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::get_ElectroMeterPolarity( ).");
}
// ============================================================================
// Novelec_MCCE2::set_ElectroMeterPolarity
// ============================================================================
void Novelec_MCCE2::set_ElectroMeterPolarity (std::string polarity)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::set_ElectroMeterPolarity( ).");
}
// ============================================================================
// Novelec_MCCE2::set_Zero_VonF_function
// ============================================================================
void Novelec_MCCE2::set_Zero_VonF_function (void)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::set_Zero_VonF_function( ).");
}
// ============================================================================
// Novelec_MCCE2::set_Offset_function
// ============================================================================
void Novelec_MCCE2::set_Offset_ZeroV1_function (void)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::set_Offset_ZeroV1_function( ).");
}
// ============================================================================
// Novelec_MCCE2::set_Leakage_ZeroV2_function
// ============================================================================
void Novelec_MCCE2::set_Leakage_ZeroV2_function (void)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::set_Leakage_ZeroV2_function( ).");
}
// ============================================================================
// Novelec_MCCE2::set_Test_function
// ============================================================================
void Novelec_MCCE2::set_Test_function (void)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::set_Test_function( ).");
}
// ============================================================================
// Novelec_MCCE2::set_Measure_function
// ============================================================================
void Novelec_MCCE2::set_Measure_function (void)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::set_Measure_function( ).");
}
// ============================================================================
// Novelec_MCCE2::mcce_on
// ============================================================================
void Novelec_MCCE2::mcce_on (void)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::mcce_on( ).");
}
// ============================================================================
// Novelec_MCCE2::mcce_off
// ============================================================================
void Novelec_MCCE2::mcce_off (void)
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::mcce_off( ).");
}
// ============================================================================
// Novelec_MCCE2::electrometer_status
// ============================================================================
std::string Novelec_MCCE2::electrometer_status (void)

ELATTAOUI
committed
std::string argout("");
throw electrometer::ElectrometerException("INIT_ERROR",
"Novelec protocol initialization failed.",
"Novelec_MCCE2::electrometer_status( ).");
NovelecProtocol* nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol);
if( !nproto )
throw electrometer::ElectrometerException("BAD_ALLOC",

ELATTAOUI
committed
"Memory allocation failed to query the electrmometer status.",

ELATTAOUI
committed
/***********************************************************************
DISABLED PART TO INCREASE SERIAL PERFORMANCE
***********************************************************************/
argout = "\n\nINFOS :\n";
argout += "----------\n";
argout += "Novelec type : " + this->_MCCE2electroTypeStr + "\n";
//- get Electrometer mode :
argout += "Novelec mode : " + _electrometerProtocol->get_mode() + "\n";
/***********************************************************************/

ELATTAOUI
committed
throw electrometer::ElectrometerException("COMMUNICATION_ERROR",
"Unable to query the electrmometer status.",
"Novelec_MCCE2::electrometer_status( ).");

ELATTAOUI
committed
argout += "\nStatus detail :\n";
argout += "------------------------\n";
//- build novelec status
argout += "Paramtres par defaut\n";
else
argout += "Ram OK\n";
argout += "Paramtre invalide\n";
else
argout += "Paramtre OK\n";
{
argout += "ERREUR\n";
set_electroState(ALARM);
}
else
{
argout += "Pas d'erreur\n";
set_electroState(ON);
}
//- error(s) detail(s)
throw electrometer::ElectrometerException("INTERNAL_ERROR",
"Unable to query the electrmometer errors.",
"Novelec_MCCE2::electrometer_status( ).");
}
argout += "\nError(s) detail(s) :\n";
argout += "------------------------\n";
change_state_to_alarm = false;
}
if(errors & 0x10)
{
argout += "Electromtre bloqu (Polarity error ?)\n";
change_state_to_alarm = false;
}
if(errors & 0x20)
//- set state according to specifications : if "bloqu" or "satur" do not change the state to ALARM !!
if ( change_state_to_alarm )
set_electroState(ALARM);
// ============================================================================
// Novelec_MCCE2::check_range_value
// ============================================================================
short Novelec_MCCE2::check_range_value (const std::string& rgToCheck, const std::string* electroRangeList)
for (unsigned int idx = 0; idx <= _rangeLimit; idx++)
/* DEBUG std::cout << "\t Novelec_MCCE2::check_range_value idx = " << idx
<< " rgToCheck = $" << rgToCheck << "$"
<< " electroRg = $" << electroRg << "$"
if( electroRg.find(rgToCheck) != std::string::npos )
{
//- value is in the list
return idx;
}