CRINSA-team2025 V1
Documentation du Club Robot INSA Rennes 2025
Chargement...
Recherche...
Aucune correspondance
Transition.h
1//
2// Created by awing on 09/05/2026.
3//
4
5#ifndef TEAM2026_TRANSITION_H
6#define TEAM2026_TRANSITION_H
7#include <functional>
8
9#include "Node.h"
10namespace Grafcet {
11 class Transition : public Node {
12 public:
13 Transition() {
14 isTransition = true;
15 }
16
20 void action() override {}
21
27 bool enabled() override {
28 bool parentReady = synchronize;
29 for (int i = 0; i < parent.size(); ++i) {
30 Node* node = parent[i];
31 if (synchronize) parentReady &= node->enabled();
32 else parentReady |= node->enabled();
33 }
34 if (condition == nullptr) return false;
35 volatile const auto t = condition();
36 return condition() && parentReady;
37 }
38
39 std::function<bool()> condition = {};
40 };
41}
42#endif //TEAM2026_TRANSITION_H
std::pmr::vector< Node * > parent
List of parents node of the current node.
Definition Node.h:38
bool isTransition
true if the current node is a transition
Definition Node.h:31
bool synchronize
true if the current node needs to wait for all its parent to be enabled before executing
Definition Node.h:33
void action() override
transition does nothing
Definition Transition.h:20
bool enabled() override
evaluate if the transition is enabled using the condition function, and the state of its parent will ...
Definition Transition.h:27
std::function< bool()> condition
std::function pointing toward a function returning true if the condition for the transition to be ena...
Definition Transition.h:39