State Machine.(状态机)
What is a State Machine?
Any device that changes its state from one to another due to some actions are defined to be state machines. For example an ATM machine, traffic signal, remote control, the computer itself, etc. Most software applications also depend and operate based on the state. There are two types of state machines.
1. Finite state machine – A state machine holding a defined set of states and they work within that.
2. Infinite state machine – Here the states can be many and cannot be predefined.
Most common state machines are finite ones
Composition of a State Machine
The following things collectively make an effective finite state machine.
State:
A defined set of states. At any point of time the state machine will be in any one of the defined states. For example Red, Green and Yellow in a traffic signal system.
State Transition:
A state machine changing its state from one to another is called State Transition. Usually there will be a state transition table built that will contain the state sequences and also metadata saying which event will cause which state transition.
Triggers:
Triggers are the points that induce the state transition in a state machine.
Events or Actions:
Actions are performed by the state machines when a particular state is attained and exited. There will be Entry and Exit actions for each state.
Guard Condition:
This is the piece of component that validates the transition and ensures that no invalid state changes are carried out.
State Transition Table:
The turnstile state machine can be represented by a state transition table, showing for each state the new state and the output (action) resulting from each input
Current State | Input | Next State | Output |
---|---|---|---|
Locked | coin | Unlocked | Unlock turnstile so customer can push through |
push | Locked | None | |
Unlocked | coin | Unlocked | None |
push | Locked | When customer has pushed through, lock turnstile |
State Machine.(状态机)的更多相关文章
- Android4.0中蓝牙适配器state machine(状态机)的分析
今天晓东和大家来一起看一下Android4.0中蓝牙适配器(Bluetooth Adapter)的状态机变化的过程.首先,我们需要了解一下,蓝牙适配器究竟有哪些状态,从代码可以清晰地看到(framew ...
- 控制结构(3) 状态机(state machine)
// 上一篇:卫语句(guard clause) // 下一篇:局部化(localization) 基于语言提供的基本控制结构,更好地组织和表达程序,需要良好的控制结构. 前情回顾 上次分析了guar ...
- 控制结构(3): 状态机(state machine)
// 上一篇:卫语句(guard clause) // 下一篇:局部化(localization) 基于语言提供的基本控制结构,更好地组织和表达程序,需要良好的控制结构. 前情回顾 上次分析了guar ...
- 【UML】-NO.43.EBook.5.UML.1.003-【UML 大战需求分析】- 状态机图(State Machine Diagram)
1.0.0 Summary Tittle:[UML]-NO.43.EBook.1.UML.1.003-[UML 大战需求分析]- 状态机图(State Machine Diagram) Style:D ...
- 【翻译】What is State Machine Diagram(什么是状态机图)?
[翻译]What is State Machine Diagram(什么是状态机图)? 写在前面 在上一篇学习类图的时候将这个网站上的类图的一篇文章翻译了出来,感觉受益良多,今天来学习UML状态机图, ...
- Java Secret: Using an enum to build a State machine(Java秘术:用枚举构建一个状态机)
近期在读Hadoop#Yarn部分的源代码.读到状态机那一部分的时候,感到enmu的使用方法实在是太灵活了,在给并发编程网翻译一篇文章的时候,正好碰到一篇这种文章.就赶紧翻译下来,涨涨姿势. 原文链接 ...
- Raft算法系列教程2:状态机复制 (State Machine Replication)
分区容错如何保证? 在分布式系统设计中,需要遵循CAP理论,如果我们要让一个服务具有容错能力,那么最常用最直接的办法就是让一个服务的多个副本同时运行在不同的节点上.但是,当一个服务的多个副本都在运行的 ...
- Finite State Machine 是什么?
状态机(Finite State Machine):状态机由状态寄存器和组合逻辑电路构成,能够根据控制信号按照预先设定的状态进行状态转移,是协调相关信号动 作.完成特定操作的控制中心. 类 ...
- Qt: The State Machine Framework 学习
State Machine,即为状态机,是Qt中一项非常好的框架.State Machine包括State以及State间的Transition,构成状态和状态转移.通过状态机,我们可以很方便地实现很 ...
随机推荐
- 计算机上没有找到was服务
控制面板->程序->打开或关闭windows功能,勾选Microsoft .net framework下的两项.
- Queue的push和front操作
#include <queue> #include <cstdlib> using namespace std; int main(){ queue<int> qu ...
- 【转载】JSP常用跳转方式
转自:http://blog.csdn.net/wanghuan203/article/details/8836326 (1)href超链接标记,属于客户端跳转 (2)使用javascript完成,属 ...
- 类库、委托、is as运算符、泛型集合
类库: 说白了,就是让别人调用你写的方法,并且不让别人看到你是怎么实现的. 如果有功能你不会做,需要别人帮忙,那么你的同事可以帮你写好一个类,然后你来调用这个类中的方法,完成你的项目. 1.C#源代码 ...
- iOS开发Swift篇—(五)元组类型
iOS开发Swift篇—(五)元组类型 一.元组类型介绍 1.什么是元组类型 元组类型由 N个 任意类型的数据组成(N >= 0),组成元组类型的数据可以称为“元素” 示例: let posit ...
- 优雅的处理Android数据库升级的问题
原始完成于:2015-04-27 19:28:22 提供一种思路,优雅的处理Android数据库升级的问题,直接上代码: 1 package com.example.databaseissuetest ...
- SQLite存储类(数据类型)
SQLite数据类型更普遍,采用动态类型系统. 说是数据类型,更像是存储类,如:INTEGER存储类就包含多种不同长度的整数数据类型 [INTEGER]带符号的整数类型 [REAL]浮点值,小数类型 ...
- php一个简单的计算器
<?php if(isset($_POST['sub'])) { $result = ''; switch($_POST['ysf']) { case '+': $result = $_POST ...
- chromium 一些设置 --插件安装
一.安装flash插件 打开网页 http://get.adobe.com/cn/flashplayer/otherversions/ 选择如图 所示 fp 18 for Opera and Chr ...
- 关于allow_url_fopen的设置与服务器的安全
allow_url_fopen与安全以及PHP libcurl allow_url_fopen=ON常常会给服务器和管理员带来麻烦,但是经常性(至少我这样认为)的我们需要远程读取某个东西,如果设置al ...