Skip to content

Nested components

Components can be defined with any number of subcomponents. This allows for a hierarchical layout of your specification. As such, you can start with your top-level components and work your way down as more details become available.

Let's say that our ElectricalDriveMechanism consists of a BrushlessMotor, a battery to power it and a switch to turn it on. We then have to add those component definitions and can add them as subcomponents to the drive mechanism like so:

world.esl
define component ElectricalDriveMechanism
  components
    electric-motor is a BrushlessMotor
    power-source is a Battery
    power-swith is a Switch


define component BrushlessMotor
  empty


define component Battery
  empty


define component Switch
  empty
world.esl
world
  components
    pump is a CentrifugalPump
    drive-mechanism is an ElectricalDriveMechanism


define component CentrifugalPump
  empty


# ---8<--- [start:highlight]
define component ElectricalDriveMechanism
  components
    electric-motor is a BrushlessMotor
    power-source is a Battery
    power-swith is a Switch


define component BrushlessMotor
  empty


define component Battery
  empty


define component Switch
  empty
# ---8<--- [end:highlight]

Tip

We only decomposed the ElectricalDriveMechanism into three subcomponents and left the CentrifugalPump untouched. The component hierarchy can have an arbitrary number of levels in each branch, allowing for entire freedom in the level of detail in each (sub-)component!

Next!

Press next (or N on your keyboard) to head over to the next page! P is for Previous.