Bean Inheritance and Bean Sharing

Basic Terms

  • Ancestor is a bean that is inherited (used) by another bean.
  • Descendant is a new bean that inherits (uses) another bean(s).
  • Shared Ancestor is a bean that can be used and shared by multiple beans.

Inheritance

Inheritance means that an ancestor bean is used only by the descendant bean. Inheritance is supported in order to allow beans to access peripherals by hardware-independent interface of the ancestor beans.
For example, a bean that emulates a simple I2C transmitter may inherit two BitIO beans for generation of an output signal.

On several complex beans (for example some MPC Pripheral Init beans) inheritance is used to separate bean settings into several components, for example settings of channel is inherited in the bean with settings of the main peripheral module.

Settings in Processor Expert

The Descendant bean contains a property which allows selecting an ancestor bean from a predefined list of templates. The bean is created after selection of an appropriate template name (or bean name) from the list of the templates fitting the specified interface. Any previously used ancestor bean is discarded.

 

Figure 1 - Example of selecting from available ancestor beans.

Press the button to edit properties, methods or events of a selected ancestor bean in the Bean Inspector.
Processor Expert allows the user to select from several ancestors that implement a required interface and are registered by the descendant bean.
The ancestor bean is displayed under its descendant in the project structure tree in the project panel.

 

Figure 2 - Example of ancestor and descendant beans in the project panel tree.

An ancestor bean requires a list of methods and events (interface), which must be implemented by an ancestor bean. The error is shown if the ancestor bean does not implement any of them (for example if the settings of the descendant bean do not allow it to generate this method).

Bean Sharing

Bean sharing allows the user to cause several beans to use capability of one bean with the way similar to inheritance. This feature allows sharing of its resources and its drivers with other beans.
For example, beans may share an I2C bean for communication with peripherals connected to the I2C bus.

Settings in Processor Expert

A shared ancestor bean contains a property which allows the user to select existing or create a new shared ancestor bean. The ancestor bean is included in the project tree as are the other beans. The ancestor bean may be used with the descendant bean only if it was created from a template registered in the descendant bean or if the bean type is registered in the descendant bean. It's recommended that you always create a shared ancestor bean through a descendant bean.
Press the button to select an existing shared ancestor bean from the current project. Press the button to select an existing or create a new ancestor bean using the Bean Wizard (see below).

 

Figure 3 - Example of popup menu for creating a new shared ancestor bean.

Selection/Creation Wizard

When a bean with a link to a shared ancestor bean is added to the project, the following "Selecting/Creating Wizard" appears. This wizard helps you to select or create the shared ancestor bean quickly.

 

Figure 4 - Example of popup menu for creating new shared ancestor bean.

Run-time Resources Allocation

Processor Expert (generated code) does not check the usage of shared resources/code. It's up to the user to use the correct run-time resources allocation of a shared ancestor bean. Usually it is not possible for a shared ancestor bean to be used simultaneously by several beans.


 

 

[top of page]