Skip to content
Snippets Groups Projects
Commit e4628b2c authored by Xavier ELATTAOUI's avatar Xavier ELATTAOUI
Browse files

Added command which returns the connected electrometer type as string.

parent 72fae5d0
Branches
Tags
No related merge requests found
...@@ -230,7 +230,7 @@ Throw : ...@@ -230,7 +230,7 @@ Throw :
<Li><Strong>Argout:<Br>DEV_VOID</Strong> <Li><Strong>Argout:<Br>DEV_VOID</Strong>
: no argout<Br>&nbsp : no argout<Br>&nbsp
<Li><Strong>Command allowed for: </Strong><Ul> <Li><Strong>Command allowed for: </Strong><Ul>
<Li>Tango::ON<Li>Tango::ALARM<Li>Tango::FAULT</Ul> <Li>Tango::ON<Li>Tango::ALARM</Ul>
<Br>&nbsp <Br>&nbsp
</ul><Br> </ul><Br>
<Br> <Br>
...@@ -420,6 +420,20 @@ Value must be set in UPPER case !!!<Br>&nbsp ...@@ -420,6 +420,20 @@ Value must be set in UPPER case !!!<Br>&nbsp
<Br>&nbsp <Br>&nbsp
</ul><Br> </ul><Br>
<Br> <Br>
<A NAME="GetElectrometerTypeStr"><!-- --></A>
<A NAME="GetElectrometerTypeStr"><!-- --></A>
<h2>26 - GetElectrometerTypeStr</h2>
<ul>
<Li><Strong>Description: </Strong> This command returns the connected electrometer type as string for the specified channel.<Br>&nbsp
<Li><Strong>Argin:<Br>DEV_USHORT</Strong>
: channel number<Br>&nbsp
<Li><Strong>Argout:<Br>DEV_STRING</Strong>
: the electrometer type as string<Br>&nbsp
<Li><Strong>Command allowed for: </Strong><Ul>
<Li>Tango::ON<Li>Tango::ALARM<Li>Tango::FAULT<Li>Tango::DISABLE</Ul>
<Br>&nbsp
</ul><Br>
<Br>
<!--- html Footer ---> <!--- html Footer --->
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
<A Href="DevCommands.html#SetHzFilter" TARGET="DevCommands"> SetHzFilter</a><Br> <A Href="DevCommands.html#SetHzFilter" TARGET="DevCommands"> SetHzFilter</a><Br>
<A Href="DevCommands.html#GetGain" TARGET="DevCommands"> GetGain</a><Br> <A Href="DevCommands.html#GetGain" TARGET="DevCommands"> GetGain</a><Br>
<A Href="DevCommands.html#SetGain" TARGET="DevCommands"> SetGain</a><Br> <A Href="DevCommands.html#SetGain" TARGET="DevCommands"> SetGain</a><Br>
<A Href="DevCommands.html#GetElectrometerTypeStr" TARGET="DevCommands"> GetElectrometerTypeStr</a><Br>
</BODY> </BODY>
......
...@@ -94,6 +94,9 @@ Revision: - Author: xavela ...@@ -94,6 +94,9 @@ Revision: - Author: xavela
<Tr><Td><b>SetPolarity</b></Td> <Tr><Td><b>SetPolarity</b></Td>
<Td><Font Size=-1>DEV_STRING</Font></Td> <Td><Font Size=-1>DEV_STRING</Font></Td>
<Td><Font Size=-1>DEV_VOID</Font></Td> <Td><Font Size=-1>DEV_VOID</Font></Td>
<Tr><Td><b>GetElectrometerTypeStr</b></Td>
<Td><Font Size=-1>DEV_USHORT</Font></Td>
<Td><Font Size=-1>DEV_STRING</Font></Td>
......
...@@ -253,6 +253,9 @@ There is no Class properties.<Br><Br> ...@@ -253,6 +253,9 @@ There is no Class properties.<Br><Br>
<Tr><Td><b>SetPolarity</b></Td> <Tr><Td><b>SetPolarity</b></Td>
<Td><Font Size=-1>DEV_STRING</Font></Td> <Td><Font Size=-1>DEV_STRING</Font></Td>
<Td><Font Size=-1>DEV_VOID</Font></Td> <Td><Font Size=-1>DEV_VOID</Font></Td>
<Tr><Td><b>GetElectrometerTypeStr</b></Td>
<Td><Font Size=-1>DEV_USHORT</Font></Td>
<Td><Font Size=-1>DEV_STRING</Font></Td>
...@@ -686,6 +689,20 @@ Value must be set in UPPER case !!!<Br>&nbsp ...@@ -686,6 +689,20 @@ Value must be set in UPPER case !!!<Br>&nbsp
<Br>&nbsp <Br>&nbsp
</ul><Br> </ul><Br>
<Br> <Br>
<A NAME="GetElectrometerTypeStr"><!-- --></A>
<A NAME="GetElectrometerTypeStr"><!-- --></A>
<h2>26 - GetElectrometerTypeStr</h2>
<ul>
<Li><Strong>Description: </Strong> This command returns the connected electrometer type as string for the specified channel.<Br>&nbsp
<Li><Strong>Argin:<Br>DEV_USHORT</Strong>
: channel number<Br>&nbsp
<Li><Strong>Argout:<Br>DEV_STRING</Strong>
: the electrometer type as string<Br>&nbsp
<Li><Strong>Command allowed for: </Strong><Ul>
<Li>Tango::ON<Li>Tango::ALARM<Li>Tango::FAULT<Li>Tango::DISABLE</Ul>
<Br>&nbsp
</ul><Br>
<Br>
</center> </center>
<Br>&nbsp;<Br><Br>&nbsp;<Br> <Br>&nbsp;<Br><Br>&nbsp;<Br>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</parent> </parent>
<groupId>fr.soleil.device</groupId> <groupId>fr.soleil.device</groupId>
<artifactId>MCCE2Electrometers-${aol}-${mode}</artifactId> <artifactId>MCCE2Electrometers-${aol}-${mode}</artifactId>
<version>2.2.6-SNAPSHOT</version> <version>2.2.6</version>
<packaging>nar</packaging> <packaging>nar</packaging>
<name>MCCE2Electrometers</name> <name>MCCE2Electrometers</name>
<!-- use for the name of executable --> <!-- use for the name of executable -->
......
...@@ -68,6 +68,7 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio ...@@ -68,6 +68,7 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
// SetHzFilter | set_hz_filter() // SetHzFilter | set_hz_filter()
// GetGain | get_gain() // GetGain | get_gain()
// SetGain | set_gain() // SetGain | set_gain()
// GetElectrometerTypeStr | get_electrometer_type_str()
// //
//=================================================================== //===================================================================
...@@ -176,6 +177,8 @@ void MCCE2Electrometers::init_device() ...@@ -176,6 +177,8 @@ void MCCE2Electrometers::init_device()
attr_electrometerChannel_write = ELETRO_CHANNEL_ONE; attr_electrometerChannel_write = ELETRO_CHANNEL_ONE;
this->_updateRange1FromHW = true; //- force update after init. this->_updateRange1FromHW = true; //- force update after init.
this->_updateRange2FromHW = true; //- force update after init. this->_updateRange2FromHW = true; //- force update after init.
this->_electroCH1StrType = "Not connected";
this->_electroCH2StrType = "Not connected";
get_device_property(); get_device_property();
...@@ -196,6 +199,7 @@ void MCCE2Electrometers::init_device() ...@@ -196,6 +199,7 @@ void MCCE2Electrometers::init_device()
INFO_STREAM << "init_device -> create_electrometers_obj : ... " << std::endl; INFO_STREAM << "init_device -> create_electrometers_obj : ... " << std::endl;
try try
{ {
//- check connected electrometer(s)
create_electrometers_obj(); create_electrometers_obj();
} }
catch(...) catch(...)
...@@ -481,9 +485,9 @@ void MCCE2Electrometers::write_electrometerChannel(Tango::WAttribute &attr) ...@@ -481,9 +485,9 @@ void MCCE2Electrometers::write_electrometerChannel(Tango::WAttribute &attr)
if ( attr_electrometerChannel_write == ELETRO_CHANNEL_ONE ) if ( attr_electrometerChannel_write == ELETRO_CHANNEL_ONE )
{ {
this->_electrometer = this->_electrometerCH1;
if ( this->_electrometerCH1 ) if ( this->_electrometerCH1 )
{ {
this->_electrometer = this->_electrometerCH1;
//- now force update from HW //- now force update from HW
this->_updateRange1FromHW = true; this->_updateRange1FromHW = true;
} }
...@@ -496,9 +500,9 @@ void MCCE2Electrometers::write_electrometerChannel(Tango::WAttribute &attr) ...@@ -496,9 +500,9 @@ void MCCE2Electrometers::write_electrometerChannel(Tango::WAttribute &attr)
} }
else if ( attr_electrometerChannel_write == ELETRO_CHANNEL_TWO ) else if ( attr_electrometerChannel_write == ELETRO_CHANNEL_TWO )
{ {
this->_electrometer = this->_electrometerCH2;
if ( this->_electrometerCH2 ) if ( this->_electrometerCH2 )
{ {
this->_electrometer = this->_electrometerCH2;
//- now force update from HW //- now force update from HW
this->_updateRange2FromHW = true; this->_updateRange2FromHW = true;
} }
...@@ -2269,20 +2273,23 @@ void MCCE2Electrometers::create_electrometers_obj() ...@@ -2269,20 +2273,23 @@ void MCCE2Electrometers::create_electrometers_obj()
try try
{ {
if(nMCCE1) if(nMCCE1)
{
//- get type as num
type1 = nMCCE1->get_electrometer_type(); type1 = nMCCE1->get_electrometer_type();
//- get type as string
this->_electroCH1StrType = nMCCE1->get_electrometer_typeStr();
}
} }
catch(const electrometer::ElectrometerException& ke) catch(const electrometer::ElectrometerException& ke)
{ {
set_state(Tango::FAULT); set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected : communication caught[...]"); set_status("Failed to find which Novelec type is connected on channel one : communication caught[...]");
Tango::DevFailed df = electrometer_to_tango_exception(ke); Tango::DevFailed df = electrometer_to_tango_exception(ke);
FATAL_STREAM << "Failed to find which Novelec type is connected on channel one : ElectrometerException EXCEPTION -> " << df << std::endl;
FATAL_STREAM << "Failed to find which Novelec type is connected : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR", "COMMUNICATION_ERROR",
"Failed to find which Novelec type is connected!", "Failed to find which Novelec type is connected on channel one!",
"MCCE2Electrometers::create_electrometers_obj()", "MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR Tango::ERR
); );
...@@ -2290,13 +2297,13 @@ void MCCE2Electrometers::create_electrometers_obj() ...@@ -2290,13 +2297,13 @@ void MCCE2Electrometers::create_electrometers_obj()
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
set_state(Tango::FAULT); set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected!"); set_status("Failed to find which Novelec type is connected on channel one!");
FATAL_STREAM << "Failed to find which Novelec type is connected : DevFailed EXCEPTION -> " << df << std::endl; FATAL_STREAM << "Failed to find which Novelec type is connected : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR", "COMMUNICATION_ERROR",
"Failed to find which Novelec type is connected!", "Failed to find which Novelec type is connected on channel one!",
"MCCE2Electrometers::create_electrometers_obj()", "MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR Tango::ERR
); );
...@@ -2304,13 +2311,13 @@ void MCCE2Electrometers::create_electrometers_obj() ...@@ -2304,13 +2311,13 @@ void MCCE2Electrometers::create_electrometers_obj()
catch(...) catch(...)
{ {
set_state(Tango::FAULT); set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected : communication caught[...]"); set_status("Failed to find which Novelec type is connected on channel one : communication caught[...]");
FATAL_STREAM << "Failed to find which Novelec type is connected : [...] EXCEPTION " << std::endl; FATAL_STREAM << "Failed to find which Novelec type is connected on channel one : [...] EXCEPTION " << std::endl;
Tango::Except::throw_exception( Tango::Except::throw_exception(
"UNKNOWN_ERROR", "UNKNOWN_ERROR",
"find which Novelec type is connected! [(...) exception]", "find which Novelec type is connected on channel one! [(...) exception]",
"MCCE2Electrometers::create_electrometers_obj()", "MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR Tango::ERR
); );
...@@ -2350,8 +2357,58 @@ void MCCE2Electrometers::create_electrometers_obj() ...@@ -2350,8 +2357,58 @@ void MCCE2Electrometers::create_electrometers_obj()
mcce2->init_protocol(); mcce2->init_protocol();
Novelec_MCCE2* nMCCE2 = dynamic_cast<Novelec_MCCE2*>(mcce2); Novelec_MCCE2* nMCCE2 = dynamic_cast<Novelec_MCCE2*>(mcce2);
short type2 = 0; short type2 = 0;
try
{
if(nMCCE2) if(nMCCE2)
{
//- get type as num
type2 = nMCCE2->get_electrometer_type(); type2 = nMCCE2->get_electrometer_type();
//- get type as string
this->_electroCH2StrType = nMCCE2->get_electrometer_typeStr();
}
}
catch(const electrometer::ElectrometerException& ke)
{
set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected on channel two : communication caught[...]");
Tango::DevFailed df = electrometer_to_tango_exception(ke);
FATAL_STREAM << "Failed to find which Novelec type is connected on channel two : ElectrometerException EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to find which Novelec type is connected on channel two!",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
catch(Tango::DevFailed& df)
{
set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected on channel two!");
FATAL_STREAM << "Failed to find which Novelec type is connected on channel two : DevFailed EXCEPTION -> " << df << std::endl;
Tango::Except::re_throw_exception(df,
"COMMUNICATION_ERROR",
"Failed to find which Novelec type is connected on channel two!",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
catch(...)
{
set_state(Tango::FAULT);
set_status("Failed to find which Novelec type is connected on channel two : communication caught[...]");
FATAL_STREAM << "Failed to find which Novelec type is connected on channel two : [...] EXCEPTION " << std::endl;
Tango::Except::throw_exception(
"UNKNOWN_ERROR",
"find which Novelec type is connected on channel two! [(...) exception]",
"MCCE2Electrometers::create_electrometers_obj()",
Tango::ERR
);
}
switch(type2) switch(type2)
{ {
...@@ -2381,10 +2438,10 @@ void MCCE2Electrometers::create_electrometers_obj() ...@@ -2381,10 +2438,10 @@ void MCCE2Electrometers::create_electrometers_obj()
//- check //- check
if (!this->_electrometerCH1 && !this->_electrometerCH2) if (!this->_electrometerCH1 && !this->_electrometerCH2)
{ {
ERROR_STREAM << "Not enough memory to create the electrometer obj!" << std::endl; ERROR_STREAM << "No connected electrometer(s) found!" << std::endl;
Tango::Except::throw_exception( Tango::Except::throw_exception(
"MEMORY_ERROR", "MEMORY_ERROR",
"Cannot build device comm obj!", "No connected electrometer(s) found!",
"MCCE2Electrometers::create_electrometers_obj()"); "MCCE2Electrometers::create_electrometers_obj()");
} }
...@@ -2539,4 +2596,53 @@ void MCCE2Electrometers::set_polarity(Tango::DevString argin) ...@@ -2539,4 +2596,53 @@ void MCCE2Electrometers::set_polarity(Tango::DevString argin)
} }
} }
//+------------------------------------------------------------------
/**
* method: MCCE2Electrometers::get_electrometer_type_str
*
* description: method to execute "GetElectrometerTypeStr"
* This command returns the connected electrometer type as string for the specified channel.
*
* @param argin channel number
* @return the electrometer type as string
*
*/
//+------------------------------------------------------------------
Tango::DevString MCCE2Electrometers::get_electrometer_type_str(Tango::DevUShort argin)
{
// 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)
//------------------------------------------------------------
Tango::DevString argout = 0;
DEBUG_STREAM << "MCCE2Electrometers::get_electrometer_type_str(): entering... !" << endl;
// Add your own code to control device here
if ( !this->_electrometerCH1 && !_electrometerCH2 )
{
ERROR_STREAM << "No electrometer connected on both channels!" << std::endl;
Tango::Except::throw_exception(
"MEMORY_ERROR",
"No electrometer connected on both channels!?",
"MCCE2Electrometers::get_electrometer_type_str()"
);
}
if ( *attr_electrometerChannel_read == ELETRO_CHANNEL_ONE )
{
argout = new char[this->_electroCH1StrType.size()+1];
::strncpy(argout, _electroCH1StrType.c_str(), _electroCH1StrType.size());
}
if ( *attr_electrometerChannel_read == ELETRO_CHANNEL_TWO )
{
argout = new char[this->_electroCH2StrType.size()+1];
::strncpy(argout, _electroCH2StrType.c_str(), _electroCH2StrType.size());
}
return argout;
}
} // namespace } // namespace
...@@ -137,7 +137,9 @@ public : ...@@ -137,7 +137,9 @@ public :
/** /**
* The object desctructor. * The object desctructor.
*/ */
~MCCE2Electrometers() {delete_device();}; ~MCCE2Electrometers() {
delete_device();
};
/** /**
* will be called at device destruction or at init command. * will be called at device destruction or at init command.
*/ */
...@@ -283,6 +285,10 @@ public : ...@@ -283,6 +285,10 @@ public :
* Execution allowed for SetGain command. * Execution allowed for SetGain command.
*/ */
virtual bool is_SetGain_allowed(const CORBA::Any &any); virtual bool is_SetGain_allowed(const CORBA::Any &any);
/**
* Execution allowed for GetElectrometerTypeStr command.
*/
virtual bool is_GetElectrometerTypeStr_allowed(const CORBA::Any &any);
/** /**
* This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller. * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
* @return State Code * @return State Code
...@@ -424,6 +430,13 @@ public : ...@@ -424,6 +430,13 @@ public :
* @exception DevFailed * @exception DevFailed
*/ */
void set_gain(Tango::DevUShort); void set_gain(Tango::DevUShort);
/**
* This command returns the connected electrometer type as string for the specified channel.
* @param argin channel number
* @return the electrometer type as string
* @exception DevFailed
*/
Tango::DevString get_electrometer_type_str(Tango::DevUShort);
/** /**
* Read the device properties from database * Read the device properties from database
...@@ -447,6 +460,9 @@ protected : ...@@ -447,6 +460,9 @@ protected :
bool _missing_property; bool _missing_property;
bool _updateRange1FromHW; bool _updateRange1FromHW;
bool _updateRange2FromHW; bool _updateRange2FromHW;
//- electrometer(s) type as string
std::string _electroCH1StrType;
std::string _electroCH2StrType;
std::string read_range_from_hw(); std::string read_range_from_hw();
......
...@@ -64,6 +64,30 @@ __declspec(dllexport) ...@@ -64,6 +64,30 @@ __declspec(dllexport)
namespace MCCE2Electrometers_ns namespace MCCE2Electrometers_ns
{ {
//+----------------------------------------------------------------------------
//
// method : GetElectrometerTypeStrClass::execute()
//
// description : method to trigger the execution of the command.
// PLEASE DO NOT MODIFY this method core without pogo
//
// in : - device : The device on which the command must be executed
// - in_any : The command input data
//
// returns : The command output data (packed in the Any object)
//
//-----------------------------------------------------------------------------
CORBA::Any *GetElectrometerTypeStrClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "GetElectrometerTypeStrClass::execute(): arrived" << endl;
Tango::DevUShort argin;
extract(in_any, argin);
return insert((static_cast<MCCE2Electrometers *>(device))->get_electrometer_type_str(argin));
}
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
// //
// method : SetPolarityClass::execute() // method : SetPolarityClass::execute()
...@@ -763,6 +787,11 @@ void MCCE2ElectrometersClass::command_factory() ...@@ -763,6 +787,11 @@ void MCCE2ElectrometersClass::command_factory()
"The new MCCE-2 gain", "The new MCCE-2 gain",
"no argout", "no argout",
Tango::EXPERT)); Tango::EXPERT));
command_list.push_back(new GetElectrometerTypeStrClass("GetElectrometerTypeStr",
Tango::DEV_USHORT, Tango::DEV_STRING,
"channel number",
"the electrometer type as string",
Tango::OPERATOR));
// add polling if any // add polling if any
for (unsigned int i=0 ; i<command_list.size(); i++) for (unsigned int i=0 ; i<command_list.size(); i++)
......
...@@ -84,6 +84,30 @@ public: ...@@ -84,6 +84,30 @@ public:
//========================================= //=========================================
// Define classes for commands // Define classes for commands
//========================================= //=========================================
class GetElectrometerTypeStrClass : public Tango::Command
{
public:
GetElectrometerTypeStrClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(name,in,out,in_desc,out_desc, level) {};
GetElectrometerTypeStrClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~GetElectrometerTypeStrClass() {};
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<MCCE2Electrometers *>(dev))->is_GetElectrometerTypeStr_allowed(any);}
};
class SetGainCmd : public Tango::Command class SetGainCmd : public Tango::Command
{ {
public: public:
......
...@@ -512,5 +512,19 @@ bool MCCE2Electrometers::is_SetPolarity_allowed(const CORBA::Any &any) ...@@ -512,5 +512,19 @@ bool MCCE2Electrometers::is_SetPolarity_allowed(const CORBA::Any &any)
} }
return true; return true;
} }
//+----------------------------------------------------------------------------
//
// method : MCCE2Electrometers::is_GetElectrometerTypeStr_allowed
//
// description : Execution allowed for GetElectrometerTypeStr command.
//
//-----------------------------------------------------------------------------
bool MCCE2Electrometers::is_GetElectrometerTypeStr_allowed(const CORBA::Any &any)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
} // namespace MCCE2Electrometers_ns } // namespace MCCE2Electrometers_ns
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment