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,构成状态和状态转移.通过状态机,我们可以很方便地实现很 ...
随机推荐
- iOS基础篇(十三)——UITableView(一)重用机制
UITableView是app开发中常用到的控件,功能很强大,常用于数据的显示.在学习UITableView使用之前,我们先简单了解一下: 1.UITableView的重用机制 UITableView ...
- react native ScrollView
ScrollView是一个通用的可滚动的容器,你可以在其中放入多个组件和视图,而且这些组件并不需要是同类型的.ScrollView不仅可以垂直滚动,还能水平滚动(通过horizontal属性来设置). ...
- PDF 补丁丁 0.4.2.1063 测试版发布:新增检查新版本功能
新版本增加了检查新版本的功能(程序不自动联网,请手动检查). 补丁丁拥趸们,你们可以更方便地用上程序的最新测试版本啦! 新测试版还修复了旧测试版的一些问题,欢迎下载试用哦!
- ExtJS 刷新后,默认选中刷新前最后一次选中的节点
在对树节点进行操作后往往需要进行reload操作刷新一下树,但是很多业务都需要在树形刷新后默认选中最后一次选中的节点.这样就必须先保存前一次选中节点的信息,在reload之后再次通过节点的 ...
- java中判断一个字符串是否“都为数字”和“是否包含数字”和“截取数字”
在javascript中有一个方法isDigit()使用来判断一个字符串是否都是数字,在java的字符串处理方法中没有这样的方法,觉得常常需要用到,于是上网搜了一下,整理出了两个用正则表达式匹配的判断 ...
- 使用PYTHON实现docx文档的读写
经常写文章的小白们会遇到这样的问题,知道想表达的意思,想出了大概描述的词汇,但就是缺乏完整漂亮的句子,也许曾经在某个地方看到过,但是找不到了.另外一种情况,阅读了大量的报告,用的时候想到了其中的某个结 ...
- DataTable的筛选,过滤后绑定数据源的两种方法(DataTable的select和使用linq返回List集合)
一般数据处理使用DataTable的情况会很多,而我们很多时候会对得到的DataTable的数据进行筛选后绑定到Combobox.GridView.Repeat等控件中,现在分享一下两种DataTab ...
- pads 扇出
1 选择BGA器件 2.扇出设置 3 安全间距问题 4 可以区域扇出也可以多点扇出
- CloseableHttpResponse的使用
*************************** *这篇随手弄出来了,很急躁,有空再改 *************************** 基本逻辑是: 1.定义一个客户端 2.定义一个方法 ...
- C#—打开文件
一.打开图片 ps:必须先在pictureBox中导入一张图片 private void button4_Click(object sender, EventArgs e)//选择.更换图片 { if ...