User Tools

Site Tools


wonham:creating_and_editing_state_machines

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

wonham:creating_and_editing_state_machines [Tuesday, 06 June 2006 : 15:23:14]
127.0.0.1 external edit
wonham:creating_and_editing_state_machines [Thursday, 02 April 2009 : 09:48:58] (current)
hvrooy
Line 1: Line 1:
 +====== Creating and editing state machines ======
 +In //​svctools//,​ state machines can be defined in several file formats, each with their own limitations.
 +At this page, an overview is given.
 +  * [[#Wonham DES]]
 +  * [[#Wonham ADS]]
 +  * [[#Sctool SCT]]
 +  * [[#​Statemachines STM]]
  
 +{{:​wonham:​pq.png|:​wonham:​pq.png}} To show the file formats 'in action',​ a simple example state machine with initial state //A// and marker state //B// has been created. The transition from state //A// to state //B// is done via controllable event //p//, and back to state //A// will then happen with uncontrollable event //q//.
 +
 +For the textual file formats, this machine will be encoded as example to give you an idea of what the file format looks like.
 +
 +===== Wonham DES =====
 +The ''​tct''​ tool by Wonham has a ''​.des''​ format, which is a binary format for storing state machines. How the information is stored in the file is not known. You can read and write these files by using the ''​tct''​ tool itself, and convert them to for example the ''​.ads''​ format described below.
 +
 +===== Wonham ADS =====
 +The ''​tct''​ tool by Wonham also has a ''​.ads''​ format. This is a text format, and can be viewed by any text editor. The format is intended for manually entering state machine specifications. However, since ''​tct''​ can also write such files, the file format can also be used to export state machines.
 +
 +The format accepted by the ''​.ads''​ format is numeric in nature. All names must be converted to numbers, and the output is also in numbers. For the example state machine, this means
 +
 +  - The initial state //A// must be state 0
 +  - All other states must be consequtively numbered starting from 1 up to '​size-1'​ for a state machine with '​size'​ states. Thus, state //B// becomes state 1
 +  - Events are also numbered. Controllable events must get an odd number, uncontrollable events must get an even number. Controllable event //p// becomes 1, and uncontrollable event //q// becomes 0. Note that these events need not start from 0 nor do they need to be consecutively numbered.
 +
 +The ''​.ads''​ file of the example becomes:
 +<​code>​
 +# Generated CTCT ADS file
 +
 +pq
 +
 +State size (State set will be (0,​1....,​size-1)):​
 +# <-- Enter state size, in range 0 to 2000000, on line below.
 +2
 +
 +Marker states:
 +# <-- Enter marker states, one per line.
 +# To mark all states, enter *.
 +# If no marker states, leave line blank.
 +# End marker list with blank line.
 +1
 +
 +Vocal states:
 +# <-- Enter vocal output states, one per line.
 +# Format: State  Vocal_Output. ​ Vocal_Output in range 10 to 99.
 +# Example: 0 10
 +# If no vocal states, leave line blank.
 +# End vocal list with blank line.
 +
 +Transitions:​
 +# <-- Enter transition triple, one per line.
 +# Format: Exit_(Source)_State ​ Transition_Label ​ Entrance_(Target)_State.
 +# Transition_Label in range 0 to 999.
 +# Example: 2 0 1 (for transition labeled 0 from state 2 to state 1).
 +0 1 1
 +1 0 0
 +</​code>​
 +This file format also supports vocal states, these are not needed for untimed state machine specifications.
 +
 +===== Sctool SCT =====
 +The ''​sctool''​ written by H.A. de Vos has its own textual Discrete Event System (DES) format. To prevent confusion with the ''​des''​ format of the ''​tct''​ tool by Wonham, files in this format use the ''​.sct''​ extension.
 +Only ''​sctool''​ can read and write these files.
 +
 +The ''​.sct''​ format of sctool is more compact than the ''​.stm''​ format. It consists of a number of sections. Unlike the ''​.ads''​ format, it allows you to use any identifier as name of a state or name of an event. The example state machine becomes:
 +<​code>​
 +[t]
 +A p B
 +B q A
 +[s0]
 +A
 +[Sm]
 +B
 +[Eu]
 +q
 +</​code>​
 +The first section is ''​[t]''​ which stands for transitions. The seocnd and third line then list the transition. In the ''​[s0]''​ section the start state is listed, while in the ''​[Sm]''​ section the marker states are listed. If you have more marker states, put them at one line with a space between them. Finally, the uncontrollable events are listed (on one line with a space between them) in the ''​[Eu]''​ section.
 +
 +If you have no data for a section (for example, you have no marker states), you should eliminate the entire section from the file.
 +
 +===== Statemachines STM =====
 +The statemachines ''​.stm''​ format is also a text format. Its primary goal is readability and extensibility. Also, a Python API exists for reading and writing files in this format. The format is defined at [[http://​se.wtb.tue.nl/​sewiki/​wonham/​fileformat]].
 +In the svctools, the ''​.stm''​ format takes a central role. ''​sctool''​ can read and write ''​.stm''​ files, and programs [[tools#​ads2stm|ads2stm]] and [[tools#​stm2ad|stm2ads]] exist for converting from and to the Wonham ''​.ads''​ format.
 +Also, programs exist to support further processing. Using ''​gen-dot'',​ a state machine can be converted to the ''​.dot''​ format of the [[http://​www.graphviz.org/​|Graphviz tool set]] (and then through the Graphviz ''​dot''​ program to a large number of 2D visualization output formats).
 +
 +The ''​.stm''​ format is the most verbose of the three textual formats. The example state machine is encoded in this file format as follows:
 +<​code>​
 +component AB:
 +
 +    state A
 +
 +    state B:
 +        marked
 +
 +    # state A is the initial state
 +    initial A
 +
 +
 +    action A -> B:
 +        label p
 +
 +    event B -> A:
 +        label q
 +</​code>​
 +The format has been inspired by the Python syntax with its use of the colon and indentation. The empty lines are optional, as is the comment line. Other keywords such as ''​description''​ may be used to add other information to the state machine.
 +The statemachines ''​.stm''​ format uses the terms ''​action''​ and ''​event''​ for Wonham controllable events and uncontrollable events.
wonham/creating_and_editing_state_machines.txt · Last modified: Thursday, 02 April 2009 : 09:48:58 by hvrooy