-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Nested states (compound / parallel) #329
Draft
fgmacedo
wants to merge
3
commits into
develop
Choose a base branch
from
macedo/compound-states
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
fgmacedo
force-pushed
the
macedo/compound-states
branch
from
January 23, 2023 19:07
86efa27
to
ba50602
Compare
fgmacedo
force-pushed
the
macedo/compound-states
branch
5 times, most recently
from
January 27, 2023 19:11
0a548c1
to
cf2cc43
Compare
I like the idea of compound states, as they tend to make my life a lot easier. I will have a look at it when I find some time. |
fgmacedo
force-pushed
the
macedo/compound-states
branch
3 times, most recently
from
February 11, 2023 19:34
c28a40c
to
64e9bc8
Compare
fgmacedo
force-pushed
the
macedo/compound-states
branch
4 times, most recently
from
February 24, 2023 17:22
3fef20a
to
c1fc3bd
Compare
fgmacedo
force-pushed
the
macedo/compound-states
branch
2 times, most recently
from
March 4, 2023 21:02
8315afd
to
4abd2ab
Compare
fgmacedo
force-pushed
the
macedo/compound-states
branch
from
March 13, 2023 01:50
4abd2ab
to
a447f6f
Compare
fgmacedo
force-pushed
the
macedo/compound-states
branch
from
March 20, 2023 12:26
93fd520
to
db6aa0d
Compare
Wow looking for this feat, required in my project. |
fgmacedo
force-pushed
the
macedo/compound-states
branch
2 times, most recently
from
November 2, 2023 09:13
d98ebff
to
a8a139a
Compare
fgmacedo
force-pushed
the
macedo/compound-states
branch
from
July 8, 2024 00:11
a8a139a
to
c765228
Compare
Repository owner
deleted a comment
Jul 9, 2024
fgmacedo
force-pushed
the
macedo/compound-states
branch
2 times, most recently
from
July 9, 2024 20:28
65536cd
to
2c427cd
Compare
fgmacedo
force-pushed
the
macedo/compound-states
branch
from
July 11, 2024 23:20
2aa8336
to
0e363ce
Compare
Quality Gate failedFailed conditions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Experimental branch to play with compound and parallel states.
On this PR, I'm trying to implement a "simple" example from SCXML called "microwave", that has parallel and compound states.
Microwave
SCXML
From the MicrowaveParallel example spec.
Using python-statemachine
** Experimental syntax **
Note that I'm using a
class
as a namespace for constructing aState
instance. Not a traditional choice, but I like the syntax so far.Diagram is already rendering nested states:
If you're reading this, feedback is welcome. Please let me know what you think.
I am trying to handle nested states in the lib (it works well for simple machines), but I have been reading quite a bit about statecharts (https://www.w3.org/TR/scxml/), and they solve a common problem with state machines: state explosion. More complex use cases become infeasible to express with a simple machine.
These nested states work in two ways:
The example I am trying to implement coming from SCXML documentation is a "microwave", in it, the "oven" and the "door" are two parallel states, as they work independently. The oven and the door are also compound states, as they have substates.
The syntax I am trying to validate is "how to express in a pythonic way" this hierarchy. The best syntax I came up with is the one in the PR, where I made "creative use" of the block context generated by a class to capture the variables created inside the context as substates of the parent state, and I use the class name and optional metaclass attributes to parameterize the parent state. The result is an instance of a 'State' already filled with the substrates.
So this:
Works like syntactic sugar for this (but keeping the parent namespace clean):
TODO