Skip to content
Snippets Groups Projects

[ICATHALES-213] The device must be in FAULT state if something goes wrong...

2 files
+ 128
54
Compare changes
  • Side-by-side
  • Inline

Files

src/SingleShotDIO.cpp 100644 → 100755
+ 119
54
@@ -114,8 +114,8 @@ namespace SingleShotDIO
@@ -114,8 +114,8 @@ namespace SingleShotDIO
out = 0;
out = 0;
}
}
this->set_state(Tango::CLOSE);
set_state(Tango::CLOSE);
this->set_status("The device is not usable");
set_status("The device is not usable");
}
}
@@ -129,38 +129,81 @@ namespace SingleShotDIO
@@ -129,38 +129,81 @@ namespace SingleShotDIO
void SingleShotDIO::init_device()
void SingleShotDIO::init_device()
{
{
INFO_STREAM << "SingleShotDIO::SingleShotDIO() create device " << device_name << endl;
INFO_STREAM << "SingleShotDIO::SingleShotDIO() create device " << device_name << endl;
 
m_is_device_initialized = false;
 
m_status_message.str("");
this->set_state(Tango::UNKNOWN);
set_state(Tango::UNKNOWN);
this->set_status("The device is not initialized");
set_status("The device is not initialized");
//default init
//default init
in = 0;
in = 0;
out = 0;
out = 0;
this->_last_out_value = 0;
_last_out_value = 0;
try
//ctor input acquisition
in = new asl::SingleShotDI();
if(in == 0)
{
{
Tango::Except::throw_exception((const char*)("out of memory"),
//ctor input acquisition
(const char*)("out of memory error"),
in = new asl::SingleShotDI();
(const char*)("SingleShotDIO::init_device"));
}
}
catch(const asl::DAQException& de)
//ctor output acquisition
{
out = new asl::SingleShotDO();
Tango::DevFailed df = daq_to_tango_exception(de);
if(out== 0)
ERROR_STREAM << df<<endl;
 
 
m_status_message << "device initialization failed." << endl;
 
m_status_message << "Origin: " << df.errors[0].origin << endl;
 
m_status_message << "Desc: " << df.errors[0].desc << endl;
 
return;
 
}
 
catch (...)
 
{
 
m_status_message << "device initialization failed." << endl;
 
m_status_message << "Origin: " << "SingleShotDIO::init_device" << endl;
 
m_status_message << "Desc: " << "Failed to create SingleShotDI object" << endl;
 
return;
 
}
 
 
try
{
{
this->delete_device();
//ctor output acquisition
    • le delete_device() n'est plus appelé ! est ce voulu ? si oui, c'était ça donc l'origine du problème?

      • Author Contributor

        le delete_device() n'est plus appelé car si on le garde le device s'arrête (or justement on ne souhaite pas arrêter le device). Quand on rentre dans le catch on passe à FAULT et pour en sortir on sera obligé de faire init() et ainsi le delete_device sera appelé proprement dans ce cas.

      • Please register or sign in to reply
Please register or sign in to reply
Tango::Except::throw_exception((const char*)("out of memory"),
out = new asl::SingleShotDO();
(const char*)("out of memory error"),
}
(const char*)("SingleShotDIO::init_device"));
catch(const asl::DAQException& de)
 
{
 
Tango::DevFailed df = daq_to_tango_exception(de);
 
ERROR_STREAM << df<<endl;
 
 
m_status_message << "device initialization failed." << endl;
 
m_status_message << "Origin: " << df.errors[0].origin << endl;
 
m_status_message << "Desc: " << df.errors[0].desc << endl;
 
return;
 
}
 
catch (...)
 
{
 
m_status_message << "device initialization failed." << endl;
 
m_status_message << "Origin: " << "SingleShotDIO::init_device" << endl;
 
m_status_message << "Desc: " << "Failed to create SingleShotDO object" << endl;
 
return;
}
}
// Initialise variables to default values
// Initialise variables to default values
//--------------------------------------------
//--------------------------------------------
get_device_property();
try
 
{
 
get_device_property();
 
}
 
catch (Tango::DevFailed & df)
 
{
 
ERROR_STREAM << df << std::endl;
 
m_status_message << "Initialization failed - <get_device_property> failed [see device log for details]";
 
return;
 
}
 
catch (...)
 
{
 
ERROR_STREAM << "Initialization failed - unknown <get_device_property> error" << std::endl;
 
m_status_message << "Initialization failed [unknown <get_device_property> error]";
 
return;
 
}
try
try
{
{
@@ -226,27 +269,25 @@ namespace SingleShotDIO
@@ -226,27 +269,25 @@ namespace SingleShotDIO
{
{
Tango::DevFailed df = daq_to_tango_exception(de);
Tango::DevFailed df = daq_to_tango_exception(de);
ERROR_STREAM << df<<endl;
ERROR_STREAM << df<<endl;
this->delete_device();
Tango::Except::re_throw_exception(df,
m_status_message << "device initialization failed ." << endl;
(const char*)("device initialization failed"),
m_status_message << "Origin: " << df.errors[0].origin << endl;
(const char*)("caugth asl::DAQException"),
m_status_message << "Desc: " << df.errors[0].desc << endl;
(const char*)("SingleShotDIO::init_device")
return;
);
}
}
catch(...)
catch(...)
{
{
ERROR_STREAM << "SingleShotDIO::init_device::unknown exception caught"<<std::endl;
ERROR_STREAM << "SingleShotDIO::init_device::unknown exception caught"<<std::endl;
this->delete_device();
m_status_message << "device initialization failed.\n" << endl;
Tango::Except::throw_exception(
m_status_message << "Origin: SingleShotDIO::init_device()" << endl;
(const char*)("device initialization failed"),
m_status_message << "Desc: Unknown exception caugth" << endl;
(const char*)("unknown exception caugth"),
return;
(const char*)("SingleShotDIO::init_device")
);
}
}
this->set_state(Tango::OPEN);
this->set_status("The device is initialized and ready to run");
 
 
m_is_device_initialized = true,
 
set_state(Tango::OPEN);
 
set_status("The device is initialized and ready to run");
}
}
@@ -552,7 +593,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -552,7 +593,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PA");
ls.svalue[0] = CORBA::string_dup("PA");
ls.lvalue[0] = attr_PortA_write;
ls.lvalue[0] = attr_PortA_write;
this->write_port(&ls);
write_port(&ls);
}
}
else
else
{
{
@@ -587,7 +628,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -587,7 +628,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PB");
ls.svalue[0] = CORBA::string_dup("PB");
ls.lvalue[0] = attr_PortB_write;
ls.lvalue[0] = attr_PortB_write;
this->write_port(&ls);
write_port(&ls);
}
}
else
else
Tango::Except::throw_exception(
Tango::Except::throw_exception(
@@ -618,7 +659,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -618,7 +659,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PC");
ls.svalue[0] = CORBA::string_dup("PC");
ls.lvalue[0] = attr_PortC_write;
ls.lvalue[0] = attr_PortC_write;
this->write_port(&ls);
write_port(&ls);
}
}
else
else
Tango::Except::throw_exception(
Tango::Except::throw_exception(
@@ -649,7 +690,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -649,7 +690,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PD");
ls.svalue[0] = CORBA::string_dup("PD");
ls.lvalue[0] = attr_PortD_write;
ls.lvalue[0] = attr_PortD_write;
this->write_port(&ls);
write_port(&ls);
}
}
else
else
Tango::Except::throw_exception(
Tango::Except::throw_exception(
@@ -680,7 +721,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -680,7 +721,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PE");
ls.svalue[0] = CORBA::string_dup("PE");
ls.lvalue[0] = attr_PortE_write;
ls.lvalue[0] = attr_PortE_write;
this->write_port(&ls);
write_port(&ls);
}
}
else
else
Tango::Except::throw_exception(
Tango::Except::throw_exception(
@@ -697,7 +738,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -697,7 +738,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PE");
ls.svalue[0] = CORBA::string_dup("PE");
ls.lvalue[0] = attr_PortE_write;
ls.lvalue[0] = attr_PortE_write;
this->write_port(&ls);
write_port(&ls);
}
}
}
}
else if (attr_name == "PortF")
else if (attr_name == "PortF")
@@ -712,7 +753,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -712,7 +753,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PF");
ls.svalue[0] = CORBA::string_dup("PF");
ls.lvalue[0] = attr_PortF_write;
ls.lvalue[0] = attr_PortF_write;
this->write_port(&ls);
write_port(&ls);
}
}
else
else
Tango::Except::throw_exception(
Tango::Except::throw_exception(
@@ -729,7 +770,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -729,7 +770,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PF");
ls.svalue[0] = CORBA::string_dup("PF");
ls.lvalue[0] = attr_PortF_write;
ls.lvalue[0] = attr_PortF_write;
this->write_port(&ls);
write_port(&ls);
}
}
}
}
else if (attr_name == "PortG")
else if (attr_name == "PortG")
@@ -750,7 +791,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -750,7 +791,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PG");
ls.svalue[0] = CORBA::string_dup("PG");
ls.lvalue[0] = attr_PortG_write;
ls.lvalue[0] = attr_PortG_write;
this->write_port(&ls);
write_port(&ls);
}
}
}
}
else if (attr_name == "PortH")
else if (attr_name == "PortH")
@@ -771,7 +812,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
@@ -771,7 +812,7 @@ void SingleShotDIO::write_attr_hardware(vector<long> &attr_list)
ls.lvalue.length(1);
ls.lvalue.length(1);
ls.svalue[0] = CORBA::string_dup("PH");
ls.svalue[0] = CORBA::string_dup("PH");
ls.lvalue[0] = attr_PortH_write;
ls.lvalue[0] = attr_PortH_write;
this->write_port(&ls);
write_port(&ls);
}
}
}
}
@@ -1620,22 +1661,22 @@ void SingleShotDIO::write_port(const Tango::DevVarLongStringArray *argin)
@@ -1620,22 +1661,22 @@ void SingleShotDIO::write_port(const Tango::DevVarLongStringArray *argin)
case 'E':
case 'E':
value = value;
value = value;
//- reset byte
//- reset byte
this->_last_out_value = this->_last_out_value & 0xFFFFFF00;
_last_out_value = _last_out_value & 0xFFFFFF00;
break;
break;
case 'F':
case 'F':
value = value<<8;
value = value<<8;
//- reset byte
//- reset byte
this->_last_out_value = this->_last_out_value & 0xFFFF00FF;
_last_out_value = _last_out_value & 0xFFFF00FF;
break;
break;
case 'G':
case 'G':
value = value<<16;
value = value<<16;
//- reset byte
//- reset byte
this->_last_out_value = this->_last_out_value & 0xFF00FFFF;
_last_out_value = _last_out_value & 0xFF00FFFF;
break;
break;
case 'H':
case 'H':
value = value<<24;
value = value<<24;
//- reset byte
//- reset byte
this->_last_out_value = this->_last_out_value & 0x00FFFFFF;
_last_out_value = _last_out_value & 0x00FFFFFF;
break;
break;
default:
default:
Tango::Except::throw_exception(
Tango::Except::throw_exception(
@@ -1646,10 +1687,10 @@ void SingleShotDIO::write_port(const Tango::DevVarLongStringArray *argin)
@@ -1646,10 +1687,10 @@ void SingleShotDIO::write_port(const Tango::DevVarLongStringArray *argin)
break;
break;
}//switch
}//switch
//- memorize the value
//- memorize the value
this->_last_out_value = value | _last_out_value;
_last_out_value = value | _last_out_value;
value = this->_last_out_value;
value = _last_out_value;
}//else
}//else
try
try
@@ -1715,4 +1756,28 @@ Tango::DevFailed SingleShotDIO::daq_to_tango_exception(const asl::DAQException&
@@ -1715,4 +1756,28 @@ Tango::DevFailed SingleShotDIO::daq_to_tango_exception(const asl::DAQException&
return Tango::DevFailed(error_list);
return Tango::DevFailed(error_list);
}
}
 
 
//+------------------------------------------------------------------
 
/**
 
* method: SingleShotDIO::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 SingleShotDIO::dev_state()
 
{
 
Tango::DevState argout = DeviceImpl::dev_state();;
 
if(!m_is_device_initialized)
 
{
 
set_state(Tango::FAULT);
 
set_status(m_status_message.str());
 
argout = Tango::FAULT;
 
}
 
 
return argout;
 
}
 
} // namespace
} // namespace
Loading