Skip to content
Snippets Groups Projects
Commit 4f74d3db authored by Jean Coquet's avatar Jean Coquet
Browse files

InitializeReferencePosition does not work.

Try to wait message handled to make it work.
some code improvements on Util:post_msg
parent 016b7e58
Branches
Tags
No related merge requests found
...@@ -227,11 +227,11 @@ namespace HexapodNewport_ns ...@@ -227,11 +227,11 @@ namespace HexapodNewport_ns
case GROUP_HOME_REF: case GROUP_HOME_REF:
{ {
INFO_STREAM << "HWProxy::handle_message handling GROUP_HOME_REF msg" << std::endl; INFO_STREAM << "HWProxy::handle_message handling GROUP_HOME_REF msg" << std::endl;
post_msg (*this, GROUP_KILL, 1000, false); post_msg (*this, GROUP_KILL, 1000, true);
INFO_STREAM << "HWProxy::handle_message handling GROUP_HOME_REF msg after GROUP_KILL" << std::endl; INFO_STREAM << "HWProxy::handle_message handling GROUP_HOME_REF msg after GROUP_KILL" << std::endl;
post_msg (*this, GROUP_INITIALIZE, 1000, false); post_msg (*this, GROUP_INITIALIZE, 1000, true);
INFO_STREAM << "HWProxy::handle_message handling GROUP_HOME_REF msg after GROUP_INITIALIZE" << std::endl; INFO_STREAM << "HWProxy::handle_message handling GROUP_HOME_REF msg after GROUP_INITIALIZE" << std::endl;
post_msg (*this, GROUP_HOME_SEARCH, 100000, false); post_msg (*this, GROUP_HOME_SEARCH, 100000, true);
INFO_STREAM << "HWProxy::handle_message handling GROUP_HOME_REF msg after GROUP_HOME_SEARCH" << std::endl; INFO_STREAM << "HWProxy::handle_message handling GROUP_HOME_REF msg after GROUP_HOME_SEARCH" << std::endl;
} }
...@@ -270,10 +270,10 @@ namespace HexapodNewport_ns ...@@ -270,10 +270,10 @@ namespace HexapodNewport_ns
_msg.detach_data (pos); _msg.detach_data (pos);
if (pos) if (pos)
{ {
post_msg(*this, GROUP_KILL, 1000, false); post_msg(*this, GROUP_KILL, 1000, true);
post_msg(*this, GROUP_INITIALIZE, 1000, false); post_msg(*this, GROUP_INITIALIZE, 1000, true);
post_msg(*this, GROUP_REFERENCING_START, 1000, false); post_msg(*this, GROUP_REFERENCING_START, 1000, true);
post_msg(*this, GROUP_REFERENCING_EXEC, 1000, false, pos); post_msg(*this, GROUP_REFERENCING_EXEC, 1000, true, pos);
} }
} }
break; break;
......
...@@ -11,22 +11,44 @@ void post_msg( yat::Task& t, size_t msg_id, size_t timeout_ms, bool wait ) ...@@ -11,22 +11,44 @@ void post_msg( yat::Task& t, size_t msg_id, size_t timeout_ms, bool wait )
{ {
RETHROW_YAT_ERROR(ex, RETHROW_YAT_ERROR(ex,
"OUT_OF_MEMORY", "OUT_OF_MEMORY",
"Out of memory", "Out of memory could not allocate msg",
"ScanTask::post_msg"); "Util::post_msg");
}
catch(std::bad_alloc)
{
THROW_YAT_ERROR(
"OUT_OF_MEMORY",
"Out of memory could not allocate msg",
"Util::post_msg");
} }
if (wait)
{
try try
{ {
if (wait)
t.wait_msg_handled( msg, timeout_ms ); t.wait_msg_handled( msg, timeout_ms );
}
catch( yat::Exception& ex )
{
RETHROW_YAT_ERROR(ex,
"SOFTWARE_FAILURE",
"Unable to wait for a message to be handled",
"Util::post_msg");
}
}
else else
{
try
{
t.post( msg, timeout_ms ); t.post( msg, timeout_ms );
} }
catch( yat::Exception& ex ) catch( yat::Exception& ex )
{ {
RETHROW_YAT_ERROR(ex, RETHROW_YAT_ERROR(ex,
"SOFTWARE_FAILURE", "SOFTWARE_FAILURE",
"Unable to post a msg", "Unable to post a message",
"ScanTask::post_msg"); "Util::post_msg");
} }
} }
}
...@@ -39,19 +39,33 @@ void post_msg( yat::Task &t, size_t msg_id, size_t timeout_ms, bool wait, ...@@ -39,19 +39,33 @@ void post_msg( yat::Task &t, size_t msg_id, size_t timeout_ms, bool wait,
"post_msg"); "post_msg");
} }
if (wait)
{
try try
{ {
if (wait)
t.wait_msg_handled( msg, timeout_ms ); t.wait_msg_handled( msg, timeout_ms );
}
catch( yat::Exception& ex )
{
RETHROW_YAT_ERROR(ex,
"SOFTWARE_FAILURE",
"Unable to wait for a message to be handled",
"Util::post_msg");
}
}
else else
{
try
{
t.post( msg, timeout_ms ); t.post( msg, timeout_ms );
} }
catch( yat::Exception& ex ) catch( yat::Exception& ex )
{ {
RETHROW_YAT_ERROR(ex, RETHROW_YAT_ERROR(ex,
"SOFTWARE_FAILURE", "SOFTWARE_FAILURE",
"Unable to post a msg", "Unable to post a message",
"ScanTask::post_msg"); "Util::post_msg");
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment