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

Crash at startup fixed.

parent 68de8d6e
Branches
Tags
No related merge requests found
......@@ -8,7 +8,7 @@
</parent>
<groupId>fr.soleil.device</groupId>
<artifactId>MCCE2Electrometers-${aol}-${mode}</artifactId>
<version>2.2.5-SNAPSHOT</version>
<version>2.2.5</version>
<packaging>nar</packaging>
<name>MCCE2Electrometers</name>
<!-- use for the name of executable -->
......@@ -27,6 +27,10 @@
<artifactId>Electrometers-${aol}-${library}-${mode}</artifactId>
<!-- <version>2.5.15</version> -->
</dependency>
<dependency>
<groupId>fr.soleil.lib</groupId>
<artifactId>YAT4Tango-${aol}-${library}-${mode}</artifactId>
</dependency>
</dependencies>
<scm>
<connection>${scm.connection.svn.tango-ds}/DeviceClasses/MeasureInstruments/MCCE/NovelecElectrometer/trunk</connection>
......
......@@ -75,6 +75,8 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
#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"
......@@ -140,6 +142,13 @@ void MCCE2Electrometers::delete_device()
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();
}
//+----------------------------------------------------------------------------
......@@ -153,6 +162,11 @@ 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;
......@@ -180,7 +194,18 @@ void MCCE2Electrometers::init_device()
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;
......@@ -2240,8 +2265,56 @@ void MCCE2Electrometers::create_electrometers_obj()
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)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment