| 22 | } |
| 23 | |
| 24 | NodeStatus SequenceWithMemory::tick() |
| 25 | { |
| 26 | const size_t children_count = children_nodes_.size(); |
| 27 | |
| 28 | if(!isStatusActive(status())) |
| 29 | { |
| 30 | skipped_count_ = 0; |
| 31 | } |
| 32 | setStatus(NodeStatus::RUNNING); |
| 33 | |
| 34 | while(current_child_idx_ < children_count) |
| 35 | { |
| 36 | TreeNode* current_child_node = children_nodes_[current_child_idx_]; |
| 37 | |
| 38 | auto prev_status = current_child_node->status(); |
| 39 | const NodeStatus child_status = current_child_node->executeTick(); |
| 40 | |
| 41 | switch(child_status) |
| 42 | { |
| 43 | case NodeStatus::RUNNING: { |
| 44 | return child_status; |
| 45 | } |
| 46 | case NodeStatus::FAILURE: { |
| 47 | // DO NOT reset current_child_idx_ on failure |
| 48 | for(size_t i = current_child_idx_; i < childrenCount(); i++) |
| 49 | { |
| 50 | haltChild(i); |
| 51 | } |
| 52 | |
| 53 | return child_status; |
| 54 | } |
| 55 | case NodeStatus::SUCCESS: { |
| 56 | current_child_idx_++; |
| 57 | // Return the execution flow if the child is async, |
| 58 | // to make this interruptible. |
| 59 | if(requiresWakeUp() && prev_status == NodeStatus::IDLE && |
| 60 | current_child_idx_ < children_count) |
| 61 | { |
| 62 | emitWakeUpSignal(); |
| 63 | return NodeStatus::RUNNING; |
| 64 | } |
| 65 | } |
| 66 | break; |
| 67 | |
| 68 | case NodeStatus::SKIPPED: { |
| 69 | // It was requested to skip this node |
| 70 | current_child_idx_++; |
| 71 | skipped_count_++; |
| 72 | } |
| 73 | break; |
| 74 | |
| 75 | case NodeStatus::IDLE: { |
| 76 | throw LogicError("[", name(), "]: A children should not return IDLE"); |
| 77 | } |
| 78 | } // end switch |
| 79 | } // end while loop |
| 80 | |
| 81 | // The entire while loop completed. This means that all the children returned SUCCESS. |
nothing calls this directly
no test coverage detected