4

This is only an extract from a very long text, the one I'm not sure about. It's about a photo booth (an automata that makes a picture of you if you insert coin).

The automata has a camera that is recording once a coin is inserted. The customer has 2 minutes to freeze the video right after the coin was inserted, such that he/she has taken a picture. Then the customer can decide if he/she likes to print this picture or change back to the recording mode such that the camera is recording again so he/she can take a picture again. Within these 2 minutes, the customer can switch from recording mode to a picture untill he/she decides to print it.

If the customer has accepted a picture, it will be printed. If after the 2 minutes no picture was taken by the customer to be printed, then the latest taken picture will be chosen and printed. If there was not a picture taken at all, then the automata returns the coin that was inserted by the customer.


I'm not sure about the beginning. So clearly we have 2 simultaneous things at the beginning when coin is inserted: The camera is recording AND the 2 minutes timer starts running. But how do you show that in an activity diagram? Can I just show both these things as an activity, like that and go on?

Edit: Here the diagram that is supposed to represent Christophe's solution enter image description here

And this is my old wrong diagram:

enter image description here

7

Problem

Your diagram has several flaws. For instance, you'd need a join to synchronize the camera recording and the timer. But then, the semantic would mean that both activities must be finished before going on, so that in the end you would wait at least 2 minutes.

Solution

To solve this correctly, you must enclose the sequence of action that can be interrupted in an interruptible region (dotted surrounding).

You would then have in this region an accept event action (or better, a wait time action), that on timer elapse would interrupt the region, leaving it through an interrupting edge to the action that will be performed upon time-out.

By the way, you could also consider a send signal action to represnet the "take picture" action, that would leave the interruptible region as well. Once an event/signal caused to leave the interruptible region, all the tokens circulating in the region are considered instantly consumed.

In this modelling you'd not need an artificial fork and join for a non existant parallel activity.

You will find a complete example with time-out here.

  • Thank you very much for all the great links and your answer of course! :) I have editted my answer by adding the activity diagram you have described. I think it's correct? I'm only not sure about one thing: The wait time action goes to a decision node instead of going to an action. Is that possible and correct too? – tenepolis Nov 25 '18 at 0:03
  • 1
    The interrupting edge is a special kind of activity edge, so it can perfectly well reach a control node as well. My only remaining remark would be that your diagram means that the 2 minutes time-out is a total limit for the interruptible region. So if a freeze of the video is done but the picture not printed, the timer will not be reset. – Christophe Nov 25 '18 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.