Skip to content
Snippets Groups Projects
Commit 67b4cc0b authored by Jade PHAM's avatar Jade PHAM
Browse files

Correction de crash in case equipment not connected

parent 76644752
Branches
Tags
No related merge requests found
......@@ -214,11 +214,6 @@ void LoCuM_4::delete_device()
// Delete device allocated objects
_proxyDevice.reset();
/*if( _proxyDevice )
{
delete _proxyDevice;
_proxyDevice = 0;
}*/
DELETE_SCALAR_ATTRIBUTE(attr_gain_read);
......@@ -238,6 +233,7 @@ void LoCuM_4::init_device()
DEBUG_STREAM << "LoCuM_4::init_device() create device " << device_name << endl;
/*----- PROTECTED REGION ID(LoCuM_4::init_device_before) ENABLED START -----*/
set_state(Tango::INIT);
_isInited = false;
// Initialization before get_device_property() call
//- initialize the inner appender (first thing to do)
try
......@@ -292,8 +288,17 @@ void LoCuM_4::init_device()
{
set_state(Tango::ON);
configure();
if (_response=="")
{
set_state( Tango::FAULT);
set_status("Initialization failed - could not communicate with Locum!");
return;
}
restore_saved_properties();
}
_isInited =true;
DEBUG_STREAM << "LoCuM_4::init_device() END " << endl;
/*----- PROTECTED REGION END -----*/ // LoCuM_4::init_device
}
......@@ -444,7 +449,8 @@ void LoCuM_4::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
{
DEBUG_STREAM << "LoCuM_4::read_attr_hardware(vector<long> &attr_list) entering... " << endl;
/*----- PROTECTED REGION ID(LoCuM_4::read_attr_hardware) ENABLED START -----*/
if (!_isInited)
return;
// get current Locum config
this->get_config();
......@@ -555,7 +561,8 @@ Tango::DevState LoCuM_4::dev_state()
{
DEBUG_STREAM << "LoCuM_4::State() - " << device_name << endl;
/*----- PROTECTED REGION ID(LoCuM_4::dev_state) ENABLED START -----*/
if (!_isInited)
return get_state();
Tango::DevState argout = Tango::UNKNOWN; // replace by your own algorithm
// Add your own code
if (!_proxyDevice)
......@@ -629,6 +636,9 @@ Tango::ConstDevString LoCuM_4::dev_status()
{
DEBUG_STREAM << "LoCuM_4::Status() - " << device_name << endl;
/*----- PROTECTED REGION ID(LoCuM_4::dev_status) ENABLED START -----*/
if (!_isInited)
return Tango::DeviceImpl::dev_status();
std::string status = _dev_status;
/*----- PROTECTED REGION END -----*/ // LoCuM_4::dev_status
......@@ -679,11 +689,6 @@ Tango::DevString LoCuM_4::send_locum4_command(Tango::DevString argin)
DEBUG_STREAM << "LoCuM_4::SendLocum4Command() - " << device_name << endl;
/*----- PROTECTED REGION ID(LoCuM_4::send_locum4_command) ENABLED START -----*/
// Add your own code
// 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 << "LoCuM_4::send_locum4_command(): entering... !" << endl;
......@@ -836,12 +841,13 @@ std::string LoCuM_4::write_read(std::string cmd_to_send,bool reading_expected)
{
try
{
DEBUG_STREAM << "LoCuM_4::write_read:: cmd : " << cmd_to_send << std::endl;
if (reading_expected)
{
//- send command
_proxyDevice->command_inout("WriteRead", cmd_to_send.c_str(), resp);
DEBUG_STREAM << "LoCuM_4::write_read:: anwser: " << resp << std::endl;
}
else
{
......@@ -849,8 +855,8 @@ std::string LoCuM_4::write_read(std::string cmd_to_send,bool reading_expected)
_proxyDevice->command_in("Write", cmd_to_send.c_str());
}
DEBUG_STREAM << "LoCuM_4::write_read:: cmd : " << cmd_to_send << std::endl;
DEBUG_STREAM << "LoCuM_4::write_read:: anwser: " << resp << std::endl;
return std::string(resp);
......@@ -861,7 +867,7 @@ std::string LoCuM_4::write_read(std::string cmd_to_send,bool reading_expected)
ERROR_STREAM << df << std::endl;
set_state(Tango::UNKNOWN);
set_status("No communication with proxy device");
set_status("Error in communication with Locum_4");
_proxyDevice.reset();
return "";
......@@ -897,13 +903,19 @@ std::string LoCuM_4::write_read(std::string cmd_to_send,bool reading_expected)
if(reading_expected)
{
long readMode = 2; //- SL_LINE : waits for LF (newline set in device Serial)
try
{
_proxyDevice->command_inout("DevSerReadString",readMode,resp);
}
catch(Tango::DevFailed &df)
{
ERROR_STREAM << df << std::endl;
_DEV_TRY_REACTION(
_proxyDevice->command_inout("DevSerReadString",readMode,resp),
"read the command _response",
"LoCuM_4::write_read",
set_state(Tango::FAULT);
);
set_state(Tango::UNKNOWN);
set_status("Error in communication with Locum_4");
return "";
}//end catch
}
set_state(Tango::ON);
......@@ -1010,7 +1022,10 @@ void LoCuM_4::configure()
DEBUG_STREAM << "LoCuM_4::configure" << std::endl;
//- get locum config
this->get_config();
if (_response=="")
{
return;
}
//- check that range == 1000, S2_value2 == Minus (BIAS voltage source) and HV_value3 == ON
double range = this->get_range(this->_response);
......@@ -1059,6 +1074,12 @@ double LoCuM_4::get_range(std::string config)
std::string range("");
int index_underscore,index_comma;
if (config=="")
{
ERROR_STREAM<<"No anwser from Locum"<<endl;
return 0;
}
// config string like "S1_100�A,S2_Plus,HV_OFF,Ext_OFF,Bias+_ON,Auto_OFF,"
index_underscore = config.find_first_of("_",0);
......@@ -1094,8 +1115,7 @@ double LoCuM_4::get_range(std::string config)
int c = '0';
while (::isdigit((unsigned char)c) && i < range.size())
c = range[++i];
//-DEBUG_STREAM << "LoCuM_4::get_range::range token:first non-digit char" << c << std::endl;
//-DEBUG_STREAM << "LoCuM_4::get_range::range token:first non-digit char location" << i << std::endl;
if (c != 'm' && c != 'n' && c != 'p')
{
c = 'u';
......
......@@ -327,7 +327,7 @@ private:
bool _biasDefinedOk; //- true if bias property is properly defined
bool _biasSetAtInit; //- true if bias value set at init
bool _isEthernet;
bool _isInited;
Tango::DevVarCharArray * _lf;
//Tango::DeviceProxyHelper * _proxyDevice;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment