After Ev5 machine goes to A2 -> A21 state.
After Ev3 machine leaves state A with history and goes to state B.
After Ev4 machine leaves state B and should go back to A2 -> A21 but
actually goes to A -> A1 -> A11 - default states.
How I can fix it?
> After Ev5 machine goes to A2 -> A21 state. > After Ev3 machine leaves state A with history and goes to state B. > After Ev4 machine leaves state B and should go back to A2 -> A21 but actually
goes to A -> A1 -> A11 - default states.
> How I can fix it?
From a cursory glance at the code, it seems it behaves as it should. Why do you think that transitioning to deep history with default A11 should go to A2? It seems you'd get what you want by transitioning to deep history with default A1.
In there are no explanation of history types in documentation , just names
- shallow, deep and full. I thought that with full history sm should go
back to that state it was before leaving A state.
Is it possible to go back to A2->A21 where it was before B in this case?
And if yes, tell me please how to do it.
ahd6974-spamboostorgt...@yahoo.com> wrote:
> Hi Ilya
> > After Ev5 machine goes to A2 -> A21 state.
> > After Ev3 machine leaves state A with history and goes to state B.
> > After Ev4 machine leaves state B and should go back to A2 -> A21 but
> actually
> goes to A -> A1 -> A11 - default states.
> > How I can fix it?
> From a cursory glance at the code, it seems it behaves as it should. Why
> do you
> think that transitioning to deep history with default A11 should go to A2?
> It
> seems you'd get what you want by transitioning to deep history with
> default A1.
I missed your advice in previous message. I changed transition code to A1
state and it worked perfectly. But ideally, I'd like to transit from B not
to A1 but to A state. How I can change this code to get it working with
saving all history for A-substates?
ahd6974-spamboostorgt...@yahoo.com> wrote:
> Hi Ilya
> > After Ev5 machine goes to A2 -> A21 state.
> > After Ev3 machine leaves state A with history and goes to state B.
> > After Ev4 machine leaves state B and should go back to A2 -> A21 but
> actually
> goes to A -> A1 -> A11 - default states.
> > How I can fix it?
> From a cursory glance at the code, it seems it behaves as it should. Why
> do you
> think that transitioning to deep history with default A11 should go to A2?
> It
> seems you'd get what you want by transitioning to deep history with
> default A1.
> I missed your advice in previous message. I changed transition code to A1
state and it worked perfectly. But ideally, I'd like to transit from B not to A1 but to A state. How I can change this code to get it working with saving all history for A-substates?
I guess you are missing the fact that the template argument passed to deep_history is actually the *default* *state*. This is the state that is entered when no history has ever been saved. If history has been saved (as is the case in your example code) then transit< sc::deep_history < StateA1 > >() will transit to whatever inner state of A was active before A was exited. This is explained in more detail here:
> > I missed your advice in previous message. I changed transition code to A1
> state and it worked perfectly. But ideally, I'd like to transit from B not
> to
> A1 but to A state. How I can change this code to get it working with
> saving all
> history for A-substates?
> I guess you are missing the fact that the template argument passed to
> deep_history is actually the *default* *state*. This is the state that is
> entered when no history has ever been saved. If history has been saved (as
> is
> the case in your example code) then transit< sc::deep_history < StateA1 >
> >()
> will transit to whatever inner state of A was active before A was exited.
> This
> is explained in more detail here:
In fact I did not missed this part of tutorial. But since documentation is
almost non-existent in area of history types description, my first attempt
was to set the same default state (A11) in every declaration of A
substates. My idea here was that if I stated deep_history for A substates
and for A itself, all history will be saved and we need default state only
if there was not action inside A state before transition into it. So A
should have only one default state. For me it makes sense. But it did not
worked for me at all.
Next, I defined different default states for each direct A substate. I
still dont understand why I should do it and how it could be that A have
several default substates. At the same time I added transition from B to
one of exact default states. For A1 default state was A11 and I put it into
return transit < sc::deep_history < StateA11 > >(); My thought here was if
I defined A11 as default state, all transactions to A should use exactly
this state. This did not worked too, as I described in my first message.
And next, using your advice I changed transit from A11 to A1, but I still
dont understand why I should do it this way.
As for me, most logical behavior should be like this - if A uses deep
history (I take it as 'total history for all substates'), A should have
single default state for cases like this C -> B -> A. But for cases A -> B
-> A in B -> A transition user should use outermost state A in transition
destination and do not care about how history is saved inside it or about
its default state.
> In fact I did not missed this part of tutorial. But since documentation is
> almost non-existent in area of history types description,
Boost.Statechart implements the state machine semantics defined by the UML standard, which is mentioned in the documentation. I hope you understand that describing how FSM history works is therefore beyond the scope of the documentation.
> As for me, most logical behavior should be like this - if A uses deep
> history (I take it as 'total history for all substates'), A should have
> single default state for cases like this C -> B -> A.
IIUC, what you find most logical is contrary to what UML defines. Moreover, in practice it does happen that you need different default states for different transitions to history.
> But for cases
> A -> B -> A in B -> A transition user should use outermost state A in
> transition destination and do not care about how history is saved inside
> it or about its default state.
As I've mentioned before, you *can* have exactly what you describe here. In your code, please replace the line
return transit< sc::deep_history < StateA1 > >();
with
return transit < StateA >();
and you should see exactly the same behavior.
This works because StateA specifies sc::deep_history < StateA1 > as its inner initial state.