MagicDraw 2022x Refresh2 Documentation

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

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++ 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.

CATIA Software Producer uses the concept of target configuration to guide the user in configuring the code generation process.

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.

Working with the code generator

The principle 

The full set of code you need to generate to cover your target is composed of at least a component and a target-specific part. The component part is relative to the behavior of your application (such as State Machine) whereas the target-specific part is relative to the architecture of your application (such as IBD). In other words, target specific is the binder and the link between the component and the target. As one does not go without the other, this is why at the end of the IBD generation, a dialog will ask you if you want the applicative code to be automatically generated if you have not yet done it (or if it has changed).


To configure the code generation in the SysML diagram


  1. Select the element you want to generate:
    • In the open SysML diagram. If you do not select any particular element in the diagram, the entire diagram view is selected as the generation input.

    • In the Containment tree.
  2. Do one of the following:
    1. In the diagram toolbar, click the Configure Target button. 
    2. From the selected element's shortcut menu, select Software Code Generation and click Configure Target.
  3. In the open Generator Details dialog, specify the needed SPO configurations.

  4. (optional) Specify the download location if you want the results saved on your local file system. The generated files will be downloaded to the folder named after the Configuration name.
  5. Click the OK button.


If the operation you selected (for example FMU Target Build) requires some other operations to be run beforehand, you will have to configure those operations in the next dialogs that will be opened automatically. The whole will constitute your “Target Configuration”.

Once the end of the configuration process is reached, i.e. you have fully configured your target, under the Configuration package you will find

  1. The Generator Configurations package: this is where classes are created to save common properties of generators (parameters especially)
  2. The Target Configurations package: this is where packages are created to store the flow of a target. Within this package,  classes are created to save specific properties for each SPO (download options, input, and generator mapping). 

The configurations are saved in the model via the “CATIA – Embedded Software Profile” (EmbeddedSoftwareProfile.mdzip) profile.

Executing the code generator

To execute the code generator


  1. Select the element you want to generate
    • In the open SysML diagram. If you do not select any particular element in the diagram, the entire diagram view is selected as the generation input.
    • In the containment tree.
  2. Do one of the following:
    • In the diagram toolbar, click the Generate Target button and choose Generate Target.
    • From the selected element's shortcut menu, select Software Code Generation and click Generate Target.

All the operations you configured previously will be launched one after the other:

  • If you click Generate Target, the operations will be launched only if it has not yet been launched or if an element has changed.
  • If you click Full Generate Target, all the operations will be launched, regardless of a previous execution.


To edit generator configuration properties


  1. In the Containment tree, right-click a Class element of the needed configuration.
  2. In the shortcut menu, click Software Code Generation and select Edit Configuration.
  3. In the open Generation Configuration dialog, make your changes.
  4. Click Apply and then Close.


If you have configured multiple targets for the same input, you might want to change the default one (which was created last).

To change the default target configuration


  1. Do one of the following:
    • In the diagram toolbar, click the Change Default Target button.  
    • In the selected element's shortcut menu, click Software Code Generation > Change Default Target
  2. Select the target you want to use. 
  3. Click OK.


You can deactivate the SPO you do not need.

To deactivate the SPO


  1. In the main menu, click Options > Environment. The Environment Options dialog opens.
  2. In the dialog, go to CATIA Software Producer Client > Operations.
  3. Select the needed operation and click the Change activation status button.


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 have access to it if you need it for the debugging purpose for example). 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.

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.

    

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 SPO is running. After the SPO is completed, the notification is displayed showing the status of the generation.


When an SPO 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 SPO 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.


The full set of code you need to generate to cover your target is composed of at least a component and a target-specific part. Component part is relative to the behavior of your application (such as State Machine) whereas the target-specific part is relative to the architecture of your application (such as IBD). In other words, target specific is the binder and the link between the component and the target. As one does not go without the other, this is why at the end of the IBD generation, a dialog will ask you if you want the applicative code to be automatically generated if you have not yet done it (or if it has changed).

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>
    • <componentA_name>
      • <configuration1_name>
      • <configuration2_name>
    • <componentB_name>
      • <configuration3_name>
      • <configuration4_name>
    • etc
      • operations
        • json3
      • backup2
      • logs
        • log4



  1. You can change the root of the local workspace path in the project options.
  2. By 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 
  3. SPO Report files are rotated by size and date so that you might see multiple report files here.
  4. Log files are rotated by size and date so that you might see multiple log files here.


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 following commands are available from the diagrams toolbar or from the shortcut menu of the supported elements in the Containment tree:

Button

Description

Configure Target

Configure the code generators according to the first operation you selected (this first operation will be your final target). You can manage the parameters of the generators here, as well as the download options.

Change Default Target

You can change the target selected for the current element.

Code Generation

Generates the code for the selected elements in, for example, the State Machine or Internal Block Definition diagrams. If the entire diagram is selected, the code is generated for the whole content.

The generation result is downloaded to your machine if you select the download option.

By default, the classic generation is triggered, but you can select the full generation to generate code in all circumstances.

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.

Sample project

The sample project Flashlight_SOP.mdzip is located in <modeling_tool_installation_directory>\samples\CATIA Software Producer. You can also open the Flashlight_SOP sample project from the modeling tool's Welcome screen, Samples tab.

  • No labels