[SCXML] Problem with setting values in Context using 2.0-SNAPSHOT (works with 0.9)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[SCXML] Problem with setting values in Context using 2.0-SNAPSHOT (works with 0.9)

Diptendu Dutta
I have the following code that is working in 0.9 but failing in 2.0-SNAPSHOT
.

SCXMLExecutor engine;
Context rootContext;
Evaluator evaluator;

.....
rootContext = evaluator.newContext(null);
engine.setRootContext(rootContext);
engine.go();

rootContext.set("intent", "StartBot");
engine.triggerEvent("run", TriggerEvent.SIGNAL_EVENT);


----------------------
    <scxml xmlns="http://www.w3.org/2005/07/scxml"
              version="1.0"
              datamodel="jexl"
              initial="Start">

        <datamodel>
                <data id="intent" expr="&quot;hello&quot;" />
         ....
        </datamodel>

     <state id="Start">
      <transition event="run" cond="intent eq &quot;startBot&quot;"
target="StartBot" />
      <transition event="run" target="Default" />
    </state>

     <state id="Default">
      <onentry>
       <log expr="intent" />
       <assign location="response" expr="&quot;Sorry I do not
understand!&quot;" />
      </onentry>
      <transition target="Start" />
     </state>

     <state id="StartBot">
            .....
--------------------------------------------------------------------------------------
The StartBot state is not entered, rather the Default state is entered and
the value
of the "intent" datamodel item is printed as 'hello' rather than 'StartBot'
as expected

INFO: transition (event = run, cond = null, from = /Start, to = /Default)
INFO: null: hello

This same code is working with version 0.9.

Do I have to do things differently with 2.0-SNAPHOT for it to work?

Regards,

Diptendu Dutta
Reply | Threaded
Open this post in threaded view
|

Re: [SCXML] Problem with setting values in Context using 2.0-SNAPSHOT (works with 0.9)

Woonsan Ko-3
Hi Diptendu,

Please see my comments inline.

On Sat, Mar 16, 2019 at 8:19 AM Diptendu Dutta <[hidden email]> wrote:

>
> I have the following code that is working in 0.9 but failing in 2.0-SNAPSHOT
> .
>
> SCXMLExecutor engine;
> Context rootContext;
> Evaluator evaluator;
>
> .....
> rootContext = evaluator.newContext(null);
> engine.setRootContext(rootContext);
> engine.go();
>
> rootContext.set("intent", "StartBot");
> engine.triggerEvent("run", TriggerEvent.SIGNAL_EVENT);
>
>
> ----------------------
>     <scxml xmlns="http://www.w3.org/2005/07/scxml"
>               version="1.0"
>               datamodel="jexl"
>               initial="Start">
>
>         <datamodel>
>                 <data id="intent" expr="&quot;hello&quot;" />
>          ....
>         </datamodel>
>
>      <state id="Start">
>       <transition event="run" cond="intent eq &quot;startBot&quot;"
> target="StartBot" />
>       <transition event="run" target="Default" />
>     </state>
>
>      <state id="Default">
>       <onentry>
>        <log expr="intent" />
>        <assign location="response" expr="&quot;Sorry I do not
> understand!&quot;" />
>       </onentry>
>       <transition target="Start" />
>      </state>
>
>      <state id="StartBot">
>             .....
> --------------------------------------------------------------------------------------
> The StartBot state is not entered, rather the Default state is entered and
> the value
> of the "intent" datamodel item is printed as 'hello' rather than 'StartBot'
> as expected
>
> INFO: transition (event = run, cond = null, from = /Start, to = /Default)
> INFO: null: hello
>
> This same code is working with version 0.9.
>
> Do I have to do things differently with 2.0-SNAPHOT for it to work?

It looks like the evaluator in v2 is case-sensitive.
I think it would work with: cond="intent eq &quot;StartBot&quot;" -
'StartBot', not 'startBot'.

Regards,

Woonsan

>
> Regards,
>
> Diptendu Dutta

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]