On this page:


The CATIA Software Producer allows you to generate and build code from a UML or SysML model. You can generate code, for example, from the UML Class structure,  UML State Machine, or SysML Blocks. The code generation and building are executed via the 3DEXPERIENCE platform. 

Key concepts and capabilities

CATIA Software Producer offers the following generation capabilities:

  • Generating C and C++ classes from UML structured classes
  • Generating C and C++ code from UML behaviors
  • Generating target dependent middleware code including AUTOSAR classic and adaptive
  • Generating and compiling code for FMU
  • Generating code from a model persisted as a file, or in TeamWorkCloud or in the 3DEXPERIENCE Platform.
  • Generate code containing traceability information establishing the relation from the model items to the code.

For more information about the Software Production Engineering application, see Software Production Engineering.

Prerequisites

  • The CATIA Software Producer Client plugin is installed in your modeling tool. Learn more about how to download the installation files.
  • The 3DEXPERIENCE platform is on the cloud.

  • You have the Software Production Engineer Role. It will give you permission to use the service.

Before starting to work on code generation, first, you have to connect to 3DEXPERIENCE by entering the URL of the Software Producer cloud server. After that, you will be able to log in with your regular identifiers.

For information about how to authenticate with the 3DEXPERIENCE platform, see Authentication with 3DEXPERIENCE platform.

If you start working with CATIA Software Producer for the first time in your project, a dialog will open to configure the local workspace path, which will host generated resources.

Configuring the code generator

The principle 

The generated code is composed of multiple layers as shown on the schemas below.

When the user configures code generators, the generated files will contain the following part:


When the user configures application generators, the generated files will contain the following part:


To configure the code generator, you have to create a Code Generation Configuration Diagram.

Click the image to enlarge.

Code generation supported so far is C and C++, you can select them in the diagram palette.

A code generation configuration is composed of:

 

Application production supported so far is FMU and AUTOSAR.


An application production is composed of:

  • code generation configurations: their generated files are used to produce the application
  • top level element
  • local workspace path
  • parameters specifics to the selected operation:
    • in the example above: platform, include_souce, C_standard, Cpp_standar, debug
  • (SCM Configuration): optional

Validating

You can check if your model is compatible with the code generation via the standard validation menu.


To run the validation


  1. In the Containment tree, right-click the code configuration.
  2. In the shortcut menu, select one of the following:
    1. Click Validate and in the open Validation dialog choose either all possible constraints, or only Code Generation Constraints.
    2. Click Validate Element to run validation for a selected element only.


You can also use the Validate Diagram command, which you can find in the configuration diagram toolbar:

The results are displayed in the Validation Results window if there are any errors or warnings. 

The operation logs are displayed in the usual Software Producer logs window.

Validation is actually a SPO (Software Production Operation) launched in dry-run mode (no file generation, no credit consumption).


Executing the code generator

To execute the code generator, you can run the generation from the main menu. 

You can do one of the following:

  • launch the default action Code generation that will launch the operations only if a change was done in the model.
    • Before each generation, the plugin checks if files were modified locally. If so, a dialog is displayed, where you can confirm the synchronization.
  • launch the Clean and full generate that will delete your previously generated local files and cloud assets then launch all the operations.
    • for the deletion of the local files: if files previously generated by this configuration are found, a dialog will be prompted to the user to confirm the deletion of local files.

      If you do not want to see this message again,  cancel the selection of the Show this message next time check box. If you want to see this message again, there is a dedicated Environment option to turn the message showing on (see Additional Information).


    • for the deletion of cloud assets: it will be done without asking for the confirmation of the user. 

      If you do not want to see this message again,  cancel the selection of the Show this message next time check box. If you want to see this message again, there is a dedicated Environment option to turn the message showing on (see Additional Information).



The operation logs are displayed in the Software Producer Logs window.

Software Governance

In order to commit elements from CATIA Magic, you have to associate a repository to the model and a branch to a SCM Configuration (linked to a code or application configuration afterwards).

SCM Repository association

To associate the SCM repository


  1. In the Containment tree, right-click Model.
  2. In the shortcut menu, click Software Code Generation > Associate SCM Repository.
  3. In the open Associate SCM Repository dialog, choose the needed repository,
  4. Click OK.

