Search code examples
cumlactivity-diagram

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


Solution

  • 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