nearly there

This commit is contained in:
Johannes Theiner 2020-05-10 11:51:33 +02:00
parent c681fcc2ee
commit ba8cc850c7
3 changed files with 14 additions and 11 deletions

Binary file not shown.

Binary file not shown.

View File

@ -47,22 +47,25 @@ proc
TrafficLight(direction : CardinalDirection) = TL(direction, red, true);
TL(direction : CardinalDirection, colour : Colour, firstStart : Bool) =
(firstStart)
-> changeDirection(direction) . ChangeLight(direction, colour)
<>
show(direction, colour) .
(colour == red)
-> ChangeDirection(direction) . ChangeLight(direction, colour)
<> ChangeLight(direction, colour)
(firstStart) %beim ersten Start nur das Licht umschalten
-> changeDirection(direction) . TL(direction, colour, false)
<> %ansonsten
show(direction, colour) . %aktuellen Zustand zeigen
(colour == red) %wenn rot
-> ChangeDirection(direction) %Richtungswechsel, wenn wieder zurück
. ChangeLight(direction, colour) % -> zur nächsten Farbe wechseln.
<> ChangeLight(direction, colour) %ansonsten zum nächsten Zustand wechseln.
;
ChangeDirection(direction : CardinalDirection) =
changeDirection(nextDirection(direction)) . changeDirection(direction)
changeDirection(nextDirection(direction)) %nächste Richtung freigeben
. changeDirection(direction) % -> warten bis eigene Richtung wieder freigegeben.
;
ChangeLight(direction : CardinalDirection, colour : Colour) =
changeLight(nextColour(colour)) . TL(direction, nextColour(colour), false)
changeLight(nextColour(colour)) %zur nächsten Farbe wechseln, wenn beide Richtungen dies autorisieren
. TL(direction, nextColour(colour), false) %fortfahren
;
System =
@ -77,10 +80,10 @@ proc
comm({
changeDirection | changeDirection -> changedDirection,
changeLight | changeLight -> changedLight
},
TrafficLight(north) || TrafficLight(east) || TrafficLight(south) || TrafficLight(west) || changeDirection(north) || changeDirection(south)
%starten der Prozesse und auslösen des ersten Richtungswechsels
));
init