Test FSM Orthogonal - Sample Xholon App
What is it
This application tests and demonstrates the ability of Xholon to model and execute hierarchical finite state machines (FSM), especially an FSM containing orthogonal states. Xholon FSMs are based on the Unified Modeling Language (UML 2) specification for State Machines. This FSM was modeled using the Magic Draw UML tool, exported to XML Metadata Interchange (XMI) format, converted to Xholon XML and Java files using a set of XSLT scripts, merged with several manually-produced Xholon Java files, and executed using the Xholon runtime framework.
In UML, an orthogonal state contains two or more regions. Each of these regions can contain separate hierarchical states, that typically operate independently of each other.
How to use it
Run the application:
- Run the Java application through the Xhn GUI (org.primordion.xholon.app.Xhn.java), and select File --> Open --> TestFsm --> TestFsmOrthog_xhn.xml.
- You should see a list of parameter settings, and then the following lines showing which hierarchical and orthogonal states are initially active.
Studying:state_10 activeSubState is Lab1:state_19 CourseAttempt:state_5 activeSubState is Studying:state_10 stateMachine_3 activeSubState is CourseAttempt:state_5 Studying:state_10 activeSubState is TermProject:state_28 CourseAttempt:state_5 activeSubState is Studying:state_10 stateMachine_3 activeSubState is CourseAttempt:state_5 Studying:state_10 activeSubState is FinalTest:state_39 CourseAttempt:state_5 activeSubState is Studying:state_10 stateMachine_3 activeSubState is CourseAttempt:state_5 CourseAttempt:state_5 activeSubState is Studying:state_10 stateMachine_3 activeSubState is CourseAttempt:state_5
Start the FSM:
- Expand the Controller node in the GUI tree.
- Press the Start node.
- You should see:
Harness Transitioning from TermProject to FinalState Studying:state_10 activeSubState is :finalState_30 CourseAttempt:state_5 activeSubState is Studying:state_10 stateMachine_3 activeSubState is CourseAttempt:state_5 Transitioning from Lab1 to Lab2 Studying:state_10 activeSubState is Lab2:state_20 CourseAttempt:state_5 activeSubState is Studying:state_10 stateMachine_3 activeSubState is CourseAttempt:state_5 Transitioning from FinalTest to FinalState Studying:state_10 activeSubState is :finalState_42 CourseAttempt:state_5 activeSubState is Studying:state_10 stateMachine_3 activeSubState is CourseAttempt:state_5 Transitioning from Lab2 to FinalState Studying:state_10 activeSubState is :finalState_22 CourseAttempt:state_5 activeSubState is Studying:state_10 stateMachine_3 activeSubState is CourseAttempt:state_5
Things to notice
The Test FSM Orthog application implements the following features of the UML 2 State Machine formalism. Each line provides the name of the UML 2 feature, and the Xholon class name in angle brakets. See the InheritanceHierarchy, CompositeStructureHierarchy, and ClassDetails XML files.
- Behavior <Behavior>
- StateMachine <StateMachine>
- Region <Region>
- Vertex <Vertex>
- State <State>
- FinalState <FinalState>
- Pseudostate <Pseudostate>
- PseudostateKind: initial <PseudostateInitial>
- Trigger <Trigger>
- Transition <Transition>
- transition effect activity <Activity>
- connectionPoint <port name="cnpt">
The MagicDraw state machine diagram specifies the hierarchical states and transitions within the behavior of FsmXholon. CourseAttempt, and Studying are UML composite States. Lab1 and Lab2 are UML simple states within one Region of the Studying state. TermProject is within another Region. FinalTest is within a third orthogonal Region. Each state is contained within an invisible Region. There are five FinalStates in the diagram. The diagram includes four instances of the initial (large filled circle) kind of Pseudostate. Arrows represent Transitions between States. Each Transition is labeled with the name of a received signal that acts as a Trigger (ex: LAB_DONE), and the name of an action (ex: labDone).
Things to try
XhTestFsmOrthog.java runs one of five different scenarios. The default is scenario TEST_SCENARIO_4. Try one of the other four scenarios by changing the TestScenario parameter in TestFsmOrthog_xhn.xml. Enter a value between 1 and 5. Look at XhTestFsmOrthog.java to see what actions are taken in each test.
Extending the model
Create additional test scenarios in XhTestFsmOrthog.java.
If you are familiar with UML and with MagicDraw, make some changes to the UML model and regenerate the Xholon application.
Xholon features
Semi-automatic generation of a Xholon application from a UML model.
Xholon hierarchical finite state machines, especially orthogonal states.
Credits and references
See the similar TestFsm Xholon model for additional information.
See additional information in _README.txt in the transform/MagicDraw folder.
Visit the OMG site to learn more about UML 2, and to view the current UML specification, Version 2.0, as a free download. This document is called the UML 2.0 Superstructure specification.
Visit the MagicDraw site. You might want to download a trial version of their UML tool, or their free model Reader. You can use either of these to load and view the TestFsm5.xml.zip MagicDraw model file in the transform/MagicDraw folder.