Skip to content

Commit

Permalink
Merge pull request #195 from josebraga/bugfix/do-not-call-request-act…
Browse files Browse the repository at this point in the history
…ivation-methods-if-already-act-ip

Bugfix/do not call request activation methods if already act ip
  • Loading branch information
mariacosta authored Sep 9, 2019
2 parents 5d6a06a + d33238b commit aefdb7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/DUNE/Entities/StatefulEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace DUNE
dispatch(m_act_state);
}

void
bool
StatefulEntity::requestActivation(void)
{
if (m_act_state.state != IMC::EntityActivationState::EAS_INACTIVE)
Expand All @@ -99,15 +99,16 @@ namespace DUNE
}

dispatch(m_act_state);
return;
return false;
}

m_next_act_state = NAS_SAME;
m_act_state.state = IMC::EntityActivationState::EAS_ACT_IP;
dispatch(m_act_state);
return true;
}

void
bool
StatefulEntity::requestDeactivation(void)
{
if (m_act_state.state != IMC::EntityActivationState::EAS_ACTIVE)
Expand All @@ -129,12 +130,13 @@ namespace DUNE
}

dispatch(m_act_state);
return;
return false;
}

m_next_act_state = NAS_SAME;
m_act_state.state = IMC::EntityActivationState::EAS_DEACT_IP;
dispatch(m_act_state);
return true;
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/DUNE/Entities/StatefulEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ namespace DUNE
}

//! Request entity activation
void
bool
requestActivation(void);

//! Request entity deactivation
void
bool
requestDeactivation(void);

//! Mark the activation as unsuccessful.
Expand Down
6 changes: 2 additions & 4 deletions src/DUNE/Tasks/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,8 @@ namespace DUNE
Task::requestActivation(void)
{
spew("request activation");
m_entity->requestActivation();

if (m_entity->isActivating())
if (m_entity->requestActivation())
{
spew("calling on request activation");
onRequestActivation();
Expand Down Expand Up @@ -314,9 +313,8 @@ namespace DUNE
Task::requestDeactivation(void)
{
spew("request deactivation");
m_entity->requestDeactivation();

if (m_entity->isDeactivating())
if (m_entity->requestDeactivation())
{
spew("calling on request deactivation");
onRequestDeactivation();
Expand Down

0 comments on commit aefdb7e

Please sign in to comment.