Prev Next

Example: Simulation in HTML with JavaScript

We already know that users can model an Executable StateMachine and simulate it in Enterprise Architect with the generated code. In the CD Player and the Regular Expression Parser examples, we will further demonstrate how users can integrate the generated code in their real projects.

Enterprise Architect provides two different mechanisms for client code to use a StateMachine:

  • Active State Based - The client can query the current active state, then 'switch' the logic based on the query result
  • Runtime Variable Based - The client does not act on the current active state, but does act on the runtime value of the variables defined in the Class containing the StateMachine

In the CD Player example, there are very few states and many buttons on the GUI, so it is quite easy to implement the example based on the Active State Mechanism; we will also query the runtime value for the current track.

In the Regular Expression Parser example the StateMachine handles everything, and a member variable bMatch changes its runtime value when states change. The client does not register how many states are there or which state is currently active.

In these topics, we will demonstrate how to model, simulate and integrate a CD Player and a Parser for a specified Regular Expression, step by step: