-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
73 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
add_subdirectory(minimal_flat) | ||
add_subdirectory(minimal_enclosed) | ||
add_subdirectory(entry_exit_actions) | ||
add_subdirectory(transition_action) | ||
add_subdirectory(self_transition) | ||
add_executable(minimal_flat minimal_flat.cpp) | ||
add_executable(minimal_enclosed minimal_enclosed.cpp) | ||
add_executable(entry_exit_actions entry_exit_actions.cpp) | ||
add_executable(transition_action transition_action.cpp) | ||
add_executable(transition_guard transition_guard.cpp) | ||
add_executable(self_transition self_transition.cpp) | ||
|
||
target_link_libraries(minimal_flat PRIVATE dsm::dsm) | ||
target_link_libraries(minimal_enclosed PRIVATE dsm::dsm) | ||
target_link_libraries(entry_exit_actions PRIVATE dsm::dsm) | ||
target_link_libraries(transition_action PRIVATE dsm::dsm) | ||
target_link_libraries(transition_guard PRIVATE dsm::dsm) | ||
target_link_libraries(self_transition PRIVATE dsm::dsm) | ||
|
||
set_target_properties(minimal_flat PROPERTIES FOLDER examples) | ||
set_target_properties(minimal_enclosed PROPERTIES FOLDER examples) | ||
set_target_properties(entry_exit_actions PROPERTIES FOLDER examples) | ||
set_target_properties(transition_action PROPERTIES FOLDER examples) | ||
set_target_properties(transition_guard PROPERTIES FOLDER examples) | ||
set_target_properties(self_transition PROPERTIES FOLDER examples) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "dsm/dsm.hpp" | ||
#include <cassert> | ||
#include <iostream> | ||
|
||
using namespace dsm; | ||
|
||
struct e1 : Event<e1>{ | ||
bool guard_flag; | ||
e1(bool guard_flag) : guard_flag{ guard_flag } {} | ||
}; | ||
|
||
struct sm : StateMachine<sm>{}; | ||
struct s0 : State<s0, sm>{ | ||
void onEvent1(const e1& evt) { std::cout << "Received event " << evt.name() << std::endl; } | ||
bool guard(const e1& evt) { return evt.guard_flag; } | ||
}; | ||
struct s1 : State<s1, sm>{}; | ||
|
||
int main() | ||
{ | ||
sm sm; | ||
|
||
sm.addState<s0, Entry>(); | ||
sm.addState<s1>(); | ||
sm.addTransition<s0, e1, s0, &s0::onEvent1, &s0::guard, s1>(); | ||
|
||
sm.start(); | ||
sm.processEvent(e1{false}); | ||
sm.processEvent(e1{true}); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
@startuml | ||
hide empty description | ||
[*] -right-> s0 | ||
s0 -> s0 : e1 | ||
s0 -> s0 : e1/onEvent1 | ||
s0: onEvent1() | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
@startuml | ||
hide empty description | ||
[*] -right-> s0 | ||
s0 -right-> s1 : e1 | ||
s0 -right-> s1 : e1/onEvent1 | ||
s0: onEvent1() | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@startuml | ||
hide empty description | ||
[*] -right-> s0 | ||
s0 -right-> s1 : e1[guard]/onEvent1 | ||
s0: onEvent1() | ||
@enduml |