add timeout transition
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#define pistatemachine_transition_H
|
||||
|
||||
#include "pistatemachine_base.h"
|
||||
#include "pitimer.h"
|
||||
|
||||
|
||||
//! \ingroup StateMachine
|
||||
@@ -39,7 +40,7 @@ class PIP_EXPORT PITransitionBase {
|
||||
|
||||
public:
|
||||
PITransitionBase(PIStateBase * source, PIStateBase * target, int event_id);
|
||||
~PITransitionBase();
|
||||
virtual ~PITransitionBase();
|
||||
|
||||
PIStateMachine * machine() const { return root; }
|
||||
PIStateBase * source() const { return source_state; }
|
||||
@@ -74,6 +75,9 @@ public:
|
||||
void trigger();
|
||||
|
||||
protected:
|
||||
virtual void enabled() {}
|
||||
virtual void disabled() {}
|
||||
|
||||
int eventID = 0;
|
||||
PIStateBase *source_state = nullptr, *target_state = nullptr;
|
||||
PIStateMachine * root = nullptr;
|
||||
@@ -81,4 +85,17 @@ protected:
|
||||
std::function<void()> action;
|
||||
};
|
||||
|
||||
|
||||
class PIP_EXPORT PITransitionTimeout: public PITransitionBase {
|
||||
public:
|
||||
PITransitionTimeout(PIStateBase * source, PIStateBase * target, PISystemTime timeout);
|
||||
~PITransitionTimeout();
|
||||
|
||||
private:
|
||||
void enabled() override;
|
||||
void disabled() override;
|
||||
|
||||
PITimer timer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user