Flow(s) Harm Inner Block's Contract

This type of issue only applies for a block that contains inner block(s). It is related to an activity step does not respect the contract of an inner block. In another words, the contract of an inner block and the behavior of its enclosing block are not consistent.

Usually, the activity step runs through one of more pins of the affected inner block. However, the contract of the block does not allow the step. It allows only some of the flows.

Severity

General Solutions

Since this type of error is related to incorrect interaction between an inner block and its environment, there are, in general, two actions that can be taken to correct it.

  1. Change the activity diagram of the enclosing block (and maybe its contract).
  2. Change the inner block's contract (and maybe its corresponding activity diagram).

Of course, you can modify both the enclosing block and the inner block. The goal is to make the inner block and its surrounding activity diagram consistent with one another.

Note that you cannot always change the inner block. This is the case when the block is taken from a library or created by other developer. Moreover, modifying the inner block might affect other blocks that also use the inner block.

When you modify the enclosing block, you may need to check whether the modification affects other part of the block including other inner blocks.

Example 1: Illegal Synchronous Step

Consider an example of using block Periodic Notification in the following figure.

In the upper part of the figure, we see that the inner block Periodic Notification is in state active and the activity step that includes pin data, operation display and pin stop harms the block. As depicted in the contract on the left hand-side, when block Periodic Notification is in state active, only two activity steps are allowed:

  • An activity step that involves only pin data.
  • An activity step that involves pins stop and stopped.

While the highlighted activity step includes pins data and stop which does not correspond to either of the allowed steps above.

Modify the Enclosing Block

As mentioned above, we can fix the error by modifying the enclosing block. As depicted in the figure below, we add a 0ms timer between operation display and pin stop.

Here, the harming activity step is cut into two:

  • one that contains pin data, operation display and the timer.
  • the other that contains the timer and pin stop (and consequently stopped according to the contract of block Periodic Notification).

These two steps corresponding to the two transitions from state active mentioned above. Hence, now the block Periodic Notification is used correctly.

Modify the Inner Block

Alternatively, we can modify the inner block. In this example, we can add an additional transition from the state active to a final state which includes nodes data, stop, and stopped (in that order!) as depicted in the following figure.

Here, we do not need to modify the activity diagram of block Periodic Notification.

Example 2: Missing a Pin

Another example for this type of error is shown in the following figure.

In the upper part of the figure, we see that the inner block Inside is in state active and the activity step that includes pin out, the fork node, pins in1 and in2 harms the block. As depicted in the contract on the left hand-side, when block Inside is in state active, only three activity steps are allowed:

  • An activity step that involves only pin in2.
  • An activity step that involves pins out and in1.
  • An activity step that involves pins stop and stopped.

The highlighted activity step includes pins out and in1 like the second allowed step above, however, in addition pin in2 is also included. Hence, the highlighted activity step does not correspond to any of the allowed steps.

You might find that this example is very similar to example 1 above. Well, it is :-). The basic idea is still the same, namely there is an activity step that is not allowed by the contract of the inner block.

There are several alternatives to fix this error. Which one should be used depends on your application and whether you can modify the inner block. Three choices are shown in the following figure.

In alternatives 1 and 2, we modify the enclosing block, while in 3, we modify the contract of the inner block.

  1. A 0ms timer is added between the fork node and pin in2.
  2. The fork node and the flow from pin out to in2 are deleted.
  3. A transition from state active to a final state with label /out; in1+in2 is added.

We can also modify both the inner block's contract and the surrounding environment as depicted in the figure below.

Here, in the enclosing block we remove the fork node and the flow from pin out to in1. In the contract we modify the first transition (the one including only pin in2). We add pin out before in2 in the label.

Example 3: Illegal Restart

Another example of this error type involves restarting an inner block with a single activity step as shown in the following figure.

In the upper part of the figure, we see that the inner block Periodic Notification is in state active and the activity step that includes pin stop, stopped, a merge node, start harms the block. The contract on the lower part of the figure depicts that when block Periodic Notification is in state active, only two activity steps are allowed:

  • An activity step that involves pins data.
  • An activity step that involves pins stop and stopped.

This shows that the inner block cannot be started with one activity step. It requires two different steps.

The following figure shows two alternatives to fix this error.

  1. A 0ms timer is added between pin stopped and the merge node.
  2. A transition from state active to itself with label stop/stopped; start is added.