Created
April 15, 2015 18:06
-
-
Save mogsie/4a3355f76a721f22aaee to your computer and use it in GitHub Desktop.
Test SCXML
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
<scxml initial="initial-default" version="1.0" xmlns="http://www.w3.org/2005/07/scxml"><!-- node-size-and-position x=0 y=0 w=778,39 h=1265 --> | |
<datamodel><!-- | |
This is the object we call out to (synchronously) ask the UI | |
for information about the state of the UI (to e.g. make | |
decisions. E.g. if the user only typed one letter, we might | |
want to not perform a "suggest" (and therefore not make a | |
transition). | |
--> | |
<data id="actions"></data> | |
<data id="guards"></data> | |
</datamodel> | |
<!-- node-size-and-position x=0 y=0 w=672,01 h=1452 We use a lot of booleans to make decisions when we go through | |
the state machine. e.g. is there a significant amount of text | |
in the text field? | |
These variables need to be updated by the | |
The first state is by default the entry point. --> | |
<state id="initial-default"><!-- node-size-and-position x=339,2 y=43 w=100 h=75 --><!-- node-size-and-position x=281,01 y=43 w=110 h=75 node-size-and-position x=244,89 y=43 w=110 h=75 node-size-and-position x=114,24 y=43 w=110 h=75 As usual, we wait for the "init" event to actually do | |
anything, since this is when we get a way to interact with | |
the UI... --> | |
<transition event="init" target="active"> | |
<assign expr="_event.data.guards || {}" location="guards"></assign> | |
<assign expr="_event.data.actions || {}" location="actions"></assign> | |
</transition> | |
</state> | |
<parallel id="active"><!-- node-size-and-position x=20 y=168 w=738,39 h=1077 --> | |
<onentry><!-- "public" event passed to the UI. The "clear" event should | |
ensure that the text field is empty, that everything is in | |
pristine shape. | |
--> | |
<script>actions.clear();</script> | |
</onentry> | |
<!-- node-size-and-position x=20 y=293 w=632,01 h=1139 --> | |
<state id="search-box" initial="waiting-for-input"><!-- node-size-and-position x=20 y=43 w=485,29 h=1014 --><!-- node-size-and-position x=234,49 y=43 w=377,53 h=1076 --> | |
<state id="waiting-for-suggestions" initial="waiting-a-bit"><!-- node-size-and-position x=160 y=349 w=280 h=115 --> | |
<onentry> | |
<script> | |
actions.fetchSuggestions(); // not implemented yet; not even stubbed! | |
</script> | |
</onentry> | |
<onexit> | |
<script> | |
actions.cleanupOutstandingFetchSuggestions(); // not even stubbed | |
</script> | |
</onexit> | |
<!-- node-size-and-position x=103,53 y=606 w=160 h=75 node-size-and-position x=89,28 y=543 w=160 h=75 node-size-and-position x=302,24 y=465 w=160 h=75 --> | |
<transition event="suggestions-available" target="pick-suggestion"></transition> | |
<transition event="input" target="processing-input"></transition> | |
<state id="waiting-a-bit"><!-- node-size-and-position x=20 y=29 w=75 h=75 --> | |
<onentry> | |
<send delay="4s" event="server-slow" id="slow-timer"></send> | |
</onentry> | |
<onexit> | |
<cancel sendid="slow-timer"></cancel> | |
</onexit> | |
<transition event="server-slow" target="slow-server"></transition> | |
</state> | |
<state id="slow-server"><!-- node-size-and-position x=170 y=29 w=75 h=75 --></state> | |
</state> | |
<state id="pick-suggestion"><!-- node-size-and-position x=45,79 y=481 w=267 h=263 --> | |
<onentry> | |
<script> | |
actions.showSuggestions(); | |
</script> | |
</onentry> | |
<onexit> | |
<script> | |
actions.hideSuggestions(); | |
</script> | |
</onexit> | |
<transition event="input" target="processing-input"></transition> | |
<state id="pick-suggestion-no-choice"><!-- node-size-and-position x=25 y=43 w=160 h=75 --> | |
<transition event="choice-made" target="pick-suggestion-choice-made"></transition> | |
</state> | |
<state id="pick-suggestion-choice-made"><!-- node-size-and-position x=20 y=168 w=170 h=75 --> | |
<transition event="choice-made" target="pick-suggestion-choice-made"></transition> | |
</state> | |
</state> | |
<state id="waiting-for-input"><!-- node-size-and-position x=201,29 y=43 w=110 h=75 --><!-- node-size-and-position x=151,53 y=293 w=120 h=75 node-size-and-position x=91,28 y=293 w=120 h=75 node-size-and-position x=160,24 y=580 w=120 h=75 Transition to the "suggestion pending" disabled pending a | |
user-interface to show suggestions... --> | |
<transition event="input" target="processing-input"><!-- edge-path [suggestion-pending] x=366,42 y=450,39 pointx=0 pointy=-19 offsetx=-2 offsety=1 --><!-- edge-path [suggestion-pending] x=185,65 y=764,61 --><!-- edge-path [suggestion-pending] x=233,99 y=392,6 --><!-- edge-path [processing-input] pointx=0 pointy=-9 offsetx=2 offsety=0 --></transition> | |
</state> | |
<state id="suggestion-pending"><!-- node-size-and-position x=230,04 y=139 w=248,5 h=138 --><!-- node-size-and-position x=88,78 y=418 w=249,5 h=138 If we get input from the UI (and significant text isn't | |
present), go back to "waiting for input" since we don't | |
care. --> | |
<transition event="input" target="processing-input"><!-- edge-path [waiting-for-input] x=166,84 y=771,39 --><!-- edge-path [waiting-for-input] x=214,01 y=393,4 --><!-- edge-path [processing-input] x=130 y=159 pointx=0 pointy=-7 offsetx=16 offsety=6 --></transition> | |
<!-- If the timer fired, let's actually look for suggestions. --> | |
<transition target="waiting-for-suggestions"><!-- edge-path [waiting-for-suggestions] x=406,97 y=442,33 --><!-- edge-path [waiting-for-suggestions] x=184,27 y=520,15 --><!-- edge-path [waiting-for-suggestions] x=245,51 y=584 pointx=0 pointy=-21 offsetx=1 offsety=-3 --><!-- edge-path [waiting-for-suggestions] x=237,4 y=332,39 --></transition> | |
</state> | |
<state id="processing-input"><!-- node-size-and-position x=30 y=60 w=100 h=40 --> | |
<transition cond="guards.isSignificantTextPresent()" target="suggestion-pending"><!-- edge-path [suggestion-pending] x=387,52 y=437,67 --><!-- edge-path [suggestion-pending-inner] x=164,73 y=515,85 --></transition> | |
<transition target="waiting-for-input"><!-- edge-path [waiting-for-input] x=170 y=39 --></transition> | |
</state> | |
</state> | |
<state id="error-box" initial="noerror"><!-- node-size-and-position x=564,89 y=43 w=153,5 h=263 --><!-- node-size-and-position x=20 y=43 w=154,5 h=263 node-size-and-position x=669,78 y=40 w=115 h=263 --> | |
<state id="noerror"><!-- node-size-and-position x=20 y=43 w=75 h=75 --> | |
<transition event="error" target="error"><!-- edge-path [error] x=110,22 y=140 pointx=0 pointy=-16 offsetx=-5 offsety=7 --><!-- edge-path [error] x=58 y=143 --></transition> | |
</state> | |
<state id="error"><!-- node-size-and-position x=20 y=168 w=75 h=75 --> | |
<onentry> | |
<script>actions.showError();</script> | |
<send delay="5s" event="noerror" id="errortimeout"></send> | |
</onentry> | |
<onexit> | |
<cancel sendid="errortimeout"></cancel> | |
</onexit> | |
<transition event="noerror" target="noerror"><!-- edge-path [noerror] x=38 y=143 --></transition> | |
<transition event="error" target="error"></transition> | |
</state> | |
</state> | |
</parallel> | |
</scxml> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment