Not so nested lifelines

0 votes
asked Oct 6, 2020 in Question / help by Jim

Hi,

It's possible to do:

Nested lifelines

But is it possible to do:

Not so nested lifelines

?

Thanks,

1 Answer

0 votes
answered May 26, 2022 by bholio
I have the same question.  I'm generating a sequence diagram out of instrumentation added to old code in an attempt to understand how it works so I can fix it.  I'm using lifelines to show the life span of open-resources, and the resources are not being closed in opposite order that they were opened.   I'm color coding the resources.  In the example, resource 3 is orange, but the orange lifeline ends when resource 2 is closed because it was the last one opened.

@startUML
participant a
participant b

activate a #red
hnote across: open 1
a->b

activate a #blue
hnote across: open 2
a->b

activate a #orange
hnote across: open 3
a->b

hnote across: close 2
a->b
deactivate a

hnote across: close 3
a->b
deactivate a

hnote across: close 1
a->b
deactivate a

@endUML
commented May 26, 2022 by The-Lu (64,340 points)

Hello B.,

What are your version?

Because with the last, we observe that resources are really being closed in opposite order that they were opened, see your modified example:

@startuml
participant a
participant b

activate a #red
hnote across: open 1
a->b

activate a #blue
hnote across: open 2
a->b

activate a #orange
hnote across: open 3
a->b

hnote across: close 3
a->b
deactivate a

hnote across: close 2
a->b
deactivate a

hnote across: close 1
a->b
deactivate a
@enduml

If that can help,
Regards.

commented May 27, 2022 by bholio
Hi,

Version 1.2022.5

I wasn't clear in my description.  The real-world-resources from which my PlantUML data was generated are not closed in reverse order from which they are opened.  

open 1,open 2,open 3  <---- Real-world-order

close **2**,close **3**,close 1  <-- Real-world-order

In my original example, I want the middle lifeline (blue for resource 2) to deactivate before the orange one (last activated).  PlantUML is deactivating in proper reverse order (3,2,1), but I want to deactivate in a different order to match my real-world resources (2,3,1).

There is a slight difference in your example from mine in the closing order.

Thanks!
commented May 27, 2022 by kirchsth (4,960 points)

It is not 100% the same but you could define for each resource a lifeline like

@startuml

box "a with resources" #LightBlue
participant a
participant "r1" as aR1
participant "r2" as aR2
participant "r3" as aR3
end box

participant b

activate aR1 #red
hnote across: open 1
a->b

activate aR2 #blue
hnote across: open 2
a->b

activate aR3 #orange
hnote across: open 3
a->b

hnote across: close 2
a->b
deactivate aR2

hnote across: close 1
a->b
deactivate aR1

hnote across: close 3
a->b
deactivate aR3
@enduml


BR Helmut

commented May 27, 2022 by bholio
Hi,

I will consider separate lines for the resources.  Not as space-efficient as I'd like.  But maybe it can work.

Thanks
...