<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>StateWORKS Blog &#187; Finite state machine</title>
	<atom:link href="http://www.stateworks.net/tag/finite-state-machine/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stateworks.net</link>
	<description>StateWORKS blog about software engineering using virtual finite state machines</description>
	<lastBuildDate>Mon, 24 Aug 2009 15:38:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Introducing &#8220;Questions&#8221;</title>
		<link>http://www.stateworks.net/2009/03/introducing-questions/</link>
		<comments>http://www.stateworks.net/2009/03/introducing-questions/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 11:16:27 +0000</pubDate>
		<dc:creator>Ferdinand Wagner</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[Finite state machine]]></category>
		<category><![CDATA[stateworks]]></category>
		<category><![CDATA[VFSM]]></category>

		<guid isPermaLink="false">http://stateworksnet.cmarc.net/2009/03/introducing-questions/</guid>
		<description><![CDATA[In the category &#8220;Questions&#8221; you can ask any question about Virtual Finite State Machines or about how to use StateWORKS development tools. Simply post a comment to this entry.
]]></description>
			<content:encoded><![CDATA[<p>In the category &#8220;Questions&#8221; you can ask any question about Virtual Finite State Machines or about how to use StateWORKS development tools. Simply post a comment to this entry.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stateworks.net/2009/03/introducing-questions/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>What is a state machine, again?</title>
		<link>http://www.stateworks.net/2009/02/what-is-a-state-machine-again/</link>
		<comments>http://www.stateworks.net/2009/02/what-is-a-state-machine-again/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 18:28:26 +0000</pubDate>
		<dc:creator>Ferdinand Wagner</dc:creator>
				<category><![CDATA[Finite state machine]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[event driven]]></category>

		<guid isPermaLink="false">http://stateworksnet.cmarc.net/2009/02/what-is-a-state-machine-again/</guid>
		<description><![CDATA[For many years we have been trying to popularize the correct concept of a finite state machine. In fact, we do not invent anything, we just present a state machine as defined ca. 60 years ago. In the beginning it had been applied to a design of hardware systems as software did not exist at [...]]]></description>
			<content:encoded><![CDATA[<p>For many years we have been trying to popularize the correct concept of a finite state machine. In fact, we do not invent anything, we just present a state machine as defined ca. 60 years ago. In the beginning it had been applied to a design of hardware systems as software did not exist at that time. But the concept of a finite state machine is not bound in any way to the hardware; it is just a notation to describe a behavior and as such it is not bound to the physical implementation.</p>
<p><span id="more-10"></span><br />
Unfortunately, the state machine concept in software has been firstly used for theoretical purposes in the mathematical foundation of computer science where obviously only the event driven parser model is useful. This model assumes that a state machine is triggered by an event to do something and possibly change a state. This model applied to application software where a control systems are modeled is totally useless: in our book (Wagner F. et al.: Modeling Software with Finite State Machines) we discussed in details the limitations of that model, especially the problem of state number explosion.<br />
A recent email has provoked us to show the solution of a <a href="http://www.stateworks.com/technology/solutions/">traffic light controller</a> in the Solution page on our web site. This email shows again the damage that is produced by tools which use the UML syntax for specifying state machines. The base is a statecharts idea that assumes the above mentioned parser model.<br />
I do not want to repeat here any extracts from the book or numerous technical notes and case studies available on our web site. I would limit my comments only to two topics that are the essence of all the misunderstandings that surround the state machine concept.<br />
1. An event is a signal that triggers the state machine to work: to do something and change a state (I do not want to go now into the different models with input action, entry actions, etc. as these are secondary issues). The conditions that determine what to do and whether to change a state is not the event itself but the value of one or more state machine inputs (see for instance Chapter 7 in the book). In the Traffic Light example the transition condition from the state Hgreen_FRed to the state HYellow_FRed is Vehicle_DETECTED &#038; Ti_Green_OVER, i.e. the transition condition is an AND operation of two input values: Vehicle_DETECTED and Ti_Green_OVER. If you try to do it using only the event as a condition you end up in a lunatic world with a state machine inside a state, flags in a state machine, inventing “guards” on transitions, concurrencies, and so on.<br />
2. There is very rarely a need for concurrent state machines. First of all a system of concurrent state machines makes sense only if you have a true multiprocessor system and you are able to partition the (multiple) state machine execution onto several processors. Secondly, you need to have a reason to do it. In reality you normally need three levels of parallelism: the system of state machines, the input handling system and the output handling system. The input handling system processes the inputs, makes them available to the state machines and generates events to trigger state machines if any input changes. The output handling system performs action as ordered by state machines. If those two time-consuming tasks run concurrently to the system of state machines this system is just a decision machine, to order the output handling system what to do on the basis of the actual input conditions and a state, and is very fast in operation. In such a model it is difficult to discover any motive for requiring concurrency of state machines.<br />
Any comments will be appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stateworks.net/2009/02/what-is-a-state-machine-again/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Getting started</title>
		<link>http://www.stateworks.net/2008/07/getting-started/</link>
		<comments>http://www.stateworks.net/2008/07/getting-started/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 10:38:38 +0000</pubDate>
		<dc:creator>Ferdinand Wagner</dc:creator>
				<category><![CDATA[stateworks]]></category>
		<category><![CDATA[entry action]]></category>
		<category><![CDATA[Finite state machine]]></category>
		<category><![CDATA[input action]]></category>
		<category><![CDATA[state transition]]></category>

		<guid isPermaLink="false">http://stateworksnet.cmarc.net/2008/07/getting-started/</guid>
		<description><![CDATA[I received an email from John M. who is evaluating StateWORKS. He started with a fairly complex example that has confronted him with several issues that must be understood to use effectively our tools and the run-time system. Because of a general nature of his questions I put (with his acceptance) my answers into that [...]]]></description>
			<content:encoded><![CDATA[<p>I received an email from John M. who is evaluating StateWORKS. He started with a fairly complex example that has confronted him with several issues that must be understood to use effectively our tools and the run-time system. Because of a general nature of his questions I put (with his acceptance) my answers into that blog.</p>
<p><span id="more-7"></span><br />
Before I answer your questions I would like to make a general comment. There are two aspects of any method that uses a state machine concept. The first one is the specification, the second its implementation. Most methods are just limited to the specification. In that case the implementation is left to the user that interprets it on his own and completes the missing issues in the specification. After a while the specification looses its meaning and only the implementation (that is the code) counts. This rule is true not only for a state machine specification but defines a relation between any specification and implementation. We want to do it better in StateWORKS and provide a run-time system that executes the specification. The obvious consequences of our approach are:<br />
- The specification must be complete as there is no chance to complete it in the code.<br />
- While specifying we have to keep in mind the execution model.<br />
The last problem should not be underestimated as you will see later when I answer your question.<br />
<em>Q1) The execution sequence of input actions in the current state is not ordered per 4th point in box at top of page 187. Fine. From page 199 : “ …. actions may change other control variables and in turn corresponding virtual inputs: all of them are treated 1-by-1 in the emerging sequence until all events are fully processed.” Does this imply that input actions in the present state may be executed iteratively? [Yes - order of consequent and causative input actions in StateA ST immaterial!] If an input action that was not due initially then becomes due after a subsequent due action is performed will it get executed? [Yes] The flowchart on page 186 implies not, I think.</em><br />
A1. The first part of the book is about specification of a state machine and a system of state machines. We have tried to keep it implementation independent and therefore we have limited our consideration of the execution path to the flow chart represented on p.186. We need the flowcharts to explain the  basic idea of multiple state transitions after a single events. Note that other implementations are imaginable and also available in StateWORKS (we can discuss it sometime later). The executor as implemented in RTDB has a queue (which is not shown on the flow chart) where events wait to be served. If the executor terminates serving of a given state machines (i.e. there are no transitions due) it returns on the flow chart to the point &#8220;wait for VI change&#8221;. The real executor checks whether the queue is empty and if not it takes the event from the queue and continues. In reality it is still more complex but I try in this moment just to explain the mechanism.<br />
<em>Q2. With multiple state transitions after a single VI event, the input actions of the intermediate states are ignored per 2nd point in box at top of page 187. Ok but what about those of the final state? [Also ignored.] If these simply do not get executed I have concerns that the vfsm will be left sitting in the final state when it may have already due input actions that would cause actions resulting in changed outputs or even further state changes. [True] Assuming such due input actions remained so, they’d then get executed when the next (unrelated?) VI event occurred – yes? [Yes – toggling the increment Cnt1 DI causes StateB to then trigger input actioned DO-HIGH showing Cnt2 over!] Possible alternative ………determining no immediate state transition is due defines the “final” state and then if the VI has changed since starting execution of the original current state this should be a “new” VI event causing any due input actions of the “final” (for now) state? </em><br />
A2. Yes, by multiple transitions only the input actions in the starting state are performed. We are not able to distinguish between intermediate states and a final one. In event driven systems there is always a chance of &#8220;missing&#8221; trigger. We have to think about it while specifying the system. We should not overuse the input actions. The best state machines are of type Moore where the only actions are the entry actions. We pay for the simplicity with more states but avoid problems with input actions. Do not forget we are not building a hardware system where number of state does cost. In  software minimizing the number of state is a rather irrelevant criteria; we should speak about optimizing the number of state, i. e. to have as many states as we need to make an understandable state machine.<br />
<em>Q3. Something that came up in my test : An entry action does ResetStart on a counter that was over. There is a transition action with condition same counter over – it gets triggered? </em><br />
A3. If the counter is reset the control value OVER is replaced by RESET. Thus, any condition containing the RESET value could be triggered (but not the condition with OVER which is not present any more). This effect has come up because of the generation I have explained in my direct email to you discussing the details of your state transition diagram.<br />
<em>Q4. Lastly a probably silly question but just to make sure I’m not missing something ……. Is it true that there is no way to cause an external source input (DI, DAT, PAR, NI) to change other than to have the controlled system or the “user” do it or for an OFUN to do it (DAT I’d assume)? Don’t see a way to connect a controlled system input to one of it’s outputs in swLab or SwMon?</em><br />
A4. There are 3 types of objects in the specification system (and consequently in RTDB): input, output and input/output type. An input type as for instance DI can be used as a condition to control a transition or an input action. An output type as for instance DO can be used to define an action to be performed. The input/output as for instance XDA can be used (with some restrictions) for both purposes.<br />
Other issues seen in your first example:<br />
- The use of Input actions should be limited to actions that can be repeated without any side effects. For instance setting a Do output several times does not do any harm. But incrementing a counter on a static control value (like Di) will in general result in erroneous behavior: if the Di value (which triggers the counter) stays HIGH any event triggers the execution of Input actions, i.e. the counter will increment. Any event causes execution of the state machine as shown in the flow chart.<br />
- Due to multi state transition mechanism a not “consumed” transition condition may cause an unintended transition while returning to the initial state. This results in an infinite loop that is detected and terminated by the Executor but it is of course an erroneous, not intended behavior.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stateworks.net/2008/07/getting-started/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Book critics</title>
		<link>http://www.stateworks.net/2008/03/book-critics/</link>
		<comments>http://www.stateworks.net/2008/03/book-critics/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 08:08:05 +0000</pubDate>
		<dc:creator>Ferdinand Wagner</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Finite state machine]]></category>
		<category><![CDATA[modeling software]]></category>

		<guid isPermaLink="false">http://stateworksnet.cmarc.net/2008/03/book-critics/</guid>
		<description><![CDATA[Our book &#8220;Modeling software with Finite State Machines&#8221; has received quite good reviews. Recently, I read in Amazon two controversial reviews on which I commented to my friends in an email as follows:

/We should not forget that we attack in the book the main streams: UML, Agile, Statecharts and in general the chaotic &#8220;traditional&#8221; on [...]]]></description>
			<content:encoded><![CDATA[<p>Our book <a href="http://www.stateworks.com/book/book/">&#8220;Modeling software with Finite State Machines&#8221;</a> has received quite good reviews. Recently, I read in Amazon two <a href="http://www.amazon.com/Modeling-Software-Finite-State-Machines/dp/0849380863/ref=sr_1_2?ie=UTF8&#038;s=books&#038;qid=1205228107&#038;sr=8-2">controversial reviews</a> on which I commented to my friends in an email as follows:</p>
<p><span id="more-6"></span><br />
<em>/We should not forget that we attack in the book the main streams: UML, Agile, Statecharts and in general the chaotic &#8220;traditional&#8221; on the one hand C-based and on the other Microsoft MFC and similar tools, generating software that tends to be easily corrupted. That means we attack the true programmers&#8217; world. It is surprising that the first negative remarks are after nearly two years. Note an interesting point: the reviewers admit that we really know the state machine topic but we do not know other things that we comment and criticize: unfortunately, they do not dare to mention one single topic that we do not know. They estimate it would be too dangerous to name something directly, so it is better just to express some general doubts about our competence outside the state machine topic. But the authors of the book have, in aggregate, many years of experience, often inside large companies, of software development in general and of the various techniques and tools criticized in Part 1 of the book in particular./ </em><br />
My friends have encouraged me to put my opinion in the blog. I will appreciate your opinion. Is the picture of the software development world presented in the book correct? If not, what are the basic weaknesses of our discussion?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stateworks.net/2008/03/book-critics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

