Add shared elements

With MLDesigner you can use a number of so-called shared elements to model the functionality of a component. Such elements are called shared elements as they are used to share information without exchanging data.

For that purpose shared elements can be linked over different model hierarchy levels. Linking means that different model components use the same model element to manipulate the data. Shared elements are:

events, and

This section covers using shared elements. For more detailed information see Shared Model Elements.

Setting Shared Model Elements

There are a number of ways to share data between blocks of a hierarchical model. You can use the property editor to set the properties of shared model instances once they have been created. To do this select the shared element to activate the relevant Properties window. The properties a shared element has depend on its type. The common properties of shared elements are the Name and the Scope.

The Scope of a shared element specifies whether it is visible in instances of the model component. If visible it can be linked to shared elements of the same type on the next higher model hierarchy level. A shared element is visible if you set the scope as External. In a system (currently the highest level of a hierachical model) the scope is set to Internal and cannot be changed.

A shared element with external scope is indicated by a small triangle at the top of the visible model element.

Exporting Shared Model Elements

It is possible to export shared model elements from one module in a hierarchical model to the next higher level until the element is instantiated in the topmost level - the system. Exporting elements makes modeling quicker and reduces the possibility of errors. It is possible to choose to Export the shared element in which case the name remains unchanged unless an element exists with the same name in the next higher level of the model in which case the name of the element is extended by a #instance number. Another possibility is to choose the Export as option in which case the name of the shared element must be defined manually.

The exported shared element has its scope set to internal by default. To share the element with the next higher level of the system set its scope to external and save the module. Instantiate the module in a system or module and click once on the model instance to activate the Instance Properties window. Activate the context menu over the relevant entry in the Instance Properties window and select Export. The shared element is then instantiated in the model in the Model Editor Window with its scope set to internal.

Events and Memories have a data type which can be any data type derived from the Root data type (see Import Libraries). By default, Memories and Events are of data type Root. If you define an external event or external memory, you must link them, in instances of the model component, to shared elements which are of the same data type or a data type that is derived from the data type you defined for the event or the memory.

In instances of model components you must link shared elements with external scope. External shared elements are shown as properties in the property editor when you select the according model instance. The icon of the property entry indicates the type of the shared element. To link a shared element right-click on the relevant property to open the context menu. If there are shared elements with compatible data type in the model in which the model instance is embedded, the Link to context menu item is enabled. In that case, a list of shared elements to which the selected one can be linked is shown. You can select one from this list to create the link. Linking is indicated by a green arrow in the default value field of the linked shared element.

If you change the type of the shared element of the model to which a shared element of an embedded model instance is linked, the link becomes invalid. In that case, MLDesigner will throw a construction error message if you try to save the model.