Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.4K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Discrete event simulation similar to Harel/UML statecharts

I use Mathematica to develop methods for formal model-based user interface evaluation. Most of the methods require creating a finite state machine (FSM) of an interface, where the states are states of the interface and the transitions are actions initiated by the user. If you think about a 4 function calculator, the actions are all of the buttons and the state contains the contents of the display plus any internal variables required to compute the next visible state, given any button press. One way to create the FSM is to define a function that takes a button and the current state and produces the next state. Starting with the initial state of the device, a tree search produces a complete FSM for the interface.

As I apply these methods to more complex interfaces, It seems easier and more efficient to first model interfaces using something like UML/Harel statecharts, then convert those charts to an FSMs. Statecharts contain abstractions that greatly reduce the number of states and also make fairly complex event-driven behavior less error prone to model/program.

After downloading the trial of SystemModeler and spending a few hours working with it, I cannot tell at all whether I can create the kinds of event-driven models that I need, or even how to go about doing this. Modelica's Stategraph library claims to have Harel statechart power, but the modelica documentation is rather poor and all of the examples in SystemModeler/Modelica seem to use time-based or equation-based transitions. In contrast, Harel/UML statecharts are based on events (such as "+ pressed"). In addiiton, transitions can raise events that are then processed throughout the chart. In one example, I have two pull down menus. Making a choice from the first does not affect the second, but making a choice in the second, sets the first to the same value. The statechart I've attached here is showing the model for one of these pull down menus. In this case, there are two orthogonal parts to the state: the menu is either open or closed and is simultaneously in one of the states shown on the right.

So my question is whether this is possible in SystemModeler and, if so, is it possible to find better documentation/examples on how to do it?

Second, it is possible to see the chart with the current state(s) highlighted as I send events to it? In the attached image, the yellow states are active and I can click events from an event list (not shown) to trigger the next event and state transition.

Right now, I'm using Yakindu statechart tools (the source of this image), because it is free to me, and allows graphical simulation while viewing the statechart. Yakindu can create Java code of the statechart that I can then access from MMA to build the FSM using depth-first search over the event and state space. Unfortunately, Yakindu is based on Eclipse and its user interface leaves a lot to be desired, plus I've not found a way to edit the textual descriptions of the model (which is often easier than using a GUI).

Todd

Attachments:
POSTED BY: Todd Johnson
3 Replies

Todd,

It sounds like you really want the model to run the way it was originally constructed in the example with buttons. The way to set the buttons is by putting an array of transition times (button on/off) in the dialog for the buttons. Alternatively you can create sets of these on/off times in MMA and pass them into SystemModeler and run the simulation (either run from MMA or SystemModeler). In fact I like using the workflow of deriving data in MMA and sending it to SystemModeler and then running the model in SystemModeler -- The SystemModeler interface is better for viewing. You can also do this with a lookup table in SystemModeler without using MMA at all.

As far as creating the model, I think it should look close to the diagram you posted. If you are still open to trying WSM, I would contact the applications people in Sweden and they can probably help you with modeling best practices for State Machines of the type you describe.

Regards

Neil

POSTED BY: Neil Singer
POSTED BY: Todd Johnson
Attachments:
POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard