Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to model different return values of a function in a UML Activity-Diagram?

See the following code for example. How can I model different return values of a function in a UML Activity-Diagram?

typedef enum {CLOSED, OPEN, UNKNOWN} sw_state_t;

sw_state_t read_input(int index)
{
    uint8_t sw_state;

    if (spi_read(&sw_state) == STATUS_OK) {
       if (sw_state & (1 << index))
           return CLOSED;
       else
           return OPEN;
    }

    return UNKNOWN;
}

What I want to show is the value the function returns. What I have is an Activity block with one input ActivityParameter and one output ActivityParameter.

Update

Does the following diagram make sense?

enter image description here

like image 511
sergej Avatar asked Oct 21 '25 14:10

sergej


2 Answers

Use a data object, as they are output of activities. Then link the object with the activity

Looking at your diagram, just before each relevant ActivityFinal (return OPEN, CLOSED, UNKNOWN) add an action to return the corresponding object the following way. Then connect each object with the OutputParameter.

enter image description here

like image 53
Aleks Avatar answered Oct 23 '25 03:10

Aleks


I think your diagram is too fine grained. Why do you need the internals?

I'd do it simply like that:

Simple

like image 27
PsiX Avatar answered Oct 23 '25 04:10

PsiX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!