On Wed, 17 Dec 2003 02:41:43 GMT, "Mountain Bikn' Guy" <>
wrote in comp.arch.embedded:
> I have just designed a statechart that includes four states that each call a
> method that performs some very long looping. The states execute in sequence
> (synchronously). I wish to allow the user to cancel within this looping. Of
> course, then the it looks as if I am violating the design principle of RTC
> (and I don't want to do that).
>
> However, in my statechart there is a state I call "Continuing". It maintains
> state info about which was the last of the long running states to completely
> finish. If the user has cancelled at some point, then resumed, the
> Continuing state is entered, and the next long running state is chosen
> appropriately.
>
> In my view, I am designing in accord with RTC. For example, my logic is that
> the completion could either be via finishing the loop or by early
> cancellation, and it is still RTC. I feel my states behave in accord with
> RTC principles.
>
> My question is whether others have encountered my type of thinking about
> design and whether I should be concerned about a flaw in my logic. Any
> comments or corrections are appreciated!
>
> Regards,
> Mountain
What do you mean by "RTC design pattern"? Real Time Clock? Real Time
Control? Really Tiny Calculator? Try to describe your acronyms.
I have never heard of designing any sort of software around a rigid
state machine mode, where states could not be skipped.
One technique that I like to avoid spaghetti state transitions has a
state machine that enters each state in turn. Each state accepts
events, one of which is "enter state". Each state returns a value for
each event it receives. The return value is essentially Boolean, one
value meaning remain in this state, the other meaning advance to the
next state.
Each state machine has a data store associated with it. If some event
in the second state should cause the skipping of states 3 and 4, state
2 sets some flag in the data store and returns "next state".
State 3 is then invoked with an "enter state" event. It determines
the flag in the data store and determines that it has nothing to do,
so it returns "next state". This same sequence is repeated with state
4, which likewise decides not to do anything. So the state machine
advances to state 5 (or perhaps wraps around back to the idle state,
state 0).
I like this model for several reasons. One is that neither any state
nor the state machine engine needs to know the order of states at all,
it is inherent in the table of state event functions.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
ftp://snurse-l.org/pub/acllc-c++/faq