Skip to content
Snippets Groups Projects
Commit 595ee0aa authored by Arafat Nourredine's avatar Arafat Nourredine
Browse files

- Improve MotionControlHelper::Stop in order to call 'Stop' through all motors...

- Improve MotionControlHelper::Stop in order to call 'Stop' through all motors even if an exception occurs
- Remove useless static_cast in throw_exception
- Update /test/main
parent f23e628c
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</parent> </parent>
<groupId>fr.soleil.lib</groupId> <groupId>fr.soleil.lib</groupId>
<artifactId>MotionControlHelper-${aol}-${library}-${mode}</artifactId> <artifactId>MotionControlHelper-${aol}-${library}-${mode}</artifactId>
<version>1.1.0-SNAPSHOT</version> <version>1.1.1-SNAPSHOT</version>
<packaging>nar</packaging> <packaging>nar</packaging>
<name>MotionControlHelper</name> <name>MotionControlHelper</name>
<description>MotionControlHelper library</description> <description>MotionControlHelper library</description>
......
...@@ -98,52 +98,31 @@ double MotionControlAxis::Read() ...@@ -98,52 +98,31 @@ double MotionControlAxis::Read()
{ {
// Exception: extract failed // Exception: extract failed
Tango::Except::throw_exception Tango::Except::throw_exception
( ( "TANGO_DEVICE_ERROR", "unable to extract attributegroup value", "MotionControlAxis::Read");
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unable to extract attributegroup value"),
static_cast<const char*> ("MotionControlAxis::Read()")
);
} }
} }
else else
{ {
// Exception: invalid list size // Exception: invalid list size
Tango::Except::throw_exception Tango::Except::throw_exception
( ( "TANGO_DEVICE_ERROR", "unexpected attributegroup reply list size", "MotionControlAxis::Read");
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unexpected attributegroup reply list size"),
static_cast<const char*> ("MotionControlAxis::Read()")
);
} }
} }
else else
{ {
// Exception: attribute groupe read failed // Exception: attribute groupe read failed
Tango::Except::throw_exception Tango::Except::throw_exception
( ( "TANGO_DEVICE_ERROR", "attributegroup read has failed", "MotionControlAxis::Read");
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("attributegroup read has failed"),
static_cast<const char*> ("MotionControlAxis::Read()")
);
} }
} }
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, "TANGO_DEVICE_ERROR", string(df.errors[0].desc).c_str(), "MotionControlAxis::Read" );
Tango::Except::re_throw_exception(df,
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (string(df.errors[0].desc).c_str()),
static_cast<const char*> ("MotionControlAxis::Read()"));
} }
catch (...) catch (...)
{ {
// Exception // Exception
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "unhandled exception", "MotionControlAxis::Read");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unhandled exception"),
static_cast<const char*> ("MotionControlAxis::Read()")
);
} }
return m_readValue; return m_readValue;
...@@ -163,19 +142,11 @@ Tango::DevDouble MotionControlAxis::ReadW() ...@@ -163,19 +142,11 @@ Tango::DevDouble MotionControlAxis::ReadW()
} }
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df, "TANGO_DEVICE_ERROR", string(df.errors[0].desc).c_str(), "MotionControlAxis::ReadW" );
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (string(df.errors[0].desc).c_str()),
static_cast<const char*> ("MotionControlAxis::ReadW()"));
} }
catch (...) catch (...)
{ {
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "unhandled exception", "MotionControlAxis::Read");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unhandled exception"),
static_cast<const char*> ("MotionControlAxis::ReadW()")
);
} }
return value; return value;
...@@ -222,19 +193,11 @@ Tango::DevState MotionControlAxis::State(void) ...@@ -222,19 +193,11 @@ Tango::DevState MotionControlAxis::State(void)
} }
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df, "TANGO_DEVICE_ERROR", string(df.errors[0].desc).c_str(), "MotionControlAxis::Read" );
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (string(df.errors[0].desc).c_str()),
static_cast<const char*> ("MotionControlAxis::Read()"));
} }
catch (...) catch (...)
{ {
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "unhandled exception", "MotionControlAxis::State");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unhandled exception"),
static_cast<const char*> ("MotionControlAxis::State()")
);
} }
return state; return state;
...@@ -257,19 +220,11 @@ string MotionControlAxis::Status(void) ...@@ -257,19 +220,11 @@ string MotionControlAxis::Status(void)
} }
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df, "TANGO_DEVICE_ERROR", string(df.errors[0].desc).c_str(), "MotionControlAxis::Status");
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (string(df.errors[0].desc).c_str()),
static_cast<const char*> ("MotionControlAxis::Status()"));
} }
catch (...) catch (...)
{ {
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "unhandled exception", "MotionControlAxis::State");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unhandled exception"),
static_cast<const char*> ("MotionControlAxis::Status()")
);
} }
return status; return status;
...@@ -287,19 +242,11 @@ void MotionControlAxis::Stop() ...@@ -287,19 +242,11 @@ void MotionControlAxis::Stop()
} }
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df, "TANGO_DEVICE_ERROR", string(df.errors[0].desc).c_str(), "MotionControlAxis::Stop" );
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (string(df.errors[0].desc).c_str()),
static_cast<const char*> ("MotionControlAxis::Stop()"));
} }
catch (...) catch (...)
{ {
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "unhandled exception", "MotionControlAxis::Stop");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unhandled exception"),
static_cast<const char*> ("MotionControlAxis::Stop()")
);
} }
} }
...@@ -309,7 +256,7 @@ void MotionControlAxis::Stop() ...@@ -309,7 +256,7 @@ void MotionControlAxis::Stop()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
Tango::DeviceProxy* MotionControlAxis::GetDeviceProxy(const yat4tango::AttributeGroup& attrGroup) ///< [in] attribute group to work on Tango::DeviceProxy* MotionControlAxis::GetDeviceProxy(const yat4tango::AttributeGroup& attrGroup) ///< [in] attribute group to work on
{ {
Tango::DeviceProxy* pProxy = NULL; Tango::DeviceProxy* proxy_p = NULL;
try try
{ {
...@@ -317,49 +264,37 @@ Tango::DeviceProxy* MotionControlAxis::GetDeviceProxy(const yat4tango::Attribute ...@@ -317,49 +264,37 @@ Tango::DeviceProxy* MotionControlAxis::GetDeviceProxy(const yat4tango::Attribute
if (1 == vectProxies.size() ) if (1 == vectProxies.size() )
{ {
pProxy = vectProxies.at(0); proxy_p = vectProxies.at(0);
if (NULL == pProxy) if (NULL == proxy_p)
{ {
// Exception: Proxy is NULL // Exception: Proxy is NULL
string sExceptionMessage; string exception_message;
sExceptionMessage = "unable to get DeviceProxy to " + m_attributeName; exception_message = "unable to get DeviceProxy to " + m_attributeName;
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR",
( exception_message.c_str(),
static_cast<const char*> ("TANGO_DEVICE_ERROR"), "MotionControlAxis::GetDeviceProxy");
static_cast<const char*> (sExceptionMessage.c_str()),
static_cast<const char*> ("MotionControlAxis::GetDeviceProxy()")
);
} }
} }
else else
{ {
// Exception: invalid list size // Exception: invalid list size
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR",
( "unexpected ordered_device_proxy_list size",
static_cast<const char*> ("TANGO_DEVICE_ERROR"), "MotionControlAxis::GetDeviceProxy");
static_cast<const char*> ("unexpected ordered_device_proxy_list size"),
static_cast<const char*> ("MotionControlAxis::GetDeviceProxy()")
);
} }
} }
catch (Tango::DevFailed& df) catch (Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df, string(df.errors[0].reason).c_str(),
static_cast<const char*> (string(df.errors[0].reason).c_str()), string(df.errors[0].desc).c_str(),
static_cast<const char*> (string(df.errors[0].desc).c_str()), string(df.errors[0].origin).c_str() );
static_cast<const char*> (string(df.errors[0].origin).c_str()));
} }
catch (...) catch (...)
{ {
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "unhandled exception", "MotionControlAxis::GetDeviceProxy");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unhandled exception"),
static_cast<const char*> ("MotionControlAxis::GetDeviceProxy()")
);
} }
return pProxy; return proxy_p;
} }
......
...@@ -94,12 +94,7 @@ void MotionControlHelper::DefineAxis(const std::string& axisName, ///< [i ...@@ -94,12 +94,7 @@ void MotionControlHelper::DefineAxis(const std::string& axisName, ///< [i
// Exception // Exception
std::string sExceptionMessage; std::string sExceptionMessage;
sExceptionMessage = "axis " + pAxis->GetName() + " already defined for the attribute "+attributeName; sExceptionMessage = "axis " + pAxis->GetName() + " already defined for the attribute "+attributeName;
Tango::Except::throw_exception Tango::Except::throw_exception("TANGO_DEVICE_ERROR", sExceptionMessage.c_str(), "MotionControlHelper::DefineAxis");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (sExceptionMessage.c_str()),
static_cast<const char*> ("MotionControlHelper::DefineAxis()")
);
} }
++iter; ++iter;
} }
...@@ -111,11 +106,9 @@ void MotionControlHelper::DefineAxis(const std::string& axisName, ///< [i ...@@ -111,11 +106,9 @@ void MotionControlHelper::DefineAxis(const std::string& axisName, ///< [i
} }
catch (Tango::DevFailed& df) catch (Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df, std::string(df.errors[0].reason).c_str(),
static_cast<const char*> (std::string(df.errors[0].reason).c_str()), std::string(df.errors[0].desc).c_str(),
static_cast<const char*> (std::string(df.errors[0].desc).c_str()), "MotionControlHelper::DefineAxis");
static_cast<const char*> ("MotionControlHelper::DefineAxis()")
);
} }
} }
else else
...@@ -123,12 +116,7 @@ void MotionControlHelper::DefineAxis(const std::string& axisName, ///< [i ...@@ -123,12 +116,7 @@ void MotionControlHelper::DefineAxis(const std::string& axisName, ///< [i
// Exception // Exception
std::string sExceptionMessage; std::string sExceptionMessage;
sExceptionMessage = "axis " + axisName + " already defined"; sExceptionMessage = "axis " + axisName + " already defined";
Tango::Except::throw_exception Tango::Except::throw_exception("TANGO_DEVICE_ERROR", sExceptionMessage.c_str(), "MotionControlHelper::DefineAxis");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (sExceptionMessage.c_str()),
static_cast<const char*> ("MotionControlHelper::DefineAxis()")
);
} }
} }
...@@ -170,12 +158,7 @@ MotionControlAxis* MotionControlHelper::operator[] (const std::string& axisName) ...@@ -170,12 +158,7 @@ MotionControlAxis* MotionControlHelper::operator[] (const std::string& axisName)
{ {
std::string sExceptionMessage; std::string sExceptionMessage;
sExceptionMessage = "axis " + axisName + " is not defined"; sExceptionMessage = "axis " + axisName + " is not defined";
Tango::Except::throw_exception Tango::Except::throw_exception("TANGO_DEVICE_ERROR", sExceptionMessage.c_str(), "MotionControlHelper::operator[]");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (sExceptionMessage.c_str()),
static_cast<const char*> ("MotionControlHelper::[]()")
);
} }
return pFoundItem; return pFoundItem;
...@@ -214,20 +197,14 @@ void MotionControlHelper::Move() ...@@ -214,20 +197,14 @@ void MotionControlHelper::Move()
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df, "TANGO_DEVICE_ERROR",
static_cast<const char*> ("TANGO_DEVICE_ERROR"), std::string(df.errors[0].desc).c_str(),
static_cast<const char*> (std::string(df.errors[0].desc).c_str()), "MotionControlHelper::Move");
static_cast<const char*> ("MotionControlHelper::Move()"));
} }
catch (...) catch (...)
{ {
// Exception // Exception
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "unhandled exception", "MotionControlHelper::Read");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unhandled exception"),
static_cast<const char*> ("MotionControlHelper::Read()")
);
} }
} }
} }
...@@ -247,12 +224,7 @@ void MotionControlHelper::SelectAxis(const std::string& axisName) ///< [in] u ...@@ -247,12 +224,7 @@ void MotionControlHelper::SelectAxis(const std::string& axisName) ///< [in] u
// Exception // Exception
std::string sExceptionMessage; std::string sExceptionMessage;
sExceptionMessage = "axis " + axisName + " is not defined"; sExceptionMessage = "axis " + axisName + " is not defined";
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", sExceptionMessage.c_str(), "MotionControlHelper::SelectAxis");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (sExceptionMessage.c_str()),
static_cast<const char*> ("MotionControlHelper::SelectAxis()")
);
} }
} }
...@@ -271,12 +243,7 @@ void MotionControlHelper::UnSelectAxis(const std::string& axisName) ...@@ -271,12 +243,7 @@ void MotionControlHelper::UnSelectAxis(const std::string& axisName)
// Exception // Exception
std::string sExceptionMessage; std::string sExceptionMessage;
sExceptionMessage = "axis " + axisName + " is not defined"; sExceptionMessage = "axis " + axisName + " is not defined";
Tango::Except::throw_exception Tango::Except::throw_exception("TANGO_DEVICE_ERROR", sExceptionMessage.c_str(), "MotionControlHelper::UnSelectAxis");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> (sExceptionMessage.c_str()),
static_cast<const char*> ("MotionControlHelper::SelectAxis()")
);
} }
} }
...@@ -329,12 +296,9 @@ void MotionControlHelper::Read() ...@@ -329,12 +296,9 @@ void MotionControlHelper::Read()
else else
{ {
// Exception // Exception
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR",
( "unable to extract attributegroup value",
static_cast<const char*> ("TANGO_DEVICE_ERROR"), "MotionControlHelper::Read");
static_cast<const char*> ("unable to extract attributegroup value"),
static_cast<const char*> ("MotionControlHelper::Read()")
);
} }
++iterSelectedAxies; ++iterSelectedAxies;
...@@ -343,31 +307,20 @@ void MotionControlHelper::Read() ...@@ -343,31 +307,20 @@ void MotionControlHelper::Read()
else else
{ {
// Exception: reply list size is not consistend // Exception: reply list size is not consistend
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "invalid reply list size", "MotionControlHelper::Read");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("invalid reply list size"),
static_cast<const char*> ("MotionControlHelper::Read()")
);
} }
} }
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
Tango::Except::re_throw_exception(df, Tango::Except::re_throw_exception(df, "TANGO_DEVICE_ERROR",
static_cast<const char*> ("TANGO_DEVICE_ERROR"), std::string(df.errors[0].desc).c_str(),
static_cast<const char*> (std::string(df.errors[0].desc).c_str()), "MotionControlHelper::Read" );
static_cast<const char*> ("MotionControlHelper::Read()"));
} }
catch (...) catch (...)
{ {
// Exception // Exception
Tango::Except::throw_exception Tango::Except::throw_exception( "TANGO_DEVICE_ERROR", "unhandled exception", "MotionControlHelper::Read");
(
static_cast<const char*> ("TANGO_DEVICE_ERROR"),
static_cast<const char*> ("unhandled exception"),
static_cast<const char*> ("MotionControlHelper::Read()")
);
} }
} }
...@@ -378,11 +331,26 @@ void MotionControlHelper::Read() ...@@ -378,11 +331,26 @@ void MotionControlHelper::Read()
void MotionControlHelper::Stop(void) void MotionControlHelper::Stop(void)
{ {
list<MotionControlAxis*>::iterator iter = m_listAxis.begin(); list<MotionControlAxis*>::iterator iter = m_listAxis.begin();
bool has_errors = false;
std::string exception_message = "The following errors occured:\n";
while (m_listAxis.end() != iter) while (m_listAxis.end() != iter)
{
try
{ {
(*iter)->Stop(); (*iter)->Stop();
}
catch(Tango::DevFailed& df)
{
exception_message = exception_message + string(df.errors[0].desc) + "\n";
has_errors = true;
}
++iter; ++iter;
} }
if (has_errors)
{
Tango::Except::throw_exception("TANGO_DEVICE_ERROR", exception_message.c_str(), "MotionControlHelper::Stop");
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -44,14 +44,14 @@ ...@@ -44,14 +44,14 @@
<dependency> <dependency>
<groupId>fr.soleil.lib</groupId> <groupId>fr.soleil.lib</groupId>
<artifactId>MotionControlHelper-${aol}-${library}-${mode}</artifactId> <artifactId>MotionControlHelper-${aol}-${library}-${mode}</artifactId>
<version>1.1.0</version> <version>1.1.1-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
<developers> <developers>
<developer> <developer>
<id>langlois</id> <id>bouladoux</id>
<name>langlois</name> <name>bouladoux</name>
<url>http://controle/</url> <url>http://controle/</url>
<organization>Synchrotron Soleil</organization> <organization>Synchrotron Soleil</organization>
<organizationUrl>http://www.synchrotron-soleil.fr</organizationUrl> <organizationUrl>http://www.synchrotron-soleil.fr</organizationUrl>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment