Import/Export of Components in TASTE
A new system is rarely created from scratch and having a library of reusable building blocks is a fundamental basics when working with models. This page explains the two forms of component reuse that are available in TASTE and how they operate:
- The shared library of component type that can be instantiated in a system
- The import/export of complete parts of an interface view
Component types are TASTE functions that contain a generic implementation in Ada, C++ or SDL and that can be instantiated several times in a system.
While the types can be defined locally in a project, they are usually exported to an external folder, from which they are shared and visible to all TASTE users.
In the TASTE VM, the default base folder for such shared component types is /home/taste/tool-inst/share/SharedTypes. It can be overridden by setting the TASTE_SHARED_TYPES environment variable and make it point to a different folder.
For example this component is present:
Details for its content are explained on this page: Technical topic: C++ Components and AIR IO Partitions
Creating and exporting a component type
A component type can be created in C++, Ada and SDL as these languages have a built-in Object-Oriented features that allow instantiation. It is not possible to create a component type in the plain C language.
The process the create the component type is the following:
- Add a Function Type and select among the possible 3 languages in the Interface View editor
- Add provided and required interfaces at will (but you cannot connect them to other functions)
- Edit the function type properties, and in the Context Parameters tab, create the default state of the component
- Generate the code skeletons and implement the generic behaviour of the component
Then the process to export the component type is the following:
- Right-Click on the function and choose Export Type
When you export the function the tool proceeds with the following actions:
- Create a new folder FunctionName in the shared component folder
- Copy DataView.aadl in that new folder
- Copy all the .asn files referenced in DataView.aadl in that new folder
- Copy recursively the folder work/FunctionName (containing the component implementation) into that new folder
- Create and copy a file named (in lowecase) functionname-iv-functionname.aadl
The file functionname-iv-functionname.aadl contains the component description itself. It is like an Interface View but containing a single package:
After the component is exported, it does not appear anymore in the local project (the block disappears). It now appears in the Workspace together with other shared components:
When the TASTE Interface View editor is executed, it parses the shared folder of components and gather the shared function types to update this workspace with the list of available components.
Non-exported shared components, if any, appear just below in the workspace.
It is possible to re-import a shared model to make local modifications and re-export it. Use the menu New -> Import Shared Types to proceed.
When doing this, special care has to be given to the DataView namespace. If you import a component for modification in a new project that has already a different dataview, this dataview will also be exported to the shared component after you are done with your modifications. Since this is unlikely what you want, make sure you don't already have a dataview before importing.
Instantiating a component type
To instantiate a component type, local or shared, the process is the following:
- Drag and drop it from the workspace or use the contextual menu
- Edit the instance properties and modify the Context Parameters default values to specialize your instance (the tool does not allow you to add new context parameters - you can only edit the default value of the ones defined in the component type)
When you instantiate a component type, the Interface view will make a reference to the component type using these two properties:
The tool does not copy any file from the component type. During the build, the component type will be retrieved and instantiated as expected.
Import/Export of complete parts of Interface View
The second option is to export a function or a group of connected functions into a different folder and let the user import it in a new project. In that case there is no instantiation: the import function will copy the component and its implementation locally as if it was created for the new project. The implementation can be modified at will without impacting the exported component.
This works for any combination of supported TASTE languages.
The default folder for the library of components is ~/tool-inst/share/components_library It contains by default the PeekPoke component:
The process for exporting is the following:
- Select a function or a group of functions and using the contextual menu choose Export Functions
When doing so the tool will copy, as for the function types:
- All selected function implementations: work/<functionNames> folders (in the case of Peek Poke, the code is zipped, but this is not the default)
- the DataView.aadl and ASN.1 files
- a file named interfaceview.aadl containing the architecture (including connections) of the exported components
The list of components appear in the workspace of the Interface View editor, as for the shared types:
Individual functions or the complete imported architecture can be drag-and-dropped to the current system. The Dataview will be merged (ASN.1 files will be copied) to the local folder (make sure the name of the ASN.1 models is not DataView.asn when you export). All the function implementations will be copied to the work folder.