Fridge Profile:
- Added profile action for basic fridge motion.
Change-Id: I170959e349b1048ce975b5348d8f8c474464e1e2
diff --git a/aos/common/actions/action_test.cc b/aos/common/actions/action_test.cc
index df204bc..0db4b29 100644
--- a/aos/common/actions/action_test.cc
+++ b/aos/common/actions/action_test.cc
@@ -23,7 +23,7 @@
explicit TestActorNOP(actions::TestActionQueueGroup* s)
: actions::ActorBase<actions::TestActionQueueGroup>(s) {}
- void RunAction() { return; }
+ bool RunAction() { return true; }
};
::std::unique_ptr<
@@ -41,11 +41,11 @@
explicit TestActorShouldCancel(actions::TestActionQueueGroup* s)
: aos::common::actions::ActorBase<actions::TestActionQueueGroup>(s) {}
- void RunAction() {
+ bool RunAction() {
while (!ShouldCancel()) {
LOG(FATAL, "NOT CANCELED!!\n");
}
- return;
+ return true;
}
};
diff --git a/aos/common/actions/actions.q b/aos/common/actions/actions.q
index fff6326..8950dd1 100644
--- a/aos/common/actions/actions.q
+++ b/aos/common/actions/actions.q
@@ -15,6 +15,9 @@
uint32_t running;
// A run value we were previously running or 0.
uint32_t last_running;
+ // If false the action failed to complete and may be in a bad state,
+ // this is a critical problem not a cancellation.
+ bool success;
};
message Goal {
diff --git a/aos/common/actions/actor.h b/aos/common/actions/actor.h
index 63cdb08..b64051a 100644
--- a/aos/common/actions/actor.h
+++ b/aos/common/actions/actor.h
@@ -19,7 +19,10 @@
public:
ActorBase(T* acq) : action_q_(acq) {}
- virtual void RunAction() = 0;
+ // Will return true if finished or asked to cancel.
+ // Will return false if it failed accomplish its goal
+ // due to a problem with the system.
+ virtual bool RunAction() = 0;
// Runs action while enabled.
void Run();
@@ -87,6 +90,7 @@
if (!action_q_->status.MakeWithBuilder()
.running(0)
.last_running(0)
+ .success(!abort_)
.Send()) {
LOG(ERROR, "Failed to send the status.\n");
}
@@ -102,10 +106,11 @@
if (!action_q_->status.MakeWithBuilder()
.running(running_id)
.last_running(0)
+ .success(!abort_)
.Send()) {
LOG(ERROR, "Failed to send the status.\n");
}
- RunAction();
+ abort_ = !RunAction();
LOG(INFO, "Done with action %" PRIx32 "\n", running_id);
// If we have a new one to run, we shouldn't say we're stopped in between.
@@ -113,6 +118,7 @@
if (!action_q_->status.MakeWithBuilder()
.running(0)
.last_running(running_id)
+ .success(!abort_)
.Send()) {
LOG(ERROR, "Failed to send the status.\n");
} else {
@@ -142,7 +148,7 @@
// Make sure the last job is done and we have a signal.
CheckInitialRunning();
- if (!action_q_->status.MakeWithBuilder().running(0).last_running(0).Send()) {
+ if (!action_q_->status.MakeWithBuilder().running(0).last_running(0).success(!abort_).Send()) {
LOG(ERROR, "Failed to send the status.\n");
}