Java的StateMachine(二)More Examples
首页
http://smc.sourceforge.net/
图形化工具
http://www.graphviz.org/
I download the Smc version 6.0.1.
we just have the examples of java one by one
EXAMPLE 1
AppClass.sm is just what the example like, I never change it, it seems that it stands for the 00011110000 things.
AppClass.java I add some comments on the key point :
_fsm.setDebugFlag(true);
I set the debug on to see the logs.
I think the most import part is here:
public void Acceptable() {
// here is the real action we want to write in App, and it will be
// called by AppClassContext
_is_acceptable = true;
}
And I make a little test file AppClassTest.java:
package com.sillycat.sm.appclass;
public class AppClassTest {
public static void main(String[] args) {
String str = "0001111";
AppClass appobject = new AppClass();
System.out.print("The string \"");
System.out.print(str);
System.out.print("\" is ");
if (appobject.CheckString(str) == false) {
System.out.println("not acceptable.");
} else {
System.out.println("acceptable.");
}
}
}
And we get the output like this:
The string "0001111" is
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.OK
acceptable.
EXAMPLE 2
We add a new Default transaction.
EXAMPLE 3
This state machine "recognizes" the palindromes (words that read the same backwards as forwards). The words consist of the alphabet {0, 1, c} where the letter 'c' may appear only once and marks the words center.
I make a test java file AppClassTest.java:
package com.sillycat.sm.appclass;
public class AppClassTest {
public static void main(String[] args) {
String str = "0c0";
AppClass appobject = new AppClass();
System.out.print("The string \"");
System.out.print(str);
System.out.print("\" is ");
if (appobject.CheckString(str) == false) {
System.out.println("not acceptable.");
} else {
System.out.println("acceptable.");
}
}
}
And we get the output like this:
The string "0c0" is
PUSH TO STATE : ZerosMap.PushIt
ENTER STATE : ZerosMap.PopIt
POP TO STATE : StartMap.PushIt
ENTER STATE : StartMap.PopIt
ENTER STATE : StartMap.Acceptable
acceptable.
EXAMPLE 7
this example stands for the telephones.
After all the work, I found that our project use the version 4.3, so there must be some small differences.
分享到:
相关推荐
This examples explores hierarchichal state machines using an example of a hardware unit that can be in the following states: •Inservice state ◦Active state ◦Standby state •Out_Of_Service ◦...
Inside the Java Virtual Machine Bill Venners $39.95 0-07-913248-0 Inside the Java Virtual Machine Acknowledgments Introduction Part One: Java's Architecture 1 Introduction to Java's Architecture Why ...
QP State Machine Framework是基于事件驱动的嵌入式软件开发中的一个关键组件,它是一个高效、可扩展的状态机实现,主要用于管理复杂系统的行为。这个框架的主要版本是sqpc_4.1.05,它提供了对状态机设计模式的标准...
安装JAVA VTK以及运行VTK EXAMPLES的指导,使用jdk5,vtk4.4.2
《OnJava8-Examples-3.0_soucecode_java_》是基于Java 8的一份源代码库,它对应于《Thinking in Java 5th Edition》这本书中的示例代码。这个压缩包包含了丰富的编程示例,旨在帮助读者深入理解Java 8的新特性以及...
1.Review on counter design 2.State Diagrams for FSM 3.Moore & Mealy Models 4.State Minimization 5.Examples 6.HDL for FSMV
这份名为"java examples"的压缩包文件提供了丰富的Java编程示例,旨在帮助学习者深入理解和掌握Java标准库中的类以及它们的方法用法。这些例子涵盖了基础语法、数据类型、控制结构、类与对象、异常处理、集合框架、...
Mastering Java Machine Learning ...A practical guide to help you explore machine learning―and an array of Java-based tools and frameworks―with the help of practical examples and real-world use cases.
【Java_Web_Examples-master】是一个关于Java Web开发的资源集合,主要包含了各种示例代码,帮助开发者理解和学习如何在实际项目中应用Java Web技术。这个压缩包可能包含了一个具体的项目——“超市库存管理系统”,...
标题“LINQ的Java示例java-linq-examples.zip”指的是一个开源项目,它将Microsoft .NET框架中的Language Integrated Query (LINQ)概念移植到了Java平台。LINQ是一种在.NET中处理数据的强大工具,它允许程序员使用...
这个“javacv-examples-0.7-src.zip”压缩包包含了用于学习如何在Java环境下使用JavaCV进行计算机视觉编程的源代码示例。这些示例对于初学者来说是非常宝贵的资源,可以帮助他们快速理解和应用JavaCV库。 OpenCV是...
《第三版 Java Examples In A Nutshell》是一本深入浅出的Java编程教程,被誉为Java学习者的进阶之作。这本书由O'Reilly出版社出版,以其独特的"Nutshell"系列风格,为读者提供了丰富的代码示例和详尽的解释,旨在...
"Java_examples.rar" 是一个包含100多个Java程序实例的压缩包,旨在帮助初学者深入理解和掌握Java编程技术。这个资源包特别关注了“progressbardemo.java”,这是一个关于进度条控件的示例,对于那些想学习如何在...
一大堆java基础类的小例子 java.applet [8 examples] java.awt [78 examples] java.awt.datatransfer [3 examples] java.awt.dnd [3 examples] java.awt.event [8 examples] java.awt.font ...
这个"Java_examples.zip"压缩包包含的是专为初学者设计的100个Java示例程序,旨在帮助新接触Java编程的人快速掌握基础概念和实践技巧。 1. **面向对象编程**:Java的核心特性之一是它的面向对象编程(OOP)模型,...
Java Examples in a Nutshell(3rd) 英文epub 第3版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Java RESTful 示例代码是用于构建基于 Representational State Transfer (REST) 架构风格的Web服务。REST是一种轻量级的架构设计,它鼓励通过HTTP协议提供服务,使得客户端和服务器之间的交互变得更加简单和高效。本...
本资源"Java Cryptography with Examples"提供了关于如何在Java环境中应用这些概念的详细教程。 首先,Java通过Java Cryptography Architecture (JCA) 和 Java Cryptography Extension (JCE) 提供了全面的加密支持...