[Qt-interest] unable to use more than 1 transition added to a state (QT StateMachine Framework)

Sean Harmer sean.harmer at maps-technology.com
Thu Mar 18 14:22:46 CET 2010


Hi,

On Thursday 18 March 2010 13:12:49 Mandeep Sandhu wrote:
> > For example, in other cases you may need to check that the SM is not in
> > either of 1 or more child states. In this case it would be worth making
> > your guarded transition class check that the SM is not in any state of a
> > list of supplied child states. This way you could reuse it for many such
> > situations. In other cases you may need to check more complicated
> > combinations of states, this would then require another specialised
> > class that inherits from
> > QAbstractTransition.
> 
> Yes, I just need to make sure I construct my SM such there's aren't
> too many states in this "ignore" list! :) Otherwise probably my HSM
> design is at fault.

Yeah. I typically go through several iterations of SM before I find one that I 
like and fits well with the problem at hand. If you hit a wall then feel free 
to provide some more specific requirements/examples and we will see if we can 
help you.

> > It is down to you to decide the best way to abstract the commonality
> > between such guarded transitions into a reasonable set of transition
> > classes. We have some pretty complex SMs that we use to control hardware
> > with many interdependent subsystems and we have found it necessary to
> > write a handful of specialised guarded transitions. It is not an onerous
> > task since you only have to override one or two functions and it brings
> > a great deal of power with it.
> 
> I too am trying to abstract out the behavior of a particular h/w into this
> SM.

OK cool. Testing the SM with real hardware is usually fun. We even went as far 
as creating a virtual hardware device as a separate application for testing 
purposes that communicates over tcp. It can make testing easier when you can 
set breakpoints on both sides to investigate the SM status at any time.

What would be *really* useful is a plugin for Qt-creator that shows a 
QGraphicsView onto a scene representing the SM's state chart and highlights 
transitions and states as they change whilst you step through in a debugger.

> >> Or should the HSM be constructed in a different way so that such hacks
> >> are not needed?
> > 
> > It is not a hack, this is a legitimate way of implementing guarded
> > transitions. If it still feels like a hack then you should examine the
> > possibility of refactoring your SM structure. But only you have the
> > domain- specific knowledge to do so in your particular case.
> 
> Thanks for your inputs Sean.

No problem, your welcome. Come back to the list if you need any other help.

Good luck,

Sean



More information about the Qt-interest-old mailing list