| 33 | {} |
| 34 | |
| 35 | NodeStatus RepeatNode::tick() |
| 36 | { |
| 37 | if(read_parameter_from_ports_) |
| 38 | { |
| 39 | if(!getInput(NUM_CYCLES, num_cycles_)) |
| 40 | { |
| 41 | throw RuntimeError("Missing parameter [", NUM_CYCLES, "] in RepeatNode"); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | bool do_loop = repeat_count_ < num_cycles_ || num_cycles_ == -1; |
| 46 | setStatus(NodeStatus::RUNNING); |
| 47 | |
| 48 | while(do_loop) |
| 49 | { |
| 50 | const NodeStatus prev_status = child_node_->status(); |
| 51 | const NodeStatus child_status = child_node_->executeTick(); |
| 52 | |
| 53 | switch(child_status) |
| 54 | { |
| 55 | case NodeStatus::SUCCESS: { |
| 56 | repeat_count_++; |
| 57 | do_loop = repeat_count_ < num_cycles_ || num_cycles_ == -1; |
| 58 | |
| 59 | resetChild(); |
| 60 | |
| 61 | // Return the execution flow if the child is async, |
| 62 | // to make this interruptible. |
| 63 | if(requiresWakeUp() && prev_status == NodeStatus::IDLE && do_loop) |
| 64 | { |
| 65 | emitWakeUpSignal(); |
| 66 | return NodeStatus::RUNNING; |
| 67 | } |
| 68 | } |
| 69 | break; |
| 70 | |
| 71 | case NodeStatus::FAILURE: { |
| 72 | repeat_count_ = 0; |
| 73 | resetChild(); |
| 74 | return (NodeStatus::FAILURE); |
| 75 | } |
| 76 | |
| 77 | case NodeStatus::RUNNING: { |
| 78 | return NodeStatus::RUNNING; |
| 79 | } |
| 80 | |
| 81 | case NodeStatus::SKIPPED: { |
| 82 | // to allow it to be skipped again, we must reset the node |
| 83 | resetChild(); |
| 84 | // the child has been skipped. Skip the decorator too. |
| 85 | // Don't reset the counter, though ! |
| 86 | return NodeStatus::SKIPPED; |
| 87 | } |
| 88 | case NodeStatus::IDLE: { |
| 89 | throw LogicError("[", name(), "]: A children should not return IDLE"); |
| 90 | } |
| 91 | } |
| 92 | } |
nothing calls this directly
no test coverage detected