资源简介
一种有限状态机(FSM)的C语言实现,在事件中判断状态。
代码片段和文件信息
/*
* Copyright (c) 2013 Andreas Misje
*
* Permission is hereby granted free of charge to any person obtaining a
* copy of this software and associated documentation files (the “Software“)
* to deal in the Software without restriction including without limitation
* the rights to use copy modify merge publish distribute sublicense
* and/or sell copies of the Software and to permit persons to whom the
* Software is furnished to do so subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
* IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING
* FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include
#include
#include “stateMachine.h“
/* This simple example checks keyboad input against the two allowed strings
* “ha\n“ and “hi\n“. If an unrecognised character is read a group state will
* handle this by printing a message and returning to the idle state. If the
* character ‘!‘ is encountered a “reset“ message is printed and the group
* state‘s entry state will be entered (the idle state).
*
* print ‘reset‘
* o +---------------------+
* | | | ‘!‘
* | v group state |
* +-----v-----------------------------------+----+
* | +------+ ‘h‘ +---+ ‘a‘ +---+ ‘\n‘ |
* +->| idle | ----> | h | ----> | a | ---------+ |
* | +------+ +---+\ +---+ | |
* | ^ ^ ^ \‘i‘ +---+ ‘\n‘ | |
* | | | | \--> | i | ------+ | |
* | | | | +---+ | | |
* +---|-|-|----------------+----------------|--|-+
* | | | | | |
* | | | | ‘[^hai!\n]‘ | |
* | | | print unrecog. | | |
* | | +----------------+ print ‘hi‘ | |
* | +-----------------------------------+ |
* | print ‘ha‘ |
* +----------------------------------------+
*/
/* Types of events */
enum eventType {
Event_keyboard
};
/* Compare keyboard character from transition‘s condition variable against
* data in event. */
static bool compareKeyboardChar( void *ch struct event *event );
static void printRecognisedChar( void *stateData struct event *event );
static void printUnrecognisedChar( void *oldStateData struct event *event
void *newStateData );
static void printReset( void *oldStateData struct event *event
void *newStateData );
static void prin
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-06 20:02 stateMachine-master\
文件 42 2014-03-21 05:29 stateMachine-master\.gitignore
文件 1082 2014-03-21 05:29 stateMachine-master\LICENSE.md
文件 172 2014-03-21 05:29 stateMachine-master\Makefile
文件 211 2014-03-21 05:29 stateMachine-master\README.md
目录 0 2018-11-06 20:02 stateMachine-master\doc\
文件 76449 2014-03-21 05:29 stateMachine-master\doc\doxyconfig
目录 0 2018-11-06 20:02 stateMachine-master\doc\img\
文件 3493 2014-03-21 05:29 stateMachine-master\doc\img\logo.png
文件 36326 2014-03-21 05:29 stateMachine-master\doc\img\stateMachine.svg
目录 0 2018-11-06 20:02 stateMachine-master\examples\
文件 7586 2014-03-21 05:29 stateMachine-master\examples\stateMachineExample.c
目录 0 2018-11-06 20:02 stateMachine-master\src\
文件 5630 2014-03-21 05:29 stateMachine-master\src\stateMachine.c
文件 17378 2014-03-21 05:29 stateMachine-master\src\stateMachine.h
目录 0 2018-11-06 20:02 stateMachine-master\tests\
文件 9684 2014-03-21 05:29 stateMachine-master\tests\nestedTest.c
- 上一篇:简易学生信息管理系统
- 下一篇:机械手臂运动程序
相关资源
- 基于STM32单片机的多路数据采集系统设
- 基于STM32单片机+MPU6050传感器做的载人
- stm32_Cjson源码
- STM32 LCD12864并口驱动实验 完整C语言代
- STM32F103ZET6 按键串口 发16进制[字符串
- STM32系列单片机C语言编程语法指导
- STM32-FM1702
- 基于stm32f407八字循迹小车代码C语言写
- HMC5883驱动,C语言
- STM32-C语言知识点
- C语言 stm32 AES加密解密
- hello world ,stm32串口打印程序
- 基于单片机的json编解码源码.zip
- mpu9250九轴姿态用STM32F103实现I2C通信
- FSME有限状态机生成器
- 基于STM32F4的加速度频域二次积分振动
- STM32F3 LCD1602 I2C驱动代码 C语言
-
Jli
nk 命令行自动程序 - stm32f103的TCS34725驱动分享
- 昆仑通态屏做主机与STM32单片机从机之
- MAX30102心率血氧显程-STM32F103C8T6-C语言
- STM32的TM1650程序.zip
- HAL基础实验源码09 stm32cubemx-F429IGT6扩展
- RA8875 STM32F407 C++驱动
- STM32驱动TMP75 C语言程序
- STM32开发板实验指导1
- I0操作_LED流水灯xws
- stm32f303休眠
- STM32游戏手柄实验
- 非阻塞式AT指令发送接收工程,可驱动
评论
共有 条评论