After you click OK in the Associate SCM Repository dialog, the repository information will be associated to the model via the «Connector» stereotype from the Embedded Software Profile:

  • repositoryType: type of SCM (example: “GitLab”)
  • repositoryHost: root url of the targeted Git server (ex: : https://gitlab.com)
  • repositoryPath: relative path of the repo (ex: SJA/cubesat-control)


To remove the association of the SCM repository


  1. In the Containment tree, right-click Model.
  2. In the shortcut menu, click Software Code Generation > Associate SCM Repository.
  3. In the open Associate SCM Repository dialog, click the selected repository for which you want to remove the association.
  4. Click OK.

When you click OK, the association will be removed and the branches will be detached from elements if there were any. 

SCM Configuration

It is necessary to associate a repository before attaching a branch from the configuration dialog.

From the diagram palette, the you can create a SCM Configuration that will contain:

  • a reminder of the repository path of the model: you cannot edit the repository here. If you need to change the repository, see SCM Repository association.
  • the branch where you need to commit the code: you can edit it in the Specification window by clicking the three dots in the branch value field:

 

  • When you click OK in the Associate Branch of Repository dialog, the branch information will be associated to the configuration via the «SoftwareLogicalItem» stereotype from Embedded Software Profile:
      • branchName: the branch name to target (example: “main”)
      • SoftwareLogicalItemId: ID of the logical Item linked to the branch (from Connected Software)

If if you remove the repository association, the branches will also be detached from elements if there were any. See SCM Repository association.


To use the SCM Configuration, you have to drag and drop the SCM configuration on the code configuration or application configuration that you wants to execute and commit:

Local workspace of the software producer

Under the local workspace, you can find the generated files, if you have selected the download option and left the default location (as seen above) in the configurations. You can also find some other files under an “etc” folder:

  • <Local_workspace_path>
    • <configuration1_name>
    • <configuration2_name>
    • etc
      • json3
      • log4
      • operations
      • backup2
      • logs

1You can change the root of the local workspace path in the project options.

2By default, a backup of your downloaded files is saved in this folder so that in case something wrong happens with the download of new files, you can still reach your previous files. You can disable this option in the Project Options 

3SPO Report files are rotated by size and date so that you might see multiple report files here.

4Log files are rotated by size and date so that you might see multiple log files here.

RoundTrip

The roundtrip action is a feature available for State Machines and Opaque Behaviors. Using the roundtrip action, you can add the modification you made in the code in between BEG_USER_CODE / END_USER_CODE tags (in files commonly named <ComponentName>_usr.c), back into the model and synchronize the file on the workspace on the cloud.

The roundtrip is available in the configuration diagram toolbar:

Views

Software Producer Logs

In the Software Producer Log panel, you can see the messages of the running SPO.

This information is saved in the log file next to your project files. To open the log file location quickly, in the Software Producer Logs window, click the Show Log File button. Each project has its own log file.

A log file for general Software Producer messages not related to a specific project is stored next to the modeling tool log file.

At the bottom right corner of the modeling tool, in the progress bar, you can see whether the generation is running. After the generation is completed, the notification is displayed in case of failure or always if the verbose mode is activated (Environment Options > CATIA Software Producer Client General Properties > Notifications section).

Validation Results

When an operation produces a report, the plugin reads it and opens it in a Validation Result window if any element has a diagnostic associated.

A diagnostic is associated with a rule consisting of a severity, message, and source.

You can navigate to the source in the Containment tree.  If you need to show more details concerning the rule or open the full report, right-click the appropriate lines of the table.

You can turn off the Validation Results window's opening after the operation produces a report.


To turn the validation report off


  1. In the modeling tool main menu, click Options and select Project.
  2. Set the Show Validation Report property to false.

Diagrams and Containment tree

The following commands are available from the diagrams toolbar or from the shortcut menu of the supported elements in the Containment tree:

Button

Description

Show in File Explorer

Open a location in your file system wherein the Software Production Operation results file is stored.

Roundtrip

The changes made in the generated code are applied in the State Machine diagram or Opaque Behavior.

Options

You can switch projects (or even shut down your computer, saving your work first) while waiting for the generation result as it is running on the cloud and as the widget keeps the IDs of the cloud assets in the record files located in <local workspace path>\etc\operations\spoRecordFile.json (you will have access to it if you need it, for example, for the debugging purpose). When you come back, another dialog will tell you that operations were running while you were away and will propose you inspect the result and download it.

Additional Information

A workspace is automatically created on our cloud servers for each of your projects using the widget. This workspace gathers the assets needed for the generation. A cloud workspace is automatically deleted after 30 days of inactivity. You can also delete it manually in the Environment Options dialog. If you delete the workspace, all the components will have to be regenerated on the cloud on your next session because you will not be able to push any files to a workspace through the plugin.

New environment options: Show next time section