Embedded Software

Embedded Software

Scade One Variant Types

    • SolutionSolution
      Participant

      Introduction

      This blog entry is special: we have a video for you!

      Aubanel, our director of Ansys Customer Excellence, demonstrates a new construct in Swan, the modeling language used in Scade One, called variant types.

      Variant types?

      A variant type defines a data structure holding a value that can take on several different, but fixed, types. The generated C code uses union in a safe, MISRA-compatible way, by using a tag field to know which type is in use.

      In short, a variant type is a type that can be this or that or something else.

      In the video, Aubanel showcases this with a shape type that can be either a rectangle, a circle or a polygon.

      This makes it easy to design generic operators that perform calculations on shapes, with no need to duplicate our logic to handle various cases for various shape types:



      Demo time 🎬

      Want to know more?

      In this video, you saw how variant types can power cleaner, easier-to-maintain models.

      If you’d like to find out more about Scade One, request a demo today over at https://www.ansys.com/products/embedded-software/ansys-scade-one.