help with SCXML state machine and special History state



  • Hello,

    I'm trying to wrap my head around the QScxmlStateMachine and the "history state" pseudo state. I just can't seem to get it to work as expected in a simple test-bed application. I'm using Qt 5.9 and Creator 4.3.1, MSVC2015 64bit.

    I visually created a simple parent state with a series of child states that transition from one to the next as the user does things. This much works just fine.

    I wanted to add a cancel+confirm type function, so outside of the parent state, I added a state called abortConfirm, and I created a transition from my parent state to it, called 'abort'.. I also added a "History" state as a child of the parent group (alongside the other child states) and from my 'abortConfirm' state, I added a transition to that history state, labeled 'abortDenied'

    When I click my 'cancel' button in my test GUI, I submitEvent('abort') to the state machine, it transitions as expected and I use a QMessageBox to ask 'are you sure?'.. From my qDebug logging I can see that the parent state is exited as I transition into my abortConfirm state.

    When the user clicks "Cancel" I then submitEvent('abortDenied') back to the state machine, which in the visual editor is tied to the History. I'd expect the "History" state to know which child state it was on at the time it received the 'abort' event, and return me to that state (as the dox say should happen). But it just doesn't seem to work.

    I know the SCXML editor is still "experimental" but should I expect the History state features to actually work?



  • Hello! The history state can be either shallow or deep. shallow is the default but your descriptions reads as if you want it to be deep. See State Chart XML, 3.10.



  • Hi!
    Thanks. I've tried both deep and shallow and I see no difference. As an aside (perhaps) I'm also wondering about the "Toggle Full Namespace" button - it does not change anything.. do I have to follow a specific naming convention for the child states for this to work?



  • I have found the problem, "history" state has nothing to do with it. Rather, I was performing my "Are you sure?" prompt (and submitting events based on the answer), inside the "steadyStateReached" handler, rather than posting an event from onEntry of the new state to trigger the "Are you sure?" prompt. Thus, none of my state transitions were happening out of that abortConfirm state. Now everything works as expected.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.