A building block is encapsulated by a contract, that describes the order in which parameters or pins can enter or exit the block. To have a contract has various benefits:
The figure bellow shows the block Speech Buffer from the outside (external point-of-view) with its corresponding contract on the right hand-side. To open a block contract, you can choose action “Show Contract” from the corresponding block's context menu.
Intuitively, we first need to initialize the block via pin init. Thereafter, pin speak can be used. At last, we terminate the block via pin stop and receive a confirmation via pin stopped.
A block contract is specified by a state machine, which consists of states and transitions. During its life cycle, a contract typically starts in the initial state, goes through some normal states before it terminates into one of its final states.
An initial state () is the first state of a block. It usually means that the block is switched off, meaning that its internal behavior is not doing anything. Each block contract must have exactly one initial state.
A normal state describes a certain phase in the building block, in which different things may happen. In all normal states, a building block is considered to be active. States with the same name are identical, so the same state may be shown several times within a diagram.
As shown in the figure above, the contract of block Speech Buffered has five states:
A transition connects a source state to a target state. It is labelled with the pins of a building block. This indicates
The source and target state of a transition can be the same. This is called self-transition. In order to improve the readability of contracts, we include this type of transitions directly below the state name (see state active in the following figure).
Transition labels include a slash (/) to improve the readability of the transitions. We'll cover its exact definition later. For now, simply think of the slash of separating the first input pin from the first output pin.
The contract of block Speech Buffered has five transitions:
As described above there are two alternative terminations for block Speech Buffered:
You may have noticed the different color of the pins on block Speech Buffered. These are also useful to understand the behavior of the block.
Within the tool, block contracts are written in a tabular form. Every row of the table describes a transition. The columns display the source state of the transition, the transition label (parameter nodes) and the target state of the transition. The tabular form of the contract of block Speech Buffer is depicted in the following figure.
Every row of the table above corresponds to exactly one transition in the contract diagram in the first figure on this page. For example, the first row of the table above corresponds to the initial transition in the contract diagram.