Skip to content

Magic Draw

  1. Create a new empty model and add a package to it.
    Project Broswer
  2. Add the Embedded Engineer Profile by opening main menu:
    • File Use Project Use Local
      Project Broswer
    • Project In the Use Project dialog select From predefined location <install.root>\profiles EmbeddedEngineerProfile.mdzip
      Project Broswer
  3. Download and import the FSM Project Template
  4. Apply the LL Embedded Stereotype to the new package
    Project Broswer
    • Set the GenerationLanguage Tagged Value to the language you would like to generate
    • Set the GenSrcDir Tagged Value to the output path where you would like to generate the code to (relative paths will be relative to the current EAP file location)
      Project Broswer
  5. Add a Usage connector to the imported FSM package to include all needed header files
    Project Broswer
  6. Create a class diagram in the new package
    Project Broswer
  7. Create a new class
    Project Broswer
  8. To this class you may add child element such as StateMachines, Activities, Operations and Attributes
    Project Broswer
  9. When finished simply open the context menu in the new package in the containment tree and select LL Embedded Engineer Generate code
    Project Broswer
    Project Broswer
  10. Using the generated code in your code

Example

This is just an example implementation to show you how to use the generated code.

// Include the main header file of the class
#include "MyClass.h"

int main(void)
{
    // Get an instance for this class (statically allocated, will always return the same instance!)
    MyClass* myClass = MyClass_new();

    // Example on how to call the constructor (if one was modelled)
    MyClass_MyConstructor(myClass);

    // Example on how to initialize a state machine (if one was modelled)
    MyClass_StateMachine_init(&myClass->StateMachine);

    // Example on how to run a state machine (if one was modelled)
    // The implementation on your target may differ
    while (true)
    {
        // Call the state machine with no signal
        MyClass_StateMachine(myClass, &myClass->StateMachine, NOSIG);
    }
}