[SCXML] Next states

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

[SCXML] Next states

Mansour Al Akeel
Is there a way to get the next valid states or transitions ?
I am working with AbstractStateMachine

Thank you

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

Reply | Threaded
Open this post in threaded view
|

Re: [SCXML] Next states

Benedikt Ritter-4
Hello Mansour,

Mansour Al Akeel <[hidden email]> schrieb am Mo., 2. Mai 2016 um
02:19 Uhr:

> Is there a way to get the next valid states or transitions ?
> I am working with AbstractStateMachine
>

I think Woosan and Ate are the ones who have worked mostly on SCXML. Maybe
they can help...

Benedikt


>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [SCXML] Next states

Mansour Al Akeel
Thank you Benedikt.


On Mon, May 2, 2016 at 6:47 AM, Benedikt Ritter <[hidden email]> wrote:

> Hello Mansour,
>
> Mansour Al Akeel <[hidden email]> schrieb am Mo., 2. Mai 2016 um
> 02:19 Uhr:
>
>> Is there a way to get the next valid states or transitions ?
>> I am working with AbstractStateMachine
>>
>
> I think Woosan and Ate are the ones who have worked mostly on SCXML. Maybe
> they can help...
>
> Benedikt
>
>
>>
>> Thank you
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

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

Reply | Threaded
Open this post in threaded view
|

Re: [SCXML] Next states

Woonsan Ko-3
In reply to this post by Mansour Al Akeel
Not sure about the use case, but maybe you can add a listener
(AbstractStateMachine#getEngine()#addListener(stateMachine, new
MyListener())).
If you get a TransitionalState in your listener, you may possibly get
all the available Transitions and TransitionTargets.

Regards,

Woonsan


On Sun, May 1, 2016 at 8:19 PM, Mansour Al Akeel
<[hidden email]> wrote:
> Is there a way to get the next valid states or transitions ?
> I am working with AbstractStateMachine
>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

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

Reply | Threaded
Open this post in threaded view
|

Re: [SCXML] Next states

Mansour Al Akeel
Thank you Woonsan,
The use case is to report transition failure or invalid path.
Using the listener is good, but it wont be triggered unless the
transition happens.
For example this was written to test commons SCXML 1:

@Override
    public boolean fireEvent(String event) {
        List<Transition> lst = this.getCurrentState().getTransitionsList(event);
        if (lst == null) {
            System.out.println("unknown event: " + event);
            return false;  // this should return true if final only
        }
        State before = this.getCurrentState();
        boolean evnetFired = super.fireEvent(event);

        State after = this.getCurrentState();

        if (after.equals(before)) {

            Status stauts = this.getEngine().getCurrentStatus();

            Set<State> valid = stauts.getStates();

            System.out.println("We are in " + before.getId() + ".
Possible next states: ");

            for (Transition transition : lst) {
                System.out.println(transition.getTarget().getId());
            }

            List<Transition> transitionList =
this.getCurrentState().getTransitionsList();

            for (Transition transition : transitionList) {
                System.out.println(transition.getTarget().getId());
            }
            // throw new
            // IllegalStateException("Can not complete transition while in " +
            // before.getId());
        } else {
            System.out.println("succefully switched state " +
before.getId() + " -> " + after.getId());
        }
        return evnetFired;
    }


Is there a way to translate it to 2 ?
Thank you


On Wed, May 4, 2016 at 11:58 AM, Woonsan Ko <[hidden email]> wrote:

> Not sure about the use case, but maybe you can add a listener
> (AbstractStateMachine#getEngine()#addListener(stateMachine, new
> MyListener())).
> If you get a TransitionalState in your listener, you may possibly get
> all the available Transitions and TransitionTargets.
>
> Regards,
>
> Woonsan
>
>
> On Sun, May 1, 2016 at 8:19 PM, Mansour Al Akeel
> <[hidden email]> wrote:
>> Is there a way to get the next valid states or transitions ?
>> I am working with AbstractStateMachine
>>
>> Thank you
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

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

Reply | Threaded
Open this post in threaded view
|

Re: [SCXML] Next states

Woonsan Ko-3
On Fri, May 6, 2016 at 2:56 AM, Mansour Al Akeel
<[hidden email]> wrote:

> Thank you Woonsan,
> The use case is to report transition failure or invalid path.
> Using the listener is good, but it wont be triggered unless the
> transition happens.
> For example this was written to test commons SCXML 1:
>
> @Override
>     public boolean fireEvent(String event) {
>         List<Transition> lst = this.getCurrentState().getTransitionsList(event);
>         if (lst == null) {
>             System.out.println("unknown event: " + event);
>             return false;  // this should return true if final only
>         }
>         State before = this.getCurrentState();
>         boolean evnetFired = super.fireEvent(event);
>
>         State after = this.getCurrentState();
>
>         if (after.equals(before)) {
>
>             Status stauts = this.getEngine().getCurrentStatus();
>
>             Set<State> valid = stauts.getStates();
>
>             System.out.println("We are in " + before.getId() + ".
> Possible next states: ");
>
>             for (Transition transition : lst) {
>                 System.out.println(transition.getTarget().getId());
>             }
>
>             List<Transition> transitionList =
> this.getCurrentState().getTransitionsList();
>
>             for (Transition transition : transitionList) {
>                 System.out.println(transition.getTarget().getId());
>             }
>             // throw new
>             // IllegalStateException("Can not complete transition while in " +
>             // before.getId());
>         } else {
>             System.out.println("succefully switched state " +
> before.getId() + " -> " + after.getId());
>         }
>         return evnetFired;
>     }
>
>
> Is there a way to translate it to 2 ?

I guess the main change and challenge in API now is that you cannot
use #getCurrentState() any more.
Ate refactored a lot with SCXML-196, 197 and 200 in this (SCXML semantics) area.
For example, #getCurrentState() seems quite confusing because in SCXML
multiple states can be active at the same time. e.g, in parallel
states.
I guess that's why the old API cannot be supported any more.
So, you need to try with SCXMLExecutor#getStatus(), Status#getStates()
and Status#getActiveStates() to figure out which state you need to get
in your implementation. Please see each javadoc description.

Regards,

Woonsan

> Thank you
>
>
> On Wed, May 4, 2016 at 11:58 AM, Woonsan Ko <[hidden email]> wrote:
>> Not sure about the use case, but maybe you can add a listener
>> (AbstractStateMachine#getEngine()#addListener(stateMachine, new
>> MyListener())).
>> If you get a TransitionalState in your listener, you may possibly get
>> all the available Transitions and TransitionTargets.
>>
>> Regards,
>>
>> Woonsan
>>
>>
>> On Sun, May 1, 2016 at 8:19 PM, Mansour Al Akeel
>> <[hidden email]> wrote:
>>> Is there a way to get the next valid states or transitions ?
>>> I am working with AbstractStateMachine
>>>
>>> Thank you
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

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