😭 How do you specify final state? The front page docs do not say #656
-
I'll take a guess that it goes in the same place as 'initial', but who knows ! 🙄 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
I just want to say this is an amazing library. I didn't get my code working using transitions alone, but I used transitions-gui, which even simulates the machine! This is freaking amaze balls 🎱 |
Beta Was this translation helpful? Give feedback.
-
Thanks Alexander. I need everything to work with Transitions Gui. I have
a nested state machine:
[image: image.png]
I need to eventually come out of a state in the Slab Heating nested
machine, and back to outer Main Loop's Start, but simply specifying
transition doesn't work.
…On Mon, Apr 22, 2024 at 9:53 AM Alexander Neumann ***@***.***> wrote:
This test case might be useful:
def test_error(self):
@add_state_features(Error)
class CustomMachine(Machine):
pass
states = ['A', 'B', 'F',
{'name': 'S1', 'tags': ['accepted']},
{'name': 'S2', 'accepted': True}]
transitions = [['to_B', ['S1', 'S2'], 'B'], ['go', 'A', 'B'], ['fail', 'B', 'F'],
['success1', 'B', 'S2'], ['success2', 'B', 'S2']]
m = CustomMachine(states=states, transitions=transitions, auto_transitions=False, initial='A')
m.go()
m.success1()
self.assertTrue(m.get_state(m.state).is_accepted)
m.to_B()
m.success2()
self.assertTrue(m.get_state(m.state).is_accepted)
m.to_B()
with self.assertRaises(MachineError):
m.fail()
—
Reply to this email directly, view it on GitHub
<#656 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMIF5474T5XMOSD2HMQKYLY6VTEDAVCNFSM6AAAAABGTMYZ3KVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TCOJTGE2TQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Alexander,
I got what you were saying about the event . Ah... got to reboot can't type
…On Mon, Apr 22, 2024 at 10:24 AM Alexander Neumann ***@***.***> wrote:
Unfortunately, the image is not visible. Maybe you could provide a
"minimal, reproducible (code) example" (MRE).
—
Reply to this email directly, view it on GitHub
<#656 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMIF54N5RP57KXIAFHLTQLY6VWXNAVCNFSM6AAAAABGTMYZ3KVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TCOJTGQYTG>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Dr. Neumann,
Your first suggestion worked. I can exit the nested machine by simply
calling its my_finalize_event.
Thank you for your responsiveness! Very greatly appreciated and the
library is awesome. The standard library for this now and hope to be using
it a lot.
Daniel
On Mon, Apr 22, 2024 at 10:28 AM Luna Tuna ***@***.***>
wrote:
… Alexander,
I got what you were saying about the event . Ah... got to reboot can't type
On Mon, Apr 22, 2024 at 10:24 AM Alexander Neumann <
***@***.***> wrote:
> Unfortunately, the image is not visible. Maybe you could provide a
> "minimal, reproducible (code) example" (MRE).
>
> —
> Reply to this email directly, view it on GitHub
> <#656 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAMIF54N5RP57KXIAFHLTQLY6VWXNAVCNFSM6AAAAABGTMYZ3KVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TCOJTGQYTG>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***
> com>
>
|
Beta Was this translation helpful? Give feedback.
Transitions does not feature a specific "final" state argument. What would you like to achieve with final states? You could wrap up things on "def on_enter_FinalState" or pass a "done" callback to transitions that enter that state.
Furthermore, you could have a look at state feature decorations. You could add "Tags" or "Error". The later will raise an Exception when a state was entered that cannot be left.