state machine, parallel seems to work, final state and info about active atomic states

This commit is contained in:
2024-07-17 21:11:01 +03:00
parent 3db26a762c
commit abdba6d68b
6 changed files with 168 additions and 61 deletions

View File

@@ -71,11 +71,24 @@ void PITransitionBase::trigger() {
target_path.remove(target_path.size_s() - common_count, common_count);
// piCout << "source_path" << source_path;
// piCout << "target_path" << target_path;
source_state->setChildActiveRecursive(false);
// piCout << "source_state before" << source_state;
for (int i = target_path.size_s() - 1; i >= 0; --i) {
// piCout << "check" << source_state->activeChild() << target_path[i];
if (source_state->activeChild() == target_path[i])
source_state = target_path[i];
else
break;
}
// piCout << "source_state after" << source_state;
source_state->setChildrenActiveRecursive(false);
for (auto * s: source_path)
s->setActive(false);
makeAction();
for (auto * s: source_target_path)
s->setActive(true);
for (int i = 0; i < source_target_path.size_s(); ++i) {
if (i == source_target_path.size_s() - 1)
source_target_path[i]->start();
else
source_target_path[i]->activeChild(source_target_path[i + 1]);
}
if (target_state->isCompound()) target_state->start();
}