6.3 Translating Component Instance Configurations to Simulink Block Diagrams
6.3.2 Translating Structured Component Instances
We create one enabled subsystem for each structured component instance that is contained in the CIC. The rules for creating the enabled subsystem and its external interface repre- sented by the port instances are the same as for atomic component instances. As a result, we can apply the generation template shown in Figure 6.6 for structured component instances as well. However, the generation of the internal structure differs for structured component
instances. In particular, we need to translate its embedded CIC into a Simulink block dia- gram. The embedded CIC is translated in two steps. In the first step, we translate all embed- ded component instances by recursively applying the translation for atomic and structured component instances to them. In the second step, we translate all connector instances that connect the component instances in the embedded CIC. This requires, on the one hand, to translate connector instances between continuous and hybrid port instances as explained in Section 6.3.2.1. On the other hand, we need to translate all connector instances between dis- crete port instances as explained in Section 6.3.2.2. A complete example of a block diagram that results from translating a structured component instance is presented in Appendix A.8.2.
6.3.2.1 Continuous Connector Instances
Continuous connector instances propagate signal values and are, thus, equivalent to lines in Simulink. Therefore, we may directly translate continuous connector instances to lines in Simulink that connect the outport corresponding to the source port instance to the inport corresponding to the target port instance.
If we want to enable reconfiguration of continuous connector instances, we need to use two additional helper blocks namedMultiSourceControlandMultiTargetControl [Vol13] shown in Figure 6.11. Both blocks are implemented using basic blocks of Simulink. We refer to Volk [Vol13] for a description of their implementation.
out in1 in2 ctrl
(a) MultiSourceControl Block
out1 in ctrl
out2 (b) MultiTargetControl Block
Figure 6.11: Helper Blocks that Enable Reconfiguration of Continuous Connector Instances in Simulink [Vol13]
TheMultiSourceControlblock in Figure 6.11a has onectrlinport and one to many data inports whose names are prefixed byin. ctrldefines which of the data inports is propagated toout. If none of the data inports shall be propagated, it outputs 0. TheMultiTargetControlblock in Figure 6.11b has two inportsctrlandin. In addition, it has one to many data outports whose names are prefixed byout. For n outports,ctrl is an array of length n of type Boolean. If the nthfield of the array is true, then the value received viainis forwarded via the nthdata outport. This enables to specifically select an arbitrary number of receivers for the input value.
Figure 6.12 shows the generation template for using theMultiTargetControlblock. We gen- erate oneMultiTargetControlblock for each continuous or hybrid out-portYof our MECHA-
TRONICUML model that has an outgoing connector instance that is reconfigurable, i.e., there exist several in-portsY1that may be connected toYat runtime. Then, we generate one out- port at the MultiTargetControl including a line to every inport Y1. The generation template forMultiSourceControlblocks is defined analogously and, therefore, omitted. It is applied for each continuous or hybrid in-portYof our MECHATRONICUML model that has an incoming
out1 in ctrl MultiTargetControl X1 Y1 X Y Legend:
Generated for embedded component instances X / X1. Generated for continuous / hybrid out-port instance Y with reconfigurable outgoing connector instance.
Generated for each continuous / hybrid in-port instance Y1 that is connected to Y by a connector instance.
Figure 6.12: Generation Template for Translating Continuous Connector Instances
refSpeed 1 standalone_ctrl curSpeed force refSpeed convoy_ctrl curSpeed refDist curDist force refSpeed out1 in ctrl MultiTargetControl out2 curSpeed 2 out1 in ctrl MultiTargetControl1 out2
Figure 6.13: Example for Using a MultiTargetControlBlock for Translating a Reconfigurable Delegation Connector
Figure 6.13 shows an example of using aMultiTargetControlblock. The block diagram in Figure 6.13 results from translating the embedded CIC of an instance ofVelocityController(cf. Figure 3.7) to Simulink. The inportsrefSpeedandcurSpeedare either connected to their coun- terparts instandalone_ctrlor to their counterparts inconvoy_ctrlor to both (cf. Section 3.3.2). Therefore, we connect both inports toMultiTargetControlwhile theout1andout2outports of the
MultiTargetControlare connected to the embedded subsystems. Thectrlinput is then a Boolean array of length 2. If the first array entry is true, the values are propagated tostandalone_ctrl. If the second entry is true, the values are propagated to convoy_ctrl. If both entries are true, the values are propagated to both embedded subsystems.
6.3.2.2 Discrete Connector Instances
Discrete connector instances transport messages from the sending port instance to the receiv- ing port instance. For the translation of a CIC into a Simulink subsystem, we need to distin- guish between the assembly connector instances and the delegation connector instances that are used in the CIC. We present generation templates for their translation in the following.
Figure 6.14 shows the generation template for translating assembly connector instances based on a helper system called communication switch. The communication switch forwards messages from the sending port structure to the receiving port structure. We generate ex- actly one communication switch for each CIC. The communication switch is connected to a
BusCreatorandBusSelector. For discrete port instances of an embedded component instance, we generate one line from the outport of the corresponding port structure to theBusCreator
fcn CommunicationSwitch inBus outBus BusCreator BusSelector X2 Z2_send Z2_recv Z2_net_addr Z2_recv_net_addr B A X1 Z1_send Z1_recv Z1_net_addr Z1_recv_net_addr A B Legend:
Generated once for the structured component instance.
Generated for each embedded component instance X1 / X2.
Generated for each discrete port instance Z1 / Z2.
Generated for assembly connector instance between Z1 and Z2.
Figure 6.14: Generation Template for Translating Assembly Connector Instances
and one line from theBusSelectorto the inport of the corresponding port structure. Then, we use the addresses of the port structures for translating the assembly connector instance. As an example, consider an assembly betweenZ1andZ2in Figure 6.14. The port structureZ1
hasnet_addr A, while the port structureZ2hasnet_addr B. As a consequence, therecv_net_addr
ofZ1isBwhile therecv_net_addrofZ2isA. We explain the behavior of the communication switch in more detail in Section 6.3.3.3 and describe how the communication switch enables to reconfigure assembly connector instances in Section 6.5.
fcn CommunicationSwitch inBus outBus BusCreator BusSelector Z1_recv Z1_net_addr Z1_recv_net_addr 3 4 2 2 Z1_send 1 Z1_DelegationSwitch extern_recv_net_addr local_net_addr local_recv_net_addr A B extern_out local_out local_in extern_in extern_net_addr X Z2_send Z2_recv Z2_net_addr Z2_recv_net_addr B A Legend:
Generated once for the structured component instance. Generated for each embedded component instance X.
Generated for each discrete port instance Z1 of structured component instance. Generated for each discrete port instance Z2 of embedded component instance.
Generated for delegation connector instance originating from Z1.
Figure 6.15: Generation Template for Translating Delegation Connector Instances Figure 6.15 shows the generation template for translating delegation connector instances based on the communication switch and an additional helper system called delegation switch. The delegation switch is responsible for forwarding messages that have been received (or sent) by a port structure of the structured component subsystem to the receiving (or send- ing) port structure of an embedded subsystem. For each port instanceZ1of the structured component instance, we generate one port structure as introduced in Section 6.3.1 including a delegation switch. The inports and the outport of the port structure are connected to the delegation switch. The delegation switch, in turn, is connected to the communication switch in the same fashion as described above for an assembly connector instance. This enables to treat assembly connector instances and delegation connector instances identically in our
MATLAB-specific reconfiguration controller as we explain in Section 6.5. Then, we use the addresses of the port structures for translating the delegation connector instance. As an ex- ample, consider a delegation betweenZ1andZ2in Figure 6.15. The delegation switch has
net_addr A, while the port structureZ2hasnet_addr B. As a consequence, therecv_net_addrof the delegation switch isBwhile therecv_net_addrofZ2isA. We explain the behavior of the delegation switch in more detail in Section 6.3.3.4.