Created
February 23, 2013 13:03
-
-
Save fabb/5019653 to your computer and use it in GitHub Desktop.
Issue #4 in PySCXML: transition also exits & enters again unaffected states
This file contains hidden or 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
import time | |
from scxml.pyscxml import StateMachine | |
import logging | |
logging.basicConfig(level=logging.NOTSET) # show detailed debug info | |
xml = ''' | |
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"> | |
<state id="main"> | |
<onentry> | |
<log expr="'hello main'"/> | |
</onentry> | |
<parallel> | |
<state id="P1"> | |
<onentry> | |
<log expr="'hello P1'"/> | |
</onentry> | |
<transition event="p1x" target="P1f"> | |
<log expr="'transition event p1x'" /> | |
</transition> | |
<onexit> | |
<log expr="'bye P1'"/> | |
</onexit> | |
<state id="bla1"> | |
<onentry> | |
<log expr="'hello bla1'"/> | |
</onentry> | |
<onexit> | |
<log expr="'bye bla1'"/> | |
</onexit> | |
</state> | |
<final id="P1f"> | |
<onentry> | |
<log expr="'hello final P1f'"/> | |
</onentry> | |
</final> | |
</state> | |
<state id="P2"> | |
<onentry> | |
<log expr="'hello P2'"/> | |
</onentry> | |
<transition event="p2x" target="P2f"> | |
<log expr="'transition event p2x'" /> | |
</transition> | |
<onexit> | |
<log expr="'bye P2'"/> | |
</onexit> | |
<state id="bla2"> | |
<onentry> | |
<log expr="'hello bla2'"/> | |
</onentry> | |
<onexit> | |
<log expr="'bye bla2'"/> | |
</onexit> | |
</state> | |
<final id="P2f"> | |
<onentry> | |
<log expr="'hello final P2f'"/> | |
</onentry> | |
</final> | |
</state> | |
</parallel> | |
<transition event="e" target="f"> | |
<log expr="'transition event e'" /> | |
</transition> | |
<onexit> | |
<log expr="'bye main'"/> | |
</onexit> | |
</state> | |
<final id="f"> | |
<onentry> | |
<log expr="'hello final f'"/> | |
</onentry> | |
</final> | |
</scxml> | |
''' | |
if __name__ == '__main__': | |
sm = StateMachine(xml) | |
sm.start_threaded() | |
time.sleep(1) #needed, as an immediate send might get ignored, also see issue #3 in PySCXML | |
sm.send("p1x") | |
time.sleep(1) |
This file contains hidden or 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
hello main | |
hello P1 | |
hello bla1 | |
hello P2 | |
hello bla2 | |
INFO:pyscxml.pyscxml_session_43744504.interpreter:external event found: p1x | |
bye bla2 | |
bye P2 | |
bye bla1 | |
bye P1 | |
transition event p1x | |
hello P1 | |
hello final P1f | |
hello P2 | |
hello bla2 | |
INFO:pyscxml.pyscxml_session_43744504.interpreter:new config: {main, main_parall | |
el_child_3, P1, P1f, P2, bla2} | |
INFO:pyscxml.pyscxml_session_43744504.interpreter:internal event found: done.sta | |
te.P1 |
This file contains hidden or 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
Inspecting the log, the following things should *not* happen: | |
7 bye bla2 | |
8 bye P2 | |
10 bye P1 | |
12 hello P1 | |
14 hello P2 | |
15 hello bla2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment