Event-driven Finite-state Machine
   HOME

TheInfoList



OR:

In
computation Computation is any type of arithmetic or non-arithmetic calculation that follows a well-defined model (e.g., an algorithm). Mechanical or electronic devices (or, historically, people) that perform computations are known as ''computers''. An es ...
, a
finite-state machine A finite-state machine (FSM) or finite-state automaton (FSA, plural: ''automata''), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number o ...
(FSM) is event driven if the transition from one state to another is triggered by an event or a message. This is in contrast to the parsing-theory origins of the term finite-state machine where the machine is described as consuming characters or tokens. Often these machines are implemented as threads or processes communicating with one another as part of a larger application. For example, a telecommunication protocol is most of the time implemented as an event-driven finite-state machine.


Example in C

This code describes the state machine for a very basic car radio system. It is basically an infinite loop that reads incoming events. The state machine is only 2 states: radio mode, or CD mode. The event is either a mode change from radio to cd back and forth, or a go to next (next preset for radio or next track for CD). /********************************************************************/ #include /********************************************************************/ typedef enum STATES; typedef enum EVENTS; EVENTS readEventFromMessageQueue(void); /********************************************************************/ int main(void)


Same Example in Ginr


Ginr
is an industrial-strength compiler producing multitape finite state automata from rational patterns, functions and relations expressed in
semiring In abstract algebra, a semiring is an algebraic structure similar to a ring, but without the requirement that each element must have an additive inverse. The term rig is also used occasionally—this originated as a joke, suggesting that rigs ar ...
algebraic terms. The example below shows a binary rational function equivalent to the above example, with an additional transition (nil, radio) to set the system into its initial state. Here the input symbols nil, mode, next denote events that drive a transducer with output effectors cd, nextTrack, radio, nextStation. Expressions like this are generally much easier to express and maintain than explicit listings of transitions.
StateMachine = (
  (nil, radio)
  (
    (mode, cd) (next, nextTrack)*
    (mode, radio) (next, nextStation)*
  )*
  (
    (mode, cd) (next, nextTrack)*
  )?
);
Compilation produces a subsequential (single-valued) binary transducer mapping sequences of events to sequences of effectors that actuate features of the CD/radio device.
StateMachine:prsseq;

(START)  nil 
radio Radio is the technology of signaling and communicating using radio waves. Radio waves are electromagnetic waves of frequency between 30 hertz (Hz) and 300 gigahertz (GHz). They are generated by an electronic device called a transmitt ...
1 1 mode
cd The compact disc (CD) is a digital optical disc data storage format that was co-developed by Philips and Sony to store and play digital audio recordings. In August 1982, the first compact disc was manufactured. It was then released in October ...
2 2 mode
radio Radio is the technology of signaling and communicating using radio waves. Radio waves are electromagnetic waves of frequency between 30 hertz (Hz) and 300 gigahertz (GHz). They are generated by an electronic device called a transmitt ...
3 2 next nextTrack 2 3 mode
cd The compact disc (CD) is a digital optical disc data storage format that was co-developed by Philips and Sony to store and play digital audio recordings. In August 1982, the first compact disc was manufactured. It was then released in October ...
2 3 next
nextStation NeXTstation is a high-end workstation computer developed, manufactured and sold by NeXT from 1990 until 1993. It runs the NeXTSTEP operating system. Overview The NeXTstation was released as a more affordable alternative to the NeXTcube at about ...
3
Modelling discrete systems in this manner obtains a clean separation of syntax (acceptable ordering of events) and semantics (effector implementation). The syntactic order of events and their extension into the semantic domain is expressed in a symbolic (semiring) domain where they can be manipulated algebraically while semantics are expressed in a procedural programming language as simple effector functions, free from syntactic concerns. The rational expressions provide concise holistic maps of the protocols that effect system governance. The compiled automata are post-processed to obtain efficient controllers for run-time deployment.


See also

*
Finite-state machine A finite-state machine (FSM) or finite-state automaton (FSA, plural: ''automata''), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number o ...
*
Specification and Description Language Specification and Description Language (SDL) is a specification language targeted at the unambiguous specification and description of the behaviour of reactive and distributed systems. Overview The ITU-T has defined SDL in Recommendations Z.100 t ...


External links


Ginr
(ginr whitepaper and user's guide)
Ribose
(demonstrates using ginr to transduce sequential media)


Further reading

* * {{DEFAULTSORT:Event-Driven Finite State Machine Models of computation