- 浏览: 2552814 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Java的StateMachine(一)说明文档
首页
http://smc.sourceforge.net/
图形化工具
http://www.graphviz.org/
I download the Smc version 6.0.1.
smc.pdf Introduction of the State Machine Compiler
FSM(Finite State Machine) is everywhere.
A input source .sm(yacc-like syntax), a output source in your language like java or python.
1.conceptions
A Simple Transition
//State
Idle {
// Trans Next State Actions
Run Running {}
}
A Reflexive Transition
//State
Idle{
// Trans Next State Actions
Timeout Idle {}
}
A Internal Event
// State
Idle {
//Trans Next State Actions
Timeout nil {}
}
A Transition with Actions
// State
Idle{
//Trans
Run
//Actions
{
StopTimer("Idle");
DoWork();
}
}
Transition Guards
conditions that must be met in order for transitions to proceed
// State
Idle{
//Trans
Run
//Guard condition
[ctxt.isValid()]
//Next State
Running
//Actions
{
StopTimer("Idle");
DoWork();
}
Run Idle {RejectRequest();}
}
Transition Arguments
// State
Idle{
//Transition
Run(msg:const Message&)
//Guard condition
[msg.isValid()]
//Next State
Running
//Actions
{
StopTimer("Idle");
DoWork(msg);
}
Run(msg:const Message&)
//Next State Actions
Idle { RejectRequest(msg);}
}
Entry and Exit Actions
Actions performed every time we enter and exit a state,respectively
// State
Idle
Entry {StartTimer("Idle",1); CheckQueue();}
Exit {StopTimer("Idle");}
{
//Transitions
}
2.A case study: a Telephone
demo url:
http://smc.sourceforge.net/SmcDemo.htm
SMC_Tutorial.pdf book
An example of simple turnstile:
1.Description of the normal operation of a turnstile:
Turnstile initially locked
A coin or ticket is inserted(event)
triggers action: turnstile unlocks
A person passes through turnstile(event)
triggers action: turnstile locks again
most important concepts:States,Transitions and Actions
Transition table for turnstile
State Transition Next State Action
Locked coin Unlocked unlock
pass Locked alarm
Unlocked coin Unlocked thankyou
pass Locked lock
I use a sm file to show the workflow Turnstile.sm:
%class Turnstile
%package turnstile
%start MainMap::Locked
%map MainMap
%%
Locked
{
coin Unlocked { unlock(); }
pass nil { alarm(); }
}
Unlocked
{
pass Locked { lock(); }
coin nil { thankyou(); }
}
%%
And I put a bat file on Windows to compile the sm file to java output, BuildSm.bat:
java -jar smc-6.0.1.jar -java -d turnstile Turnstile.sm
rem -jar smc-6.0.1.jar The SMC Compiler
rem -java Specify java language output
rem -d turnstile Optionally specify target directory
rem turnstile.sm Specify the .sm file to process
After we run the bat shell, we get a single file named TurnstileContext.java and we get many classes:
TurnstileContext$MainMap.class
TurnstileContext$MainMap_Default$MainMap_Locked.class
TurnstileContext$MainMap_Default$MainMap_Unlocked.class
TurnstileContext$MainMap_Default.class
TurnstileContext$TurnstileState.class
TurnstileContext.class
Write the AppClass Turnstile.java:
package com.sillycat.sm.turnstile;
public class Turnstile implements TurnstileActions{
TurnstileContext _fsm;
TurnstileActions _actions;
public Turnstile(TurnstileActions actions){
_fsm = new TurnstileContext(this);
_actions = actions;
}
public void coin(){_fsm.coin();}
public void pass(){_fsm.pass();}
public void alarm(){_actions.alarm();}
public void lock() {_actions.lock();}
public void thankyou() {_actions.thankyou();}
public void unlock() {_actions.unlock();}
}
TurnstileActions.java:
package com.sillycat.sm.turnstile;
public interface TurnstileActions {
public void coin();
public void pass();
public void alarm();
public void lock();
public void thankyou();
public void unlock();
}
And we can build sm file into a .dot file and view the picturn of the workflow,GraphSm.bat:
java -jar smc-6.0.1.jar -graph -glevel 1 Turnstile.sm
we can get a Turnstile_sm.dot file after we run the command, and we can install graphviz-2.26.3.msi from URL
http://www.graphviz.org/
And we use Gvedit to open the file Turnstile_sm.dot and then we can see the picture.
首页
http://smc.sourceforge.net/
图形化工具
http://www.graphviz.org/
I download the Smc version 6.0.1.
smc.pdf Introduction of the State Machine Compiler
FSM(Finite State Machine) is everywhere.
A input source .sm(yacc-like syntax), a output source in your language like java or python.
1.conceptions
A Simple Transition
//State
Idle {
// Trans Next State Actions
Run Running {}
}
A Reflexive Transition
//State
Idle{
// Trans Next State Actions
Timeout Idle {}
}
A Internal Event
// State
Idle {
//Trans Next State Actions
Timeout nil {}
}
A Transition with Actions
// State
Idle{
//Trans
Run
//Actions
{
StopTimer("Idle");
DoWork();
}
}
Transition Guards
conditions that must be met in order for transitions to proceed
// State
Idle{
//Trans
Run
//Guard condition
[ctxt.isValid()]
//Next State
Running
//Actions
{
StopTimer("Idle");
DoWork();
}
Run Idle {RejectRequest();}
}
Transition Arguments
// State
Idle{
//Transition
Run(msg:const Message&)
//Guard condition
[msg.isValid()]
//Next State
Running
//Actions
{
StopTimer("Idle");
DoWork(msg);
}
Run(msg:const Message&)
//Next State Actions
Idle { RejectRequest(msg);}
}
Entry and Exit Actions
Actions performed every time we enter and exit a state,respectively
// State
Idle
Entry {StartTimer("Idle",1); CheckQueue();}
Exit {StopTimer("Idle");}
{
//Transitions
}
2.A case study: a Telephone
demo url:
http://smc.sourceforge.net/SmcDemo.htm
SMC_Tutorial.pdf book
An example of simple turnstile:
1.Description of the normal operation of a turnstile:
Turnstile initially locked
A coin or ticket is inserted(event)
triggers action: turnstile unlocks
A person passes through turnstile(event)
triggers action: turnstile locks again
most important concepts:States,Transitions and Actions
Transition table for turnstile
State Transition Next State Action
Locked coin Unlocked unlock
pass Locked alarm
Unlocked coin Unlocked thankyou
pass Locked lock
I use a sm file to show the workflow Turnstile.sm:
%class Turnstile
%package turnstile
%start MainMap::Locked
%map MainMap
%%
Locked
{
coin Unlocked { unlock(); }
pass nil { alarm(); }
}
Unlocked
{
pass Locked { lock(); }
coin nil { thankyou(); }
}
%%
And I put a bat file on Windows to compile the sm file to java output, BuildSm.bat:
java -jar smc-6.0.1.jar -java -d turnstile Turnstile.sm
rem -jar smc-6.0.1.jar The SMC Compiler
rem -java Specify java language output
rem -d turnstile Optionally specify target directory
rem turnstile.sm Specify the .sm file to process
After we run the bat shell, we get a single file named TurnstileContext.java and we get many classes:
TurnstileContext$MainMap.class
TurnstileContext$MainMap_Default$MainMap_Locked.class
TurnstileContext$MainMap_Default$MainMap_Unlocked.class
TurnstileContext$MainMap_Default.class
TurnstileContext$TurnstileState.class
TurnstileContext.class
Write the AppClass Turnstile.java:
package com.sillycat.sm.turnstile;
public class Turnstile implements TurnstileActions{
TurnstileContext _fsm;
TurnstileActions _actions;
public Turnstile(TurnstileActions actions){
_fsm = new TurnstileContext(this);
_actions = actions;
}
public void coin(){_fsm.coin();}
public void pass(){_fsm.pass();}
public void alarm(){_actions.alarm();}
public void lock() {_actions.lock();}
public void thankyou() {_actions.thankyou();}
public void unlock() {_actions.unlock();}
}
TurnstileActions.java:
package com.sillycat.sm.turnstile;
public interface TurnstileActions {
public void coin();
public void pass();
public void alarm();
public void lock();
public void thankyou();
public void unlock();
}
And we can build sm file into a .dot file and view the picturn of the workflow,GraphSm.bat:
java -jar smc-6.0.1.jar -graph -glevel 1 Turnstile.sm
we can get a Turnstile_sm.dot file after we run the command, and we can install graphviz-2.26.3.msi from URL
http://www.graphviz.org/
And we use Gvedit to open the file Turnstile_sm.dot and then we can see the picture.
发表评论
-
Update Site will come soon
2021-06-02 04:10 1679I am still keep notes my tech n ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 431Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 374Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 456VPN Server 2020(2)Docker on Cen ... -
Nginx Deal with OPTIONS in HTTP Protocol
2020-02-15 01:33 356Nginx Deal with OPTIONS in HTTP ... -
PDF to HTML 2020(1)pdftohtml Linux tool or PDFBox
2020-01-29 07:37 409PDF to HTML 2020(1)pdftohtml Li ... -
Elasticsearch Cluster 2019(2)Kibana Issue or Upgrade
2020-01-12 03:25 721Elasticsearch Cluster 2019(2)Ki ... -
Spark Streaming 2020(1)Investigation
2020-01-08 07:19 295Spark Streaming 2020(1)Investig ... -
Hadoop Docker 2019 Version 3.2.1
2019-12-10 07:39 295Hadoop Docker 2019 Version 3.2. ... -
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 241MongoDB 2019(3)Security and Aut ... -
MongoDB 2019(1)Install 4.2.1 Single and Cluster
2019-11-11 05:07 294MongoDB 2019(1) Follow this ht ... -
Monitor Tool 2019(1)Monit Installation and Usage
2019-10-17 08:22 325Monitor Tool 2019(1)Monit Insta ... -
Ansible 2019(1)Introduction and Installation on Ubuntu and CentOS
2019-10-12 06:15 312Ansible 2019(1)Introduction and ... -
Timezone and Time on All Servers and Docker Containers
2019-10-10 11:18 332Timezone and Time on All Server ... -
Kafka Cluster 2019(6) 3 Nodes Cluster on CentOS7
2019-10-05 23:28 283Kafka Cluster 2019(6) 3 Nodes C ... -
K8S Helm(1)Understand YAML and Kubectl Pod and Deployment
2019-10-01 01:21 326K8S Helm(1)Understand YAML and ... -
Rancher and k8s 2019(5)Private Registry
2019-09-27 03:25 362Rancher and k8s 2019(5)Private ... -
Jenkins 2019 Cluster(1)Version 2.194
2019-09-12 02:53 444Jenkins 2019 Cluster(1)Version ... -
Redis Cluster 2019(3)Redis Cluster on CentOS
2019-08-17 04:07 373Redis Cluster 2019(3)Redis Clus ...
相关推荐
COLA StateMachine的另一个特点是支持用DSL(Domain Specific Language,领域特定语言)表达状态转移,其设计注重语义清晰性,让状态流转逻辑变得直观和易于理解。这样的设计不仅可以帮助开发者快速上手状态机,也...
标签再次确认了文档的主题,"StateMachine",意味着文档内容将深入探讨状态机这一主题,对于学习和理解状态机的理论和应用非常有帮助。通过阅读这份PDF文档,读者可以系统地学习状态机的概念,掌握其设计和实现技巧...
标题中的“Projet machine d'états_statemachine_”暗示了我们正在讨论的是一个与状态机相关的项目。状态机,或称为状态图,是一种用于建模系统行为的工具,它描述了系统在不同时间可能存在的状态以及如何从一个...
有限状态机 (Finite State Machine, FSM) 是一种常用的设计模式,用于表示 Actor 的不同状态及其转换。 ##### 3.8 Persistence Persistence 是 Akka 的一个扩展功能,用于存储 Actor 的状态。这使得即使在 Actor ...
总的来说,开源的“Finite State Machine Generator”工具为C++和Java开发者提供了一个高效、轻量的解决方案,帮助他们轻松应对复杂的状态管理问题,提升了软件的可维护性和性能。同时,通过参与开源社区,开发者还...
对于希望更深入了解代码生成过程的用户,可以查看安装目录下的 `StateMachine_Sample.eap` 文件,该文件包含了更详细的示例。 - **文件位置**:Enterprise Architect 的安装目录下。 - **示例内容**: - 包含更...
12. 使用 Spring StateMachine 实现一个状态机 13. SpringBoot 实现文件上传系统 14. springboot 实现短链接系统 15. springboot 实现数据库文档生成器 16. 基于 SpringBoot2+Freemarker 的代码生成器 17. 使用 ...
标题中的“State Machine Compiler-开源”表明我们正在讨论一个用于编译状态机的开源项目。状态机是一种数学模型,常用于计算机科学和软件工程中,它以一系列状态和触发状态转换的事件为基础,用于描述系统行为。...
Java可以利用axis、cxf等框架创建SOAP(Simple Object Access Protocol)或REST(Representational State Transfer)风格的Web服务。同时,.NET和CORBA(Common Object Request Broker Architecture)也是跨平台...
* JVM (Java Virtual Machine):Java 虚拟机,是 Java 程序的运行环境。 * JNI (Java Native Interface):Java 本地接口,是一种允许 Java 程序调用本地代码的接口。 二、Java 企业级概念 * JNDI (Java Naming & ...
5. **JVM (Java Virtual Machine)**:JVM是JAVA程序的执行引擎,负责解析并执行字节码。 6. **JNI (Java Native Interface)**:JNI允许JAVA代码调用操作系统原生的函数,实现JAVA与其他语言的互操作性。 7. **AWT ...
#### Chapter 14 - StateMachine(状态机) - **状态机设计**:介绍了如何利用状态机模式优化Mina应用程序的状态管理。 #### Chapter 15 - 代理 - **代理支持**:探讨了Mina对代理服务器的支持情况,包括配置和使用...
28. **JavaDoc**:Java文档生成工具,自动生成API文档,方便代码阅读和维护。 29. **模块系统(Java Modules System)**:Java 9引入的新特性,用于管理和隔离项目中的依赖。 30. **Lambda表达式**:Java 8引入的...
- **Finite State Machine (FSM)**:有限状态机,用于实现状态驱动的Actor。 - **Akka Extensions**:扩展模块,提供了更多的高级功能。 - **ZeroMQ**:与ZeroMQ消息队列集成的模块。 - **Microkernel**:微内核架构...
4. 状态与状态机(State & State Machine):流程实例在运行过程中会经历不同的状态,形成一个状态机模型。状态机设计确保流程按照预定规则进行。 在实际使用OSWorkflow时,我们通常会经历以下步骤: 1. 配置与...
3. **状态机**:词法分析器通常通过有限状态自动机(Finite State Machine, FSM)的工作原理来工作,从输入字符流中识别出符合规则的序列。 4. **缓冲区管理**:为了高效处理输入,词法分析器会使用一个缓冲区来...
"macjava源码-javascript-state-machine-notes" 提到的项目可能是一个专门研究和实现JavaScript状态机的开源项目。这个项目可能包含了一个或多个实现状态机的JavaScript库,供开发者学习和使用。通过阅读源码,...