Support for composite structure diagram, notably parts

0 votes
asked Apr 2 in Wanted features by Ansgar

Dear all,

unless I'm mistaken, PlantUML offers a component diagram, but not a composite structure diagram. The main difference is that the latter supports parts (part usage in SysML v2) and connections between (ports of) parts, I can have nested components in the component diagram, but not parts, i.e. elements typed with existing components (representing the role that the instances of referenced components play in a composition).

A current workaround is to use nested components with a ":" in the name, but this requires a redefinition of parts as nested components and that port names are unique. In the following example of a HifiSystem with two speakers, it requires to rename the port of the right speaker, although it is the same port. Is there any work in this directions?

Best regards

Ansgar

@startuml
component HifiSystem {
  component "a: Amplifier" {
    port outL
    port outR
  }
  component "left: Speaker" {
    port in
  }

  component "right: Speaker" {
    port in2
  }
  outL -- in
  outR -- in2
}
@enduml

1 Answer

0 votes
answered Nov 14 by Ansgar
I refined my workaround by qualifying the port names with the part name via "as", as shown below. However, as said before, I'd rather like to declare a part by referencing an existing component definition (eventually hidden) instead of declaring the typing component on the fly (and potentially duplicating it as in case of the Speaker). This is shown in the 2nd specification below.

Best

Ansgar

Refined workaround:

@startuml
component HifiSystem {
  component "a: Amplifier" {
    port outL as a.outL
    port outR as a.outR
  }
  component "left: Speaker" {
    port in as left.in
  }

  component "right: Speaker" {
    port in as right.in
  }
  a.outL -- left.in
  a.outR -- right.in
}
@enduml

Wanted specification (or similar syntax) referencing existing component definition. Rendering should be identical to working PlantUML specification above.

@startuml
hide component Amplifier {
  port outL
  port outR
}

hide component Speaker {
  port in
}

component HifiSystem {
  part a : Amplifier
  part left: Speaker
  part right: Speaker

  a.outL -- left.in
  a.outR -- right.in
}
@enduml
...