Embedded Systems

Assignment 2

Jan Hendrik Dithmar

2031259

Pascal Gwosdek

2505221

Assignment 2  Dithmar (2031259), Gwosdek (2505221)

2.1 Statecharts

a.

running white pausing white_{black moves}_{tick [white = 0] / black wins}  ^{white moves [wm = 0] /}^{wm := 20, white := 3600}^{white moves [wm ≠ 0] /}^{wm := wm - 1}_{tick [white > 0] / white := white - 1}  running black pausing black_{white moves}_{tick [black = 0] / white wins}  ^{black moves [bm = 0] /}^{bm := 20, black := 3600}^{black moves [bm ≠ 0] /}^{bm := bm - 1}_{tick [black > 0] / black := black - 1}  1 sec_{timeout/tick}  off^{key on / white := 7200, black := 7200,}^{wm := 40, bm := 40}_{key off}

b.

running white pausing white_{black moves}_{tick [white = 0] / black wins}  ^{white moves [wm = 0] /}^{wm := -1, white := 3600}^{white moves [wm ≠ 0] /}^{wm := wm - 1}_{tick [white > 0] / white := white - 1}  running black pausing black_{white moves}_{tick [black = 0] / white wins}  ^{black moves [bm = 0] /}^{bm := -1, black := 3600}^{black moves [bm ≠ 0] /}^{bm := bm - 1}_{tick [black > 0] / black := black - 1}  1 sec_{timeout/tick}  off^{key on / white := 7200, black := 7200,}^{wm := 40, bm := 40}_{key off}

c.

running white pausing white_{black moves}_{tick [white = 0] / black wins}_{white moves / white := white + 12}_{tick [white > 0] / white := white - 1} running black pausing black_{white moves}_{tick [black = 0] / white wins}_{black moves / black := black + 12}_{tick [black > 0] / black := black - 1}  1 sec_{timeout/tick}  off_{key on / white := 300, black := 300}_{key off}

d. We create one big OR superstate which contains the AND superstates of the exercise parts a, b and c. These are marked as boxed letters for the sake of readability. Our solution looks like this:

start  a_{[gt = classic] / white := 7200, black := 7200, wm := 40, bm := 40}  b_{[gt = quickplay] / white := 7200, black := 7200, wm := 40, bm := 40}  c_{[gt = fischer] / white := 300, black := 300}  off_{key on c / gt := classic}  ^{key on q /}^{gt := quickplay}  ^{key on f /}^{gt := fischer}_{key off}

In this (whole) exercise we used some variables, which we want to explain here:

• white, black The number of seconds left to the white and the black player.

• wm, bm The number of moves left to the white and the black player. This is needed to determine whether the player is still whithin his first 40 moves or not.

• gt This simply stands for gametype.

2.2 Petri nets

c_{1}  e_{1} e_{2}  c_{2} c_{3} c_{4}  e_{3}

The preconditions of e_{3} are: {c_{2}, c_{3}, c_{4}}. The postconditions of e_{1} are: {c_{2}, c_{3}}. The net is pure, because it does not contain any loops. The net is simple, because e_{1} and e_{2} have the same set of preconditions, namely {c_{1}}, but do not have the same set of postconditions.

2.3 Petri nets

The following abbreviations are used: M. for Milan, V. for Villa San Giovanni, M.M. for Messina Marittima, M.C. for Messina Centrale, S. for Siracusa and P. for Palermo.

2.4 Petri nets

... ... N_{0}  N_{1}  ...  N_{k}  ... ... ...

2.5 Petri nets

a.

x  t_{1}  z y  t_{2} 1111

b.

x  t_{1}  z y  t_{2} trash 11111

c.

x  t_{1}  div 71