Tutorial library workspace

This tutorial uses an example to show how you can call up or import packages, projects, project generators and user Python libraries stored in a library workspace from another workspace.

To perform this tutorial, copy the provided example Workspace Tutorial-LibraryWorkspace. The necessary steps are described here.

For further details see Content of library workspaces

Library declaration

The given workspace ExampleLibraryWorkspace is declared as a library workspace.

  1. Open the workspace ExampleLibraryWorkspace (subfolder of the folder in which you have loaded the tutorial data) in ecu.test.

  2. Navigate to the workspace settings under Options ‣ Settings ‣ Workspace settings.

Info

The option Is a library is already enabled and the Title, Version and Namespace of the library workspace are defined as well.

../_images/configureWorkspaceSettings.png

Library integration

A library workspace is integrated into another workspace by adding the library workspace as a dependency in its settings under Libraries.

  1. Switch to the workspace where you loaded the tutorial data.

  2. Navigate to the Libraries settings under Options ‣ Settings ‣ Workspace settings ‣ Libraries.

  3. Use the img_add button to include the ExampleLibraryWorkspace in the workspace.

../_images/configureLibraries.png

Packages and projects

Once a library has been integrated into a workspace, packages from the library workspace can be called in projects and packages in the main workspace. Projects from the library workspace can also be integrated into projects in the main workspace.

  1. Open the package Caller.pkg.

  2. Open the first test step.

    This is a call to the library package LibCallee.pkg from the included library workspace ExampleLibraryWorkspace. In the field Package path you see a path reference as follows:

    <libraries.[namespace of the workspace].packages>\[relative package path in library workspace]

    ../_images/libPackageCall.png
  3. Open the project Caller.prj.

    The first line shows a library package call from a project. In the second line, a project from the library workspace is used.

  4. To create a new library package call, simply drag the desired library package from the workspace explorer and drop it into the package or project.

Test configuration and test bench configuration

Test configurations (TCF) and test bench configurations (TBC) can be moved to a library for reuse.

  1. Open the test bench configuration FMI_BusPortGeneric.tbc within the library.

    In the TBC the base path is set to <workspace>. This means that the library in which the TBC is stored is used as the base path for the subordinate tools.

  2. Open the test configuration BusPortGeneric.tcf within the library.

    In the Platform and Bus Access tabs, artifacts are referenced using relative paths. These paths refer to the library in which the TCF resides.

  3. Open the project ConfigChangeFromLibrary_BusPortGeneric.prj within the main workspace.

    Here, TBC and TCF from a library are used in a configuration change.

  4. Select the TBC and TCF in the Workspace Explorer and drag & drop them into the Configurations panel.

    Info

    Configurations can be loaded from the main workspace, from the same library, or from different libraries.

    ../_images/libConfig.png
  5. Open the configuration change step from the project.

    The paths are displayed in the following format:

    <libraries.[namespace of the workspace].configurations>\[relative path in the library's configurations folder]

    ../_images/libConfigChange.png

For more details, see Configurations.

Trace step templates

After a library has been included in a workspace, trace step templates from the library workspace can be used in packages of the main workspace.

  1. Open the package Caller.pkg.

  2. Switch to the tab Trace analysis.

  3. Open the first trace step of the first episode.

    This is a call to the library trace step template UpperBound from the included library workspace ExampleLibraryWorkspace. In the field Path you see a path expression as follows:

    libraries.<namespace of library>.traceStepTemplates + <relative trace step template path in the library workspace>

    ../_images/libTraceStepTemplate.png
  4. In order to use a library trace step template, simply drag the desired template from the tab Trace step templates and drop it into the trace analysis.

Generators

  1. Open the Caller.prj project.

    ../_images/libProjektGenerator.png

    Lines three, four and five each show example calls to generators, that come from a library. In the project editor, the calls of project generators from library workspaces are easily distinguishable by their petrol icons.

    Generator

    standard icon

    library icon

    project generator

    prjgen_icon

    lib_prjgen_icon

    package generator

    pkggen_icon

    lib_pkggen_icon

    parameter set generator

    pargen_icon

    lib_pargen_icon

    Further general information on generators, which also applies to generators from library workspaces, can be found in chapters Project generator, Package generator and Parameter generator respectively.

  2. Inserting another generator call can be done via the context menu (e.g. New ‣ Project generator) or via the vertical quick bar in the project editor.

User Python libraries

Usage of user Python libraries

  1. Open the package Caller.pkg.

    In the second test step you see the call of an example function from return42Module.py of the library workspace ExampleLibraryWorkspace.

  2. Open the test step.

    In the field Expression you see the expression that is used for the call. Unlike ordinary function calls, a call from a library workspace must always use the libraries.<namespace of library>.user module instead of the user module.

../_images/libUserPyModule.png

Import a user Python library

  1. Open the directory for user Python libraries (via Extras ‣ Edit user python library …)

  2. Open the file libImporterModule.py.

    Line four shows an example of importing a user Python library from an integrated library workspace. Note that also here from the module libraries.<namespace of library>.user is imported.

  3. Switch to the ExampleLibraryWorkspace and open the directory for user Python libraries (e.g. via Extras ‣ Edit user Python library …)

  4. Open the directory for UserPyModules (via Extras ‣ Edit user python library …)

  5. Open the file absoluteImporterModule.py.

    Line four shows an example of importing a user Python library within the same library workspace. The import is identical to an import from another workspace that uses this library workspace as a dependency (as in the libImporterModule.py file we looked at earlier).

  6. Open the file relativImporterModule.py.

    On line four, you can see another example of importing a user Python library within the same library workspace. In this case, a relative import is performed.

Info

In the directory for user Python libraries you will also see the folder PackageCheckExample. This is an example implementation of a package check. To run the package check you use the button Check Package in the desired package as usual.

User-defined utilities

  1. Open the package Caller.pkg.

  2. Open the third test step.

    This is a call to to the user-defined utility LibUtility of the included library workspace ExampleLibraryWorkspace.

  3. To create a call to a user-defined utility, simply drag and drop the desired utility test step from the test step explorer to the package.

Mapping and constants definition files

Once a library has been integrated into a workspace, mapping files and constants definition files can be used in test configurations and projects in the main workspace.

Global Mapping

  1. Open the test configuration Test config with library XAM.tcf.

  2. Open the Tab Common tab.

    This is a reference to the mapping file GlobalMapping in Library.xam from the included library workspace ExampleLibraryWorkspace.

Constants definition

  1. Open the test configuration Test config with library GCD.tcf.

  2. Open the Tab Global constants tab.

    This is a reference to the constants definition file GlobalConstants in Library.gcd from the included library workspace ExampleLibraryWorkspace.