This functionality is only available for certain module packages.

You are here: Tutorial > Text discipline > Adding the ListsofComponents discipline to the mechatronic model > Adding lines to mechatronic components

Adding lines to mechatronic components

Add the Text component Sensors_Actuators_Line to all non-abstract actuators and sensors that are located in the T_Mechatronic_ModularSystem library in the Mechatronic unit and the Actuators and Sensors subunits:

The task is to use formulas to calculate the parameter values of the component Sensors_Actuators_Line:

  1. To do so, double-click to open Sensors_Actuators_Line and switch to the Parameters editor page.

  1. Enter this formula under Descriptor:
=mroot.name + mc.absoluteName.substring(mroot.absoluteName.size, mc.absoluteName.size - 1)
  1. and this formula under Pos:
=dc.dos.indexOf(this) + 1

For Descriptor, the absolute name (e.g., Feeder.Mechatronic.Feeder.Insert.Magazine.Positionssensor_optical) is to be used to determine the component (e.g., Feeder.Insert.Magazine.Positionsensor_optical). To do so, the result of mroot.name (e.g., Feeder) is added to the result of the mc.absoluteName.substring method. The length of the absolute name (mroot.absoluteName.size = e.g. Feeder.Mechatronic.Feeder = 41) and the length of the name starting at the parent component (mc.absoluteName.size-1 = e.g. Feeder.Mechatronic.Feeder.Insert.Stack.Positionsensor_optical = 84) is transferred to the substring method.

The position of the discipline component for Pos is determined from the list of discipline components. dc.dos is used to identify a list of all children of the parent discipline components and indexOf(this) to determine its own position. Since the counter in lists begins at 0 (zero), a 1 is added.