diff options
Diffstat (limited to 'test/samples/w3c')
-rw-r--r-- | test/samples/w3c/Blackjack.scxml | 99 | ||||
-rw-r--r-- | test/samples/w3c/Main.scxml | 204 | ||||
-rw-r--r-- | test/samples/w3c/Test2Sub1.xml | 9 | ||||
-rw-r--r-- | test/samples/w3c/TrafficReport.scxml | 88 | ||||
-rw-r--r-- | test/samples/w3c/calc.scxml | 158 | ||||
-rw-r--r-- | test/samples/w3c/edit-profile-config.scxml | 70 | ||||
-rw-r--r-- | test/samples/w3c/log-on-config.scxml | 32 | ||||
-rw-r--r-- | test/samples/w3c/microwave-01.scxml | 50 | ||||
-rw-r--r-- | test/samples/w3c/microwave-02.scxml | 63 | ||||
-rw-r--r-- | test/samples/w3c/simple.xml | 9 |
10 files changed, 782 insertions, 0 deletions
diff --git a/test/samples/w3c/Blackjack.scxml b/test/samples/w3c/Blackjack.scxml new file mode 100644 index 0000000..4f55e53 --- /dev/null +++ b/test/samples/w3c/Blackjack.scxml @@ -0,0 +1,99 @@ +<?xml version="1.0"?> +<?access-control allow="*"?> +<scxml version="1.0" datamodel="ecmascript" initial="master"> <state id="master"> + <initial id="init1"> + <transition target="_home"/> + </initial> + <transition event="new_dealer" target="NewDealer"/> + <transition event="mumble" target="_home"/> <!-- bail out to caller --> + <transition event="silence" target="_home"/> <!-- bail out to caller --> + <state id="_home"> + <onenter> + <script> + _data = {}; + </script> + </onenter> + <invoke src="datamodel.v3#InitDataModel" type="vxml3"> + <finalize> + <script> + var n; + for (n in event) { + _data[n] = event[n]; + } + </script> + </finalize> + </invoke> + <transition event="success" target="Welcome"/> + </state> + + <state id="Welcome"> + <invoke src="dialog.vxml#Welcome" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + </invoke> + <transition event="success" target="Intro2"/> + </state> + + <state id="Intro2"> + <invoke src="dialog.vxml#Intro2" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + </invoke> + <transition event="success" target="EvalDeal"/> + </state> + + <state id="EvalDeal"> + <onenter> + <script>enterEvalDeal();</script> + </onenter> + <invoke src="dialog.vxml#EvalDeal" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + <param name="playercard1" expr="playercard1"/> + <param name="playercard2" expr="playercard2"/> + <param name="playertotal" expr="blackjack.GetTotalOf('caller').toString()"/> + <param name="dealercardshowing" expr="dealercardshowing"/> + </invoke> + <transition event="success" target="AskHit"/> + </state> + + <state id="AskHit"> + <invoke src="dialog.vxml#AskHit" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + <finalize> + <script>finalizeAskHit();</script> + </finalize> + </invoke> + <transition event="hit" target="PlayNewCard"/> + <transition event="stand" target="PlayDone"/> + </state> + + <state id="PlayNewCard"> + <invoke src="dialog.vxml#PlayNewCard" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + <param name="playernewcard" expr="playernewcard"/> + <param name="playertotal" expr="blackjack.GetTotalOf('caller').toString()"/> + </invoke> + <transition event="success" cond="blackjack.GetTotalOf('caller') >= 21" target="PlayDone"/> + <transition event="success" target="AskHit"/> <!-- less than 21 --> + </state> + + <state id="PlayDone"> + <onenter> + <script>enterPlayDone();</script> + </onenter> + <invoke src="dialog.vxml#PlayDone" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + <param name="gameresult" expr="blackjack.GetGameResult()"/> + <param name="dealertotal" expr="blackjack.GetTotalOf('dealer').toString()"/> + </invoke> + <transition event="playagain" target="Intro2"/> + <transition event="quit" target="_home"/> + </state> + + <state id="NewDealer"> + <onenter> + <script>enterNewDealer();</script> + </onenter> + <invoke src="dialog.vxml#Dummy" type="vxml3"/> + <transition event="success" target="Welcome"/> + </state> + </state> +</scxml> diff --git a/test/samples/w3c/Main.scxml b/test/samples/w3c/Main.scxml new file mode 100644 index 0000000..4c03631 --- /dev/null +++ b/test/samples/w3c/Main.scxml @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- A wrapper state that contains all other states in this file +- it represents the complete state machine --> +<scxml + xmlns:xi="http://www.w3.org/2001/XInclude" + version="1.0" + initial="Main" + datamodel="ecmascript"> + <state id="Main"> + <!-- its initial state is Test1 --> + <initial> + <transition target="Test1"/> + </initial> + + <!-- Really simple state showing the basic syntax. --> + <state id="Test1"> + <initial> + <transition target="Test1Sub1"/> + </initial> + <!-- Runs before we go into the substate --> + <onentry> + <log expr="'Inside Test1'"/> + </onentry> + + <!-- Here is our first substate --> + <state id="Test1Sub1"> + <onentry> + <log expr="'Inside Test1Sub1.'"/> + </onentry> + <onexit> + <log expr="'Leaving Test1Sub1'"/> + </onexit> + <!-- Go to Sub2 on Event1 --> + <transition event="Event1" target="Test1Sub2"/> + </state> + + <!-- Here is the second substate + It is final, so Test1 is done when we get here --> + <final id="Test1Sub2"/> + + <!-- We get this event when we reach Test1Sub2. --> + <transition event="Test1.done" target="Test2"/> + + <!-- We run this on the way out of Test1 --> + <onexit> + <log expr="'Leaving Test1...'"/> + </onexit> + </state> + + <state id="Test2"> + <initial> + <transition target="Test2Sub1"/> + </initial> + + <!-- This time we reference a state + defined in an external file. --> + <xi:include href="Test2Sub1.xml" parse="text"/> + + <final id="Test2Sub2"/> + + <!-- Test2Sub2 is defined as final, so this + event is generated when we reach it --> + <transition event="done.state.Test2" next="Test3"/> + </state> + + <state id="Test3"> + <initial> + <transition target="Test3Sub1"/> + </initial> + + <state id="Test3Sub1"> + <onentry> + <log expr="'Inside Test3Sub1...'"/> + <!-- Send our self an event in 5s --> + <send event="'Timer'" delay="'5s'"/> + </onentry> + <!-- Transition on to Test4. + This will exit both us and our parent. --> + <transition event="Timer" target="Test4"/> + <onexit> + <log expr="'Leaving Test3Sub1...'"/> + </onexit> + </state> + + <onexit> + <log expr="'Leaving Test3...'"/> + </onexit> + </state> + + <state id="Test4"> + <onentry> + <log expr="'Inside Test4...'"/> + </onentry> + <initial> + <transition target="Test4Sub1"/> + </initial> + + <state id="Test4Sub1"> + <onexit> + <log expr="'Leaving Test4Sub1...'"/> + </onexit> + <!-- This transition causes the state to exit immediately + after entering Test4Sub1. The transition has no event + or guard so it is always active --> + <transition target="Test5"/> + </state> + </state> + + <state id="Test5"> + <onentry> + <log expr="'Inside Test5...'"/> + </onentry> + <initial> + <transition target="Test5P"/> + </initial> + + <!-- Fire off parallel states. In a more realistic example + the parallel substates Test5PSub1 and Test5PSub2 would themselves + have substates and would do some real work before transitioning to final substates --> + <parallel id="Test5P"> + <state id="Test5PSub1" initial="Test5PSub1Final"> + <final id="Test5PSub1Final"/> + </state> + <state id="Test5PSub2" initial="Test5PSub2Final"> + <final id="Test5PSub2Final"/> + </state> + <onexit> + <log expr="'all parallel states done'"/> + </onexit> + </parallel> + + <!-- The parallel states immediately transition to final substates, + so this event is generated immediately. --> + <transition event="done.state.Test5P" target="Test6"/> + </state> + + <!-- + - This state shows invocation of an external component. + - We will use CCXML + VoiceXML actions as an example + - as it is a good smoke test to show how it all + - fits together. + - Note: In a real app you would likely + - split this over several states but we + - are trying to keep it simple here. + --> + <state id="Test6" + xmlns:ccxml="http://www.w3.org/2002/09/ccxml" + xmlns:v3="http://www.w3.org/2005/07/vxml3"> + <datamodel> + <data name="ccxmlid" expr="32459"/> + <date name="v3id" expr="17620"/> + <data name="dest" expr="'tel:+18315552020'"/> + <data name="src" expr="'helloworld2.vxml'"/> + <data name="id" expr="'HelloWorld'"/> + </datamodel> + + <onentry> + <!-- Use <send> a message to a CCXML Processor asking it to run createcall --> + <send target="ccxmlid" type="basichttp" event="ccxml:createcall" namelist="dest"/> + </onentry> + + <transition event="ccxml:connection.connected"> + <!-- Here as a platform-specific extension we use example V3 + Custom Action Elements instead of send. The implementation of this logic + would be platform-dependent. --> + <v3:form id="HelloWorld"> + <v3:block><v3:prompt>Hello World!</v3:prompt></v3:block> + </v3:form> + </transition> + + <transition event="v3:HelloWorld.done"> + <!-- Here we are using the low level <send> + element to run a v3 form. Note that the event "v3:HelloWorld.done" + is assumed either to be set/sent explicitly by the v3:form code or + implicitly by some process outside of the v3:form --> + <send target="v3id" type="basichttp" event="v3:formstart" namelist="src id"/> + </transition> + + <transition event="v3:HelloWorld2.done"> + <!-- we use _event.data to access data in the event we're processing. + Again we assume the v3:HelloWorld2.done is set/sent from outside + this document --> + <ccxml:disconnect connectionid="_event.data.connectionid"/> + </transition> + + <transition event="ccxml:connection.disconnected" target="Done"/> + + <transition event="send.failed" target="Done"> + <!-- If we get an error event we move to the Done state that + is a final state. --> + <log expr="'Sending to and External component failed'"/> + </transition> + + <onexit> + <log expr="'Finished with external component'"/> + </onexit> + </state> + + <!-- This final state is an immediate child of Main + - when we get here, Main.done is generated. --> + <final id="Done"/> + <!-- End of Main > --> + </state> +</scxml>
\ No newline at end of file diff --git a/test/samples/w3c/Test2Sub1.xml b/test/samples/w3c/Test2Sub1.xml new file mode 100644 index 0000000..6ab7b98 --- /dev/null +++ b/test/samples/w3c/Test2Sub1.xml @@ -0,0 +1,9 @@ +<!-- This is an example substate defined in +- an external file and included by Main.scxml. +--> +<state id="Test2Sub1"> +<onentry> + <log expr="'Inside Test2Sub1'"/> +</onentry> +<transition event="Event2" target="Test2Sub2"/> +</state> diff --git a/test/samples/w3c/TrafficReport.scxml b/test/samples/w3c/TrafficReport.scxml new file mode 100644 index 0000000..09e2e93 --- /dev/null +++ b/test/samples/w3c/TrafficReport.scxml @@ -0,0 +1,88 @@ +<?xml version="1.0"?> +<?access-control allow="*"?> +<!-- A comment! --> +<scxml version="1.0" initial="Intro" datamodel="ecmascript"> + <state id="Intro"> + <invoke src="dialog.vxml#Intro" type="vxml2"/> + <transition event="success" cond="sessionChrome.playAds" target="PlayAds"/> + <transition event="success" cond="!sessionChrome.playAds && ANIQuality" + target="ShouldGoBack"/> + <transition event="success" cond="!sessionChrome.playAds && !ANIQuality" + target="StartOver"/> + </state> + + <state id="PlayAds"> + <invoke src="dialog.vxml#PlayAds" type="vxml2"/> + <transition event="success" cond="ANIQuality" target="ShouldGoBack"/> + <transition event="success" cond="!ANIQuality" target="StartOver"/> + </state> + + <state id="StartOver"> + <onentry> + <script>enterStartOver();</script> + </onentry> + <invoke src="dialog.vxml#StartOver" type="vxml2"> + <param name="gotItFromANI" expr="gotItFromANI"/> + <finalize> + <script>finalizeStartOver();</script> + </finalize> + </invoke> + <transition event="success" target="ShouldGoBack"/> + <transition event="doOver" target="StartOver"/> + <transition event="restart" target="Intro"/> <!-- bail out to caller --> + </state> + + <state id="ShouldGoBack"> + <invoke src="dialog.vxml#ShouldGoBack" type="vxml2"> + <param name="cityState" expr="cityState"/> + <param name="gotItFromANI" expr="gotItFromANI"/> + <finalize> + <script>finalizeShouldGoBack();</script> + </finalize> + </invoke> + <transition event="highWay" target="HighwayReport"/> + <transition event="go_back" target="StartOver"/> + <transition event="doOver" target="ShouldGoBack"/> + <transition event="restart" target="Intro"/> + </state> + + <state id="HighwayReport"> + <invoke src="dialog.vxml#HighwayReport" type="vxml2"> + <param name="cityState" expr="cityState"/> + <param name="gotItFromANI" expr="gotItFromANI"/> + <param name="playHRPrompt" expr="playHRPrompt"/> + <param name="metroArea" expr="metroArea"/> + <finalize> + <script>finalizeHighwayReport();</script> + </finalize> + </invoke> + <transition event="highway" target="PlayHighway"/> + <transition event="go_back" target="StartOver"/> + <transition event="doOver" target="HighwayReport"/> + <transition event="fullreport" target="FullReport"/> + <transition event="restart" target="Intro"/> + </state> + + <state id="FullReport"> + <invoke src="dialog.vxml#FullReport" type="vxml2"> + <param name="cityState" expr="cityState"/> + <param name="metroArea" expr="metroArea"/> + <finalize> + <script>finalizeFullReport();</script> + </finalize> + </invoke> + <transition event="go_back" target="HighwayReport"/> + <transition event="new_city" target="StartOver"/> + </state> + + <state id="PlayHighway"> + <invoke src="dialog.vxml#PlayHighway" type="vxml2"> + <param name="cityState" expr="cityState"/> + <param name="curHighway" expr="curHighway"/> + <finalize> + <script>finalizePlayHighway();</script> + </finalize> + </invoke> + <transition event="go_back" target="HighwayReport"/> + </state> +</scxml> diff --git a/test/samples/w3c/calc.scxml b/test/samples/w3c/calc.scxml new file mode 100644 index 0000000..e759b45 --- /dev/null +++ b/test/samples/w3c/calc.scxml @@ -0,0 +1,158 @@ +<?xml version="1.0" ?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initial="on" datamodel="ecmascript" name="calc"> + <datamodel> + <data id="long_expr" /> + <data id="short_expr" expr="0" /> + <data id="res" /> + </datamodel> + <state id="wrapper" initial="on"> + <state id="on" initial="ready"> + <onentry> + <send event="DISPLAY.UPDATE" /> + </onentry> + <state id="ready" initial="begin"> + <state id="begin"> + <transition event="OPER.MINUS" target="negated1" /> + <onentry> + <send event="DISPLAY.UPDATE" /> + </onentry> + </state> + <state id="result"> + </state> + <transition event="OPER" target="opEntered" /> + <transition event="DIGIT.0" target="zero1"> + <assign location="short_expr" expr="''" /> + </transition> + <transition event="DIGIT" target="int1"> + <assign location="short_expr" expr="''" /> + </transition> + <transition event="POINT" target="frac1"> + <assign location="short_expr" expr="''" /> + </transition> + </state> + <state id="negated1"> + <onentry> + <assign location="short_expr" expr="'-'" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="DIGIT.0" target="zero1" /> + <transition event="DIGIT" target="int1" /> + <transition event="POINT" target="frac1" /> + </state> + <state id="operand1"> + <state id="zero1"> + <transition event="DIGIT" cond="_event.name != 'DIGIT.0'" target="int1" /> + <transition event="POINT" target="frac1" /> + </state> + <state id="int1"> + <transition event="POINT" target="frac1" /> + <transition event="DIGIT"> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </transition> + <onentry> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + </state> + <state id="frac1"> + <onentry> + <assign location="short_expr" expr="short_expr+'.'" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="DIGIT"> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </transition> + </state> + <transition event="OPER" target="opEntered" /> + </state> + <state id="opEntered"> + <transition event="OPER.MINUS" target="negated2" /> + <transition event="POINT" target="frac2" /> + <transition event="DIGIT.0" target="zero2" /> + <transition event="DIGIT" target="int2" /> + <onentry> + <raise event="CALC.SUB" /> + <send target="_internal" event="OP.INSERT"> + <param name="operator" expr="_event.name" /> + </send> + </onentry> + </state> + <state id="negated2"> + <onentry> + <assign location="short_expr" expr="'-'" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="DIGIT.0" target="zero2" /> + <transition event="DIGIT" target="int2" /> + <transition event="POINT" target="frac2" /> + </state> + <state id="operand2"> + <state id="zero2"> + <transition event="DIGIT" cond="_event.name != 'DIGIT.0'" target="int2" /> + <transition event="POINT" target="frac2" /> + </state> + <state id="int2"> + <transition event="DIGIT"> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </transition> + <onentry> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="POINT" target="frac2" /> + </state> + <state id="frac2"> + <onentry> + <assign location="short_expr" expr="short_expr +'.'" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="DIGIT"> + <assign location="short_expr" expr="short_expr +_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </transition> + </state> + <transition event="OPER" target="opEntered"> + <raise event="CALC.SUB" /> + <raise event="OP.INSERT" /> + </transition> + <transition event="EQUALS" target="result"> + <raise event="CALC.SUB" /> + <raise event="CALC.DO" /> + </transition> + </state> + <transition event="C" target="on" /> + </state> + <transition event="CALC.DO"> + <assign location="short_expr" expr="''+ res" /> + <assign location="long_expr" expr="''" /> + <assign location="res" expr="0" /> + </transition> + <transition event="CALC.SUB"> + <if cond="short_expr!=''"> + <assign location="long_expr" expr="long_expr+'('+short_expr+')'" /> + </if> + <assign location="res" expr="eval(long_expr)" /> + <assign location="short_expr" expr="''" /> + <send event="DISPLAY.UPDATE" /> + </transition> + <transition event="DISPLAY.UPDATE"> + <log level="0" label="'result'" expr=".short_expr==''?res:short_expr" /> + </transition> + <transition event="OP.INSERT"> + <log level="0" expr="_event.data[0]" /> + <if cond="_event.data[0] == 'OPER.PLUS'"> + <assign location="long_expr" expr="long_expr+'+'" /> + <elseif cond="_event.data[0]=='OPER.MINUS'" /> + <assign location="long_expr" expr="long_expr+'-'" /> + <elseif cond="_event.data[0]=='OPER.STAR'" /> + <assign location="long_expr" expr="long_expr+'*'" /> + <elseif cond="_event.data[0]=='OPER.DIV'" /> + <assign location="long_expr" expr="long_expr+'/'" /> + </if> + </transition> + </state> +</scxml> diff --git a/test/samples/w3c/edit-profile-config.scxml b/test/samples/w3c/edit-profile-config.scxml new file mode 100644 index 0000000..2f8753e --- /dev/null +++ b/test/samples/w3c/edit-profile-config.scxml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Dialog definitions for Shale Use Cases Example Web Application + written out as SCXML to demonstrate use of Commons SCXML as one + of Shale's Dialog Manager implementations. + For details, see: http://shale.apache.org/shale-dialog-scxml/ +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:my="http://scxml.example.com/" + version="1.0" initial="edit" datamodel="el"> + + <state id="edit"> + <initial> + <transition target="setup"/> + </initial> + + <!-- global transitions (within state "edit") --> + <transition event="faces.outcome" cond="${outcome eq 'cancel'}" target="cancel"/> + <transition event="faces.outcome" cond="${outcome eq 'finish'}" target="finish"/> + + <state id="setup"> + <onentry> + <my:var name="setupOutcome" expr="#{profile$edit.setup}" /> + </onentry> + <transition cond="${setupOutcome eq 'success'}" target="page1"/> + </state> + + <state id="page1"> + <transition event="faces.outcome" cond="${outcome eq 'next'}" target="page2"/> + </state> + + <state id="page2"> + + <transition event="faces.outcome" cond="${outcome eq 'previous'}" target="page1"/> + <transition event="faces.outcome" cond="${outcome eq 'next'}" target="page3"/> + + </state> + + <state id="page3"> + <transition event="faces.outcome" cond="${outcome eq 'previous'}" target="page2"/> + <transition event="faces.outcome" cond="${outcome eq 'next'}" target="editExit"/> + </state> + + </state> + + <state id="cancel"> + + <onentry> + <my:var name="cancelOutcome" expr="#{profile$edit.cancel}" /> + </onentry> + <transition cond="${cancelOutcome eq 'success'}" target="editExit"> + <my:var name="outcome" expr="cancel"/> + </transition> + </state> + + <state id="finish"> + + <onentry> + <my:var name="finishOutcome" expr="#{profile$edit.finish}" /> + </onentry> + + <transition cond="${finishOutcome eq 'username'}" target="page1"/> + <transition cond="${finishOutcome eq 'password'}" target="page1"/> + <transition cond="${finishOutcome eq 'success'}" target="editExit"> + <my:var name="outcome" expr="success"/> + </transition> + </state> + + <final id="editExit"/> + +</scxml> diff --git a/test/samples/w3c/log-on-config.scxml b/test/samples/w3c/log-on-config.scxml new file mode 100644 index 0000000..01f45d6 --- /dev/null +++ b/test/samples/w3c/log-on-config.scxml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Dialog definitions for Shale Use Cases Example Web Application + written out as SCXML to demonstrate use of Commons SCXML as one + of Shale's Dialog Manager implementations. + For details, see: http://shale.apache.org/shale-dialog-scxml/ +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:my="http://scxml.example.com/" + version="1.0" initial="checkCookie" datamodel="el" > + + <state id="checkCookie"> + <onentry> + <my:var name="cookieOutcome" expr="#{profile$logon.check}" /> + </onentry> + <transition cond="${cookieOutcome eq 'authenticated'}" target="exit"/> + <transition cond="${cookieOutcome eq 'unauthenticated'}" target="logon"/> + + </state> + + <state id="logon"> + <transition event="faces.outcome" cond="${outcome eq 'authenticated'}" target="exit"/> + <transition event="faces.outcome" cond="${outcome eq 'create'}" target="createProfile"/> + </state> + + + <state id="createProfile" src="edit-profile-config.xml" > + <transition event="createProfile.done" cond="${outcome eq 'success' or outcome eq 'cancel'}" target="exit"/> + </state> + + <final id="exit"/> + +</scxml> diff --git a/test/samples/w3c/microwave-01.scxml b/test/samples/w3c/microwave-01.scxml new file mode 100644 index 0000000..71e2f98 --- /dev/null +++ b/test/samples/w3c/microwave-01.scxml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + datamodel="ecmascript" + initial="off"> + + <!-- trivial 5 second microwave oven example --> + <datamodel> + <data id="cook_time" expr="5"/> + <data id="door_closed" expr="true"/> + <data id="timer" expr="0"/> + </datamodel> + + <state id="off"> + <!-- off state --> + <transition event="turn.on" target="on"/> + </state> + + <state id="on"> + <initial> + <transition target="idle"/> + </initial> + <!-- on/pause state --> + + <transition event="turn.off" target="off"/> + <transition cond="timer >= cook_time" target="off"/> + + <state id="idle"> + <!-- default immediate transition if door is shut --> + <transition cond="door_closed" target="cooking"/> + <transition event="door.close" target="cooking"> + <assign location="door_closed" expr="true"/> + <!-- start cooking --> + </transition> + </state> + + <state id="cooking"> + <transition event="door.open" target="idle"> + <assign location="door_closed" expr="false"/> + </transition> + + <!-- a 'time' event is seen once a second --> + <transition event="time"> + <assign location="timer" expr="timer + 1"/> + </transition> + </state> + + </state> + +</scxml> diff --git a/test/samples/w3c/microwave-02.scxml b/test/samples/w3c/microwave-02.scxml new file mode 100644 index 0000000..a96f1fd --- /dev/null +++ b/test/samples/w3c/microwave-02.scxml @@ -0,0 +1,63 @@ +<?xml version="1.0"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + datamodel="ecmascript" + initial="oven"> + + <!-- trivial 5 second microwave oven example --> + <!-- using parallel and In() predicate --> + <datamodel> + <data id="cook_time" expr="5"/> + <data id="door_closed" expr="true"/> + <data id="timer" expr="0"/> + </datamodel> + + <parallel id="oven"> + + <!-- this region tracks the microwave state and timer --> + <state id="engine"> + <transition target="off"/> + + <state id="off"> + <!-- off state --> + <transition event="turn.on" target="on"/> + </state> + + <state id="on"> + <transition target="idle"/> + <!-- on/pause state --> + + <transition event="turn.off" target="off"/> + <transition cond="timer >= cook_time" target="off"/> + + <state id="idle"> + <transition cond="In('closed')" target="cooking"/> + </state> + + <state id="cooking"> + <transition cond="In('open')" target="idle"/> + + <!-- a 'time' event is seen once a second --> + <transition event="time"> + <assign location="timer" expr="timer + 1"/> + </transition> + </state> + </state> + </state> + + <!-- this region tracks the microwave door state --> + <state id="door"> + <initial> + <transition target="closed"/> + </initial> + <state id="closed"> + <transition event="door.open" target="open"/> + </state> + <state id="open"> + <transition event="door.close" target="closed"/> + </state> + </state> + + </parallel> + +</scxml> diff --git a/test/samples/w3c/simple.xml b/test/samples/w3c/simple.xml new file mode 100644 index 0000000..d3badc8 --- /dev/null +++ b/test/samples/w3c/simple.xml @@ -0,0 +1,9 @@ +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="Main" + datamodel="ecmascript"> + <state /> + <state /> + <state /> + <state /> +</scxml>
\ No newline at end of file |