Skip to main content

Generate Code with Workflows

Now that you have a Component based system design all wired up, it is time to use Tangram Pro™ to generate a Component Software Interface (CSI) - code that will allow Components to pass the messages you specified to other Components or systems. I know what you might be thinking..."Generated code is rubbish! It just spits out a template, but you still have to do all the real work." Well, in the case of our generated CSI, it is fully executable and the "real work" is done for you, saving you a ton of time on the tedious code, so that you can work on the code that matters to you. Plus, the output is your choice, C++ or Rust!

You'll learn how to:

  • Create a Workflow
  • Add tasks to a Workflow
  • Configure Workflow tasks
  • Run a Workflow to generate a CSI

Step 1: Create a Workflow

In Tangram Pro™, Workflows are a key piece to tightening the linkages between system engineers and software developers to help cross that treacherous gap. Using the available task plug-ins, Workflows can be created at the Component or system level, and persist as part of the system design model even as changes are made in the code base. Of course, Workflows can be easily updated to meet new design requirements too.

How to create a Workflow

For this Workflow, we are going to generate the CSI for the Communication Component. If you haven't already, complete the previous tutorial to design your system: Visualize a Component Based System Design .

  1. Hover over and click the “meatball menu” icon on the top right corner of the UAS Communication.First System Component
  2. Click Open New Tab
  3. Click the Workflow icon on the far left side of the Workspace to expand the Workflow fly-out menu
  4. Click + New Workflow
  5. Type the name, UAS Comms Workflow , in the Workflow Name text box
  6. Click Create Workflow

Now it's time to add some tasks to that Workflow

Step 2: Add tasks to a Workflow

Tasks are selected from the menu of available plug-ins in Tangram Pro™. By adding tasks to a Workflow you are telling the platform to put those plug-ins to work on your whole Component based system design, or just a part of it.

To add tasks to a Workflow

  1. Click UAS Comms Workflow in the Workflow fly-out menu
  2. Click + Tasks
  3. Click and drag the Code Gen 3.0 plugin into the right area
  4. Click and drag the G++ plugin into the right area

Add Plugins

Step 3: Configure Workflow tasks

Configuring Workflow tasks allow you specify a sequence of tasks applied to a Component. You can also select things like the output language and preferred transport library in Tangram Pro™.

Configure Code Gen 3.0

  1. Click the Settings icon of the Code Gen 3.0 plugin
  2. Select Code Gen to Generate a CSI
  3. Select false as the configuration setting for Allow failure
  4. Select cpp as the configuration setting for Output Language
  5. Select ZeroMQ as the configuration setting for Transport Library
  6. Notice Tangram Pro™ populates an name output folder field which you can change. For the purposes of this tutorial, let's keep the default name code-gen-3.
  7. Click Done

Configure Code Gen

Configure G++

  1. Click the Settings icon of the G++ plugin
  2. Select Configuration: Makefile Compilation
  3. Keep the default values for Make directory and name output folder
  4. Click Done

Add Dependency

Now let's make a dependency between the two plugins to ensure the G++ task runs after Code Gen 3.0 completes.

  1. Click the connection icon in the Code Gen 3.0 plugin
  2. Then click anywhere in the G++ plugin
  3. You should now see line between the two plugins
  4. Click Save Changes

Add Dependency


Workflow tasks will run in parallel if a dependency is not created. You can also remove a dependency line by hovering over the line and clicking the X.

Step 4: Run your Workflow

Generating executable C++ code by running a Workflow is incredibly easy with Tangram Pro™.

How to run a Workflow

  1. Click Close to exit the Workflow editor
  2. Click Run to kick off the Workflow you just created

Run Workflow

Step 5: Download Artifacts

Download the artifact from the G++ plugin to see the results of the Tangram Pro™ Workflow. The extracted file will contain a fully generated and built CSI.

  1. Wait until the Workflow completes
  2. Click on the Artifacts icon for the G++ task to download the generated code
  3. Then extract the file

Download Artifacts

The generated code will be in a folder called code-gen-3, which was the name we chose for the output folder.



By completing this tutorial, you've learned to generate a CSI by running a Workflow in Tangram Pro™!

Check out what you accomplished:

  • Created a Workflow
  • Added multiple tasks to a Workflow
  • Configured the task dependencies and settings
  • Ran your Workflow to produce an executable CSI

Our blog is another great place to learn more!


Join Discuss, our Tangram Flex community to find out more about Workflows, ask questions, or provide feedback.

Ready to see you how your CSI in action? Make your way to the next tutorial below!


Additional items available in Tangram Pro™, but not discussed in this tutorial

  • Additional Code Generation plug-ins
  • Additional software analysis (assurance) plug-ins
  • Customizable Workflow plug-ins
  • Workflow outputs in Rust
  • Choose between ActiveMQ, ZeroMQ, RabbitMQ, and Kafka message brokers
  • Webhooks that trigger Workflows when changes are made to a Component's repository