Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Modern-day toolchain for UML to Embedded C code generation(What are the correct code generation tools to be used with Papyrus for embedded c?)
Modern-day toolchain for UML to Embedded C code generation [message #1863492] Tue, 06 February 2024 10:40 Go to next message
Nick T is currently offline Nick TFriend
Messages: 1
Registered: February 2024
Junior Member
Hi - I used a legacy version of Papyrus for UML-to-C code creation in a previous embedded C software job. It was a fantastic tool - I now want to set it up for a new project.

However, after a full day immersed in docs/examples/forums/installs without much luck, I'm still unsure about the modern-day version of this toolchain - a bit confused about which tools are now deprecated.

I am posting on this forum, because it seems that Papyrus is the common component in the solution.

This is the simple workflow I used at my old job - this is what I am trying to recreate a modern-day version of:

1. I have a pre-defined library of my client's own 'Primitive Types' in Papyrus, which code-generate to the same types used in my embedded C project - for example, 'Short', which is typedef'd as uint8_t in a PrimitiveTypes.h file someplace. But every time I use the 'Short' primitive type in my Papyrus model, the generated code will also have a 'Short' type.
2. I design a software class as a UML model in Papyrus editor, using our own "Primitive Types" library.
3. I right-click on the model's .di file in the project explorer view, and select 'uml2ec'. The C 'skeleton' code equivalent of my UML model - associated getter/setter functions, etc - are generated into a folder that I specified in a properties tab somewhere.
4. The generated .c/.h files use a standardised Doxygen-style format of headers, comments, etc.
5. My 'hand-written' user code is then typed inside of /* Start/End of user code */ guard comments in the .c/.h files. These 'guard' comments protect my hand-written code from being deleted by subsequent model-to-code generation when I make iterative changes to the UML design.

That's it - nothing more complex than that.

Please can someone advise on what tools are suitable for the up-to-date version of this workflow?
At the conceptual level, what components of the Papyrus ecosystem are required, and how they should work together?
I'd like to sketch a block diagram of each stage in the generation process to ensure I understand the i/o of each component.

Platform is Ubuntu 22.04 if that matters.

Thankyou in advance for volunteering your time to help - it is hugely appreciated :)

Nick
Re: Modern-day toolchain for UML to Embedded C code generation [message #1863574 is a reply to message #1863492] Mon, 12 February 2024 08:59 Go to previous message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 470
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi,

it seems that the embedded code generator that you used previously is not part of Papyrus SW designer. I'll answer your questions below

1. I have a pre-defined library of my client's own 'Primitive Types' in Papyrus, which code-generate to the same types used in my embedded C project - for example, 'Short', which is typedef'd as uint8_t in a PrimitiveTypes.h file someplace. But every time I use the 'Short' primitive type in my Papyrus model, the generated code will also have a 'Short' type.
> You can disable the code generation for the elements in your clients primitive types library, if you mark the contained elements either as External (stereotype <<C_Cpp::External>>) or disabling the code generation (stereotype <<Codegen::NoCodeGen>>, Codegen is a profile capturing common aspects in several languages)

2. I design a software class as a UML model in Papyrus editor, using our own "Primitive Types" library.
> That should work with current designer version (see also above). If you want to avoid workspace references, you could also place the library into a plugin (you can have a look at the SW designer plugin org.eclipse.papyrus.designer.languages.cpp.library and the additional .ui plugin)

3. I right-click on the model's .di file in the project explorer view, and select 'uml2ec'. The C 'skeleton' code equivalent of my UML model - associated getter/setter functions, etc - are generated into a folder that I specified in a properties tab somewhere.
> The default location for the code is a project with a configurable prefix (prepended to the model name). Getters and Setters are not automatically generated. It might be useful to add this option (post an issue)

4. The generated .c/.h files use a standardised Doxygen-style format of headers, comments, etc.
> Should work with current version, comments in UML are taken into account

5. My 'hand-written' user code is then typed inside of /* Start/End of user code */ guard comments in the .c/.h files. These 'guard' comments protect my hand-written code from being deleted by subsequent model-to-code generation when I make iterative changes to the UML design.
> Protected sections are supported in general by SW designer, but the start/end tags are not produced automatically (this is done in the Robotics customization, if the model does not contain code). An option is to add the required tags manually via an opaque behavior, but it would be better, if the generators add these automatically - e.g. via a preference or in the absence of an opaque behavior.
Previous Topic:Component diagram bug?
Next Topic:Problems with reinstall of Papyrus
Goto Forum:
  


Current Time: Mon Sep 16 23:21:47 GMT 2024

Powered by FUDForum. Page generated in 0.03673 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top