Getting started with the FDC toolbox
7.9 Linking to S IMULINK libraries
Notice the three blocks with shadow borders (in reality, these blocks have been ac-centuated by a blue colour). The shadow indicates that some action will occur when these blocks are double-clicked. In this case, related help information will be dis-played in your webbrowser or the MATLAB help browser. The upper-left block is called a ‘title block’, which shows the blockname, the author, and the latest revision date; it has been linked to help information about the subsystem itself. Similar title blocks can be found in all models and most subsystems from the FDC toolbox.
If you double-click on the subsystem ‘Beaver dynamics and output equations’, the dialog window from figure 7.9 will be shown. The first line below the window title provides the blockname, and indicates that we are dealing with a masked subsystem, that has been linked from a SIMULINK library. Directly beneath, a brief description about the block is given. Detailed information about the masked subsystem will be shown in a webbrowser or in the MATLABhelp browser if the Help button is clicked.
The dialog window can be closed by clicking Cancel, which will cause SIMULINK
to return to the systemBeaver. Without further interaction from the user, the subsys-tem ‘Beaver dynamics and output equations’ will remain active, which is indicated by four tiny black squares in its corners. The active status of the subsystem can be cycled by repeated single-clicking on the subsystem block (the tiny squares will disappear when the block is deactivated, and reappear when it is reactivated again).
In order to examine the internal structure of this block, we need to look under the mask. This can be done in several ways: (i) right-click the block, and select ‘Look under Mask’ in the context-menu, (ii) activate the block and select ‘Look under Mask’
in the Edit menu, or (iii) activate the block and press Ctrl + U in order to unmask the block. Use whatever method you prefer. Unmasking the subsystem ‘Beaver dy-namics and output equations’ results in the opening of the new window shown in figure 7.10, which reveals the internal structure of this subsystem.
This second level of the aircraft model again contains a title block in the upper-left corner; double-clicking this block will reveal the same help information as the Help button from figure 7.9. The subsystem includes four masked blocks, which have been linked from a SIMULINKlibrary, and five subsystems without a mask interface.
To indicate that these unmasked subsystems also have library links, they have been highlighted with a light-blue colour (shown as a grey colour in figure 7.10).
7.9 Linking to S
IMULINKlibraries
SIMULINK libraries enable users to copy blocks from external libraries into the si-mulation models, and automatically update these blocks when the source libraries change. In fact, the model only contains a placeholder for the block, instead of the block itself, with a link referring to the applicable source library that contains the actual block contents. This promotes the re-use of existing blocks, and prevents in-advertent proliferation of multiple versions of the same block (some being properly updated, some inadvertently remaining unchanged).
To demonstrate the use of the libraries in the FDC toolbox, we will take a closer look at the blockGravity, which can be found slightly left of the center of figure 7.10.
Double-clicking this block results in the mask-dialog from figure 7.11. As we have seen before in figure 7.9, the mask-dialog includes a short description of the block, a
110 Chapter 7. Getting started with the FDC toolbox
Figure 7.9:Mask dialog for the system Beaver
Figure 7.10:Level 2 of the system Beaver (main level of the aircraft model)
7.9. Linking to SIMULINKlibraries 111
Figure 7.11:Mask dialog for the block Gravity
Figure 7.12:Gravity and wind forces blocklibrary
Figure 7.13:Looking under the mask of Gravity
Figure 7.14:Error when trying to edit a locked library
112 Chapter 7. Getting started with the FDC toolbox
note that the block has been masked, and a note that the block has been linked from a library. In this case, there is also a parameter field, although it has been locked because the parameter definition for this particular block can only be changed in the library in which it is defined.
It is possible to quickly jump from a block in a model (actually: its placeholder) to the corresponding library by: (i) right-clicking the block and selecting ‘Go To Library Link’ from the context-menu, (ii) activating the block and selecting ‘Go To Library Link’ from the Edit menu, or (iii) activating the block and pressing Ctrl + L. If we apply this method to theGravityblock, figure 7.12 will be opened, with theGravity block being activated as shown in the figure. Of course, if you know the name of the library, it is also possible to open it directly from the command-line. In this example typing fdclib4 or double-clicking the ‘Gravity and wind forces’ button in the main FDC library will open the library shown in figure 7.12.
The internal structure of this block can again be shown by unmasking it first.
This yields figure 7.13, which shows the deepest level of this block, i.e. the level in which the actual equations are evaluated. The expressions within the individual Fcnblocks will probably look rather cryptic at first sight, but once one knows the meaning of the input and output signals (as explained in the next chapters and the on-line help information) and the part of the theory on which these equations are based, understanding the block-equations actually turns out to be relatively easy.
Notice that it is not necessary to open the blocklibrary to view the deepest level of a block: it is possible to look beneath the mask of a linked block within a model too.
The only drawback is that this may cause confusion because linked blocks can not be edited within the model. Libraries are ‘read-only’ or ‘locked’ by default, which means that it is not possible to change any elements in library blocks, unless the library is released first by selecting the ‘Unlock Library’ option in the Edit menu. If the user does try to edit a locked library, or manipulate a linked block directly from within a model, the error message from figure 7.14 will be displayed.
It is not possible to edit the contents of a linked block within a model, because the actual block contents are included in the library only. However, it is possible to break a library link after copying a block from the library, by selecting the option ‘Break Library Link’ in the Edit menu. In that case, the placeholder containing the library link will be overwritten with the block’s actual contents – effectively creating a clone of the block, and editing the block within the model will become possible. Since this breaks the library link, it will obviously not affect the contents of the library itself.
Unfortunately, the placeholder containing the library link will look exactly the same as the original block in the library; the only visual difference is the link indica-tion in the mask-dialog, and that is only present if a mask dialog exists in the first place. Some subsystems from the FDC toolbox do not have a mask-dialog, even though they have been linked from a library. To make the user aware of the library links in those cases, such linked, yet unmasked subsystems have been highlighted with a light-blue colour.
Please be very careful when editing existing blocks in the FDC libraries: since they may be called by several other models, it is not recommended to alter their in-put/output definitions (e.g. increase the number of outputs), or change the names of blocks within a library. The latter is important, because library links are defined